use of org.eclipse.jface.viewers.CheckboxTableViewer in project cubrid-manager by CUBRID.
the class CommonUITool method createCheckBoxTableViewer.
/**
*
* Create the common checkbox table viewer that can be sorted by
* TableViewerSorter object,this viewer's input object must be
* List<Map<String,Object>> and Map's key must be column index,Map's value
* of the column must be String.
*
* @param parent the parent composite
* @param sorter the table sorter
* @param columnNameArr the column name array
* @param gridData the gridData layout object
* @return the TableViewer object
*/
public static TableViewer createCheckBoxTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, GridData gridData) {
final CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
tableViewer.setContentProvider(new TableContentProvider());
tableViewer.setLabelProvider(new TableLabelProvider());
if (sorter != null) {
tableViewer.setSorter(sorter);
}
tableViewer.getTable().setLinesVisible(true);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLayoutData(gridData);
for (int i = 0; i < columnNameArr.length; i++) {
final TableColumn tblColumn = new TableColumn(tableViewer.getTable(), SWT.LEFT);
tblColumn.setText(columnNameArr[i]);
if (sorter != null) {
tblColumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
TableColumn column = (TableColumn) event.widget;
int j = 0;
for (j = 0; j < columnNameArr.length; j++) {
if (column.getText().equals(columnNameArr[j])) {
break;
}
}
TableViewerSorter sorter = ((TableViewerSorter) tableViewer.getSorter());
if (sorter == null) {
return;
}
sorter.doSort(j);
tableViewer.getTable().setSortColumn(column);
tableViewer.getTable().setSortDirection(sorter.isAsc() ? SWT.UP : SWT.DOWN);
tableViewer.refresh();
packTable(tableViewer);
}
});
}
tblColumn.pack();
}
return tableViewer;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project eclipse.platform.text by eclipse.
the class HyperlinkDetectorsConfigurationBlock method createControl.
@Override
public Control createControl(Composite parent) {
PixelConverter pixelConverter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
addFiller(composite, 2);
String label = TextEditorMessages.HyperlinksEnabled_label;
fHyperlinksEnabledCheckBox = addCheckBox(composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED, 0);
fHyperlinksEnabledCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean state = fHyperlinksEnabledCheckBox.getSelection();
fHyperlinkDefaultKeyModifierText.setEnabled(state);
fHyperlinkKeyModifierText.setEnabled(state && getSelectedItem() != null);
fHyperlinkDetectorsViewer.getTable().setEnabled(state);
handleHyperlinkKeyModifierModified();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
// Text field for default modifier string
label = TextEditorMessages.HyperlinkDefaultKeyModifier_label;
fHyperlinkDefaultKeyModifierText = (Text) addTextField(composite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER, 15, 20, pixelConverter)[1];
fHyperlinkDefaultKeyModifierText.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
@Override
public void keyPressed(KeyEvent e) {
isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
@Override
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
// && e.time -time < 1000) {
String modifierString = fHyperlinkDefaultKeyModifierText.getText();
Point selection = fHyperlinkDefaultKeyModifierText.getSelection();
int i = selection.x - 1;
while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
i--;
}
boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
i = selection.y;
while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
i++;
}
boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask));
else if (needsPrefixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask));
else if (needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask));
else
insertString = Action.findModifierString(e.stateMask);
fHyperlinkDefaultKeyModifierText.insert(insertString);
}
}
});
fHyperlinkDefaultKeyModifierText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
handleHyperlinkDefaultKeyModifierModified();
}
});
addFiller(composite, 2);
Composite editorComposite = new Composite(composite, SWT.NONE);
GridData gd;
gd = new GridData(SWT.FILL, SWT.TOP, true, false);
gd.horizontalSpan = 2;
gd.horizontalIndent = 20;
editorComposite.setLayoutData(gd);
TableColumnLayout tableColumnlayout = new TableColumnLayout();
editorComposite.setLayout(tableColumnlayout);
// Hyperlink detector table
Table hyperlinkDetectorTable = new Table(editorComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
hyperlinkDetectorTable.setHeaderVisible(true);
hyperlinkDetectorTable.setLinesVisible(true);
hyperlinkDetectorTable.setFont(parent.getFont());
hyperlinkDetectorTable.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
handleListSelection();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
ColumnLayoutData columnLayoutData = new ColumnWeightData(1);
TableColumn nameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 0);
nameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_nameColumn);
tableColumnlayout.setColumnData(nameColumn, columnLayoutData);
TableColumn modifierKeysColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 1);
modifierKeysColumn.setText(TextEditorMessages.HyperlinkDetectorTable_modifierKeysColumn);
tableColumnlayout.setColumnData(modifierKeysColumn, columnLayoutData);
TableColumn targetNameColumn = new TableColumn(hyperlinkDetectorTable, SWT.NONE, 2);
targetNameColumn.setText(TextEditorMessages.HyperlinkDetectorTable_targetNameColumn);
tableColumnlayout.setColumnData(targetNameColumn, columnLayoutData);
fHyperlinkDetectorsViewer = new CheckboxTableViewer(hyperlinkDetectorTable);
fHyperlinkDetectorsViewer.setUseHashlookup(true);
fHyperlinkDetectorsViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
String id = ((ListItem) event.getElement()).id;
if (id == null)
return;
fStore.setValue(id, !event.getChecked());
}
});
fHyperlinkDetectorsViewer.setLabelProvider(new ItemLabelProvider());
fHyperlinkDetectorsViewer.setContentProvider(new ItemContentProvider());
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = pixelConverter.convertHeightInCharsToPixels(10);
fHyperlinkDetectorsViewer.getControl().setLayoutData(gd);
// addFiller(composite, 2);
// Text field for modifier string
label = TextEditorMessages.HyperlinkKeyModifier_label;
fHyperlinkKeyModifierText = (Text) addTextField(composite, label, null, 15, 20, pixelConverter)[1];
fHyperlinkKeyModifierText.addKeyListener(new KeyListener() {
private boolean isModifierCandidate;
@Override
public void keyPressed(KeyEvent e) {
isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
@Override
public void keyReleased(KeyEvent e) {
if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
// && e.time -time < 1000) {
String modifierString = fHyperlinkKeyModifierText.getText();
Point selection = fHyperlinkKeyModifierText.getSelection();
int i = selection.x - 1;
while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
i--;
}
boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
i = selection.y;
while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
i++;
}
boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(MODIFIER_DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifierAndDelimiter, Action.findModifierString(e.stateMask));
else if (needsPrefixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertDelimiterAndModifier, Action.findModifierString(e.stateMask));
else if (needsPostfixDelimiter)
insertString = NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_insertModifierAndDelimiter, Action.findModifierString(e.stateMask));
else
insertString = Action.findModifierString(e.stateMask);
fHyperlinkKeyModifierText.insert(insertString);
}
}
});
fHyperlinkKeyModifierText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
handleHyperlinkKeyModifierModified();
}
});
return composite;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project linuxtools by eclipse.
the class RunImageVolumesTab method createVolumesTable.
private CheckboxTableViewer createVolumesTable(final Composite container) {
final Table table = new Table(container, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
final CheckboxTableViewer tableViewer = new CheckboxTableViewer(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
addTableViewerColumn(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.containerPathColumn"), 150);
addTableViewerColumn(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.mountColumn"), 150);
addTableViewerColumn(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.readonlyColumn"), 60);
return tableViewer;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project linuxtools by eclipse.
the class ImageRunResourceVolumesVariablesPage method createVolumeSettingsContainer.
private void createVolumeSettingsContainer(final Composite container) {
final Label volumesLabel = new Label(container, SWT.NONE);
volumesLabel.setText(WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.dataVolumesLabel"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(COLUMNS, 1).applyTo(volumesLabel);
final CheckboxTableViewer dataVolumesTableViewer = createVolumesTable(container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).hint(200, 100).applyTo(dataVolumesTableViewer.getTable());
// buttons
final Composite buttonsContainers = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(false, false).applyTo(buttonsContainers);
GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(SWT.DEFAULT, 0).applyTo(buttonsContainers);
final Button addButton = new Button(buttonsContainers, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(addButton);
addButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.addButton"));
addButton.addSelectionListener(onAddDataVolume(dataVolumesTableViewer));
final Button editButton = new Button(buttonsContainers, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(editButton);
editButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.editButton"));
editButton.addSelectionListener(onEditDataVolume(dataVolumesTableViewer));
editButton.setEnabled(false);
final Button removeButton = new Button(buttonsContainers, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(removeButton);
removeButton.setText(WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.removeButton"));
removeButton.addSelectionListener(onRemoveDataVolumes(dataVolumesTableViewer));
removeButton.setEnabled(false);
// update table content when selected image changes
bind(dataVolumesTableViewer, model.getDataVolumes(), BeanProperties.values(DataVolumeModel.class, DataVolumeModel.CONTAINER_PATH, DataVolumeModel.MOUNT, DataVolumeModel.READ_ONLY_VOLUME));
dbc.bindSet(ViewersObservables.observeCheckedElements(dataVolumesTableViewer, DataVolumeModel.class), BeanProperties.set(ImageRunResourceVolumesVariablesModel.SELECTED_DATA_VOLUMES).observe(model));
// disable the edit and removeButton if the table is empty
dataVolumesTableViewer.addSelectionChangedListener(onSelectionChanged(editButton, removeButton));
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project linuxtools by eclipse.
the class ImageRunResourceVolumesVariablesPage method createVolumesTable.
private CheckboxTableViewer createVolumesTable(final Composite container) {
final Table table = new Table(container, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
final CheckboxTableViewer tableViewer = new CheckboxTableViewer(table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
dbc.bindSet(ViewersObservables.observeCheckedElements(tableViewer, DataVolumeModel.class), BeanProperties.set(ImageRunResourceVolumesVariablesModel.SELECTED_DATA_VOLUMES).observe(model));
addTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.containerPathColumn"), 150);
addTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.mountColumn"), 150);
addTableViewerColum(tableViewer, WizardMessages.getString(// $NON-NLS-1$
"ImageRunResourceVolVarPage.readonlyColumn"), 60);
return tableViewer;
}
Aggregations