use of org.eclipse.jface.viewers.CellEditor in project cubrid-manager by CUBRID.
the class ShardConnectionPanel method linkEditorForTable.
/**
* Links the editable column of table
*/
private void linkEditorForTable() {
connectionTableViewer.setColumnProperties(columnNameArrs);
CellEditor[] editors = new CellEditor[3];
editors[0] = new TextCellEditor(connectionTable);
editors[1] = new TextCellEditor(connectionTable);
editors[2] = new TextCellEditor(connectionTable);
connectionTableViewer.setCellEditors(editors);
connectionTableViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
return true;
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArrs[0])) {
return map.get("0");
} else if (property.equals(columnNameArrs[1])) {
return map.get("1");
} else if (property.equals(columnNameArrs[2])) {
return map.get("2");
}
return null;
}
public void modify(Object element, String property, Object value) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
}
if (obj == null) {
return;
}
@SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) obj;
boolean isValid = true;
if (property.equals(columnNameArrs[0])) {
isValid = ValidateUtil.isInteger(value.toString());
if (isValid) {
for (Map<String, String> paras : parameterList) {
if (paras == obj) {
continue;
}
if (paras.get("0").equals(value)) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errShardIdExist, new Object[] { value.toString() }));
break;
}
}
} else {
CommonUITool.openErrorBox(Messages.errShardIdNotNumeric);
}
if (isValid) {
map.put("0", value.toString());
}
} else if (property.equals(columnNameArrs[1])) {
map.put("1", value.toString());
} else if (property.equals(columnNameArrs[2])) {
map.put("2", value.toString());
}
connectionTableViewer.refresh();
// Notice the upper layer
modifyListener.modifyText(null);
}
});
}
use of org.eclipse.jface.viewers.CellEditor in project sling by apache.
the class MVPEditor method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
// now add the node type dropbox-combo
Composite header = new Composite(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.numColumns = 3;
header.setLayout(layout);
Label label = new Label(header, SWT.WRAP);
label.setText("Modify property " + property.getName() + ":");
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
label.setLayoutData(data);
label.setFont(parent.getFont());
ToolBar buttonBar = new ToolBar(header, SWT.NONE);
ToolItem invisible = new ToolItem(buttonBar, SWT.NONE);
ToolItem plus = new ToolItem(buttonBar, SWT.NONE);
plus.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_ADD).createImage());
plus.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
plus();
}
});
final ToolItem minus = new ToolItem(buttonBar, SWT.NONE);
minus.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE).createImage());
minus.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
minus();
}
});
minus.setEnabled(false);
Composite tableParent = new Composite(composite, SWT.NONE);
final GridData layoutData = new GridData(GridData.FILL_BOTH);
layoutData.heightHint = 150;
tableParent.setLayoutData(layoutData);
TableColumnLayout tableLayout = new TableColumnLayout();
tableParent.setLayout(tableLayout);
viewer = new TableViewer(tableParent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
// accessing property here directly, instead of going via (JcrProperty)inputElement;
String[] rawLines = property.getValuesAsString();
// convert raw lines to Line objects for easier editing management
for (int i = 0; i < rawLines.length; i++) {
lines.add(new Line(rawLines[i]));
}
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 lines.toArray();
}
});
TableViewerColumn column0 = new TableViewerColumn(viewer, SWT.NONE);
column0.getColumn().setText("Type");
column0.getColumn().setResizable(true);
column0.getColumn().setWidth(100);
tableLayout.setColumnData(column0.getColumn(), new ColumnWeightData(20, 100));
column0.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
try {
cell.setText(property.getTypeAsString());
cell.setForeground(greyColor);
} catch (Exception e) {
cell.setText("n/a");
cell.setForeground(greyColor);
}
}
});
TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE);
column1.getColumn().setText("Value");
column1.getColumn().setResizable(true);
column1.getColumn().setWidth(200);
tableLayout.setColumnData(column1.getColumn(), new ColumnWeightData(80, 200));
column1.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Line line = (Line) cell.getElement();
cell.setText(line.getValue());
}
});
column1.setEditingSupport(new EditingSupport(viewer) {
@Override
protected void setValue(Object element, Object value) {
Line line = (Line) element;
line.setValue(String.valueOf(value));
// trigger a refresh:
viewer.setInput(property);
}
@Override
protected Object getValue(Object element) {
final Line line = (Line) element;
final String value = line.getValue();
System.out.println("Value=" + value);
return value;
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(viewer.getTable());
}
@Override
protected boolean canEdit(Object element) {
// all values are editable
return true;
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection iss = (IStructuredSelection) selection;
if (iss.isEmpty()) {
minus.setEnabled(false);
} else {
minus.setEnabled(true);
}
} else {
minus.setEnabled(false);
}
}
});
viewer.setInput(property);
return composite;
}
use of org.eclipse.jface.viewers.CellEditor in project sling by apache.
the class JcrEditingSupport method getCellEditor.
@Override
protected CellEditor getCellEditor(Object element) {
try {
final CellEditor result = doGetCellEditor(element);
if (result != null) {
Field field = asField(element);
view.setLastValueEdited(field.getPropertyName(), field.getNewPropertyName(), columnId);
}
return result;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of org.eclipse.jface.viewers.CellEditor in project Palladio-Editors-Sirius by PalladioSimulator.
the class EventTypesEditorSection method createViewerCellEditors.
/* (non-Javadoc)
* @see org.palladiosimulator.editors.commons.tabs.generic.EditorSection#createViewerCellEditors(org.eclipse.swt.widgets.Table)
*/
@Override
protected CellEditor[] createViewerCellEditors(Table table) {
CellEditor[] editors = new CellEditor[columnNames.length];
editors[EVENTTYPENAME_COLUMN_INDEX] = new TextCellEditor(table);
// create 'DeleteCellValueListener' and as SelectionListener to the 'TableVewer'
EventTypeDeleteCellValueListener cellValueListener = new EventTypeDeleteCellValueListener(viewer);
viewer.addSelectionChangedListener(cellValueListener);
editors[PARAMETER_NAME_COLUMN_INDEX] = new TextCellEditor(table);
editors[PARAMETER_TYPE_COLUMN_INDEX] = new TypeDialogCellEditor(table, cellValueListener) {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
*/
@Override
protected Object openDialogBox(Control cellEditorWindow) {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(getSelectedEventType());
ArrayList<Object> filterList = new ArrayList<Object>();
filterList.add(DataType.class);
filterList.add(Repository.class);
ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
CallDataTypeDialog dialog = new CallDataTypeDialog(cellEditorWindow.getShell(), filterList, additionalReferences, editingDomain.getResourceSet());
dialog.setProvidedService(DataType.class);
dialog.open();
if (!(dialog.getResult() instanceof DataType))
return null;
return dialog.getResult();
}
};
return editors;
}
use of org.eclipse.jface.viewers.CellEditor in project dbeaver by dbeaver.
the class EntityDirectEditPolicy method storeOldEditValue.
@Override
protected void storeOldEditValue(DirectEditRequest request) {
CellEditor cellEditor = request.getCellEditor();
oldValue = (String) cellEditor.getValue();
}
Aggregations