Search in sources :

Example 1 with LoggingBit

use of org.eclipse.titan.common.parsers.cfg.indices.LoggingBit in project titan.EclipsePlug-ins by eclipse.

the class LoggingBitsSubPage method checkStateChangeHandler.

private void checkStateChangeHandler(final Map<LoggingBit, ParseTree> bitMask, final ParseTree bitmaskRoot, final CheckStateChangedEvent event) {
    editor.setDirty();
    LoggingBit bit = (LoggingBit) event.getElement();
    if (LoggingBitHelper.hasChildren(bit)) {
        LoggingBit[] children = LoggingBitHelper.getChildren(bit);
        if (bitMask.containsKey(bit)) {
            removeLoggingBit(bitMask, bitmaskRoot, bit);
        } else {
            addLoggingBit(bitMask, bitmaskRoot, bit);
        }
        for (int i = 0; i < children.length; i++) {
            if (bitMask.containsKey(children[i])) {
                removeLoggingBit(bitMask, bitmaskRoot, children[i]);
            }
        }
    } else {
        if (bitMask.containsKey(bit)) {
            removeLoggingBit(bitMask, bitmaskRoot, bit);
        } else {
            LoggingBit parent = LoggingBitHelper.getParent(bit);
            if (parent == null) {
                return;
            }
            LoggingBit[] children = LoggingBitHelper.getChildren(parent);
            int elementCount = 0;
            for (LoggingBit child : children) {
                if (bitMask.containsKey(child)) {
                    elementCount++;
                }
            }
            if (bitMask.containsKey(parent)) {
                removeLoggingBit(bitMask, bitmaskRoot, parent);
                for (int i = 0; i < children.length; i++) {
                    if (!bitMask.containsKey(children[i]) && !bit.equals(children[i])) {
                        addLoggingBit(bitMask, bitmaskRoot, children[i]);
                    }
                }
            } else if (elementCount == children.length - 1) {
                addLoggingBit(bitMask, bitmaskRoot, parent);
                for (int i = 0; i < children.length; i++) {
                    if (bitMask.containsKey(children[i])) {
                        removeLoggingBit(bitMask, bitmaskRoot, children[i]);
                    }
                }
            } else {
                addLoggingBit(bitMask, bitmaskRoot, bit);
            }
        }
    }
}
Also used : LoggingBit(org.eclipse.titan.common.parsers.cfg.indices.LoggingBit) Point(org.eclipse.swt.graphics.Point)

Example 2 with LoggingBit

use of org.eclipse.titan.common.parsers.cfg.indices.LoggingBit in project titan.EclipsePlug-ins by eclipse.

the class LoggingBitsSubPage method evaluateSelection.

private void evaluateSelection(final CheckboxTreeViewer viewer, final Map<LoggingBit, ParseTree> bitMask) {
    LoggingBit[] firstLevelnodes = LoggingBitHelper.getFirstLevelNodes();
    LoggingBit[] children;
    List<LoggingBit> toBeGrayed = new ArrayList<LoggingBit>();
    List<LoggingBit> toBeSelected = new ArrayList<LoggingBit>();
    toBeSelected.addAll(bitMask.keySet());
    for (LoggingBit firstLevelnode : firstLevelnodes) {
        children = LoggingBitHelper.getChildren(firstLevelnode);
        int count = 0;
        for (LoggingBit child : children) {
            if (bitMask.containsKey(child)) {
                count++;
            }
        }
        if (count != 0) {
            toBeGrayed.add(firstLevelnode);
            toBeSelected.add(firstLevelnode);
        }
        if (bitMask.containsKey(firstLevelnode)) {
            for (LoggingBit child : children) {
                toBeSelected.add(child);
            }
        }
    }
    viewer.setGrayedElements(toBeGrayed.toArray());
    viewer.setCheckedElements(toBeSelected.toArray());
}
Also used : LoggingBit(org.eclipse.titan.common.parsers.cfg.indices.LoggingBit) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point)

Example 3 with LoggingBit

use of org.eclipse.titan.common.parsers.cfg.indices.LoggingBit 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 4 with LoggingBit

use of org.eclipse.titan.common.parsers.cfg.indices.LoggingBit 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)

Example 5 with LoggingBit

use of org.eclipse.titan.common.parsers.cfg.indices.LoggingBit in project titan.EclipsePlug-ins by eclipse.

the class LoggingBitsSubPage method logAllHandler.

private void logAllHandler(final Map<LoggingBit, ParseTree> bitMask, final ParseTree bitmaskRoot) {
    if (bitMask.containsKey(LoggingBit.LOG_ALL)) {
        LoggingBit[] logAllBits = LoggingBitHelper.getLogAllBits();
        for (LoggingBit bit : logAllBits) {
            if (!bitMask.containsKey(bit)) {
                addLoggingBit(bitMask, bitmaskRoot, bit);
            }
        }
        removeLoggingBit(bitMask, bitmaskRoot, LoggingBit.LOG_ALL);
    }
}
Also used : LoggingBit(org.eclipse.titan.common.parsers.cfg.indices.LoggingBit)

Aggregations

LoggingBit (org.eclipse.titan.common.parsers.cfg.indices.LoggingBit)5 Point (org.eclipse.swt.graphics.Point)4 ParseTree (org.antlr.v4.runtime.tree.ParseTree)2 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)2 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)2 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)2 ITreeViewerListener (org.eclipse.jface.viewers.ITreeViewerListener)2 TreeExpansionEvent (org.eclipse.jface.viewers.TreeExpansionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)2 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)2 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)2 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)2 Section (org.eclipse.ui.forms.widgets.Section)2 ArrayList (java.util.ArrayList)1