use of org.eclipse.jface.viewers.CheckboxTableViewer in project translationstudio8 by heartsome.
the class ConfigureColumnsAction method createColumnControlPanel.
/**
* Create the dialog area. TODO can be done much nicer ... but works for the first draft
*
* @param parent parent composite
* @return initialized control
*/
private Control createColumnControlPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NULL);
panel.setLayout(new RowLayout());
Label l = new Label(panel, SWT.NULL);
l.setText("Configure the columns");
Table table = new Table(parent, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
_chkBoxViewer = new CheckboxTableViewer(table);
_chkBoxViewer.setContentProvider(new ColTableContentProvider());
_chkBoxViewer.setLabelProvider(new ColTableLabelProvider());
TableColumn column = new TableColumn(_chkBoxViewer.getTable(), SWT.LEFT);
column.setText("Column");
column.setWidth(100);
_chkBoxViewer.getTable().setHeaderVisible(true);
_chkBoxViewer.setInput("x");
final int firstColIdx = _allowFixedColumns ? 0 : _table.getFixedColumns();
for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
IColumn col = _table.getTableModel().getColumn(i);
_chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
}
table.getColumn(0).pack();
table.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
TableItem item = (TableItem) event.item;
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (_allowFixedColumns || idx >= _table.getFixedColumns()) {
_tvs.setColumnVisible(col, item.getChecked());
} else {
_chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
}
}
}
});
Button upButton = new Button(panel, SWT.PUSH);
upButton.setText("up");
upButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (idx > firstColIdx) {
_tvs.getSortedColumns().remove(col);
_tvs.getSortedColumns().add(idx - 1, col);
_table.updateColumnList();
_table.redraw();
_chkBoxViewer.refresh();
}
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
Button downButton = new Button(panel, SWT.PUSH);
downButton.setText("down");
downButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
IColumn col = (IColumn) item.getData();
int idx = _tvs.getSortedColumns().indexOf(col);
if (idx < _tvs.getSortedColumns().size() - 1) {
_tvs.getSortedColumns().remove(col);
_tvs.getSortedColumns().add(idx + 1, col);
_table.updateColumnList();
_table.redraw();
_chkBoxViewer.refresh();
}
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
return panel;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project archi by archimatetool.
the class ConnectionsPreferencePage method createRelationsTable.
private CheckboxTableViewer createRelationsTable(Composite parent) {
final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 80;
viewer.getTable().setLayoutData(gd);
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ArchiLabelProvider.INSTANCE.getDefaultName((EClass) element);
}
@Override
public Image getImage(Object element) {
return ArchiLabelProvider.INSTANCE.getImage(element);
}
});
viewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object inputElement) {
return ConnectionPreferences.RELATION_KEYMAP.keySet().toArray();
}
});
viewer.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isGrayed(Object element) {
return false;
}
@Override
public boolean isChecked(Object element) {
int value = (Integer) viewer.getInput();
return (value & ConnectionPreferences.RELATION_KEYMAP.get(element)) != 0;
}
});
return viewer;
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project sling by apache.
the class ConvertProjectsPage method createControl.
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 5;
container.setLayout(layout);
Table table = new Table(container, SWT.MULTI | SWT.CHECK | SWT.BORDER);
GridData gd = new GridData(GridData.FILL_BOTH);
table.setLayoutData(gd);
ctv = new CheckboxTableViewer(table);
ctv.setLabelProvider(new ProjectLabelProvider());
ctv.add(projects.toArray());
ctv.setCheckedElements(initialSelection);
setControl(container);
Dialog.applyDialogFont(container);
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project eclipse.platform.text by eclipse.
the class SearchDialog method handleCustomizePressed.
private void handleCustomizePressed() {
List<SearchPageDescriptor> input = SearchPlugin.getDefault().getSearchPageDescriptors();
input = filterByActivities(input);
final ArrayList<Image> createdImages = new ArrayList<>(input.size());
ILabelProvider labelProvider = new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof SearchPageDescriptor)
return LegacyActionTools.removeMnemonics(((SearchPageDescriptor) element).getLabel());
return null;
}
@Override
public Image getImage(Object element) {
if (element instanceof SearchPageDescriptor) {
ImageDescriptor imageDesc = ((SearchPageDescriptor) element).getImage();
if (imageDesc == null)
return null;
Image image = imageDesc.createImage();
if (image != null)
createdImages.add(image);
return image;
}
return null;
}
};
String message = SearchMessages.SearchPageSelectionDialog_message;
ListSelectionDialog dialog = new ListSelectionDialog(getShell(), input, new ArrayContentProvider(), labelProvider, message) {
Button fLastUsedPageButton;
@Override
public void create() {
super.create();
final CheckboxTableViewer viewer = getViewer();
final Button okButton = this.getOkButton();
viewer.addCheckStateListener(event -> okButton.setEnabled(viewer.getCheckedElements().length > 0));
SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
okButton.setEnabled(viewer.getCheckedElements().length > 0);
}
};
this.getButton(IDialogConstants.SELECT_ALL_ID).addSelectionListener(listener);
this.getButton(IDialogConstants.DESELECT_ALL_ID).addSelectionListener(listener);
}
@Override
protected Control createDialogArea(Composite parent) {
Composite control = (Composite) super.createDialogArea(parent);
fLastUsedPageButton = new Button(control, SWT.CHECK);
fLastUsedPageButton.setText(SearchMessages.SearchPageSelectionDialog_rememberLastUsedPage_message);
fLastUsedPageButton.setSelection(fDialogSettings.getBoolean(STORE_IS_OPEN_PREVIOUS_PAGE));
return control;
}
@Override
protected void okPressed() {
fDialogSettings.put(STORE_IS_OPEN_PREVIOUS_PAGE, fLastUsedPageButton.getSelection());
super.okPressed();
}
};
dialog.setTitle(SearchMessages.SearchPageSelectionDialog_title);
dialog.setInitialSelections(SearchPlugin.getDefault().getEnabledSearchPageDescriptors(fInitialPageId).toArray());
if (dialog.open() == Window.OK) {
SearchPageDescriptor.setEnabled(dialog.getResult());
Display display = getShell().getDisplay();
close();
if (display != null && !display.isDisposed()) {
display.asyncExec(() -> new OpenSearchDialogAction().run());
}
}
destroyImages(createdImages);
}
use of org.eclipse.jface.viewers.CheckboxTableViewer in project eclipse.platform.text by eclipse.
the class MatchFilterSelectionDialog method createMatchFilterControls.
private void createMatchFilterControls(Composite parent) {
// Create list viewer
Label l = new Label(parent, SWT.NONE);
l.setFont(parent.getFont());
l.setText(SearchMessages.MatchFilterSelectionDialog_filter_description);
Table table = new Table(parent, SWT.CHECK | SWT.BORDER);
table.setFont(parent.getFont());
fListViewer = new CheckboxTableViewer(table);
GridData data = new GridData(GridData.FILL_BOTH);
data.minimumHeight = convertHeightInCharsToPixels(8);
table.setLayoutData(data);
class ListenerAndLabelProvider extends LabelProvider implements ISelectionChangedListener, ICheckStateListener {
@Override
public void selectionChanged(SelectionChangedEvent event) {
performFilterListSelectionChanged();
}
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
performFilterListCheckStateChanged();
}
@Override
public String getText(Object element) {
return ((MatchFilter) element).getName();
}
}
ListenerAndLabelProvider listenerAndLP = new ListenerAndLabelProvider();
fListViewer.setLabelProvider(listenerAndLP);
fListViewer.setContentProvider(new ArrayContentProvider());
fListViewer.addSelectionChangedListener(listenerAndLP);
fListViewer.addCheckStateListener(listenerAndLP);
fListViewer.setInput(fAllFilters);
fListViewer.setCheckedElements(fEnabledFilters);
l = new Label(parent, SWT.NONE);
l.setFont(parent.getFont());
l.setText(SearchMessages.MatchFilterSelectionDialog_description_label);
fDescription = new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
fDescription.setFont(parent.getFont());
data = new GridData(GridData.FILL_HORIZONTAL);
data.heightHint = convertHeightInCharsToPixels(3);
fDescription.setLayoutData(data);
}
Aggregations