use of org.eclipse.jface.viewers.EditingSupport in project yamcs-studio by yamcs.
the class PropertyDataLabelProvider 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(200);
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;
}
use of org.eclipse.jface.viewers.EditingSupport in project egit by eclipse.
the class RefSpecPanel method createModeColumn.
private void createModeColumn(final TableColumnLayout columnLayout) {
final TableViewerColumn column = createColumn(columnLayout, UIText.RefSpecPanel_columnMode, COLUMN_MODE_WEIGHT, SWT.CENTER);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return (isDeleteRefSpec(element) ? UIText.RefSpecPanel_modeDelete : UIText.RefSpecPanel_modeUpdate);
}
@Override
public Image getImage(Object element) {
return (isDeleteRefSpec(element) ? imageRegistry.get(IMAGE_DELETE) : imageRegistry.get(IMAGE_ADD));
}
@Override
public String getToolTipText(Object element) {
if (isDeleteRefSpec(element))
return UIText.RefSpecPanel_modeDeleteDescription + '\n' + UIText.RefSpecPanel_clickToChange;
return UIText.RefSpecPanel_modeUpdateDescription + '\n' + UIText.RefSpecPanel_clickToChange;
}
});
column.setEditingSupport(new EditingSupport(tableViewer) {
@Override
protected boolean canEdit(final Object element) {
return true;
}
@Override
protected CellEditor getCellEditor(final Object element) {
return modeCellEditor;
}
@SuppressWarnings("boxing")
@Override
protected Object getValue(final Object element) {
return isDeleteRefSpec(element);
}
@SuppressWarnings("boxing")
@Override
protected void setValue(final Object element, final Object value) {
final RefSpec oldSpec = (RefSpec) element;
final RefSpec newSpec;
if ((Boolean) value) {
newSpec = setRefSpecSource(oldSpec, null);
setRefSpec(oldSpec, newSpec);
} else {
newSpec = setRefSpecSource(oldSpec, UIText.RefSpecPanel_refChooseSome);
setRefSpec(oldSpec, newSpec);
tableViewer.getControl().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
tableViewer.editElement(newSpec, srcColumnIndex);
}
});
}
}
});
}
use of org.eclipse.jface.viewers.EditingSupport in project egit by eclipse.
the class RefSpecPanel method createForceColumn.
private void createForceColumn(final TableColumnLayout columnLayout) {
final TableViewerColumn column = createColumn(columnLayout, UIText.RefSpecPanel_columnForce, COLUMN_FORCE_WEIGHT, SWT.CENTER);
column.setLabelProvider(new CheckboxLabelProvider(tableViewer.getControl()) {
@Override
protected boolean isChecked(final Object element) {
return ((RefSpec) element).isForceUpdate();
}
@Override
protected boolean isEnabled(Object element) {
return !isDeleteRefSpec(element);
}
@Override
public String getToolTipText(Object element) {
if (!isEnabled(element))
return UIText.RefSpecPanel_forceDeleteDescription;
if (isChecked(element))
return UIText.RefSpecPanel_forceTrueDescription + '\n' + UIText.RefSpecPanel_clickToChange;
return UIText.RefSpecPanel_forceFalseDescription + '\n' + UIText.RefSpecPanel_clickToChange;
}
});
column.setEditingSupport(new EditingSupport(tableViewer) {
@Override
protected boolean canEdit(final Object element) {
return !isDeleteRefSpec(element);
}
@Override
protected CellEditor getCellEditor(final Object element) {
return forceUpdateCellEditor;
}
@SuppressWarnings("boxing")
@Override
protected Object getValue(final Object element) {
return ((RefSpec) element).isForceUpdate();
}
@SuppressWarnings("boxing")
@Override
protected void setValue(final Object element, final Object value) {
final RefSpec oldSpec = (RefSpec) element;
final RefSpec newSpec = oldSpec.setForceUpdate((Boolean) value);
setRefSpec(oldSpec, newSpec);
}
});
}
use of org.eclipse.jface.viewers.EditingSupport in project egit by eclipse.
the class RefSpecPanel method createSrcColumn.
private void createSrcColumn(final TableColumnLayout columnLayout) {
final TableViewerColumn column = createColumn(columnLayout, UIText.RefSpecPanel_columnSrc, COLUMN_SRC_WEIGHT, SWT.LEFT);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return ((RefSpec) element).getSource();
}
@Override
public String getToolTipText(Object element) {
if (isInvalidSpec(element))
return errorMessage;
if (isDeleteRefSpec(element))
return UIText.RefSpecPanel_srcDeleteDescription;
if (pushSpecs)
return UIText.RefSpecPanel_srcPushDescription;
return UIText.RefSpecPanel_srcFetchDescription;
}
@Override
public Color getBackground(final Object element) {
if (isInvalidSpec(element))
return errorBackgroundColor;
return null;
}
@Override
public Color getToolTipForegroundColor(Object element) {
if (isInvalidSpec(element))
return errorTextColor;
return null;
}
});
column.setEditingSupport(new EditingSupport(tableViewer) {
@Override
protected boolean canEdit(final Object element) {
return !isDeleteRefSpec(element);
}
@Override
protected CellEditor getCellEditor(final Object element) {
return (pushSpecs ? localRefCellEditor : remoteRefCellEditor);
}
@Override
protected Object getValue(final Object element) {
return ((RefSpec) element).getSource();
}
@Override
protected void setValue(final Object element, final Object value) {
if (value == null || ((String) value).length() == 0 || ObjectId.zeroId().name().equals(value)) {
// If user want to delete ref, let change the mode.
return;
}
final RefSpec oldSpec = (RefSpec) element;
final RefSpec newSpec = setRefSpecSource(oldSpec, (String) value);
setRefSpec(oldSpec, newSpec);
}
});
// find index of this column - for later usage
final TableColumn[] columns = tableViewer.getTable().getColumns();
for (srcColumnIndex = 0; srcColumnIndex < columns.length; srcColumnIndex++) if (columns[srcColumnIndex] == column.getColumn())
break;
}
use of org.eclipse.jface.viewers.EditingSupport in project tdq-studio-se by Talend.
the class ParticularDefaultSurvivorShipTableViewer method addEditingSupportForColumn.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataquality.record.linkage.ui.composite.tableviewer.AbstractMatchAnalysisTableViewer#addEditingSupportForColumn
* (org.eclipse.swt.widgets.TableColumn, java.lang.String)
*/
@Override
protected void addEditingSupportForColumn(TableViewerColumn tableViewerColumn, String columnTechnologyLabel) {
if (MatchAnalysisConstant.FUNCTION.equals(columnTechnologyLabel)) {
EditingSupport support = new FunctionEditingSupport(tableViewerColumn.getViewer());
tableViewerColumn.setEditingSupport(support);
}
}
Aggregations