use of org.eclipse.jface.viewers.CellEditor in project yamcs-studio by yamcs.
the class TextEditManager method createCellEditorOn.
@Override
protected CellEditor createCellEditorOn(Composite composite) {
CellEditor editor = new TextCellEditor(composite, (multiLine ? SWT.MULTI : SWT.SINGLE) | SWT.WRAP) {
@Override
protected void focusLost() {
// lose focus should cancel the editing
if (editPart.getExecutionMode() == ExecutionMode.RUN_MODE && editPart instanceof IPVWidgetEditpart && ((IPVWidgetEditpart) editPart).getPV() != null) {
if (isActivated()) {
fireCancelEditor();
deactivate();
}
editPart.getFigure().requestFocus();
} else
super.focusLost();
}
@Override
protected void handleDefaultSelection(SelectionEvent event) {
// In run mode, hit ENTER should force to write the new value even it doesn't change.
if (editPart.getExecutionMode() == ExecutionMode.RUN_MODE) {
setDirty(true);
}
super.handleDefaultSelection(event);
}
@Override
protected void keyReleaseOccured(KeyEvent keyEvent) {
// In run mode, CTRL+ENTER will always perform a write if it is multiline text input
if (keyEvent.character == '\r' && editPart.getExecutionMode() == ExecutionMode.RUN_MODE) {
// Return key
if (text != null && !text.isDisposed() && (text.getStyle() & SWT.MULTI) != 0) {
if ((keyEvent.stateMask & SWT.CTRL) != 0) {
setDirty(true);
}
}
}
super.keyReleaseOccured(keyEvent);
}
};
editor.getControl().moveAbove(null);
return editor;
}
use of org.eclipse.jface.viewers.CellEditor in project yamcs-studio by yamcs.
the class MultiLineTextPropertyDescriptor method createPropertyEditor.
/**
* {@inheritDoc}
*/
@Override
public CellEditor createPropertyEditor(final Composite parent) {
final String title = NLS.bind("Edit {0}", getDisplayName());
CellEditor editor = new MultiLineTextCellEditor(parent, title);
if (getValidator() != null) {
editor.setValidator(getValidator());
}
return editor;
}
use of org.eclipse.jface.viewers.CellEditor in project yamcs-studio by yamcs.
the class RuleDataEditDialog method createExpressionsTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createExpressionsTableViewer(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);
TableViewerColumn expressionColumn = new TableViewerColumn(viewer, SWT.NONE);
expressionColumn.getColumn().setText("Boolean Expression");
expressionColumn.getColumn().setMoveable(false);
expressionColumn.getColumn().setWidth(200);
expressionColumn.setEditingSupport(new EditingSupport(viewer) {
@Override
protected void setValue(Object element, Object value) {
if (element instanceof Expression)
((Expression) element).setBooleanExpression(value.toString());
viewer.refresh();
}
@Override
protected Object getValue(Object element) {
if (element instanceof Expression)
return ((Expression) element).getBooleanExpression();
return null;
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(viewer.getTable());
}
@Override
protected boolean canEdit(Object element) {
return true;
}
});
valueColumn = new TableViewerColumn(viewer, SWT.NONE);
valueColumn.getColumn().setText(ruleData.isOutputExpValue() ? "Output Expression" : "Output Value");
valueColumn.getColumn().setMoveable(false);
valueColumn.getColumn().setWidth(200);
EditingSupport editingSupport = new EditingSupport(viewer) {
@Override
protected void setValue(Object element, Object value) {
if (element instanceof Expression) {
((Expression) element).setValue(value);
}
viewer.refresh();
}
@Override
protected Object getValue(Object element) {
if (element instanceof Expression) {
if (((Expression) element).getValue() == null)
// $NON-NLS-1$
return "";
return ((Expression) element).getValue();
}
return null;
}
@Override
protected CellEditor getCellEditor(Object element) {
if (element instanceof Expression) {
if (ruleData.isOutputExpValue() || ruleData.getProperty().getPropertyDescriptor() == null)
return new TextCellEditor(viewer.getTable());
else
return ruleData.getProperty().getPropertyDescriptor().createPropertyEditor(viewer.getTable());
}
return null;
}
@Override
protected boolean canEdit(Object element) {
return true;
}
};
valueColumn.setEditingSupport(editingSupport);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ExpressionLabelProvider());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
viewer.getTable().setLayoutData(gd);
return viewer;
}
use of org.eclipse.jface.viewers.CellEditor in project dbeaver by dbeaver.
the class UIUtils method createPropertyEditor.
public static CellEditor createPropertyEditor(final IServiceLocator serviceLocator, Composite parent, DBPPropertySource source, DBPPropertyDescriptor property, int style) {
if (source == null) {
return null;
}
final Object object = source.getEditableValue();
if (!property.isEditable(object)) {
return null;
}
CellEditor cellEditor = UIUtils.createCellEditor(parent, object, property, style);
if (cellEditor != null) {
final Control editorControl = cellEditor.getControl();
addDefaultEditActionsSupport(serviceLocator, editorControl);
}
return cellEditor;
}
use of org.eclipse.jface.viewers.CellEditor in project erlide_eclipse by erlang.
the class ControlPanelView method createProcessesTable.
private Composite createProcessesTable(final Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout());
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.grabExcessVerticalSpace = true;
processesTableViewer = new TableViewer(container, style);
processesTableViewer.setUseHashlookup(true);
// table
final Table table = processesTableViewer.getTable();
table.setLayoutData(gridData);
table.setHeaderVisible(true);
table.setLinesVisible(true);
// columns
final String[] columnProperties = new String[ProcessColumn.values().length + ProcessFlag.values().length];
// columns: process properties
for (final ProcessColumn column : ProcessColumn.values()) {
final TableColumn tableColumn = new TableColumn(table, SWT.LEFT, column.ordinal());
tableColumn.setResizable(true);
tableColumn.setMoveable(false);
tableColumn.setWidth(column.getWidth());
tableColumn.setText(column.getName());
columnProperties[column.ordinal()] = column.name();
}
// columns: process flags
for (final ProcessFlag flag : ProcessFlag.values()) {
final TableColumn tableColumn = new TableColumn(table, SWT.CENTER, ProcessColumn.values().length + flag.ordinal());
tableColumn.setResizable(true);
tableColumn.setMoveable(false);
tableColumn.setWidth(60);
tableColumn.setText(flag.getName());
columnProperties[ProcessColumn.values().length + flag.ordinal()] = flag.name();
}
processesTableViewer.setColumnProperties(columnProperties);
// providers
processesTableViewer.setLabelProvider(new ProcessLabelProvider());
processesTableViewer.setContentProvider(new ProcessContentProvider());
// input
fillProcessesList(processesTableViewer);
processesTableViewer.setInput(TraceBackend.getInstance().getProcesses());
// editors
final CellEditor[] editors = new CellEditor[ProcessFlag.values().length + ProcessFlag.values().length];
editors[ProcessColumn.SELECTED.ordinal()] = new CheckboxCellEditor(table);
for (final ProcessFlag flag : ProcessFlag.values()) {
editors[ProcessColumn.values().length + flag.ordinal()] = new CheckboxCellEditor(table);
}
processesTableViewer.setCellEditors(editors);
processesTableViewer.setCellModifier(new ProcessCellModifier(processesTableViewer));
return container;
}
Aggregations