Search in sources :

Example 36 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter in project hale by halestudio.

the class MismatchDetailsPage method createConsequenceSection.

private void createConsequenceSection(Composite parent) {
    // create "Consequence" Section
    Section sectionConsequence = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    ColumnLayoutData cd = new ColumnLayoutData();
    sectionConsequence.setLayoutData(cd);
    sectionConsequence.addExpansionListener(new ExpansionAdapter() {

        public void expansionStateChanged(ExpansionEvent e) {
            overviewForm.reflow(true);
        }
    });
    sectionConsequence.setText("Consequence(s)");
    sectionConsequence.setDescription("What impacts this mismatch has.");
    Composite sectionConsequenceClient = toolkit.createComposite(sectionConsequence);
    ColumnLayout consequenceColumnLayout = new ColumnLayout();
    consequenceColumnLayout.maxNumColumns = 1;
    sectionConsequenceClient.setLayout(consequenceColumnLayout);
    Tree treeConsequence = toolkit.createTree(sectionConsequenceClient, SWT.NULL);
    treeConsequence.setLayout(new ColumnLayout());
    ColumnLayoutData treeLayoutData = new ColumnLayoutData(50, 123);
    treeConsequence.setLayoutData(treeLayoutData);
    toolkit.paintBordersFor(sectionConsequenceClient);
    sectionConsequence.setClient(sectionConsequenceClient);
    this.consequenceTreeViewer = new TreeViewer(treeConsequence);
    this.consequenceTreeViewer.setContentProvider(new ConsequenceContentProvider());
    this.consequenceTreeViewer.setLabelProvider(new ConsequenceLabelProvider());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ColumnLayout(org.eclipse.ui.forms.widgets.ColumnLayout) ColumnLayoutData(org.eclipse.ui.forms.widgets.ColumnLayoutData) Tree(org.eclipse.swt.widgets.Tree) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 37 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter 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 38 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter 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 39 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.

the class LoggingBitsSubPage method createSubSectionFileMaskBits.

void createSubSectionFileMaskBits(final FormToolkit toolkit, final ScrolledForm form, final Composite parent) {
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    section.setText("File Log bitmask");
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    client.setLayout(layout);
    section.setClient(client);
    toolkit.paintBordersFor(client);
    fileMaskViewer = new CheckboxTreeViewer(client, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    fileMaskViewer.setContentProvider(new LoggingBitsContentProvider());
    fileMaskViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    fileMaskViewer.setLabelProvider(new LoggingBitsLabelProvider());
    fileMaskViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            if (event.getChecked() && selectedLogEntry.getFileMaskRoot() == null) {
                createFileMaskRootNode(loggingPage.getSelectedTreeElement(), selectedLogEntry);
            }
            checkStateChangeHandler(selectedLogEntry.getFileMaskBits(), selectedLogEntry.getFileMask(), event);
            bitCompression(selectedLogEntry.getFileMaskBits(), selectedLogEntry.getFileMask());
            evaluateSelection(fileMaskViewer, selectedLogEntry.getFileMaskBits());
            if (!event.getChecked()) {
                if (selectedLogEntry.getFileMaskBits().keySet().isEmpty()) {
                    ConfigTreeNodeUtilities.removeChild(loggingSectionHandler.getLastSectionRoot(), selectedLogEntry.getFileMaskRoot());
                    selectedLogEntry.setFileMaskRoot(null);
                }
            }
        }
    });
    fileMaskViewer.getTree().addListener(SWT.MouseHover, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            TreeItem item = fileMaskViewer.getTree().getItem(new Point(event.x, event.y));
            if (item != null) {
                if (item.getData() instanceof LoggingBit) {
                    fileMaskViewer.getTree().setToolTipText(((LoggingBit) item.getData()).getToolTip());
                    return;
                }
            }
            fileMaskViewer.getTree().setToolTipText("");
        }
    });
    fileMaskViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(final TreeExpansionEvent event) {
        // Do nothing
        }

        @Override
        public void treeExpanded(final TreeExpansionEvent event) {
            evaluateSelection(fileMaskViewer, selectedLogEntry.getFileMaskBits());
        }
    });
    if (selectedLogEntry == null) {
        fileMaskViewer.getControl().setEnabled(false);
        fileMaskViewer.setInput(new EnumMap<LoggingBit, ParseTree>(LoggingBit.class));
    } else {
        fileMaskViewer.getControl().setEnabled(true);
        fileMaskViewer.setInput(selectedLogEntry.getFileMaskBits());
        bitCompression(selectedLogEntry.getFileMaskBits(), selectedLogEntry.getFileMask());
        evaluateSelection(fileMaskViewer, selectedLogEntry.getFileMaskBits());
    }
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TreeItem(org.eclipse.swt.widgets.TreeItem) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Point(org.eclipse.swt.graphics.Point) Section(org.eclipse.ui.forms.widgets.Section) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) LoggingBit(org.eclipse.titan.common.parsers.cfg.indices.LoggingBit) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 40 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.

