use of org.eclipse.jface.viewers.ArrayContentProvider in project knime-core by knime.
the class PluginSelectionPage method createControl.
/**
* {@inheritDoc}
*/
@Override
public void createControl(final Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
container.setBounds(0, 0, 600, 200);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
container.setLayout(layout);
m_table = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.SHADOW_IN);
m_table.setLabelProvider(new LabelProvider());
m_table.setContentProvider(new ArrayContentProvider());
m_table.setSorter(new ViewerSorter() {
/**
* {@inheritDoc}
*/
@Override
public int compare(final Viewer viewer, final Object e1, final Object e2) {
String s1 = (String) e1;
String s2 = (String) e2;
return s1.compareTo(s2);
}
});
initTable();
m_table.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
String selection = (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
m_table.setChecked(selection, !m_table.getChecked(selection));
updatePageComplete();
}
});
/*
m_table.addSelectionChangedListener(new ISelectionChangedListener() {
/**
*
* {@inheritDoc}
*
public void selectionChanged(final SelectionChangedEvent event) {
updatePageComplete();
}
});
*/
GridData gridData = new GridData();
gridData.widthHint = 400;
m_table.getControl().setLayoutData(gridData);
Composite buttonCont = new Composite(container, SWT.TOP);
GridLayout layout2 = new GridLayout();
layout2.numColumns = 1;
buttonCont.setLayout(layout2);
gridData = new GridData();
buttonCont.setLayoutData(gridData);
Button selectAll = new Button(buttonCont, SWT.PUSH);
selectAll.setText("Select all");
gridData = new GridData();
gridData.verticalAlignment = SWT.TOP;
gridData.horizontalAlignment = SWT.RIGHT;
gridData.widthHint = 80;
selectAll.setLayoutData(gridData);
selectAll.addSelectionListener(new SelectionListener() {
/**
* {@inheritDoc}
*/
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
m_table.setAllChecked(true);
updatePageComplete();
}
/**
* {@inheritDoc}
*/
@Override
public void widgetSelected(final SelectionEvent e) {
m_table.setAllChecked(true);
updatePageComplete();
}
});
Button deselectAll = new Button(buttonCont, SWT.PUSH);
deselectAll.setText("Deselect all");
gridData = new GridData();
gridData.verticalAlignment = SWT.TOP;
gridData.horizontalAlignment = SWT.RIGHT;
gridData.widthHint = 80;
deselectAll.setLayoutData(gridData);
deselectAll.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
m_table.setAllChecked(false);
updatePageComplete();
}
@Override
public void widgetSelected(final SelectionEvent e) {
m_table.setAllChecked(false);
updatePageComplete();
}
});
setControl(container);
updatePageComplete();
setMessage(null);
setErrorMessage(null);
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project yamcs-studio by yamcs.
the class ColorMapEditDialog method createColorListViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createColorListViewer(final Composite parent) {
final TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
final TableViewerColumn tvColumn = new TableViewerColumn(viewer, SWT.NONE);
tvColumn.getColumn().setText("Value");
tvColumn.getColumn().setMoveable(false);
tvColumn.getColumn().setWidth(100);
tvColumn.setEditingSupport(new ValueColumnEditingSupport(viewer, viewer.getTable()));
tvColumn.getColumn().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Table table = viewer.getTable();
int dir = table.getSortDirection();
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
viewer.getTable().setSortDirection(dir);
Object[] colorTupleArray = colorList.toArray();
Arrays.sort(colorTupleArray);
colorList.clear();
int i = 0;
ColorTuple[] array = new ColorTuple[colorTupleArray.length];
for (Object o : colorTupleArray) {
if (dir == SWT.UP)
array[i++] = (ColorTuple) o;
else
array[colorTupleArray.length - 1 - i++] = (ColorTuple) o;
}
colorList.addAll(Arrays.asList(array));
viewer.refresh();
}
});
final TableViewerColumn colorColumn = new TableViewerColumn(viewer, SWT.NONE);
colorColumn.getColumn().setText("Color");
colorColumn.getColumn().setMoveable(false);
colorColumn.getColumn().setWidth(100);
colorColumn.setEditingSupport(new ColorColumnEditingSupport(viewer, viewer.getTable()));
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ColorListLabelProvider());
viewer.getTable().setSortColumn(tvColumn.getColumn());
viewer.getTable().setSortDirection(SWT.UP);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
refreshToolbarOnSelection();
}
});
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
return viewer;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project yamcs-studio by yamcs.
the class ConnectionsDialog method createServerPanel.
private Composite createServerPanel(Composite parent, ResourceManager resourceManager) {
Composite serverPanel = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
serverPanel.setLayoutData(gd);
TableColumnLayout tcl = new TableColumnLayout();
serverPanel.setLayout(tcl);
Image serverImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ConnectionsDialog.class, "icons/obj16/server.gif"));
connViewer = new TableViewer(serverPanel, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
connViewer.getTable().setHeaderVisible(true);
connViewer.getTable().setLinesVisible(false);
TableViewerColumn nameColumn = new TableViewerColumn(connViewer, SWT.NONE);
nameColumn.getColumn().setText("Connection Name");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
return serverImage;
}
@Override
public String getText(Object element) {
YamcsConfiguration conf = (YamcsConfiguration) element;
return conf.getName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(400));
connViewer.setContentProvider(new ArrayContentProvider());
connViewer.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.getFirstElement() != null) {
YamcsConfiguration conf = (YamcsConfiguration) sel.getFirstElement();
yamcsInstanceText.setText(forceString(conf.getInstance()));
yamcsUserText.setText(forceString(conf.getUser()));
yamcsPasswordText.setText(forceString(conf.getPassword()));
savePasswordButton.setSelection(conf.isSavePassword());
yamcsPrimaryHostText.setText(forceString(conf.getPrimaryHost()));
yamcsPrimaryPortText.setText(forceString(conf.getPrimaryPort()));
yamcsFailoverHostText.setText(forceString(conf.getFailoverHost()));
yamcsFailoverPortText.setText(forceString(conf.getFailoverPort()));
nameText.setText(forceString(conf.getName()));
updateState();
}
});
connViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
YamcsConfiguration c1 = (YamcsConfiguration) o1;
YamcsConfiguration c2 = (YamcsConfiguration) o2;
if (c1.getName() != null && c2.getName() != null)
return c1.getName().compareTo(c2.getName());
else
return 0;
}
});
return serverPanel;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project yamcs-studio by yamcs.
the class PVTupleTableEditor method createPVTupleListTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createPVTupleListTableViewer(final Composite parent) {
final TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
final TableViewerColumn numColumn = new TableViewerColumn(viewer, SWT.NONE);
numColumn.getColumn().setText("#");
numColumn.getColumn().setMoveable(false);
numColumn.getColumn().setWidth(50);
final TableViewerColumn pvColumn = new TableViewerColumn(viewer, SWT.NONE);
pvColumn.getColumn().setText("PV Name");
pvColumn.getColumn().setMoveable(false);
pvColumn.getColumn().setWidth(220);
pvColumn.setEditingSupport(new PVColumnEditingSupport(viewer, viewer.getTable()));
final TableViewerColumn TrigColumn = new TableViewerColumn(viewer, SWT.NONE);
TrigColumn.getColumn().setText("Trigger");
TrigColumn.getColumn().setMoveable(false);
TrigColumn.getColumn().pack();
TrigColumn.setEditingSupport(new TriggerColumnEditingSupport(viewer, viewer.getTable()));
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new PVTupleLabelProvider(pvTupleList));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
refreshToolbarOnSelection();
}
});
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
DropTarget target = new DropTarget(viewer.getControl(), DND.DROP_MOVE | DND.DROP_COPY);
target.setTransfer(new Transfer[] { TextTransfer.getInstance() });
target.addDropListener(new DropTargetListener() {
@Override
public void dragEnter(DropTargetEvent event) {
}
@Override
public void dragLeave(DropTargetEvent event) {
}
@Override
public void dragOperationChanged(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetEvent event) {
}
@Override
public void drop(DropTargetEvent event) {
if (event == null || !(event.data instanceof String))
return;
String txt = (String) event.data;
String[] names = txt.split("[\r\n]+");
PVTuple[] tuples = new PVTuple[names.length];
int i = 0;
for (String name : names) {
tuples[i] = new PVTuple(name, true);
pvTupleList.add(tuples[i]);
i++;
}
refreshTableViewerFromAction(tuples);
}
@Override
public void dropAccept(DropTargetEvent event) {
}
});
return viewer;
}
use of org.eclipse.jface.viewers.ArrayContentProvider in project yamcs-studio by yamcs.
the class PropertiesEditDialog method createPropertiesViewer.
private TableViewer createPropertiesViewer(Composite parent) {
TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
TableViewerColumn tvColumn = new TableViewerColumn(viewer, SWT.NONE);
tvColumn.getColumn().setText("Property");
tvColumn.getColumn().setMoveable(false);
tvColumn.getColumn().setWidth(150);
tvColumn = new TableViewerColumn(viewer, SWT.NONE);
tvColumn.getColumn().setText("Value");
tvColumn.getColumn().setMoveable(false);
tvColumn.getColumn().setWidth(150);
EditingSupport editingSupport = new PropertyDataEditingSupport(viewer, viewer.getTable());
tvColumn.setEditingSupport(editingSupport);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new PropertyDataLabelProvider());
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
return viewer;
}
Aggregations