use of org.eclipse.jface.viewers.ICellModifier in project webtools.sourceediting by eclipse.
the class ParametersBlock method createControl.
public void createControl(Composite parent) {
Font font = parent.getFont();
Group group = new Group(parent, SWT.NONE);
group.setText(getName());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
group.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
group.setLayout(layout);
group.setFont(font);
setControl(group);
fTable = new Table(group, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
// data.heightHint = 100;
fTable.setLayoutData(data);
fTable.setFont(font);
fTable.setHeaderVisible(true);
fTable.setLinesVisible(true);
TableColumn column1 = new TableColumn(fTable, SWT.NONE);
column1.setWidth(150);
column1.setResizable(true);
column1.setText(Messages.ParametersBlock_0);
TableColumn column3 = new TableColumn(fTable, SWT.NONE);
column3.setWidth(250);
column3.setResizable(true);
column3.setText(Messages.ParametersBlock_2);
parametersViewer = new ParameterViewer(fTable);
parametersViewer.getViewer().setLabelProvider(new ParametersLabelProvider());
parametersViewer.getViewer().setContentProvider(new ParametersContentProvider());
parametersViewer.addParametersChangedListener(new IParametersChangedListener() {
public void parametersChanged(ParameterViewer viewer) {
updateLaunchConfigurationDialog();
}
});
parametersViewer.getViewer().getTable().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
RemoveParameterAction ra = new RemoveParameterAction(parametersViewer);
ra.run();
updateLaunchConfigurationDialog();
}
}
});
parametersViewer.getViewer().setColumnProperties(// $NON-NLS-1$ //$NON-NLS-2$
new String[] { "name", "value" });
TextCellEditor textEditor = new TextCellEditor(fTable);
CellEditor[] editors = new CellEditor[] { null, textEditor };
parametersViewer.getViewer().setCellEditors(editors);
parametersViewer.getViewer().setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
// $NON-NLS-1$
return "value".equals(property);
}
public Object getValue(Object element, String property) {
LaunchAttribute att = (LaunchAttribute) element;
// $NON-NLS-1$
return att.value == null ? "" : att.value;
}
public void modify(Object element, String property, Object value) {
Item item = (Item) element;
LaunchAttribute att = (LaunchAttribute) item.getData();
att.value = (String) value;
parametersViewer.getViewer().update(att, null);
updateLaunchConfigurationDialog();
}
});
Composite parameterButtonComp = new Composite(group, SWT.NONE);
GridLayout parameterButtonCompLayout = new GridLayout();
parameterButtonCompLayout.marginHeight = 0;
parameterButtonCompLayout.marginWidth = 0;
parameterButtonComp.setLayout(parameterButtonCompLayout);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
parameterButtonComp.setLayoutData(gd);
parameterButtonComp.setFont(font);
addParameterButton = createButton(parameterButtonComp, new AddParameterAction(parametersViewer));
removeParameterButton = createButton(parameterButtonComp, new RemoveParameterAction(parametersViewer));
transformsBlock.getStylesheetViewer().addSelectionChangedListener(selectionListener);
restoreColumnSettings();
}
use of org.eclipse.jface.viewers.ICellModifier in project netxms by netxms.
the class AgentFileManager method enableInPlaceRename.
/**
* Enable in-place renames
*/
private void enableInPlaceRename() {
TreeViewerEditor.create(viewer, new ColumnViewerEditorActivationStrategy(viewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
}, ColumnViewerEditor.DEFAULT);
viewer.setCellEditors(new CellEditor[] { new TextCellEditor(viewer.getTree()) });
// $NON-NLS-1$
viewer.setColumnProperties(new String[] { "name" });
viewer.setCellModifier(new ICellModifier() {
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof Item)
element = ((Item) element).getData();
if (// $NON-NLS-1$
property.equals("name")) {
if (element instanceof AgentFile) {
doRename((AgentFile) element, value.toString());
}
}
}
@Override
public Object getValue(Object element, String property) {
if (// $NON-NLS-1$
property.equals("name")) {
if (element instanceof AgentFile) {
return ((AgentFile) element).getName();
}
}
return null;
}
@Override
public boolean canModify(Object element, String property) {
// $NON-NLS-1$
return property.equals("name");
}
});
}
use of org.eclipse.jface.viewers.ICellModifier in project tdq-studio-se by Talend.
the class UDIMasterPage method attachDefiniationParameterCellEditors.
/**
* attach Definiation Parameter Cell Editors.
*
* @param table
* @param titles
*/
private void attachDefiniationParameterCellEditors(Composite table, String[] titles) {
parameterTableViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
return true;
}
public Object getValue(Object element, String property) {
if (PARAMETERS_KEY.equals(property)) {
return ((IndicatorDefinitionParameter) element).getKey();
} else if (PARAMETERS_VALUE.equals(property)) {
return ((IndicatorDefinitionParameter) element).getValue();
}
return null;
}
public void modify(Object element, String property, Object value) {
TableItem tableItem = (TableItem) element;
IndicatorDefinitionParameter data = (IndicatorDefinitionParameter) tableItem.getData();
if (PARAMETERS_KEY.equals(property)) {
if (!data.getKey().equals(value.toString())) {
data.setKey(value.toString());
parameterTableViewer.refresh(data);
setDirty(true);
}
} else if (PARAMETERS_VALUE.equals(property)) {
if (!data.getValue().equals(value)) {
data.setValue((String) value);
parameterTableViewer.refresh(data);
setDirty(true);
}
}
}
});
parameterTableViewer.setColumnProperties(titles);
parameterTableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(table), new TextCellEditor(table) });
}
use of org.eclipse.jface.viewers.ICellModifier in project tdq-studio-se by Talend.
the class JavaUDIParametersForm method attachCellEditors.
/**
* DOC klliu Comment method "attachCellEditors".figure 13429 2010-08-03.
*
* @param viewer
* @param parent
*/
private void attachCellEditors(final TableViewer viewer, Composite parent) {
viewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
return true;
}
public Object getValue(Object element, String property) {
if (NAME_PROPERTY.equals(property)) {
return ((JavaUDIIndicatorParameter) element).getKey();
} else {
return ((JavaUDIIndicatorParameter) element).getValue();
}
}
public void modify(Object element, String property, Object value) {
TableItem tableItem = (TableItem) element;
JavaUDIIndicatorParameter data = (JavaUDIIndicatorParameter) tableItem.getData();
if (NAME_PROPERTY.equals(property)) {
data.setKey(value.toString());
} else {
data.setValue(value.toString());
}
viewer.refresh(data);
checkFieldsValue();
}
});
viewer.setCellEditors(new CellEditor[] { new TextCellEditor(parent), new TextCellEditor(parent) });
viewer.setColumnProperties(new String[] { NAME_PROPERTY, VALUE_PROPERTY });
}
use of org.eclipse.jface.viewers.ICellModifier in project bndtools by bndtools.
the class NewTypeWizardPage method createSuperInterfacesControls.
/**
* Creates the controls for the superclass name field. Expects a <code>GridLayout</code> with at least 3 columns.
*
* @param composite the parent composite
* @param nColumns number of columns to span
*/
protected void createSuperInterfacesControls(Composite composite, int nColumns) {
// $NON-NLS-1$
final String INTERFACE = "interface";
fSuperInterfacesDialogField.doFillIntoGrid(composite, nColumns);
final TableViewer tableViewer = fSuperInterfacesDialogField.getTableViewer();
tableViewer.setColumnProperties(new String[] { INTERFACE });
TableTextCellEditor cellEditor = new TableTextCellEditor(tableViewer, 0) {
@Override
protected void doSetFocus() {
if (text != null) {
text.setFocus();
text.setSelection(text.getText().length());
checkSelection();
checkDeleteable();
checkSelectable();
}
}
};
JavaTypeCompletionProcessor superInterfaceCompletionProcessor = new JavaTypeCompletionProcessor(false, false, true);
superInterfaceCompletionProcessor.setCompletionContextRequestor(new CompletionContextRequestor() {
@Override
public StubTypeContext getStubTypeContext() {
return getSuperInterfacesStubTypeContext();
}
});
@SuppressWarnings("deprecation") org.eclipse.jface.contentassist.SubjectControlContentAssistant contentAssistant = ControlContentAssistHelper.createJavaContentAssistant(superInterfaceCompletionProcessor);
Text cellEditorText = cellEditor.getText();
@SuppressWarnings({ "deprecation", "unused" }) org.eclipse.ui.contentassist.ContentAssistHandler contentAssistantHandler = org.eclipse.ui.contentassist.ContentAssistHandler.createHandlerForText(cellEditorText, contentAssistant);
TextFieldNavigationHandler.install(cellEditorText);
cellEditor.setContentAssistant(contentAssistant);
tableViewer.setCellEditors(new CellEditor[] { cellEditor });
tableViewer.setCellModifier(new ICellModifier() {
@Override
public void modify(Object element, String property, Object value) {
Object el = element;
if (el instanceof Item)
el = ((Item) el).getData();
((InterfaceWrapper) el).interfaceName = (String) value;
fSuperInterfacesDialogField.elementChanged((InterfaceWrapper) el);
}
@Override
public Object getValue(Object element, String property) {
return ((InterfaceWrapper) element).interfaceName;
}
@Override
public boolean canModify(Object element, String property) {
return true;
}
});
tableViewer.getTable().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.keyCode == SWT.F2 && event.stateMask == 0) {
ISelection selection = tableViewer.getSelection();
if (!(selection instanceof IStructuredSelection))
return;
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
tableViewer.editElement(structuredSelection.getFirstElement(), 0);
}
}
});
GridData gd = (GridData) fSuperInterfacesDialogField.getListControl(null).getLayoutData();
if (fTypeKind == CLASS_TYPE) {
gd.heightHint = convertHeightInCharsToPixels(3);
} else {
gd.heightHint = convertHeightInCharsToPixels(6);
}
gd.grabExcessVerticalSpace = false;
gd.widthHint = getMaxFieldWidth();
}
Aggregations