use of org.eclipse.jface.viewers.CheckboxTableViewer 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.CheckboxTableViewer 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.CheckboxTableViewer in project bndtools by bndtools.
the class ResolutionChoiceSelectionDialog method createDialogArea.
@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Multiple Provider Candidates");
setMessage("Use the candidate list to specify your preferences. Candidates at the top of the list will be preferred by the resolver.");
// Create controls
Composite outer = (Composite) super.createDialogArea(parent);
Composite contents = new Composite(outer, SWT.NONE);
Label lblRequirement = new Label(contents, SWT.NONE);
lblRequirement.setText("Requirement Info");
lblRequirement.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
StyledText txtRequirement = new StyledText(contents, SWT.WRAP | SWT.BORDER);
txtRequirement.setEditable(false);
txtRequirement.setCaret(null);
// txtRequirement.setBackground(contents.getBackground());
txtRequirement.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
new Label(contents, SWT.NONE);
Label lblCandidates = new Label(contents, SWT.NONE);
lblCandidates.setText("Candidates");
lblCandidates.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
Composite lowerPanel = new Composite(contents, SWT.NONE);
Table tbl = new Table(lowerPanel, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
viewer = new CheckboxTableViewer(tbl);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new CapabilityLabelProvider());
btnUp = new Button(lowerPanel, SWT.PUSH);
btnUp.setText("Move Up");
btnUp.setEnabled(false);
btnDown = new Button(lowerPanel, SWT.PUSH);
btnDown.setText("Move Down");
btnDown.setEnabled(false);
Composite cmpPreferences = new Composite(contents, SWT.NONE);
btnSavePreference = new Button(cmpPreferences, SWT.CHECK | SWT.WRAP);
txtSavePreference = new StyledText(cmpPreferences, SWT.WRAP);
txtSavePreference.setEditable(false);
txtSavePreference.setCaret(null);
txtSavePreference.setBackground(contents.getBackground());
txtSavePreference.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
// Events
txtSavePreference.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
btnSavePreference.setSelection(!btnSavePreference.getSelection());
}
});
// Load data
StyledString label = createRequirementText();
txtRequirement.setText(label.getString());
txtRequirement.setStyleRanges(label.getStyleRanges());
viewer.setInput(candidates);
updateSavePreferenceText();
// Layout
GridLayout layout;
GridData gd;
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
contents.setLayoutData(gd);
layout = new GridLayout(1, false);
contents.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
gd.horizontalIndent = 5;
txtRequirement.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
lowerPanel.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
lowerPanel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
gd.widthHint = 450;
gd.heightHint = 250;
tbl.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
btnUp.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, false, false);
btnDown.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.NONE, true, false);
cmpPreferences.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
cmpPreferences.setLayout(layout);
gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
btnSavePreference.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
txtSavePreference.setLayoutData(gd);
return contents;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project tesb-studio-se by Talend.
the class CheckedCamelDependenciesPanel method selectAll.
private void selectAll(boolean state) {
boolean hasChanged = false;
Collection<? extends ManifestItem> input = getInput();
for (ManifestItem bcp : input) {
if (bcp.isBuiltIn() || !bcp.isOptional() == state) {
continue;
}
hasChanged = true;
bcp.setOptional(!state);
((CheckboxTableViewer) tableViewer).setChecked(bcp, state);
}
if (hasChanged) {
// ((CheckboxTableViewer) tableViewer).setAllChecked(state);
fireDependenciesChangedListener();
}
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project hale by halestudio.
the class LayersDialog method createDialogArea.
/**
* @see TitleAreaDialog#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
page.setLayoutData(data);
page.setLayout(new FillLayout());
CheckboxTableViewer table = CheckboxTableViewer.newCheckList(page, SWT.V_SCROLL | SWT.BORDER);
TableColumn names = new TableColumn(table.getTable(), SWT.NONE);
names.setWidth(200);
names.setText(Messages.LayersDialog_2);
TableColumn descs = new TableColumn(table.getTable(), SWT.NONE);
descs.setWidth(200);
descs.setText(Messages.LayersDialog_3);
// labels
table.setLabelProvider(new LayerLabelProvider());
table.setCheckStateProvider(new LayerCheckStateProvider());
table.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
((Layer) event.getElement()).setSelected(event.getChecked());
}
});
// content
table.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
}
@Override
public void dispose() {
// ignore
}
@Override
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
return ((List<Layer>) inputElement).toArray();
}
});
table.setInput(layers);
table.getTable().setLinesVisible(true);
table.getTable().setHeaderVisible(true);
// pack columns
names.pack();
descs.pack();
return page;
}
Aggregations