📄 descriptionpropertysection.java
字号:
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.Group;
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 DescriptionPropertySection extends AbstractPropertySection {
private FileModel fileModel = null;
private Text descriptionText;
@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(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Group group = getWidgetFactory().createGroup(composite, "description");
group.setLayout(new GridLayout(1, false));
group.setLayoutData(new GridData(GridData.FILL_BOTH));
descriptionText = getWidgetFactory().createText(group, "",
SWT.MULTI | SWT.BORDER);
descriptionText.setText("");
descriptionText.setLayoutData(new GridData(GridData.FILL_BOTH));
section.setClient(composite);
}
@Override
public void refresh() {
super.refresh();
descriptionText.setText(fileModel.getDescription());
}
@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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -