use of org.eclipse.jface.viewers.CheckboxTableViewer in project whole by wholeplatform.
the class PlatformLibraryContainerPage method createControl.
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
Table table = new Table(container, SWT.CHECK | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn column = new TableColumn(table, SWT.NONE);
column.setText("Bundle ID");
column = new TableColumn(table, SWT.NONE);
column.setText("Version");
TableLayout layout = new TableLayout();
layout.addColumnData(new ColumnWeightData(60));
layout.addColumnData(new ColumnWeightData(40));
table.setLayout(layout);
// PluginRegistry.findModel(bundleId)
container.setLayout(new GridLayout());
Label label = new Label(container, SWT.NULL);
label.setText("Included Jar Files:");
jarsViewer = new CheckboxTableViewer(table);
jarsViewer.setContentProvider(new ArrayContentProvider());
jarsViewer.setLabelProvider(new ClasspathLabelProvider());
jarsViewer.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return super.compare(viewer, ((Bundle) e1).getSymbolicName(), ((Bundle) e2).getSymbolicName());
}
});
jarsViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
Set<String> excludedBundleIDs = getExclusions(containerEntry.getPath());
List<Bundle> bundles = new ArrayList<Bundle>();
List<Bundle> checkedElements = new ArrayList<Bundle>();
for (String bundleId : PlatformLibraryClasspathContainer.BUNDLE_IDS) {
Bundle bundle = Platform.getBundle(bundleId);
if (bundle == null)
continue;
bundles.add(bundle);
if (!excludedBundleIDs.contains(bundleId))
checkedElements.add(bundle);
}
jarsViewer.setInput(bundles);
jarsViewer.setCheckedElements(checkedElements.toArray());
setControl(container);
Dialog.applyDialogFont(container);
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project eclipse-integration-commons by spring-projects.
the class ChooseMultipleSection method createContents.
@Override
public void createContents(Composite page) {
Composite composite = new Composite(page, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
composite.setLayout(layout);
GridDataFactory grab = GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, UIConstants.SCROLLABLE_LIST_HEIGTH);
grab.applyTo(composite);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(composite, SWT.NONE);
label.setText(labelText);
GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).hint(UIConstants.fieldLabelWidthHint(label), SWT.DEFAULT).applyTo(label);
CheckboxTableViewer tv = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
grab.applyTo(tv.getTable());
tv.setContentProvider(new ContentProvider());
tv.setLabelProvider(new LabelProvider());
tv.setInput(validChoices);
tv.setCheckedElements(chosen.getValues().toArray());
tv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
@SuppressWarnings("unchecked") T e = (T) event.getElement();
boolean checked = event.getChecked();
if (checked) {
chosen.add(e);
} else {
chosen.remove(e);
}
}
});
if (DEBUG) {
chosen.addListener(new ValueListener<Set<T>>() {
public void gotValue(LiveExpression<Set<T>> exp, Set<T> value) {
System.out.println(">>>> starters");
for (T e : value) {
System.out.println(e.getLabel());
}
System.out.println("<<<< starters");
}
});
}
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project webtools.sourceediting by eclipse.
the class TextHoverPreferenceTab method createContents.
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.sse.ui.preferences.ui.IPreferenceTab#createContents(org.eclipse.swt.widgets.Composite)
*/
public Control createContents(Composite tabFolder) {
Composite hoverComposite = new Composite(tabFolder, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
hoverComposite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
hoverComposite.setLayoutData(gd);
// commented out until these preferences are actually handled in some
// way
// String rollOverLabel=
// ResourceHandler.getString("TextHoverPreferenceTab.annotationRollover");
// //$NON-NLS-1$
// addCheckBox(hoverComposite, rollOverLabel,
// CommonEditorPreferenceNames.EDITOR_ANNOTATION_ROLL_OVER, 0);
//
// // Affordance checkbox
// String showAffordanceLabel =
// ResourceHandler.getString("TextHoverPreferenceTab.showAffordance");
// //$NON-NLS-1$
// addCheckBox(hoverComposite, showAffordanceLabel,
// CommonEditorPreferenceNames.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, 0);
Label label = new Label(hoverComposite, SWT.NONE);
// $NON-NLS-1$
label.setText(SSEUIMessages.TextHoverPreferenceTab_hoverPreferences);
gd = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
gd.horizontalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
fHoverTableViewer = CheckboxTableViewer.newCheckList(hoverComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
// Hover table
fHoverTable = fHoverTableViewer.getTable();
fHoverTable.setHeaderVisible(true);
fHoverTable.setLinesVisible(true);
gd = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=104507
GC gc = new GC(fHoverTable);
gc.setFont(fHoverTable.getFont());
FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
int heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 7);
gd.heightHint = heightHint;
fHoverTable.setLayoutData(gd);
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnWeightData(1, 140, true));
tableLayout.addColumnData(new ColumnWeightData(1, 140, true));
fHoverTable.setLayout(tableLayout);
fHoverTable.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
handleHoverListSelection();
}
});
fNameColumn = new TableColumn(fHoverTable, SWT.NONE);
// $NON-NLS-1$
fNameColumn.setText(SSEUIMessages.TextHoverPreferenceTab_nameColumnTitle);
fNameColumn.setResizable(true);
fModifierColumn = new TableColumn(fHoverTable, SWT.NONE);
// $NON-NLS-1$
fModifierColumn.setText(SSEUIMessages.TextHoverPreferenceTab_modifierColumnTitle);
fModifierColumn.setResizable(true);
fHoverTableViewer.setUseHashlookup(true);
fHoverTableViewer.setContentProvider(new ArrayContentProvider());
fHoverTableViewer.setLabelProvider(new InternalTableLabelProvider());
((CheckboxTableViewer) fHoverTableViewer).addCheckStateListener(new ICheckStateListener() {
/*
* @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
*/
public void checkStateChanged(CheckStateChangedEvent event) {
String id = ((TextHoverDescriptor) event.getElement()).getId();
if (id == null)
return;
TextHoverManager.TextHoverDescriptor[] descriptors = getTextHoverManager().getTextHovers();
TextHoverManager.TextHoverDescriptor hoverConfig = null;
int i = 0, length = fTextHovers.length;
while (i < length) {
if (id.equals(descriptors[i].getId())) {
hoverConfig = fTextHovers[i];
hoverConfig.setEnabled(event.getChecked());
fModifierEditor.setEnabled(event.getChecked());
fHoverTableViewer.setSelection(new StructuredSelection(descriptors[i]));
}
i++;
}
handleHoverListSelection();
updateStatus(hoverConfig);
}
});
// Text field for modifier string
label = new Label(hoverComposite, SWT.LEFT);
// $NON-NLS-1$
label.setText(SSEUIMessages.TextHoverPreferenceTab_keyModifier);
fModifierEditor = new Text(hoverComposite, SWT.BORDER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
fModifierEditor.setLayoutData(gd);
fModifierEditor.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
public void keyPressed(KeyEvent e) {
isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
// &&
// e.time
// -time
// <
// 1000)
// {
String text = fModifierEditor.getText();
Point selection = fModifierEditor.getSelection();
int i = selection.x - 1;
while (i > -1 && Character.isWhitespace(text.charAt(i))) {
i--;
}
boolean needsPrefixDelimiter = i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
i = selection.y;
while (i < text.length() && Character.isWhitespace(text.charAt(i))) {
i++;
}
boolean needsPostfixDelimiter = i < text.length() && !String.valueOf(text.charAt(i)).equals(DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString = NLS.bind(SSEUIMessages.TextHoverPreferenceTab_insertDelimiterAndModifierAndDelimiter, new String[] { Action.findModifierString(e.stateMask) });
else if (needsPrefixDelimiter)
insertString = NLS.bind(SSEUIMessages.TextHoverPreferenceTab_insertDelimiterAndModifier, new String[] { Action.findModifierString(e.stateMask) });
else if (needsPostfixDelimiter)
insertString = NLS.bind(SSEUIMessages.TextHoverPreferenceTab_insertModifierAndDelimiter, new String[] { Action.findModifierString(e.stateMask) });
else
insertString = Action.findModifierString(e.stateMask);
if (insertString != null)
fModifierEditor.insert(insertString);
}
}
});
fModifierEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
handleModifierModified();
}
});
// Description
Label descriptionLabel = new Label(hoverComposite, SWT.LEFT);
// $NON-NLS-1$
descriptionLabel.setText(SSEUIMessages.TextHoverPreferenceTab_description);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
gd.horizontalSpan = 2;
descriptionLabel.setLayoutData(gd);
fDescription = new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd.horizontalSpan = 2;
fDescription.setLayoutData(gd);
initialize();
Dialog.applyDialogFont(hoverComposite);
PlatformUI.getWorkbench().getHelpSystem().setHelp(hoverComposite, IHelpContextIds.PREFSTE_HOVERS_HELPID);
return hoverComposite;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project webtools.sourceediting by eclipse.
the class InstalledProcessorsBlock method createControl.
public void createControl(Composite ancestor) {
Composite parent = new Composite(ancestor, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
parent.setLayout(layout);
Font font = ancestor.getFont();
parent.setFont(font);
fControl = parent;
GridData data;
Label tableLabel = new Label(parent, SWT.NONE);
tableLabel.setText(Messages.InstalledProcessorsBlock_0);
data = new GridData();
data.horizontalSpan = 2;
tableLabel.setLayoutData(data);
tableLabel.setFont(font);
Table fTable = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
data = new GridData(GridData.FILL_BOTH);
data.widthHint = 450;
fTable.setLayoutData(data);
fTable.setFont(font);
fTable.setHeaderVisible(true);
fTable.setLinesVisible(true);
TableColumn column1 = new TableColumn(fTable, SWT.NONE);
column1.setWidth(180);
column1.setResizable(true);
column1.setText(Messages.InstalledProcessorsBlock_1);
column1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sortByName();
}
});
TableColumn column2 = new TableColumn(fTable, SWT.NONE);
column2.setWidth(90);
column2.setResizable(true);
column2.setText(Messages.InstalledProcessorsBlock_2);
column2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sortByType();
}
});
TableColumn column4 = new TableColumn(fTable, SWT.NONE);
column4.setWidth(180);
column4.setResizable(true);
column4.setText(Messages.InstalledProcessorsBlock_4);
column4.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sortByVersion();
}
});
tableViewer = new CheckboxTableViewer(fTable);
tableViewer.setLabelProvider(new VMLabelProvider());
tableViewer.setContentProvider(new ProcessorsContentProvider());
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent evt) {
enableButtons();
}
});
tableViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getChecked()) {
setCheckedInstall((IProcessorInstall) event.getElement());
} else {
setCheckedInstall(null);
}
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent e) {
if (!tableViewer.getSelection().isEmpty()) {
editProcessor();
}
}
});
fTable.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
removeProcessors();
}
}
});
Composite buttons = new Composite(parent, SWT.NULL);
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
buttons.setLayout(layout);
buttons.setFont(font);
fAddButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_5);
fAddButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
addProcessor();
}
});
fEditButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_6);
fEditButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
editProcessor();
}
});
fRemoveButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_7);
fRemoveButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event evt) {
removeProcessors();
}
});
// copied from ListDialogField.CreateSeparator()
Label separator = new Label(buttons, SWT.NONE);
separator.setVisible(false);
GridData gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.verticalAlignment = GridData.BEGINNING;
gd.heightHint = 4;
separator.setLayoutData(gd);
fillWithWorkspaceProcessors();
enableButtons();
restoreColumnSettings();
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project bndtools by bndtools.
the class JpmDependencyWizardPage method createControl.
@Override
@SuppressWarnings("unused")
public void createControl(Composite parent) {
// CREATE CONTROLS
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
Label lblDirect = new Label(container, SWT.NONE);
lblDirect.setFont(JFaceResources.getBannerFont());
lblDirect.setText("Direct Dependencies:");
Table tblDirect = new Table(container, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
viewerDirect = new TableViewer(tblDirect);
viewerDirect.setContentProvider(ArrayContentProvider.getInstance());
viewerDirect.setLabelProvider(new ResourceDescriptorLabelProvider());
createHelpLabel(container, "The above dependencies will be added to the project and, if necessary, to the Searchable Repository local index.");
Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
Label lblIndirect = new Label(container, SWT.NONE);
lblIndirect.setFont(JFaceResources.getBannerFont());
lblIndirect.setText("Transitive Dependencies:");
Composite cmpIndirect = new Composite(container, SWT.NONE);
Table tblIndirect = new Table(cmpIndirect, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
viewerIndirect = new CheckboxTableViewer(tblIndirect);
viewerIndirect.setContentProvider(ArrayContentProvider.getInstance());
viewerIndirect.setLabelProvider(new ResourceDescriptorLabelProvider());
Button btnSelectAll = new Button(cmpIndirect, SWT.PUSH);
btnSelectAll.setText("All");
Button btnSelectNone = new Button(cmpIndirect, SWT.PUSH);
btnSelectNone.setText("None");
new Label(cmpIndirect, SWT.NONE);
createHelpLabel(container, "The above dependencies will be added to the Searchable Repository local index. Checked dependencies will also be added directly to the project.");
// LISTENERS
// Query JPM and show results *after* dialog is shown. This ensures progress is visible in the dialog's
// progress bar
getContainer().getShell().addShellListener(new ShellAdapter() {
@Override
public void shellActivated(ShellEvent e) {
runQuery();
}
});
viewerIndirect.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent ev) {
if (selectedIndirectResources == null)
selectedIndirectResources = new HashSet<ResourceDescriptor>();
ResourceDescriptor resource = (ResourceDescriptor) ev.getElement();
if (ev.getChecked())
selectedIndirectResources.add(resource);
else
selectedIndirectResources.remove(resource);
}
});
btnSelectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedIndirectResources.addAll(indirectResources);
updateSelectedCheckboxes();
}
});
btnSelectNone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedIndirectResources.clear();
updateSelectedCheckboxes();
}
});
viewerDirect.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
if (sel.isEmpty())
selection = (ResourceDescriptor) ((IStructuredSelection) viewerIndirect.getSelection()).getFirstElement();
else
selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
getContainer().updateMessage();
}
});
viewerIndirect.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
if (sel.isEmpty())
selection = (ResourceDescriptor) ((IStructuredSelection) viewerDirect.getSelection()).getFirstElement();
else
selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
getContainer().updateMessage();
}
});
// LAYOUT
GridLayout layout;
GridData gd;
layout = new GridLayout(1, true);
container.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 30;
tblDirect.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
separator.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
cmpIndirect.setLayoutData(gd);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = 2;
layout.verticalSpacing = 2;
cmpIndirect.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
gd.heightHint = 100;
tblIndirect.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
btnSelectAll.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, false, false);
btnSelectNone.setLayoutData(gd);
}
Aggregations