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