Search in sources :

Example 16 with ITreeViewerListener

use of org.eclipse.jface.viewers.ITreeViewerListener 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 17 with ITreeViewerListener

use of org.eclipse.jface.viewers.ITreeViewerListener 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

ITreeViewerListener (org.eclipse.jface.viewers.ITreeViewerListener)17 TreeExpansionEvent (org.eclipse.jface.viewers.TreeExpansionEvent)17 GridData (org.eclipse.swt.layout.GridData)8 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)7 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)7 TreeItem (org.eclipse.swt.widgets.TreeItem)5 IRepositoryNode (org.talend.repository.model.IRepositoryNode)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4 CheckboxRepositoryTreeViewer (org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer)4 DeferredContentProvider (com.cubrid.common.ui.common.navigator.DeferredContentProvider)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 Viewer (org.eclipse.jface.viewers.Viewer)3