Search in sources :

Example 46 with ExpansionEvent

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

the class JAREntryPart method createContent.

private void createContent(Composite parent, FormToolkit toolkit) {
    Section textSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED);
    textSection.setText("Entry Content");
    Composite textComposite = toolkit.createComposite(textSection);
    text = toolkit.createText(textComposite, "", SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
    text.setFont(JFaceResources.getTextFont());
    textSection.setClient(textComposite);
    Section encodingSection = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED);
    encodingSection.setText("Display Options");
    Composite encodingPanel = toolkit.createComposite(encodingSection);
    encodingSection.setClient(encodingPanel);
    toolkit.createLabel(encodingPanel, "Show As:");
    final Button btnText = toolkit.createButton(encodingPanel, "Text", SWT.RADIO);
    btnText.setSelection(showAsText);
    Button btnBinary = toolkit.createButton(encodingPanel, "Binary (hex)", SWT.RADIO);
    btnBinary.setSelection(!showAsText);
    toolkit.createLabel(encodingPanel, "Text Encoding:");
    final Combo encodingCombo = new Combo(encodingPanel, SWT.READ_ONLY);
    encodingCombo.setEnabled(showAsText);
    // INITIALISE
    encodingCombo.setItems(charsets);
    encodingCombo.select(selectedCharset);
    // LISTENERS
    encodingSection.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            getManagedForm().reflow(true);
        }
    });
    SelectionListener radioListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showAsText = btnText.getSelection();
            encodingCombo.setEnabled(showAsText);
            loadContent();
        }
    };
    btnText.addSelectionListener(radioListener);
    btnBinary.addSelectionListener(radioListener);
    encodingCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectedCharset = encodingCombo.getSelectionIndex();
            loadContent();
        }
    });
    // LAYOUT
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(1, false);
    parent.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    textSection.setLayoutData(gd);
    layout = new GridLayout(1, false);
    textComposite.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    text.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    encodingSection.setLayoutData(gd);
    encodingSection.setLayout(new FillLayout());
    encodingPanel.setLayout(new GridLayout(3, false));
    encodingCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Combo(org.eclipse.swt.widgets.Combo) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) IPartSelectionListener(org.eclipse.ui.forms.IPartSelectionListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 47 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project eclipse-integration-commons by spring-projects.

the class ExpandableSection method createContents.

@Override
public void createContents(final Composite page) {
    final ExpandableComposite comp = new ExpandableComposite(page, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(comp);
    comp.setText(title);
    comp.setLayout(new FillLayout());
    comp.addExpansionListener(new IExpansionListener() {

        public void expansionStateChanging(ExpansionEvent e) {
        }

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            expansionState.setValue(comp.isExpanded());
            reflow(owner, comp);
        }
    });
    expansionState.addListener(new ValueListener<Boolean>() {

        public void gotValue(LiveExpression<Boolean> exp, Boolean value) {
            if (value != null && comp != null && !comp.isDisposed()) {
                boolean newState = value;
                boolean currentState = comp.isExpanded();
                if (currentState != newState) {
                    comp.setExpanded(newState);
                    reflow(owner, comp);
                }
            }
        }
    });
    visibleState.addListener(new ValueListener<Boolean>() {

        @Override
        public void gotValue(LiveExpression<Boolean> exp, Boolean value) {
            if (value != null && comp != null && !comp.isDisposed()) {
                boolean newState = value;
                comp.setVisible(newState);
                GridData data = (GridData) comp.getLayoutData();
                data.exclude = !newState;
                reflow(owner, comp);
            }
        }
    });
    Composite client = new Composite(comp, SWT.NONE);
    client.setLayout(new GridLayout());
    child.createContents(client);
    comp.setClient(client);
}
Also used : IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 48 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project webtools.sourceediting by eclipse.

the class AbstractValidationSettingsPage method createStyleSectionWithContentComposite.

protected Composite createStyleSectionWithContentComposite(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() {

        public void expansionStateChanged(ExpansionEvent e) {
            expandedStateChanged((ExpandableComposite) e.getSource());
        }
    });
    fExpandables.add(excomposite);
    makeScrollableCompositeAware(excomposite);
    Composite inner = new Composite(excomposite, SWT.NONE);
    inner.setFont(excomposite.getFont());
    inner.setLayout(new GridLayout(nColumns, false));
    excomposite.setClient(inner);
    return inner;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) 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 49 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project webtools.sourceediting by eclipse.

the class AbstractValidationSettingsPage 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() {

        public void expansionStateChanged(ExpansionEvent e) {
            expandedStateChanged((ExpandableComposite) e.getSource());
        }
    });
    fExpandables.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 50 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project webtools.sourceediting by eclipse.

the class XSLValidationPreferencePage method createTwistie.

protected ExpandableComposite createTwistie(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());
        }
    });
    Expandables.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)

Aggregations

ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)94 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)73 Composite (org.eclipse.swt.widgets.Composite)71 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)70 GridData (org.eclipse.swt.layout.GridData)62 GridLayout (org.eclipse.swt.layout.GridLayout)56 Section (org.eclipse.ui.forms.widgets.Section)45 IExpansionListener (org.eclipse.ui.forms.events.IExpansionListener)18 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)16 Label (org.eclipse.swt.widgets.Label)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 Point (org.eclipse.swt.graphics.Point)14 TableViewer (org.eclipse.jface.viewers.TableViewer)12 ArrayList (java.util.ArrayList)11 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 Button (org.eclipse.swt.widgets.Button)10 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)9 List (java.util.List)8 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)8