private ExpandableComposite optionsTypeSection(PipelineLaunchConfiguration launchConfiguration, String optionsTypeName, Collection<String> optionsTypeProperties, Map<String, Optional<String>> optionsDescriptions, int style) { ExpandableComposite expandable = formToolkit.createSection(form.getBody(), style); expandable.setLayout(new GridLayout()); expandable.setBackground(parent.getBackground()); expandable.setForeground(parent.getForeground()); expandable.setText(optionsTypeName); expandable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); LabeledTextMapComponent typeArgs = new LabeledTextMapComponent(formToolkit, expandable, new GridData(SWT.FILL, SWT.CENTER, true, false), argumentSeparator); for (ModifyListener modifyListener : modifyListeners) { typeArgs.addModifyListener(modifyListener); } for (IExpansionListener expandListener : expansionListeners) { expandable.addExpansionListener(expandListener); } for (String property : optionsTypeProperties) { typeArgs.addLabeledText(property, optionsDescriptions.get(property)); } optionsComponents.put(expandable, typeArgs); expandable.setClient(typeArgs.getControl()); typeArgs.setTextValuesForExistingLabels(launchConfiguration.getArgumentValues()); return expandable; }
/** * 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) { Section section = toolkit.createSection(parent, sectionFlags); TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB); td.grabHorizontal = true; section.setLayoutData(td); 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 IExpansionListener getExpansionListener() { if (this.formRebuildingListener == null) { this.formRebuildingListener = new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { getManagedForm().reflow(true); } }; } return this.formRebuildingListener; }
public void addExpandListener(IExpansionListener expandListener) { for (ExpandableComposite expandable : optionsComponents.keySet()) { expandable.addExpansionListener(expandListener); } expansionListeners.add(expandListener); }