下面列出了org.eclipse.ui.forms.widgets.Section#setLayout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
static public Section createSection(FormToolkit toolkit, Composite parent, String title, int hSpan, int vSpan) {
Section section = toolkit.createSection(parent, Section.SHORT_TITLE_BAR);
GridData osectionGridData = new GridData(SWT.FILL, SWT.BEGINNING, false, false);
osectionGridData.horizontalSpan = hSpan;
osectionGridData.verticalSpan = vSpan;
osectionGridData.horizontalIndent = 5;
section.setLayoutData(osectionGridData);
section.setText(title);
GridLayout osectionGL = new GridLayout(1, true);
osectionGL.marginHeight = 0;
osectionGL.marginWidth = 0;
section.setLayout(osectionGL);
return section;
}
private void createPluginsSection(Composite parent) {
Section sctnPlugins = createSection(parent, "Plug-ins");
sctnPlugins.setLayout(FormUtils.createClearTableWrapLayout(false, 1));
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
sctnPlugins.setLayoutData(data);
FormText text = formToolkit.createFormText(sctnPlugins, true);
ImageDescriptor idesc = HybridUI.getImageDescriptor(HybridUI.PLUGIN_ID, "/icons/etool16/cordovaplug_wiz.png");
text.setImage("plugin", idesc.createImage());
text.setText(PLUGINS_SECTION_CONTENT, true, false);
sctnPlugins.setClient(text);
text.addHyperlinkListener(this);
}
private void createConstraintDescriptionSection(Composite parent, DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.description);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
client.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
IObservableValue descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
selectedConstraintObservable, BusinessDataModelPackage.Literals.UNIQUE_CONSTRAINT__DESCRIPTION);
new TextAreaWidget.Builder()
.widthHint(500)
.heightHint(70)
.bindTo(descriptionObservable)
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(client);
section.setClient(client);
}
private void createConstraintEditionSection(Composite parent) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.attributes);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
client.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
formPage.getToolkit()
.createLabel(client, Messages.selectUniqueConstraintFieldsMessage, SWT.WRAP)
.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
formPage.getToolkit()
.createLabel(client, Messages.warningTextConstraint, SWT.WRAP)
.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
createValidationLabel(client);
createConstraintEditionViewer(client);
section.setClient(client);
}
private void createContentSection() {
Section section = formPage.getToolkit().createSection(this, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.queryContent);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
client.setLayout(
GridLayoutFactory.fillDefaults().margins(10, 10).create());
createLink(client);
createQueryTextArea(client);
createParametersComposite(client);
createReturnTypeComposite(client);
section.setClient(client);
}
private void createIndexDescriptionSection(Composite parent, DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.description);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
client.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
IObservableValue descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
selectedIndexObservable, BusinessDataModelPackage.Literals.INDEX__DESCRIPTION);
new TextAreaWidget.Builder()
.widthHint(500)
.heightHint(70)
.bindTo(descriptionObservable)
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(client);
section.setClient(client);
}
private void buildDescriptionSection(Composite parent, BusinessDataModelFormPage formPage, DataBindingContext ctx) {
IObservableValue<String> descriptionObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
boSelectedObservable, BusinessDataModelPackage.Literals.BUSINESS_OBJECT__DESCRIPTION);
Section descriptionSection = formPage.getToolkit().createSection(parent, Section.EXPANDED);
descriptionSection.setLayoutData(GridDataFactory.fillDefaults().create());
descriptionSection.setLayout(GridLayoutFactory.fillDefaults().create());
descriptionSection.setText(Messages.description);
Composite client = formPage.getToolkit().createComposite(descriptionSection);
client.setLayoutData(GridDataFactory.fillDefaults().create());
client.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(10, 0, 10, 0).create());
new TextAreaWidget.Builder()
.widthHint(500)
.heightHint(70)
.bindTo(descriptionObservable)
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(client);
descriptionSection.setClient(client);
}
private void doCreateWorkspaceTips(Composite mainComposite) {
Label workspaceTips = new Label(mainComposite, SWT.NONE);
workspaceTips.setLayoutData(GridDataFactory.fillDefaults().create());
workspaceTips.setText(Messages.workspaceTips);
final Section section = new Section(mainComposite, Section.TREE_NODE | Section.CLIENT_INDENT);
section.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create());
section.setLayoutData(
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.TOP).hint(200, SWT.DEFAULT)
.grab(true, false).create());
section.setText(Messages.moreInfo);
Label label = new Label(section, SWT.WRAP);
label.setLayoutData(GridDataFactory.swtDefaults().create());
label.setText(Messages.importWorkspaceOverwriteBehavior);
section.setClient(label);
section.setExpanded(false);
section.addExpansionListener(new UpdateLayoutListener(mainComposite));
}
private void createBdmTipsSection(Composite parent) {
final Section bdmTipsSection = getWidgetFactory().createSection(parent, Section.NO_TITLE);
bdmTipsSection.setLayout(GridLayoutFactory.fillDefaults().create());
bdmTipsSection.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
CreateBusinessDataProposalListener createBusinessDataProposalListener = new CreateBusinessDataProposalListener();
DocumentProposalListener documentProposalListener = new DocumentProposalListener();
Link tips = new Link(bdmTipsSection, SWT.None);
tips.setText(getBdmTipsMessage());
getWidgetFactory().adapt(tips, true, true);
tips.addListener(SWT.Selection, e -> {
if (Objects.equals(e.text, "documents")) {
documentProposalListener.handleEvent((EObject) poolSelectionProvider.getAdapter(EObject.class),
"");
} else {
createBusinessDataProposalListener.handleEvent((EObject) poolSelectionProvider.getAdapter(EObject.class),
"");
}
});
selectionProvider.addSelectionChangedListener(e -> tips.setText(getBdmTipsMessage()));
bdmTipsSection.setClient(tips);
}
private void createExportSection(Composite parent) {
Section sctnExport = createSection(parent, "Export");
sctnExport.setLayout(FormUtils.createClearTableWrapLayout(false, 1));
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
sctnExport.setLayoutData(data);
FormText text = formToolkit.createFormText(sctnExport, true);
ImageDescriptor idesc = HybridUI.getImageDescriptor(HybridUI.PLUGIN_ID, "/icons/etool16/export_wiz.png");
text.setImage("export", idesc.createImage());
text.setText(EXPORT_SECTION_CONTENT, true, false);
sctnExport.setClient(text);
text.addHyperlinkListener(this);
}
private void createDetailsSection() {
Section detailsSection = formPage.getToolkit().createSection(this, Section.EXPANDED);
detailsSection.setLayout(GridLayoutFactory.fillDefaults().create());
detailsSection.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
detailsSection.setText(Messages.details);
fieldDetailsControl = new FieldDetailsControl(detailsSection, formPage, selectedFieldObservable, ctx);
detailsSection.setClient(fieldDetailsControl);
ctx.bindValue(WidgetProperties.visible().observe(detailsSection), new ComputedValueBuilder<Boolean>()
.withSupplier(() -> selectedFieldObservable.getValue() != null)
.build());
}
private void createIndexEditionSection(Composite parent, DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.attributes);
indexEditionControl = new IndexEditionControl(section, formPage, ctx, selectedIndexObservable,
actualsFieldsObservable);
section.setClient(indexEditionControl);
}
private void buildEditionSection(Composite parent, BusinessDataModelFormPage formPage,
DataBindingContext ctx) {
Section editionSection = formPage.getToolkit().createSection(parent, Section.EXPANDED);
editionSection.setLayoutData(GridDataFactory.fillDefaults().indent(0, 10).grab(true, true).create());
editionSection.setLayout(GridLayoutFactory.fillDefaults().create());
editionSection.setText(Messages.attributes);
Composite client = formPage.getToolkit().createComposite(editionSection);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
client.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
attributeEditionControl = new AttributeEditionControl(client, formPage, boSelectedObservable, ctx);
editionSection.setClient(client);
}
private void createMavenArtifactPropertiesGroup(Composite parent, DataBindingContext ctx) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setText(Messages.mavenArtifactProperties);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
client.setLayout(GridLayoutFactory.fillDefaults().margins(5, 10).create());
new TextWidget.Builder()
.withLabel(Messages.groupId)
.labelAbove()
.fill()
.withTootltip(Messages.mavenArtifactPropertiesHint)
.grabHorizontalSpace()
.bindTo(EMFObservables.observeDetailValue(Realm.getDefault(), formPage.observeWorkingCopy(),
BusinessDataModelPackage.Literals.BUSINESS_OBJECT_MODEL__GROUP_ID))
.withTargetToModelStrategy(UpdateStrategyFactory.updateValueStrategy()
.withValidator(new GroupIdValidator(formPage.getRepositoryAccessor().getWorkspace()))
.create())
.inContext(ctx)
.adapt(formPage.getToolkit())
.createIn(client);
formPage.getToolkit().createLabel(client, "");
section.setClient(client);
}
private void createTreeHeader(Composite parent, DataBindingContext ctx) {
treeSection = new Section(parent, Section.TREE_NODE);
treeSection.setLayout(GridLayoutFactory.fillDefaults().create());
treeSection.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
treeSection.setText(Messages.importDetails);
treeSection.addExpansionListener(new UpdateLayoutListener(parent));
treeSection.setExpanded(false);
descriptionLabel = new Label(treeSection, SWT.WRAP);
archiveStatusObservable = PojoProperties.value("archiveStatus").observe(this);
ctx.bindValue(WidgetProperties.text().observe(descriptionLabel), archiveStatusObservable,
neverUpdateValueStrategy().create(), updateValueStrategy().withValidator(this::archiveStatusValidator)
.withConverter(createArchiveStatusConverter()).create());
treeSection.setDescriptionControl(descriptionLabel);
}
private Section createStatusSection(Composite parent) {
final Section section = new Section(parent, Section.TREE_NODE | Section.CLIENT_INDENT);
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setText(Messages.importDetails);
section.addExpansionListener(new UpdateLayoutListener(parent));
section.setExpanded(false);
return section;
}
@Override
protected void createFormContent(IManagedForm managedForm) {
// Get the parent form and the toolkit
final ScrolledForm scrolledForm = managedForm.getForm();
final FormToolkit formToolkit = managedForm.getToolkit();
// Set a GridLayout with a single column. Remove the default margins.
GridLayout layout = new GridLayout(1, true);
layout.marginWidth = 0;
layout.marginHeight = 0;
scrolledForm.getBody().setLayout(layout);
// Only create something if there is valid input.
if (list != null) {
// Get the parent
Composite parent = managedForm.getForm().getBody();
shell = parent.getShell();
// Create the section and set its layout info
Section listSection = formToolkit.createSection(parent,
ExpandableComposite.TITLE_BAR | Section.DESCRIPTION
| ExpandableComposite.TWISTIE
| ExpandableComposite.EXPANDED
| ExpandableComposite.COMPACT);
listSection.setLayout(new GridLayout(1, false));
listSection.setLayoutData(
new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// Create the section client, which is the client area of the
// section that will actually render data.
sectionClient = new Composite(listSection, SWT.FLAT);
sectionClient.setLayout(new GridLayout(2, false));
sectionClient.setLayoutData(
new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// Fixes section header bug where label color is spammed
sectionClient.setBackground(
Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
// Fixes background color bug for NatTable
sectionClient.setBackgroundMode(SWT.INHERIT_FORCE);
// Draws the table and sets that instance variable
table = new ListComponentNattable(sectionClient, list, true);
// Create the buttons for add, delete, up, and down
createButtons();
// Set the section client.
listSection.setClient(sectionClient);
}
return;
}
private void createAvailableAttributesTableViewer(Composite parent) {
Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setText(Messages.availableAttributes);
Composite client = formPage.getToolkit().createComposite(section);
client.setLayout(GridLayoutFactory.fillDefaults().create());
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
availableAttributesTableViewer = new TableViewer(client,
SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
availableAttributesTableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
availableAttributesTableViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, AVAILABLE_FIELDS_VIEWER_ID);
formPage.getToolkit().adapt(availableAttributesTableViewer.getTable());
ColumnViewerToolTipSupport.enableFor(availableAttributesTableViewer);
availableAttributesTableViewer.setUseHashlookup(true);
availableAttributesTableViewer.getTable().setLinesVisible(true);
availableAttributesTableViewer.setFilters(indexableFieldFilter, indexedFieldsFilter());
TableLayout layout = new TableLayout();
layout.addColumnData(new ColumnWeightData(1, true));
availableAttributesTableViewer.getTable().setLayout(layout);
createAttributesColumn(availableAttributesTableViewer);
availableAttributesTableViewer.setContentProvider(new ObservableListContentProvider());
availableAttributesTableViewer.setInput(actualsFieldsObservable);
selectedAvailableAttributeObservable = ViewersObservables.observeMultiSelection(availableAttributesTableViewer);
availableAttributesTableViewer.getTable().addMouseMoveListener(e -> updateCursor(e, availableAttributesTableViewer));
availableAttributesTableViewer.addDragSupport(DND.DROP_MOVE, new Transfer[] { FieldTransfer.getInstance() },
dragSourceAdapter(selectedAvailableAttributeObservable));
availableAttributesTableViewer.addDropSupport(DND.DROP_MOVE,
new Transfer[] { FieldTransfer.getInstance() },
new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
dragLeave(event);
indexedFieldsObservable.removeAll((Collection<?>) event.data);
}
});
section.setClient(client);
}