Mercurial > projects > dwt2
comparison org.eclipse.jface/src/org/eclipse/jface/viewers/EditingSupport.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2006, 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation | |
11 * fix in bug 151295,167325,201905 | |
12 * Port to the D programming language: | |
13 * Frank Benoit <benoit@tionex.de> | |
14 *******************************************************************************/ | |
15 | |
16 module org.eclipse.jface.viewers.EditingSupport; | |
17 | |
18 import org.eclipse.jface.viewers.ColumnViewer; | |
19 import org.eclipse.jface.viewers.CellEditor; | |
20 import org.eclipse.jface.viewers.ViewerCell; | |
21 | |
22 import org.eclipse.core.runtime.Assert; | |
23 | |
24 import java.lang.all; | |
25 import java.util.Set; | |
26 | |
27 /** | |
28 * EditingSupport is the abstract superclass of the support for cell editing. | |
29 * | |
30 * @since 3.3 | |
31 * | |
32 */ | |
33 public abstract class EditingSupport { | |
34 | |
35 private ColumnViewer viewer; | |
36 | |
37 /** | |
38 * @param viewer | |
39 * a new viewer | |
40 */ | |
41 public this(ColumnViewer viewer) { | |
42 Assert.isNotNull(viewer, "Viewer is not allowed to be null"); //$NON-NLS-1$ | |
43 this.viewer = viewer; | |
44 } | |
45 | |
46 /** | |
47 * The editor to be shown | |
48 * | |
49 * @param element | |
50 * the model element | |
51 * @return the CellEditor | |
52 */ | |
53 protected abstract CellEditor getCellEditor(Object element); | |
54 package CellEditor getCellEditor_package(Object element){ | |
55 return getCellEditor(element); | |
56 } | |
57 | |
58 /** | |
59 * Is the cell editable | |
60 * | |
61 * @param element | |
62 * the model element | |
63 * @return true if editable | |
64 */ | |
65 protected abstract bool canEdit(Object element); | |
66 package bool canEdit_package(Object element){ | |
67 return canEdit(element); | |
68 } | |
69 | |
70 /** | |
71 * Get the value to set to the editor | |
72 * | |
73 * @param element | |
74 * the model element | |
75 * @return the value shown | |
76 */ | |
77 protected abstract Object getValue(Object element); | |
78 | |
79 /** | |
80 * Restore the value from the CellEditor | |
81 * | |
82 * <p> | |
83 * <b>Subclasses should overwrite!</b> | |
84 * </p> | |
85 * | |
86 * @param element | |
87 * the model element | |
88 * @param value | |
89 * the new value | |
90 */ | |
91 protected abstract void setValue(Object element, Object value); | |
92 | |
93 /** | |
94 * @return the viewer this editing support works for | |
95 */ | |
96 public ColumnViewer getViewer() { | |
97 return viewer; | |
98 } | |
99 | |
100 /** | |
101 * Initialize the editor. Frameworks like Databinding can hook in here and provide | |
102 * a customized implementation. <p><b>Standard customers should not overwrite this method but {@link #getValue(Object)}</b></p> | |
103 * | |
104 * @param cellEditor | |
105 * the cell editor | |
106 * @param cell | |
107 * the cell the editor is working for | |
108 */ | |
109 protected void initializeCellEditorValue(CellEditor cellEditor, ViewerCell cell) { | |
110 Object value = getValue(cell.getElement()); | |
111 cellEditor.setValue(value); | |
112 } | |
113 package void initializeCellEditorValue_package(CellEditor cellEditor, ViewerCell cell) { | |
114 initializeCellEditorValue(cellEditor, cell); | |
115 } | |
116 | |
117 /** | |
118 * Save the value of the cell editor back to the model. Frameworks like Databinding can hook in here and provide | |
119 * a customized implementation. <p><b>Standard customers should not overwrite this method but {@link #setValue(Object, Object)} </b></p> | |
120 * @param cellEditor | |
121 * the cell-editor | |
122 * @param cell | |
123 * the cell the editor is working for | |
124 */ | |
125 protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell) { | |
126 Object value = cellEditor.getValue(); | |
127 setValue(cell.getElement(), value); | |
128 } | |
129 package void saveCellEditorValue_package(CellEditor cellEditor, ViewerCell cell) { | |
130 saveCellEditorValue(cellEditor, cell); | |
131 } | |
132 | |
133 bool isLegacySupport() { | |
134 return false; | |
135 } | |
136 } |