下面列出了怎么用org.eclipse.ui.forms.widgets.Section的API类实例代码及写法,或者点击链接到github查看源代码。
public ProjectInfoSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
section.setText(Messages.AppOverviewEditorProjectInfoSection);
section.setLayoutData(new GridData(SWT.FILL,SWT.FILL, true, false, hSpan, vSpan));
section.setExpanded(true);
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 10;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
toolkit.paintBordersFor(composite);
section.setClient(composite);
typeEntry = new StringEntry(composite, Messages.AppOverviewEditorTypeEntry);
languageEntry = new StringEntry(composite, Messages.AppOverviewEditorLanguageEntry);
projectIdEntry = new StringEntry(composite, Messages.AppOverviewEditorProjectIdEntry);
locationEntry = new StringEntry(composite, Messages.AppOverviewEditorLocationEntry);
}
@Override
protected void createFormContent(IManagedForm mform) {
FormToolkit toolkit = mform.getToolkit();
UI.formHeader(mform, M.SearchParameters);
Composite body = UI.formBody(mform.getForm(), mform.getToolkit());
UI.gridLayout(body, 1);
Label filterLabel = UI.formLabel(body, toolkit, M.Filter);
filterLabel.setFont(UI.boldFont());
filterText = UI.formText(body, SWT.SEARCH);
filterText.addModifyListener(e -> viewer.refresh());
Section section = UI.section(body, toolkit, M.Parameters);
UI.gridData(section, true, true);
Composite composite = UI.sectionClient(section, toolkit, 1);
createViewer(composite);
}
void create(FormToolkit tk, Composite body) {
Section section = UI.section(body, tk, "Pinned contributions");
section.setExpanded(false);
Composite comp = UI.sectionClient(section, tk);
UI.gridLayout(comp, 1);
Composite filterComp = tk.createComposite(comp);
UI.gridLayout(filterComp, 2, 10, 0);
UI.gridData(filterComp, true, false);
filter = UI.formText(filterComp, tk, M.Filter);
filter.addModifyListener(e -> table.setInput(selectInput()));
table = Tables.createViewer(comp,
"Pin / Unpin",
"Process / Sub-System",
M.Product,
"Display in chart");
Tables.bindColumnWidths(table, 0.15, 0.35, 0.35, 0.15);
Label label = new Label();
table.setLabelProvider(label);
Viewers.sortByLabels(table, label, 0, 1);
table.setInput(selectInput());
bindActions();
}
/**
* Constructs a section and returns a section client composite
*
* the section layout is TableWrapLayout
*
*
* @param parent parent container for the section
* @param title title of the section
* @param description description of the section
* @param toolkit toolkit to create the composite
* @param sectionFlags parameters of the section
* @param expansionListener
* @return a section client (the content container of the section)
*/
public static Section createSectionComposite(Composite parent, String title, String description,
FormToolkit toolkit, int sectionFlags, IExpansionListener expansionListener)
{
final Section section = toolkit.createSection(parent, sectionFlags);
section.setData(SECTION_IS_NOT_SPACE_GRABBING, new Object());
section.setText(title);
section.setDescription(description);
if (expansionListener != null)
{
section.addExpansionListener(expansionListener);
}
// create section client
Composite sectionClient = toolkit.createComposite(section);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 1;
sectionClient.setLayout(layout);
section.setClient(sectionClient);
// draw flat borders
toolkit.paintBordersFor(sectionClient);
return section;
}
public void bindActions(Section section) {
Action add = Actions.onAdd(this::add);
Action remove = Actions.onRemove(this::remove);
Action copy = TableClipboard.onCopy(table);
Action paste = TableClipboard.onPaste(table, this::onPaste);
Action usage = Actions.create(M.Usage, Icon.LINK.descriptor(), () -> {
ParameterRedef redef = Viewers.getFirstSelected(table);
if (redef != null) {
ParameterUsagePage.show(redef.name);
}
});
CommentAction.bindTo(section, "parameterRedefs",
editor.getComments(), add, remove);
Actions.bind(table, add, remove, copy, paste, usage);
Tables.onDeletePressed(table, (e) -> remove());
Tables.onDoubleClick(table, (event) -> {
TableItem item = Tables.getItem(table, event);
if (item == null)
add();
});
}
void render(Composite body, FormToolkit tk) {
Section section = UI.section(body, tk, "Geographic data");
UI.gridData(section, true, true);
Composite comp = UI.sectionClient(section, tk);
comp.setLayout(new FillLayout());
UI.gridData(comp, true, true);
map = new MapView(comp);
map.addBaseLayers();
feature = MsgPack.unpackgz(location().geodata);
if (feature != null) {
updateMap();
}
Action edit = Actions.onEdit(() -> {
new GeoJSONDialog().open();
});
Actions.bind(section, edit);
}
private void createGeneralInformationSection(Composite parent) {
FormToolkit toolkit = super.getToolkit();
Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
section.setDescription(TsconfigEditorMessages.OverviewPage_GeneralInformationSection_desc);
section.setText(TsconfigEditorMessages.OverviewPage_GeneralInformationSection_title);
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
section.setLayoutData(data);
Composite body = createBody(section);
// Target/Module
createCombo(body, TsconfigEditorMessages.OverviewPage_target_label, new JSONPath("compilerOptions.target"),
TsconfigJson.getAvailableTargets(), TsconfigJson.getDefaultTarget());
createCombo(body, TsconfigEditorMessages.OverviewPage_module_label, new JSONPath("compilerOptions.module"),
TsconfigJson.getAvailableModules());
createCombo(body, TsconfigEditorMessages.OverviewPage_moduleResolution_label,
new JSONPath("compilerOptions.moduleResolution"), TsconfigJson.getAvailableModuleResolutions(),
TsconfigJson.getDefaultModuleResolution());
// Others....
createCheckbox(body, TsconfigEditorMessages.OverviewPage_experimentalDecorators_label,
new JSONPath("compilerOptions.experimentalDecorators"));
}
private void createComponents(Composite body, FormToolkit toolkit) {
String title = forInputParameters ? M.InputParameters : M.DependentParameters;
Section section = UI.section(body, toolkit, title);
UI.gridData(section, true, true);
Composite parent = UI.sectionClient(section, toolkit, 1);
table = Tables.createViewer(parent, columns());
ParameterLabelProvider label = new ParameterLabelProvider();
table.setLabelProvider(label);
addSorters(table, label);
bindActions(section);
Tables.bindColumnWidths(table, 0.3, 0.3, 0.2, 0.17, 0.03);
int col = forInputParameters ? 1 : 2;
table.getTable().getColumns()[col].setAlignment(SWT.RIGHT);
Tables.onDoubleClick(table, e -> {
var item = Tables.getItem(table, e);
if (item == null) {
onAdd();
}
});
}
private void createDebuggingSection(Composite parent) {
FormToolkit toolkit = super.getToolkit();
Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
section.setDescription(TsconfigEditorMessages.OutputPage_DebuggingSection_desc);
section.setText(TsconfigEditorMessages.OutputPage_DebuggingSection_title);
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
section.setLayoutData(data);
Composite body = createBody(section);
createCheckbox(body, TsconfigEditorMessages.OutputPage_sourceMap_label,
new JSONPath("compilerOptions.sourceMap"));
createTextAndBrowseButton(body, TsconfigEditorMessages.OutputPage_sourceRoot_label,
new JSONPath("compilerOptions.sourceRoot"), false);
createTextAndBrowseButton(body, TsconfigEditorMessages.OutputPage_mapRoot_label,
new JSONPath("compilerOptions.mapRoot"), false);
createCheckbox(body, TsconfigEditorMessages.OutputPage_inlineSourceMap_label,
new JSONPath("compilerOptions.inlineSourceMap"));
createCheckbox(body, TsconfigEditorMessages.OutputPage_inlineSources_label,
new JSONPath("compilerOptions.inlineSources"));
}
public void render(Section section, FormToolkit toolkit) {
Composite composite = UI.sectionClient(section, toolkit, 1);
String[] columnTitles = getColumnTitles();
viewer = Tables.createViewer(composite, columnTitles);
viewer.setLabelProvider(new FactorLabel());
Action copy = TableClipboard.onCopy(viewer);
Actions.bind(viewer, copy);
Tables.bindColumnWidths(viewer, 0.2, 0.1, 0.1, 0.1);
createModifySupport();
Table table = viewer.getTable();
for (int i = 0; i < table.getColumnCount(); i++) {
if (i < 4)
continue;
TableColumn column = table.getColumn(i);
if (!editor.hasAnyComment("allocationFactors") || i % 2 == 0) {
column.setWidth(80);
column.setToolTipText(columnTitles[i]);
} else {
column.setWidth(24);
}
}
for (int i = 3; i < table.getColumnCount(); i++) {
viewer.getTable().getColumns()[i].setAlignment(SWT.RIGHT);
}
}
private void createScopeSection(Composite parent) {
FormToolkit toolkit = super.getToolkit();
Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
section.setDescription(TsconfigEditorMessages.FilesPage_ScopeSection_desc);
section.setText(TsconfigEditorMessages.FilesPage_ScopeSection_title);
TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
section.setLayoutData(data);
Composite client = toolkit.createComposite(section);
section.setClient(client);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginWidth = 2;
layout.marginHeight = 2;
client.setLayout(layout);
Table table = toolkit.createTable(client, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
gd.widthHint = 100;
table.setLayoutData(gd);
}
@Override
protected void createFormContent(IManagedForm managedForm) {
form = UI.formHeader(this);
toolkit = managedForm.getToolkit();
Composite body = UI.formBody(form, toolkit);
InfoSection infoSection = new InfoSection(getEditor());
infoSection.render(body, toolkit);
createButton(infoSection.getContainer());
new ImpactSection(editor).render(body, toolkit);
createVariantsSection(body);
Section section = UI.section(body, toolkit, M.Parameters);
parameterTable = new ProjectParameterTable(editor);
parameterTable.render(section, toolkit);
initialInput();
new ProcessContributionSection(editor).create(body, toolkit);
body.setFocus();
form.reflow(true);
}
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);
}
void render(Composite body, FormToolkit toolkit) {
log.trace("render flow-use-section for flow {}", flow);
FlowDao dao = new FlowDao(database);
Set<Long> recipients = dao.getWhereInput(flow.id);
Set<Long> providers = dao.getWhereOutput(flow.id);
if (recipients.isEmpty() && providers.isEmpty())
return;
Section section = UI.section(body, toolkit, M.UsedInProcesses);
section.setExpanded(false);
parent = UI.sectionClient(section, toolkit);
this.toolkit = toolkit;
App.runInUI("Render usage links", () -> {
renderLinks(M.ConsumedBy, recipients, Icon.INPUT.get());
renderLinks(M.ProducedBy, providers, Icon.OUTPUT.get());
});
}
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);
}
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 createBrowserOptions(Composite parent) {
Section rtSection = XSPEditorUtil.createSection(toolkit, parent, "Rich Text Options", 1, 1); // $NLX-XSPGenPage.RichTextOptions-1$
Composite rtDCP = XSPEditorUtil.createSectionChild(rtSection, 2);
rtDCP.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false, 1, 1));
Label lfLabel = XSPEditorUtil.createLabel(rtDCP, "Save links in:", 1); // $NLX-XSPGenPage.Savelinksin-1$
lfLabel.setToolTipText("Defines how links should be saved in a Domino document"); // $NLX-XSPGenPage.DefineshowlinksshouldbesavedinaDo-1$
Composite buttonHolder = new Composite(rtDCP, SWT.NONE);
buttonHolder.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
GridLayout gl = SWTLayoutUtils.createLayoutNoMarginDefaultSpacing(2);
buttonHolder.setLayout(gl);
buttonHolder.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false, 1, 1));
XSPEditorUtil.createRadio(buttonHolder, LINK_SAVE_PROP, "Notes format", XSP_SAVE_USE_NOTES, "notesLinks", 1); // $NON-NLS-2$ $NLX-XSPGenPage.Notesformat-1$
XSPEditorUtil.createRadio(buttonHolder, LINK_SAVE_PROP, "Web format", XSP_SAVE_USE_WEB, "webLinks", 1); // $NON-NLS-2$ $NLX-XSPGenPage.Webformat-1$
rtSection.setClient(rtDCP);
}
private void createDefinitionSection(Composite parent) {
this.section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayoutData(GridDataFactory.fillDefaults().create());
section.setLayout(GridLayoutFactory.fillDefaults().create());
Composite client = formPage.getToolkit().createComposite(section);
client.setLayout(
GridLayoutFactory.fillDefaults().create());
client.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
Composite definitionComposite = formPage.getToolkit().createComposite(client);
definitionComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
definitionComposite.setLayout(
GridLayoutFactory.fillDefaults().numColumns(2).spacing(LayoutConstants.getSpacing().x, 1)
.margins(10, 10).create());
createToolbar(definitionComposite);
createSearchField(definitionComposite);
createViewer(definitionComposite);
section.setClient(client);
}
private void createDaArea(Composite parent) {
Section section = XSPEditorUtil.createSection(_toolkit, parent, "Directory Assistance", 1, 1); // $NLX-ManifestHybridEditorPage.DirectoryAssistance-1$
Composite container = XSPEditorUtil.createSectionChild(section, 2);
_daEnabledCheckbox = XSPEditorUtil.createCheckboxTF(container, "Enable directory assistance for authentication", "appDaEnabled", 2); // $NON-NLS-2$ $NLX-ManifestHybridEditorPage.Enabledirectoryassistanceforauthe-1$
_daEnabledCheckbox.setToolTipText(StringUtil.format("Enable to allow the runtime application server to use a Domino user directory on the remote server as follows:{0}to authenticate Internet users against the credentials in the directory,{0}to resolve users during NAMELookup calls,{0}to resolve members of groups when authorizing database access.", "\n")); // $NON-NLS-2$ $NLX-ManifestHybridEditorPage.Enabletoallowtheruntimeapplicatio-1$
_daEnabledCheckbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
refreshDaControlState();
}
});
_domainNameLabel = XSPEditorUtil.createLabel(container, "Domain name:", 1); // $NLX-ManifestHybridEditorPage.Domainname-1$
_domainNameLabel.setToolTipText("The domain name of a Domino directory on the remote server"); // $NLX-ManifestHybridEditorPage.ThedomainnameofaDominodirectoryon-1$
_domainNameText = XSPEditorUtil.createText(container, "appDaDomain", 1, 0, 40); // $NON-NLS-1$
_dominoDirLabel = XSPEditorUtil.createLabel(container, "Domino directory:", 1); // $NLX-ManifestHybridEditorPage.Dominodirectory-1$
_dominoDirLabel.setToolTipText("The file name of a Domino directory on the remote server"); // $NLX-ManifestHybridEditorPage.ThefilenameofaDominodirectoryonth-1$
_dominoDirText = XSPEditorUtil.createText(container, "appDaAddressBook", 1, 0, 1); // $NON-NLS-1$
section.setClient(container);
}
private void createDebugArea(Composite parent) {
Section section = XSPEditorUtil.createSection(_toolkit, parent, "Debug Environment Variables", 1, 1); // $NLX-ManifestEnvEditorPage.DebugEnvironmentVariables-1$
Composite container = XSPEditorUtil.createSectionChild(section, 3);
Button btn = XSPEditorUtil.createCheckboxTF(container, "Include XPages Toolbox", "appIncludeXPagesToolbox", 3); // $NON-NLS-2$ $NLX-ManifestEnvEditorPage.IncludeXPagesToolbox-1$
btn.setToolTipText("APP_INCLUDE_XPAGES_TOOLBOX\nWhen enabled, the XPages Toolbox will be pushed along with your application to facilitate debugging.\nDisabled by default."); // $NLX-ManifestEnvEditorPage.APP_INCLUDE_XPAGES_TOOLBOXnWhenen-1$
btn = XSPEditorUtil.createCheckboxTF(container, "Verbose staging", "appVerboseStaging", 3); // $NON-NLS-2$ $NLX-ManifestEnvEditorPage.Verbosestaging-1$
btn.setToolTipText("APP_VERBOSE_STAGING\nWhen enabled, the command-line interface (CLI) will show full logging details when staging your application.\nDisabled by default."); // $NLX-ManifestEnvEditorPage.APP_VERBOSE_STAGINGnWhenenabledth-1$
btn = XSPEditorUtil.createCheckboxTF(container, "Debug staging", "appDebugStaging", 3); // $NON-NLS-2$ $NLX-ManifestEnvEditorPage.Debugstaging-1$
btn.setToolTipText("APP_DEBUG_STAGING\nWhen enabled, detailed debug information generated during application staging will be collected into\nthe console log file in the IBM_TECHNICAL_SUPPORT directory.\nDisabled by default."); // $NLX-ManifestEnvEditorPage.APP_DEBUG_STAGINGnWhenenableddeta-1$
btn = XSPEditorUtil.createCheckboxTF(container, "Debug threads", "appDebugThreads", 3); // $NON-NLS-2$ $NLX-ManifestEnvEditorPage.Debugthreads-1$
btn.setToolTipText("APP_DEBUG_THREADS\nWhen enabled, detailed thread request and response information will be collected into separate thread\nlog files in the IBM_TECHNICAL_SUPPORT directory.\nDisabled by default."); // $NLX-ManifestEnvEditorPage.APP_DEBUG_THREADSnWhenenableddeta-1$
btn = XSPEditorUtil.createCheckboxTF(container, "Debug directory assistance", "appDebugDa", 3); // $NON-NLS-2$ $NLX-ManifestEnvEditorPage.Debugdirectoryassistance-1$
btn.setToolTipText("APP_DEBUG_DIRECTORY_ASSISTANCE\nWhen enabled, detailed directory assistance debug information will be collected into\nthe console log file in the IBM_TECHNICAL_SUPPORT directory.\nDisabled by default."); // $NLX-ManifestEnvEditorPage.APP_DEBUG_DIRECTORY_ASSISTANCEnWh-1$
btn = XSPEditorUtil.createCheckboxTF(container, "Debug name lookup", "appDebugNameLookup", 3); // $NON-NLS-2$ $NLX-ManifestEnvEditorPage.Debugnamelookup-1$
btn.setToolTipText("APP_DEBUG_NAMELOOKUP\nWhen enabled, detailed name lookup information will be collected into the console log file in\nthe IBM_TECHNICAL_SUPPORT directory.\nDisabled by default."); // $NLX-ManifestEnvEditorPage.APP_DEBUG_NAMELOOKUPnWhenenabledd-1$
section.setClient(container);
}
private void createAuthorSection(Composite parent) {
Section sctnAuthor = createSection(parent, "Author");
sctnAuthor.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
Composite composite = formToolkit.createComposite(sctnAuthor, SWT.WRAP);
formToolkit.paintBordersFor(composite);
sctnAuthor.setClient(composite);
composite.setLayout(FormUtils.createSectionClientGridLayout(false, 2));
createFormFieldLabel(composite, "Name:");
txtAuthorname = formToolkit.createText(composite, "", SWT.WRAP);
txtAuthorname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
createFormFieldLabel(composite, "Email:");
txtEmail = formToolkit.createText(composite, "", SWT.NONE);
txtEmail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
createFormFieldLabel(composite, "URL:");
txtUrl = formToolkit.createText(composite, "", SWT.NONE);
txtUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
}
private void bindGlobalParamActions(Section section, TableViewer table) {
var copy = TableClipboard.onCopy(table);
var refresh = Actions.create(M.Reload, Icon.REFRESH.descriptor(), () -> {
setGlobalTableInput();
support.evaluate();
editor.setDirty(true);
});
var usage = Actions.create(M.Usage, Icon.LINK.descriptor(), () -> {
Parameter p = Viewers.getFirstSelected(table);
if (p != null) {
ParameterUsagePage.show(p.name);
}
});
Actions.bind(table, copy, refresh, usage);
Actions.bind(section, refresh);
}
private void createResultSection(FormToolkit tk, Composite body) {
if (result == null)
return;
Section section = UI.section(body, tk, M.Results);
SimulationExportAction exportAction = new SimulationExportAction(
result, editor.setup);
Actions.bind(section, exportAction);
Composite comp = UI.sectionClient(section, tk);
initFlowCheckViewer(tk, comp);
if (result.hasImpactResults()) {
initImpactCheckViewer(tk, comp);
}
statisticsCanvas = new StatisticsCanvas(body);
GridData gd = UI.gridData(statisticsCanvas, true, true);
gd.verticalIndent = 10;
gd.minimumHeight = 250;
}
public BusinessObjectList(
Composite parent, AbstractBdmFormPage formPage,
DataBindingContext ctx) {
this.ctx = ctx;
section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
section.setLayout(GridLayoutFactory.fillDefaults().create());
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
section.setText(Messages.listOfBusinessObjects);
Composite boListComposite = createBusinessObjectListComposite(formPage);
ctx.bindValue(businessObjectSelectionObservable, selectionObservable,
UpdateStrategyFactory.updateValueStrategy().create(),
UpdateStrategyFactory.updateValueStrategy()
.withConverter(ConverterBuilder.<Object, BusinessObject> newConverter()
.fromType(Object.class)
.toType(BusinessObject.class)
.withConvertFunction(o -> o instanceof BusinessObject ? (BusinessObject) o : null)
.create())
.create());
ctx.bindValue(businessObjectSelectionObservable, formPage.observeBusinessObjectSelected());
section.setClient(boListComposite);
}
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));
}
public void createListSection ( final ScrolledForm form, final ConfigurationEditorInput input, final String attribute, final String label, final String delimiter, final String pattern )
{
final IObservableList list = StringSplitListObservable.observeString ( Observables.observeMapEntry ( input.getDataMap (), attribute, String.class ), delimiter, pattern );
// section
final Section section = this.toolkit.createSection ( form.getBody (), ExpandableComposite.TITLE_BAR );
section.setText ( label );
final Composite client = this.toolkit.createComposite ( section, SWT.NONE );
section.setClient ( client );
this.toolkit.paintBordersFor ( client );
client.setLayout ( new GridLayout ( 1, true ) );
final GridData gd = new GridData ( GridData.FILL_BOTH );
gd.horizontalSpan = 2;
section.setLayoutData ( gd );
// fields
final ListViewer viewer = new ListViewer ( client );
viewer.setContentProvider ( new ObservableListContentProvider () );
viewer.setInput ( list );
viewer.getControl ().setLayoutData ( new GridData ( GridData.FILL_BOTH ) );
viewer.setSorter ( new ViewerSorter () );
}
private void createTree(Composite body, FormToolkit tk) {
Section section = UI.section(body, tk, M.ContributionTreeLocations);
UI.gridData(section, true, true);
Composite comp = UI.sectionClient(section, tk);
UI.gridLayout(comp, 1);
label = new TreeLabel();
String[] labels = { M.Location, M.Amount, M.Unit };
tree = Trees.createViewer(comp, labels, label);
tree.setContentProvider(new TreeContentProvider(this));
Trees.bindColumnWidths(tree.getTree(), 0.4, 0.3, 0.3);
// tree actions
Action onOpen = Actions.onOpen(() -> {
Object obj = Viewers.getFirstSelected(tree);
if (obj == null)
return;
if (obj instanceof Contribution) {
Contribution<?> c = (Contribution<?>) obj;
if (c.item instanceof CategorizedDescriptor) {
App.openEditor((CategorizedDescriptor) c.item);
} else if (c.item instanceof CategorizedEntity) {
App.openEditor((CategorizedEntity) c.item);
}
}
});
Actions.bind(tree, onOpen, TreeClipboard.onCopy(tree));
Trees.onDoubleClick(tree, e -> onOpen.run());
tree.getTree().getColumns()[1].setAlignment(SWT.RIGHT);
}
public void render(Composite parent, FormToolkit tk) {
Section section = UI.section(parent, tk, sectionTitle);
Composite comp = UI.sectionClient(section, tk);
UI.gridLayout(comp, 1);
Composite header = tk.createComposite(comp);
UI.gridLayout(header, 2);
createCombo(tk, header);
chart = ContributionChart.create(comp, tk);
Actions.bind(section, new ImageExportAction(comp));
refresh();
}
@Override
protected Control createDialogArea(final Composite parent) {
final Composite mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, SWT.DEFAULT).create());
mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create());
final Label operatorType = new Label(mainComposite, SWT.NONE);
operatorType.setText(Messages.operatorType);
final ComboViewer operatorViewer = new ComboViewer(mainComposite, SWT.READ_ONLY | SWT.BORDER);
operatorViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
operatorViewer.setContentProvider(ArrayContentProvider.getInstance());
operatorViewer.setLabelProvider(new OperatorLabelProvider());
operatorViewer.addFilter(new OperatorViewerFilter(operation));
operatorViewer.setInput(operatorTypeList);
section = new Section(mainComposite, Section.NO_TITLE);
section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
final Expression exp = operation.getLeftOperand();
for (final IOperatorEditor opEditor : operatorEditors) {
if (!opEditor.appliesTo(exp) && opEditor.appliesTo(operator.getType())) {
operator.setType(ExpressionConstants.ASSIGNMENT_OPERATOR);
}
}
createOperatorEditorFor(section, operator.getType(), operator, exp);
context.bindValue(ViewersObservables.observeSingleSelection(operatorViewer),
EMFObservables.observeValue(operator, ExpressionPackage.Literals.OPERATOR__TYPE));
operatorViewer.addSelectionChangedListener(this);
return mainComposite;
}
/**
* Creates a wrapper around the section
* @param section
* @param page
*/
public ValidateableSectionPart(Section section, BasicFormPage page, String sectionName)
{
super(section);
this.page = page;
page.getDataBindingManager().bindSection(this, sectionName, page.getId());
}