use of org.eclipse.jface.viewers.ICheckStateListener in project bndtools by bndtools.
the class EnableSubBundlesDialog method createDialogArea.
/**
* Create contents of the dialog.
*
* @param parent
*/
@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
setMessage(Messages.EmptyBndFileWizard_questionSubBundlesNotEnabled);
setTitle("Sub-bundles not enabled");
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginTop = 20;
layout.marginWidth = 10;
layout.verticalSpacing = 10;
container.setLayout(layout);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
btnEnableSubbundles = new Button(container, SWT.CHECK);
btnEnableSubbundles.setText(Messages.EnableSubBundlesDialog_btnEnableSubbundles_text_3);
btnEnableSubbundles.setSelection(enableSubBundles);
new Label(container, SWT.NONE);
link = new Link(container, SWT.NONE);
link.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
link.setText(Messages.EnableSubBundlesDialog_link_text);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getShell().notifyListeners(SWT.Help, new Event());
}
});
propsTable = new Table(container, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION);
GridData gd_propsTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
gd_propsTable.heightHint = 100;
gd_propsTable.widthHint = 175;
propsTable.setLayoutData(gd_propsTable);
viewer = new CheckboxTableViewer(propsTable);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setInput(allProperties);
viewer.setCheckedElements(selectedProperties.toArray());
btnCheckAll = new Button(container, SWT.NONE);
btnCheckAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
btnCheckAll.setText(Messages.EnableSubBundlesDialog_btnCheckAll_text);
btnUncheckAll = new Button(container, SWT.NONE);
btnUncheckAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
btnUncheckAll.setText(Messages.EnableSubBundlesDialog_btnUncheckAll_text);
lblHeaderCount = new Label(container, SWT.NONE);
lblHeaderCount.setText(MessageFormat.format("", allProperties.size()));
// Spacer
new Label(container, SWT.NONE);
btnEnableSubbundles.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enableSubBundles = btnEnableSubbundles.getSelection();
updateEnablement();
}
});
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
String property = (String) event.getElement();
if (event.getChecked())
selectedProperties.add(property);
else
selectedProperties.remove(property);
}
});
btnCheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedProperties.clear();
selectedProperties.addAll(allProperties);
viewer.setCheckedElements(selectedProperties.toArray());
}
});
btnUncheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedProperties.clear();
viewer.setCheckedElements(selectedProperties.toArray());
}
});
PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), Plugin.PLUGIN_ID + ".enableSubBundles");
return area;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project bndtools by bndtools.
the class WizardBndFileSelector method createControl.
@Override
public void createControl(Composite composite) {
checkboxTreeViewer = new CheckboxTreeViewer(composite);
checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
ITreeContentProvider contentProvider = (ITreeContentProvider) checkboxTreeViewer.getContentProvider();
alterChildren(element, contentProvider, event.getChecked());
alterParents(element, contentProvider);
}
private void alterChildren(Object element, ITreeContentProvider contentProvider, boolean checked) {
Queue<Object> toRecurse = new LinkedList<Object>();
toRecurse.offer(element);
while (!toRecurse.isEmpty()) {
Object o = toRecurse.poll();
for (Object child : contentProvider.getChildren(o)) {
if (contentProvider.hasChildren(child))
toRecurse.offer(child);
checkboxTreeViewer.setChecked(child, checked);
checkboxTreeViewer.setGrayed(child, false);
}
}
}
private void alterParents(Object element, ITreeContentProvider contentProvider) {
Object parent = contentProvider.getParent(element);
while (parent != null) {
boolean allChecked = true;
boolean noneChecked = true;
for (Object child : contentProvider.getChildren(parent)) {
boolean checked = checkboxTreeViewer.getChecked(child);
boolean grayed = checkboxTreeViewer.getGrayed(child);
allChecked &= checked & !grayed;
noneChecked &= !checked;
}
if (allChecked) {
checkboxTreeViewer.setChecked(parent, true);
checkboxTreeViewer.setGrayed(parent, false);
} else if (noneChecked) {
checkboxTreeViewer.setGrayChecked(parent, false);
} else {
checkboxTreeViewer.setGrayChecked(parent, true);
}
parent = contentProvider.getParent(parent);
}
}
});
setControl(checkboxTreeViewer.getControl());
}
use of org.eclipse.jface.viewers.ICheckStateListener in project bndtools by bndtools.
the class ResolutionSuccessPanel method createControl.
public void createControl(Composite parent) {
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
composite = toolkit.createComposite(parent);
GridLayout layout = new GridLayout(1, false);
composite.setLayout(layout);
SashForm form = new SashForm(composite, SWT.VERTICAL);
form.setLayout(new GridLayout(1, false));
form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridData gd;
Section sectRequired = toolkit.createSection(form, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED);
sectRequired.setText("Required Resources");
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 150;
sectRequired.setLayoutData(gd);
Table tblRequired = toolkit.createTable(sectRequired, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
sectRequired.setClient(tblRequired);
requiredViewer = new TableViewer(tblRequired);
requiredViewer.setContentProvider(ArrayContentProvider.getInstance());
requiredViewer.setLabelProvider(new ResourceLabelProvider());
requiredViewer.setSorter(new BundleSorter());
requiredViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
Resource resource = (Resource) sel.getFirstElement();
reasonsContentProvider.setOptional(false);
if (result != null)
reasonsContentProvider.setResolution(result.getResourceWirings());
reasonsViewer.setInput(resource);
reasonsViewer.expandToLevel(2);
}
});
sectOptional = toolkit.createSection(form, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
sectOptional.setText("Optional Resources");
Composite cmpOptional = toolkit.createComposite(sectOptional);
sectOptional.setClient(cmpOptional);
cmpOptional.setLayout(new GridLayout(2, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 150;
sectOptional.setLayoutData(gd);
Table tblOptional = toolkit.createTable(cmpOptional, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
tblOptional.setLayoutData(gd);
optionalViewer = new CheckboxTableViewer(tblOptional);
optionalViewer.setContentProvider(ArrayContentProvider.getInstance());
optionalViewer.setLabelProvider(new ResourceLabelProvider());
optionalViewer.setSorter(new BundleSorter());
optionalViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
doOptionalReasonUpdate((Resource) sel.getFirstElement());
}
});
optionalViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Resource resource = (Resource) event.getElement();
if (!addedOptionals.containsKey(resource)) {
if (event.getChecked()) {
checkedOptional.add(resource);
} else {
checkedOptional.remove(resource);
}
}
presenter.updateButtons();
updateResolveOptionalButton();
optionalViewer.setSelection(new ISelection() {
@Override
public boolean isEmpty() {
return true;
}
});
doOptionalReasonUpdate(resource);
}
});
Composite cmpOptionalButtons = toolkit.createComposite(cmpOptional);
cmpOptionalButtons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
GridLayout gl_cmpOptionalButtons = new GridLayout(3, false);
gl_cmpOptionalButtons.marginHeight = 0;
gl_cmpOptionalButtons.marginWidth = 0;
cmpOptionalButtons.setLayout(gl_cmpOptionalButtons);
btnAddResolveOptional = toolkit.createButton(cmpOptionalButtons, "Update and Resolve", SWT.NONE);
btnAddResolveOptional.setEnabled(false);
btnAddResolveOptional.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAddResolve();
}
});
btnAddResolveOptional.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));
Button btnAllOptional = toolkit.createButton(cmpOptionalButtons, "Select All", SWT.NONE);
btnAllOptional.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
optionalViewer.setAllChecked(true);
checkedOptional.clear();
for (Object object : optionalViewer.getCheckedElements()) {
if (!addedOptionals.containsKey(object)) {
checkedOptional.add((Resource) object);
}
}
presenter.updateButtons();
updateResolveOptionalButton();
}
});
btnAllOptional.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Button btnClearOptional = toolkit.createButton(cmpOptionalButtons, "Clear All", SWT.NONE);
btnClearOptional.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
optionalViewer.setAllChecked(false);
checkedOptional.clear();
presenter.updateButtons();
updateResolveOptionalButton();
}
});
btnClearOptional.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Section sectReason = toolkit.createSection(form, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
sectReason.setText("Reasons");
Tree tblReasons = new Tree(sectReason, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
sectReason.setClient(tblReasons);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 150;
sectReason.setLayoutData(gd);
reasonsViewer = new TreeViewer(tblReasons);
reasonsViewer.setContentProvider(reasonsContentProvider);
reasonsViewer.setLabelProvider(new ResolutionTreeLabelProvider());
}
use of org.eclipse.jface.viewers.ICheckStateListener 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.ICheckStateListener 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