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);
}
}
}
}
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());
}
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());
}
}
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());
}
}
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);
}
}
Aggregations