use of org.eclipse.jface.viewers.ICellModifier in project cubrid-manager by CUBRID.
the class BrokerParameterPropertyPage method linkEditorForTable.
/**
* Links the editable column of table
*/
private void linkEditorForTable() {
paraTableViewer.setColumnProperties(columnNameArrs);
CellEditor[] editors = new CellEditor[3];
editors[0] = null;
editors[1] = null;
editors[2] = new TextCellEditor(paraTable);
paraTableViewer.setCellEditors(editors);
paraTableViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(columnNameArrs[2])) {
return true;
}
return false;
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArrs[2])) {
return map.get("2");
}
return null;
}
@SuppressWarnings("unchecked")
public void modify(Object element, String property, Object value) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
}
if (obj == null) {
return;
}
Map<String, String> map = (Map<String, String>) obj;
String paramName = map.get("0");
String type = map.get("1");
boolean isValid = true;
if (type.indexOf("int") >= 0) {
boolean isInt = ValidateUtil.isInteger(value.toString());
if (!isInt) {
isValid = false;
}
} else if (type.startsWith("string")) {
String valueStr = value.toString().trim();
int start = type.indexOf("(");
int end = type.indexOf(")");
if (start > 0) {
String valueStrs = type.substring(start + 1, end);
String[] values = valueStrs.split("\\|");
boolean isExist = false;
for (String val : values) {
if (valueStr.equals(val)) {
isExist = true;
}
}
if (!isExist) {
isValid = false;
}
}
}
if (!isValid) {
CommonUITool.openErrorBox(Messages.bind(Messages.errParameterValue, new Object[] { paramName }));
}
if (type.indexOf("int") >= 0 && isValid) {
int intValue = Integer.parseInt(value.toString());
if (paramName.equalsIgnoreCase(ConfConstants.MAX_STRING_LENGTH)) {
if (intValue == 0 || intValue < -1) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errMaxStringLengthValue, new Object[] { paramName }));
}
} else {
if (intValue <= 0) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errPositiveValue, new Object[] { paramName }));
}
List<Map<String, String>> parameterList = (List<Map<String, String>>) paraTableViewer.getInput();
if (paramName.equalsIgnoreCase(ConfConstants.MIN_NUM_APPL_SERVER)) {
Map<String, String> dataMap = parameterList.get(3);
String maxNumApplServer = dataMap.get("2");
if (maxNumApplServer.trim().length() > 0 && intValue > Integer.parseInt(maxNumApplServer.trim())) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errMinNumApplServerValue, new Object[] { paramName }));
}
}
if (paramName.equalsIgnoreCase(ConfConstants.MAX_NUM_APPL_SERVER)) {
Map<String, String> dataMap = parameterList.get(2);
String minNumApplServer = dataMap.get("2");
if (minNumApplServer.trim().length() > 0 && intValue < Integer.parseInt(minNumApplServer.trim())) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errMaxNumApplServeValue, new Object[] { paramName }));
}
}
}
}
if (paramName.equalsIgnoreCase(ConfConstants.BROKER_PORT) && isValid) {
int port = Integer.parseInt(value.toString());
if (port < 1024 || port > 65535) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errBrokerPortAndShmId, paramName));
}
if (isValid) {
String paramValue = value.toString().trim();
for (Map.Entry<String, Map<String, String>> entry : oldConfParaMap.entrySet()) {
if (entry.getKey().equals(node.getLabel())) {
isValid = true;
continue;
} else {
String otherPort = entry.getValue().get(ConfConstants.BROKER_PORT);
if (paramValue.equalsIgnoreCase(otherPort)) {
isValid = false;
CommonUITool.openErrorBox(Messages.errReduplicatePort);
break;
} else {
isValid = true;
}
}
}
Map<String, String> brokerSectionMap = oldConfParaMap.get(ConfConstants.BROKER_SECTION_NAME);
String masterShmId = brokerSectionMap.get(ConfConstants.MASTER_SHM_ID);
if (paramValue.equals(masterShmId)) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errUseMasterShmId, paramValue));
}
}
if (isValid) {
String paramValue = value.toString().trim();
int intServerPortValue = Integer.parseInt(paramValue) + 1;
List<Map<String, String>> parameterList = (List<Map<String, String>>) paraTableViewer.getInput();
for (Map<String, String> dataMap : parameterList) {
if (dataMap.get("0").equalsIgnoreCase(ConfConstants.APPL_SERVER_PORT)) {
String serverPortValue = Integer.toString(intServerPortValue);
dataMap.put("2", serverPortValue);
}
}
}
}
if (paramName.equalsIgnoreCase(ConfConstants.APPL_SERVER_SHM_ID) && isValid) {
int port = Integer.parseInt(value.toString());
if (port < 1024 || port > 65535) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errBrokerPortAndShmId, paramName));
}
if (isValid) {
String paramValue = value.toString().trim();
for (Map.Entry<String, Map<String, String>> entry : oldConfParaMap.entrySet()) {
if (entry.getKey().equals(node.getLabel())) {
isValid = true;
continue;
} else {
String otherPort = entry.getValue().get(ConfConstants.APPL_SERVER_SHM_ID);
if (paramValue.equalsIgnoreCase(otherPort)) {
isValid = false;
CommonUITool.openErrorBox(Messages.errReduplicateShmId);
break;
} else {
isValid = true;
}
}
}
Map<String, String> brokerSectionMap = oldConfParaMap.get(ConfConstants.BROKER_SECTION_NAME);
String masterShmId = brokerSectionMap.get(ConfConstants.MASTER_SHM_ID);
if (paramValue.equals(masterShmId)) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errUseMasterShmId, paramValue));
}
}
}
if (isValid) {
map.put("2", value.toString());
}
paraTableViewer.refresh();
}
});
}
use of org.eclipse.jface.viewers.ICellModifier in project cubrid-manager by CUBRID.
the class DatabaseConfigPropertyPage method linkEditorForTable.
/**
* Link editor for table
*/
private void linkEditorForTable() {
advancedOptionTableViewer.setColumnProperties(columnNameArrs);
CellEditor[] editors = new CellEditor[4];
editors[0] = null;
editors[1] = null;
editors[2] = null;
editors[3] = new TextCellEditor(advancedOptionTable);
advancedOptionTableViewer.setCellEditors(editors);
advancedOptionTableViewer.setCellModifier(new ICellModifier() {
@SuppressWarnings("unchecked")
public boolean canModify(Object element, String property) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
} else if (element instanceof Map) {
obj = element;
}
if (obj == null) {
return false;
}
Map<String, String> map = (Map<String, String>) obj;
String parameter = map.get("0");
if (parameter.equals(ConfConstants.HA_MODE) && !isCanSetOnForHaMode) {
return false;
}
if (property.equals(columnNameArrs[3])) {
return true;
}
return false;
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArrs[3])) {
return map.get("3");
}
return null;
}
@SuppressWarnings("unchecked")
public void modify(Object element, String property, Object value) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
}
if (obj == null) {
return;
}
Map<String, String> map = (Map<String, String>) obj;
modifyTable(map, property, value);
}
});
}
use of org.eclipse.jface.viewers.ICellModifier in project cubrid-manager by CUBRID.
the class SettingCubridConfPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
setDescription(Messages.descSettingCubridPage);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(3, false));
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(50, -5);
leftComposite.setLayoutData(leftData);
Label separator = new Label(container, SWT.SEPARATOR);
FormData separatorData = new FormData();
separatorData.top = new FormAttachment(0, 5);
separatorData.bottom = new FormAttachment(100, -5);
separatorData.left = new FormAttachment(50, -5);
separatorData.right = new FormAttachment(50, 5);
separator.setLayoutData(separatorData);
Composite rightComposite = new Composite(container, SWT.NONE);
rightComposite.setLayout(new GridLayout(3, false));
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 5);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
/*Create left widget*/
Label hostALabel = new Label(leftComposite, SWT.None);
hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostALabel.setText(Messages.lblMaster);
masterHostLabel = new Label(leftComposite, SWT.None);
masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
masterViewer.getTable().setLinesVisible(true);
masterViewer.getTable().setHeaderVisible(true);
masterViewer.setContentProvider(new TableContentProvider());
masterViewer.setLabelProvider(new CubridConfTableProvider());
masterViewer.setColumnProperties(PROPS);
CellEditor[] editorsA = new CellEditor[2];
editorsA[0] = null;
editorsA[1] = new TextCellEditor(masterViewer.getTable());
masterViewer.setCellEditors(editorsA);
masterViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
masterViewer.refresh(model);
updateHAModel(masterViewer, model, false);
}
});
TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
keyAColumn.setText(Messages.lblKey);
keyAColumn.setWidth(160);
TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
valueAColumn.setText(Messages.lblValue);
valueAColumn.setWidth(200);
Label masterDBLabel = new Label(leftComposite, SWT.None);
masterDBLabel.setText(Messages.lblDatabase);
masterDBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
masterDBCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
HAModel haModel = getConfigHAWizard().getHaModel();
/*Init table data*/
initTableData(haModel.getMasterServer(), true);
HAServer haServer = haModel.getSlaveServer();
initTableData(haServer, false);
}
});
ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
addItemA.setToolTipText(Messages.itemAddParameter);
addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(masterViewer);
}
});
ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
editItemA.setToolTipText(Messages.itemEditParameter);
editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(masterViewer);
}
});
ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
dropItemA.setToolTipText(Messages.itemDeleteParameter);
dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(masterViewer);
}
});
/*Create right widget*/
Label hostBLabel = new Label(rightComposite, SWT.None);
hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostBLabel.setText(Messages.lblSlave);
slaveHostLabel = new Label(rightComposite, SWT.None);
slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
slaveViewer.getTable().setLinesVisible(true);
slaveViewer.getTable().setHeaderVisible(true);
slaveViewer.setContentProvider(new TableContentProvider());
slaveViewer.setLabelProvider(new CubridConfTableProvider());
slaveViewer.setColumnProperties(PROPS);
CellEditor[] editorsB = new CellEditor[2];
editorsB[0] = null;
editorsB[1] = new TextCellEditor(slaveViewer.getTable());
slaveViewer.setCellEditors(editorsB);
slaveViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
slaveViewer.refresh(model);
updateHAModel(slaveViewer, model, false);
}
});
TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
keyBColumn.setText(Messages.lblKey);
keyBColumn.setWidth(160);
TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
valueBColumn.setText(Messages.lblValue);
valueBColumn.setWidth(200);
ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 3, 1, -1, -1));
ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
addItemB.setToolTipText(Messages.itemAddParameter);
addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(slaveViewer);
}
});
ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
editItemB.setToolTipText(Messages.itemEditParameter);
editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(slaveViewer);
}
});
ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
dropItemB.setToolTipText(Messages.itemDeleteParameter);
dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(slaveViewer);
}
});
}
use of org.eclipse.jface.viewers.ICellModifier 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.ICellModifier in project sling by apache.
the class ArchetypeParametersWizardPage method createControl.
/**
* @see IDialogPage#createControl(Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 2;
layout.verticalSpacing = 9;
Label label = new Label(container, SWT.NULL);
label.setText("&Group Id:");
groupId = new Text(container, SWT.BORDER | SWT.SINGLE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
groupId.setLayoutData(gd);
groupId.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
dialogChanged();
if (!javaPackageModified) {
if (artifactId.getText().length() == 0) {
javaPackage.setText(getDefaultJavaPackage(groupId.getText(), ""));
} else {
javaPackage.setText(getDefaultJavaPackage(groupId.getText(), artifactId.getText()));
}
}
}
});
label = new Label(container, SWT.NULL);
label.setText("&Artifact Id:");
artifactId = new Text(container, SWT.BORDER | SWT.SINGLE);
gd = new GridData(GridData.FILL_HORIZONTAL);
artifactId.setLayoutData(gd);
artifactId.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
dialogChanged();
if (javaPackageModified) {
return;
}
if (groupId.getText().length() == 0) {
javaPackage.setText(getDefaultJavaPackage("", artifactId.getText()));
} else {
javaPackage.setText(getDefaultJavaPackage(groupId.getText(), artifactId.getText()));
}
}
});
label = new Label(container, SWT.NULL);
label.setText("&Version:");
version = new Text(container, SWT.BORDER | SWT.SINGLE);
gd = new GridData(GridData.FILL_HORIZONTAL);
version.setLayoutData(gd);
version.setText("0.0.1-SNAPSHOT");
version.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
dialogChanged();
}
});
label = new Label(container, SWT.NULL);
label.setText("&Package:");
javaPackage = new Text(container, SWT.BORDER | SWT.SINGLE);
gd = new GridData(GridData.FILL_HORIZONTAL);
javaPackage.setLayoutData(gd);
javaPackageModified = false;
javaPackage.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
javaPackageModified = true;
}
});
javaPackage.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
dialogChanged();
}
});
label = new Label(container, SWT.NULL);
gd = new GridData(SWT.LEFT, SWT.TOP, false, false);
label.setLayoutData(gd);
label.setText("&Parameters:");
propertiesViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION);
propertiesTable = propertiesViewer.getTable();
propertiesTable.setLinesVisible(true);
propertiesTable.setHeaderVisible(true);
propertiesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2));
CellNavigationStrategy strategy = new CellNavigationStrategy();
TableViewerFocusCellManager focusCellMgr = new TableViewerFocusCellManager(propertiesViewer, new FocusCellOwnerDrawHighlighter(propertiesViewer), strategy);
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(propertiesViewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
};
int features = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.KEEP_EDITOR_ON_DOUBLE_CLICK;
TableViewerEditor.create(propertiesViewer, focusCellMgr, actSupport, features);
TableColumn propertiesTableNameColumn = new TableColumn(propertiesTable, SWT.NONE);
propertiesTableNameColumn.setWidth(130);
propertiesTableNameColumn.setText("Name");
TableColumn propertiesTableValueColumn = new TableColumn(propertiesTable, SWT.NONE);
propertiesTableValueColumn.setWidth(230);
propertiesTableValueColumn.setText("Value");
propertiesViewer.setColumnProperties(new String[] { KEY_PROPERTY, VALUE_PROPERTY });
propertiesViewer.setCellEditors(new CellEditor[] { new TextCellEditor(propertiesTable, SWT.NONE), new TextCellEditor(propertiesTable, SWT.NONE) });
propertiesViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
return true;
}
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem) {
((TableItem) element).setText(getTextIndex(property), String.valueOf(value));
dialogChanged();
}
}
public Object getValue(Object element, String property) {
if (element instanceof TableItem) {
return ((TableItem) element).getText(getTextIndex(property));
}
return null;
}
});
initialize();
setPageComplete(false);
setControl(container);
}
Aggregations