Search in sources :

Example 31 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project yamcs-studio by yamcs.

the class EditStackedCommandDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new GridLayout());
    // command namespace selection
    // populate namespace combo
    // (switching ops name and qualified name)
    List<String> aliases = new ArrayList<String>();
    aliases.add(command.getMetaCommand().getQualifiedName());
    for (NamedObjectId noi : command.getMetaCommand().getAliasList()) {
        String alias = noi.getNamespace() + "/" + noi.getName();
        if (alias.equals(command.getMetaCommand().getQualifiedName()))
            continue;
        aliases.add(alias);
    }
    Composite namespaceComposite = new Composite(composite, SWT.NONE);
    namespaceComposite.setLayout(new GridLayout(2, false));
    Label chooseNamespace = new Label(namespaceComposite, SWT.NONE);
    chooseNamespace.setText("Choose Command Namespace: ");
    Combo namespaceCombo = new Combo(namespaceComposite, SWT.READ_ONLY);
    namespaceCombo.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            command.setSelectedAliase(aliases.get(namespaceCombo.getSelectionIndex()));
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    namespaceCombo.setItems(aliases.toArray(new String[aliases.size()]));
    for (int i = 0; i < aliases.size(); i++) {
        if (aliases.get(i).equals(command.getSelectedAlias())) {
            namespaceCombo.select(i);
        }
    }
    ExpandableComposite ec = new ExpandableComposite(composite, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
    ec.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ec.setLayout(new GridLayout(1, false));
    ec.setText("Command Options");
    Composite optionsComposite = new Composite(ec, SWT.NONE);
    optionsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    optionsComposite.setLayout(new GridLayout(2, false));
    Label l1 = new Label(optionsComposite, SWT.NONE);
    l1.setText("Comment");
    GridData gridData = new GridData(SWT.NONE, SWT.TOP, false, false);
    l1.setLayoutData(gridData);
    Text comment = new Text(optionsComposite, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    comment.setText(command.getComment() != null ? command.getComment() : "");
    ec.setExpanded(!comment.getText().isEmpty());
    gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gridData.heightHint = 2 * comment.getLineHeight();
    comment.setLayoutData(gridData);
    ec.setClient(optionsComposite);
    ec.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            parent.layout(true);
            composite.layout();
            optionsComposite.layout();
        }
    });
    comment.addModifyListener(evt -> {
        if (comment.getText().trim().isEmpty()) {
            command.setComment(null);
        } else {
            command.setComment(comment.getText());
        }
    });
    atb = new ArgumentTableBuilder(command);
    atb.createArgumentTable(composite);
    atb.updateCommandArguments();
    atb.pack();
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 32 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project xtext-eclipse by eclipse.

the class OptionsConfigurationBlock method createStyleSection.

protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
    ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
    excomposite.setText(label);
    excomposite.setExpanded(false);
    excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
    excomposite.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            expandedStateChanged((ExpandableComposite) e.getSource());
        }
    });
    expandedComposites.add(excomposite);
    makeScrollableCompositeAware(excomposite);
    return excomposite;
}
Also used : GridData(org.eclipse.swt.layout.GridData) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 33 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project tmdm-studio-se by Talend.

the class AMainPage method createFormContent.

@Override
protected void createFormContent(IManagedForm managedForm) {
    super.createFormContent(managedForm);
    try {
        // managedForm.getToolkit();
        FormToolkit toolkit = WidgetFactory.getWidgetFactory();
        final ScrolledForm form = managedForm.getForm();
        TableWrapLayout formLayout = new TableWrapLayout();
        form.getBody().setLayout(formLayout);
        formLayout.numColumns = 1;
        // create the FormPart
        firstSectionPart = new SectionPart(form.getBody(), toolkit, Section.DESCRIPTION | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED | ExpandableComposite.TITLE_BAR);
        managedForm.addPart(firstSectionPart);
        // Layout the components
        Section firstSection = firstSectionPart.getSection();
        firstSection.setText(Messages.AMainPage_Characteristics);
        firstSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
        firstSection.addExpansionListener(new ExpansionAdapter() {

            @Override
            public void expansionStateChanged(ExpansionEvent e) {
                form.reflow(true);
            }
        });
        firstSection.setDescription(Messages.AMainPage_MainCharacteristics);
        firstSection.setLayout(new GridLayout(1, false));
        // toolkit.createCompositeSeparator(firstSection);
        Composite charComposite = toolkit.createComposite(firstSection);
        charComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        GridLayout charLayout = new GridLayout(2, false);
        charComposite.setLayout(charLayout);
        firstSection.setClient(charComposite);
        createCharacteristicsContent(toolkit, charComposite);
        // adapt body add mouse/focus listener for child
        // WidgetFactory factory=WidgetFactory.getWidgetFactory();
        toolkit.adapt(form.getBody());
        initReadOnly(form);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) XtentisException(com.amalto.workbench.utils.XtentisException) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) SectionPart(org.eclipse.ui.forms.SectionPart) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 34 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project tmdm-studio-se by Talend.

the class AMainPage method getNewSection.

protected Section getNewSection(String title, int style) {
    // create the FormPart
    SectionPart newSectionPart = new SectionPart(this.getManagedForm().getForm().getBody(), this.getManagedForm().getToolkit(), style);
    this.getManagedForm().addPart(newSectionPart);
    // Layout the components
    Section newSection = newSectionPart.getSection();
    if (title != null) {
        newSection.setText(title);
    }
    newSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    newSection.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            AMainPage.this.getManagedForm().getForm().reflow(true);
        }
    });
    newSection.setLayout(new GridLayout(1, false));
    // this.getManagedForm().getToolkit().createCompositeSeparator(newSection);
    // in case someone calls getClient directly
    newSection.setClient(getNewSectionComposite(newSection));
    return newSection;
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) SectionPart(org.eclipse.ui.forms.SectionPart) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 35 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project tmdm-studio-se by Talend.

the class AMainPageV2 method getNewSection.

protected Section getNewSection(String title, int style) {
    // create the FormPart
    SectionPart newSectionPart = new SectionPart(this.getManagedForm().getForm().getBody(), this.getManagedForm().getToolkit(), style);
    this.getManagedForm().addPart(newSectionPart);
    // Layout the components
    Section newSection = newSectionPart.getSection();
    if (title != null) {
        newSection.setText(title);
    }
    newSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    newSection.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            AMainPageV2.this.getManagedForm().getForm().reflow(true);
        }
    });
    newSection.setLayout(new GridLayout(1, false));
    // this.getManagedForm().getToolkit().createCompositeSeparator(newSection);
    // in case someone calls getClient directly
    newSection.setClient(getNewSectionComposite(newSection));
    return newSection;
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) SectionPart(org.eclipse.ui.forms.SectionPart) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Aggregations

ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)58 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)53 GridData (org.eclipse.swt.layout.GridData)46 Composite (org.eclipse.swt.widgets.Composite)46 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)46 GridLayout (org.eclipse.swt.layout.GridLayout)38 Section (org.eclipse.ui.forms.widgets.Section)30 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 TableViewer (org.eclipse.jface.viewers.TableViewer)11 ArrayList (java.util.ArrayList)7 ICellModifier (org.eclipse.jface.viewers.ICellModifier)7 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)7 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)7 SelectionListener (org.eclipse.swt.events.SelectionListener)7 Point (org.eclipse.swt.graphics.Point)7 Label (org.eclipse.swt.widgets.Label)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 TableItem (org.eclipse.swt.widgets.TableItem)7 ParseTree (org.antlr.v4.runtime.tree.ParseTree)6 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)6