if (!isEditable(item)) {
table.setSelection(new TableItem[0]);
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);
String value = item.getText(1);
if (value.equals(AEDeploymentConstants.ERROR_KIND_STRING_NO_TIMEOUT)
|| value.equals(AEDeploymentConstants.ERROR_KIND_STRING_NO_RETRIES)
|| value.equals(AEDeploymentConstants.ERROR_KIND_STRING_NO_THRESHOLD_COUNT)
|| value.equals(AEDeploymentConstants.ERROR_KIND_STRING_NO_THRESHOLD_WINDOW)) {
value = "0";
}
int level = Integer.parseInt(value);
spinner.setSelection(level);
spinner.setFocus();
spinner.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
// Clean up any previous editor control
Control oldEditor = editor1.getEditor();
if (oldEditor != null)
oldEditor.dispose();
oldEditor = editor2.getEditor();
if (oldEditor != null)
oldEditor.dispose();
spinner.dispose();
}
});
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();
}
multiPageEditor.setFileDirty();
}
});
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.setFocus();
combo.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
// Clean up any previous editor control
Control oldEditor = editor1.getEditor();
if (oldEditor != null)
oldEditor.dispose();
oldEditor = editor2.getEditor();
if (oldEditor != null)
oldEditor.dispose();
combo.dispose();
}
});
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();
}
multiPageEditor.setFileDirty();
}
});
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.setFocus();
combo.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
// Clean up any previous editor control
Control oldEditor = editor1.getEditor();
if (oldEditor != null)
oldEditor.dispose();
oldEditor = editor2.getEditor();
if (oldEditor != null)
oldEditor.dispose();
combo.dispose();
}
});
combo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String selection = combo.getText();
int id = nvp.getId();
item.setText(1,selection);
ProcessCasErrors processCasErrors = (ProcessCasErrors) obj;
processCasErrors.setValueById(id, selection);
processCasErrorsViewer.refresh();
multiPageEditor.setFileDirty();
}
});
editor2.setEditor(combo, item, 1);
}
} else {
Trace.err("nvp.getType(): " + nvp.getType().getClass().getName());
}
}
});
}