Search in sources :

Example 91 with ExpansionEvent

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

the class LoggingBitsSubPage method createSubSectionConsoleMaskBits.

void createSubSectionConsoleMaskBits(final FormToolkit toolkit, final ScrolledForm form, final Composite parent) {
    final 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);
        }
    });
    final Composite client = toolkit.createComposite(section, SWT.WRAP);
    final 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());
    final 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) {
            final 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)

Example 92 with ExpansionEvent

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

the class ModuleParameterSectionPage method createDetailsPart.

private void createDetailsPart(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
    final Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
    section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
    final Composite client = toolkit.createComposite(section, SWT.WRAP);
    final GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    client.setLayout(layout);
    parameterValueText = toolkit.createText(client, "", SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    parameterValueText.setLayoutData(new GridData(GridData.FILL_BOTH));
    parameterValueText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            final StructuredSelection selection = (StructuredSelection) moduleParametersTableViewer.getSelection();
            final Iterator<?> iterator = selection.iterator();
            if (!iterator.hasNext()) {
                return;
            }
            final ModuleParameter moduleParameter = (ModuleParameter) iterator.next();
            ConfigTreeNodeUtilities.setText(moduleParameter.getValue(), parameterValueText.getText());
            if (valueChanged) {
                valueChanged = false;
                return;
            }
            editor.setDirty();
        }
    });
    parameterValueText.setEnabled(moduleParametersHandler != null);
    section.setText("Module parameter value");
    section.setDescription("Specify the concrete value for the actually selected module parameter.");
    section.setClient(client);
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    final GridData gd = new GridData(GridData.FILL_BOTH);
    gd.grabExcessVerticalSpace = true;
    section.setLayoutData(gd);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModuleParameter(org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Iterator(java.util.Iterator) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 93 with ExpansionEvent

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

the class ErrorsWarningsPreferencePage method createExtendableComposite.

/**
 * Creates an expandable composite on the user interface.
 *
 * @param parent
 *                the parent composite where this one can be added to.
 * @param title
 *                the title of the new composite.
 *
 * @return the created composite.
 */
private ExpandableComposite createExtendableComposite(final Composite parent, final String title) {
    final ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
    ex.setText(title);
    ex.setExpanded(false);
    final GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    ex.setLayoutData(data);
    ex.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            Composite temp = parent;
            while (temp != null && !(temp instanceof ScrolledComposite)) {
                temp = temp.getParent();
            }
            if (temp != null) {
                final Point point = pagecomp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                ((ScrolledComposite) temp).setMinSize(point);
                ((ScrolledComposite) temp).layout(true, true);
            }
        }
    });
    return ex;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Point(org.eclipse.swt.graphics.Point) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 94 with ExpansionEvent

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

the class BaseNamingConventionPropertyPage method createExtendableComposite.

/**
 * Creates an expandable composite on the user interface.
 *
 * @param parent
 *                the parent composite where this one can be added to.
 * @param title
 *                the title of the new composite.
 *
 * @return the created composite.
 */
private ExpandableComposite createExtendableComposite(final Composite parent, final String title) {
    final ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
    ex.setText(title);
    ex.setExpanded(false);
    final GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    ex.setLayoutData(data);
    ex.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            Composite temp = parent;
            while (temp != null && !(temp instanceof ScrolledComposite)) {
                temp = temp.getParent();
            }
            if (temp != null) {
                final Point point = pagecomp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                ((ScrolledComposite) temp).setMinSize(point);
                ((ScrolledComposite) temp).layout(true, true);
            }
        }
    });
    return ex;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Point(org.eclipse.swt.graphics.Point) 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