01: /**
02: *
03: */package newprocess.diagram.cust.annotations.dialogs;
04:
05: import org.eclipse.jface.viewers.ICellModifier;
06: import org.eclipse.swt.widgets.TableItem;
07:
08: /**
09: * This class implements an ICellModifier
10: * An ICellModifier is called when the user modifes a cell in the
11: * tableViewer
12: *
13: * @author sh
14: */
15:
16: public class AnnotationCellModifier implements ICellModifier {
17: private AnnotationDialog newAnnotationDialog;
18:
19: /**
20: * Constructor
21: * @param newAnnotationDialog an instance of a NewAnnotationDialog
22: */
23: public AnnotationCellModifier(AnnotationDialog newAnnotationDialog) {
24: super ();
25: this .newAnnotationDialog = newAnnotationDialog;
26: }
27:
28: /* (non-Javadoc)
29: * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
30: */
31: public boolean canModify(Object element, String property) {
32: return true;
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
37: */
38: public Object getValue(Object element, String property) {
39: // Find the index of the column
40: int columnIndex = newAnnotationDialog.getColumnNames().indexOf(
41: property);
42:
43: Object result = null;
44: Annotation annotation = (Annotation) element;
45:
46: switch (columnIndex) {
47: case 0: // URL_COLUMN
48: result = annotation.getUri();
49: break;
50: default:
51: result = "";
52: }
53: return result;
54: }
55:
56: /* (non-Javadoc)
57: * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
58: */
59: public void modify(Object element, String property, Object value) {
60:
61: // Find the index of the column
62: int columnIndex = newAnnotationDialog.getColumnNames().indexOf(
63: property);
64:
65: TableItem item = (TableItem) element;
66: Annotation annotation = (Annotation) item.getData();
67: String valueString;
68:
69: switch (columnIndex) {
70: case 0: // URL_COLUMN
71: valueString = ((String) value).trim();
72: if (valueString.equals(AnnotationList.STANDARD_TEXT)
73: || valueString.equals("")) {
74: System.err
75: .println("\"(standard)\" or an empty string is not accepted !");
76: return;
77: }
78: annotation.setUri(valueString);
79: break;
80: default:
81: }
82: newAnnotationDialog.getAnnotationList().annotationChanged(
83: annotation);
84: }
85:
86: }
|