parentpathpropertysection.java

来自「基于Java RCP 应用的属性编辑, 可以对RCP 程序进行属性的设置」· Java 代码 · 共 68 行

JAVA
68
字号
package commonproperties.tab;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

import commonproperties.model.FileModel;

public class ParentPathPropertySection extends AbstractPropertySection {
	private FileModel fileModel = null;

	private Text parentPath;

	@Override
	public void createControls(Composite parent,
			TabbedPropertySheetPage aTabbedPropertySheetPage) {
		super.createControls(parent, aTabbedPropertySheetPage);

		parent.setLayout(new GridLayout(1, false));
		parent.setLayoutData(new GridData(GridData.FILL_BOTH));

		Section section = getWidgetFactory().createSection(parent,
				Section.TITLE_BAR | Section.TWISTIE);
		section.setText("description");
		section.setLayout(new GridLayout(1, false));
		section.setLayoutData(new GridData(GridData.FILL_BOTH));

		Composite composite = getWidgetFactory().createComposite(section,
				SWT.NONE);
		composite.setLayout(new GridLayout(2, false));
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));

		getWidgetFactory().createLabel(composite,"parent Path: ");
		
		parentPath = getWidgetFactory().createText(composite, "",
				SWT.SINGLE | SWT.BORDER);
		parentPath.setText("");
		parentPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

		section.setClient(composite);
	}

	@Override
	public void refresh() {
		super.refresh();
		parentPath.setText(fileModel.getFile().getParent());
	}

	@Override
	public void setInput(IWorkbenchPart part, ISelection selection) {
		super.setInput(part, selection);
		Object obj = ((IStructuredSelection) selection).getFirstElement();
		if (obj instanceof FileModel) {
			fileModel = (FileModel) obj;
		}
	}


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?