}
});
}
private void createEditorsForTable_NOT_USED(final Table table) {
final TableEditor editor1 = new TableEditor(table);
editor1.horizontalAlignment = SWT.CENTER;
editor1.grabHorizontal = true;
editor1.minimumWidth = 60;
final TableEditor editor2 = new TableEditor(table);
editor2.horizontalAlignment = SWT.CENTER;
editor2.grabHorizontal = true;
editor2.minimumWidth = 60;
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor1.getEditor();
if (oldEditor != null)
oldEditor.dispose();
oldEditor = editor2.getEditor();
if (oldEditor != null)
oldEditor.dispose();
// Identify the selected row
final TableItem item = (TableItem) e.item;
// if (!isEditable(item))
// return;
final NameValuePair nvp = (NameValuePair) item.getData();
if (nvp == null) {
Trace.err("No item's object");
return;
}
final Object obj = nvp.getParent();
if (nvp.getType() == Integer.class) {
// For Integer Editing
final Spinner spinner = new Spinner(table, SWT.BORDER);
spinner.setMinimum(0);
spinner.setMaximum(Integer.MAX_VALUE);
int level = Integer.parseInt(item.getText(1));
spinner.setSelection(level);
spinner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
int selection = spinner.getSelection();
item.setText(1, Integer.toString(selection));
int id = nvp.getId();
if (obj instanceof GetMetadataErrors) {
GetMetadataErrors getMetadataErrors = (GetMetadataErrors) obj;
getMetadataErrors.setValueById(id, selection);
getMetaDataViewer.refresh();
} else if (obj instanceof ProcessCasErrors) {
ProcessCasErrors processCasErrors = (ProcessCasErrors) obj;
processCasErrors.setValueById(id, selection);
processCasErrorsViewer.refresh();
} else if (obj instanceof CollectionProcessCompleteErrors) {
CollectionProcessCompleteErrors completeErrors = (CollectionProcessCompleteErrors) obj;
completeErrors.setValueById(id, selection);
collProcessCompleteErrorsViewer.refresh();
}
}
});
editor1.setEditor(spinner, item, 1);
} else if (nvp.getType() == String.class) {
final CCombo combo = new CCombo(table, SWT.BORDER | SWT.READ_ONLY);
combo.setItems(new String[] { "terminate", "disable" }); //$NON-NLS-1$
combo.setText(item.getText(1));
combo.pack();
combo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String selection = combo.getText();
item.setText(1, selection);
int id = nvp.getId();
if (obj instanceof GetMetadataErrors) {
GetMetadataErrors getMetadataErrors = (GetMetadataErrors) obj;
getMetadataErrors.setValueById(id, selection);
getMetaDataViewer.refresh();
} else if (obj instanceof ProcessCasErrors) {
ProcessCasErrors processCasErrors = (ProcessCasErrors) obj;
processCasErrors.setValueById(id, selection);
processCasErrorsViewer.refresh();
} else if (obj instanceof CollectionProcessCompleteErrors) {
CollectionProcessCompleteErrors completeErrors = (CollectionProcessCompleteErrors) obj;
completeErrors.setValueById(id, selection);
collProcessCompleteErrorsViewer.refresh();
}
}
});
editor2.setEditor(combo, item, 1);
} else if (nvp.getType() == Boolean.class) {
// Only for ProcessCasErrors
if (obj instanceof ProcessCasErrors) {
final CCombo combo = new CCombo(table, SWT.BORDER | SWT.READ_ONLY);
combo.setItems(new String[] { Boolean.toString(true), Boolean.toString(false) }); //$NON-NLS-1$
combo.setText(item.getText(1));
combo.pack();
combo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int id = nvp.getId();
item.setText(1, combo.getText());
ProcessCasErrors processCasErrors = (ProcessCasErrors) obj;
processCasErrors.setValueById(id, combo.getText());
processCasErrorsViewer.refresh();
}
});
editor2.setEditor(combo, item, 1);
}
} else {
Trace.err("nvp.getType(): " + nvp.getType().getClass().getName());
}
}