the class LoggingBitsSubPage method createSubSectionConsoleMaskBits.

void createSubSectionConsoleMaskBits(final FormToolkit toolkit, final ScrolledForm form, final Composite parent) {
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    section.setText("Console Log bitmask");
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    client.setLayout(layout);
    section.setClient(client);
    toolkit.paintBordersFor(client);
    consoleMaskViewer = new CheckboxTreeViewer(client, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    consoleMaskViewer.setContentProvider(new LoggingBitsContentProvider());
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 230;
    consoleMaskViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    consoleMaskViewer.setLabelProvider(new LoggingBitsLabelProvider());
    consoleMaskViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            if (event.getChecked() && selectedLogEntry.getConsoleMaskRoot() == null) {
                createConsoleMaskRootNode(loggingPage.getSelectedTreeElement(), selectedLogEntry);
            }
            checkStateChangeHandler(selectedLogEntry.getConsoleMaskBits(), selectedLogEntry.getConsoleMask(), event);
            bitCompression(selectedLogEntry.getConsoleMaskBits(), selectedLogEntry.getConsoleMask());
            evaluateSelection(consoleMaskViewer, selectedLogEntry.getConsoleMaskBits());
            if (!event.getChecked()) {
                if (selectedLogEntry.getConsoleMaskBits().keySet().isEmpty()) {
                    ConfigTreeNodeUtilities.removeChild(loggingSectionHandler.getLastSectionRoot(), selectedLogEntry.getConsoleMaskRoot());
                    selectedLogEntry.setConsoleMaskRoot(null);
                }
            }
        }
    });
    consoleMaskViewer.getTree().addListener(SWT.MouseHover, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            TreeItem item = consoleMaskViewer.getTree().getItem(new Point(event.x, event.y));
            if (item != null) {
                if (item.getData() instanceof LoggingBit) {
                    consoleMaskViewer.getTree().setToolTipText(((LoggingBit) item.getData()).getToolTip());
                    return;
                }
            }
            consoleMaskViewer.getTree().setToolTipText("");
        }
    });
    consoleMaskViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(final TreeExpansionEvent event) {
        // Do nothing
        }

        @Override
        public void treeExpanded(final TreeExpansionEvent event) {
            evaluateSelection(consoleMaskViewer, selectedLogEntry.getConsoleMaskBits());
        }
    });
    if (selectedLogEntry == null) {
        consoleMaskViewer.getControl().setEnabled(false);
        consoleMaskViewer.setInput(new EnumMap<LoggingBit, ParseTree>(LoggingBit.class));
    } else {
        consoleMaskViewer.getControl().setEnabled(true);
        consoleMaskViewer.setInput(selectedLogEntry.getConsoleMaskBits());
        bitCompression(selectedLogEntry.getConsoleMaskBits(), selectedLogEntry.getConsoleMask());
        evaluateSelection(consoleMaskViewer, selectedLogEntry.getConsoleMaskBits());
    }
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TreeItem(org.eclipse.swt.widgets.TreeItem) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Point(org.eclipse.swt.graphics.Point) Section(org.eclipse.ui.forms.widgets.Section) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) LoggingBit(org.eclipse.titan.common.parsers.cfg.indices.LoggingBit) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)53 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)53 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)43 Composite (org.eclipse.swt.widgets.Composite)42 GridData (org.eclipse.swt.layout.GridData)40 GridLayout (org.eclipse.swt.layout.GridLayout)33 Section (org.eclipse.ui.forms.widgets.Section)28 TableViewer (org.eclipse.jface.viewers.TableViewer)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 ICellModifier (org.eclipse.jface.viewers.ICellModifier)7 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)7 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 TableItem (org.eclipse.swt.widgets.TableItem)7 ArrayList (java.util.ArrayList)6 ParseTree (org.antlr.v4.runtime.tree.ParseTree)6 Point (org.eclipse.swt.graphics.Point)6 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5