KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > valueeditors > IValueEditor


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.valueeditors;
22
23
24 import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy;
25 import org.apache.directory.ldapstudio.browser.core.model.IConnection;
26 import org.apache.directory.ldapstudio.browser.core.model.IEntry;
27 import org.apache.directory.ldapstudio.browser.core.model.IValue;
28 import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException;
29 import org.eclipse.jface.resource.ImageDescriptor;
30 import org.eclipse.jface.viewers.CellEditor;
31 import org.eclipse.swt.widgets.Composite;
32
33
34 /**
35  * A ValueEditor knows how to display and edit values of a LDAP attribute.
36  * ValueEditors are used from the entry editor or search result editor
37  * to display and edit values in a user-friendly way.
38  *
39  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
40  * @version $Rev$, $Date$
41  */

42 public interface IValueEditor
43 {
44
45     /**
46      * Returns the string representation of the given attribute hierarchy
47      * presented to the user.
48      * <p>
49      * This method is called from the search result editor. A attribute hierarchy may
50      * contain multiple attributes each with multiple values. It is common that
51      * a ValueEditor returns a comma-separated list.
52      *
53      * @param attributeHierarchy the attribute hierarchy
54      * @return the string representation of the attribute hierarchy
55      */

56     public abstract String JavaDoc getDisplayValue( AttributeHierarchy attributeHierarchy );
57
58
59     /**
60      * Returns the string representation of the given value
61      * presented to the user.
62      * <p>
63      * This method is called from the entry editor.
64      *
65      * @param value the value
66      * @return the string representation of the value
67      */

68     public abstract String JavaDoc getDisplayValue( IValue value );
69
70
71     /**
72      * Returns the raw value if this value editor can handle the given
73      * attribute hierarchy. The returned value is used as input for
74      * the CellEditor returned by getCellEditor().
75      * <p>
76      * If this value editor can't handle the given attribute hierarchy
77      * it must return null.
78      * <p>
79      * Note: It is also possilbe that the attribute hierarchy doesn't contain
80      * a value. This means the value is up to be created.
81      * <p>
82      * This method is called from the search result editor. It is common
83      * to return null if the attribute hierarchy contains more than
84      * one value.
85      *
86      * @param attributeHierarchy the attribute hierarchy
87      * @return the raw value of the attribute hierarchy or null
88      */

89     public abstract Object JavaDoc getRawValue( AttributeHierarchy attributeHierarchy );
90
91
92     /**
93      * Returns the raw value if this value editor can handle the given
94      * value. The returned value is used as input for the CellEditor
95      * returned by getCellEditor().
96      * <p>
97      * If this value editor can't handle the given value it must
98      * return null.
99      * <p>
100      * Note: It is also possible that the value is empty!
101      * <p>
102      * This method is called from the entry editor.
103      *
104      * @param value the value
105      * @return the raw value of the value or null
106      */

107     public abstract Object JavaDoc getRawValue( IValue value );
108
109
110     /**
111      * Returns the raw value if this value editor can handle the given
112      * value. The returned value is used as input for the CellEditor
113      * returned by getCellEditor().
114      * <p>
115      * If this value editor can't handle the given value it must
116      * return null.
117      * <p>
118      * This method is called from the LDIF editor. The connection object
119      * could be used for editors handling connection-dependent values.
120      *
121      * @param connection the connection
122      * @param stringOrBinaryValue the value either String or byte[]
123      * @return the raw value of the value or null
124      */

125     public abstract Object JavaDoc getRawValue( IConnection connection, Object JavaDoc stringOrBinaryValue );
126
127
128     /**
129      * Returns the String or binary byte[] value of the given raw value.
130      * The return value is used to create, modify or delete the value
131      * in directory.
132      * <p>
133      * This method is called after editing has been finished. The
134      * given rawValue is the one returned by the CellEditor.
135      *
136      * @param rawValue the raw value return from cell editor
137      * @return the String or byte[] value
138      */

139     public abstract Object JavaDoc getStringOrBinaryValue( Object JavaDoc rawValue );
140
141
142     /**
143      * Returns the editors name, previously set with
144      * setValueEditorName().
145      *
146      * @return the editors name
147      */

148     public abstract String JavaDoc getValueEditorName();
149
150
151     /**
152      * Sets the editors name.
153      *
154      * This method is called during initialization of the
155      * value editor, the name specified in value editor
156      * extension is assigned.
157      *
158      * @param name the editors name
159      */

160     public abstract void setValueEditorName( String JavaDoc name );
161
162
163     /**
164      * Returns the editors image, previously set with
165      * setValueEditorImageDescriptor().
166      *
167      * @return the editors image
168      */

169     public abstract ImageDescriptor getValueEditorImageDescriptor();
170
171
172     /**
173      * Sets the editors image.
174      *
175      * This method is called during initialization of the
176      * value editor, the icon specified in value editor
177      * extension is assigned.
178      *
179      * @param imageDescriptor the editors image
180      */

181     public abstract void setValueEditorImageDescriptor( ImageDescriptor imageDescriptor );
182
183
184     /**
185      * Creates the attribute with the given value at the entry.
186      *
187      * It is called from a ICellModifier if no attribute of value exists and
188      * the raw value returned by the CellEditor isn't null.
189      *
190      * @param entry
191      * @param attributeDescription
192      * @param newRawValue
193      * @throws ModelModificationException
194      * @deprecated This functionality will be removed from IValueEditor soon.
195      */

196     public abstract void createValue( IEntry entry, String JavaDoc attributeDescription, Object JavaDoc newRawValue )
197         throws ModelModificationException;
198
199
200     /**
201      * Modifies the value and sets the given raw value
202      *
203      * It is called from a ICellModfier if the value exists and the raw
204      * value returned by the CellEditor isn't null.
205      *
206      * @param value
207      * @param newRawValue
208      * @throws ModelModificationException
209      * @deprecated This functionality will be removed from IValueEditor soon.
210      */

211     public abstract void modifyValue( IValue value, Object JavaDoc newRawValue ) throws ModelModificationException;
212
213
214     /**
215      * Deletes the attributes
216      *
217      * It is called from a ICellModfier if the attribute exists and the raw
218      * value returned by the CellEditor is null.
219      *
220      * @param attributeHierarchy the attribute hierarchy
221      * @throws ModelModificationException
222      * @deprecated This functionality will be removed from IValueEditor soon.
223      */

224     public abstract void deleteAttribute( AttributeHierarchy attributeHierarchy ) throws ModelModificationException;
225
226
227     /**
228      * Deletes the value
229      *
230      * It is called from a ICellModfier if the value exists and the raw
231      * value returned by the CellEditor is null.
232      *
233      * @param oldValue
234      * @throws ModelModificationException
235      * @deprecated This functionality will be removed from IValueEditor soon.
236      */

237     public abstract void deleteValue( IValue oldValue ) throws ModelModificationException;
238
239
240     /**
241      * Creates the control for this value editor under the given parent control.
242      *
243      * @param parent the parent control
244      */

245     public abstract void create( Composite parent );
246
247
248     /**
249      * Disposes of this value editor and frees any associated SWT resources.
250      */

251     public abstract void dispose();
252
253
254     /**
255      * Returns the JFace CellEditor that is able to handle values returned by
256      * one of the getRawValue() or the getEmptyRawValue() methods.
257      *
258      * The object returned by the CellEditor's getValue() method is
259      * then sent to the getStringOrBinary() method to get the
260      * directory value.
261      *
262      * @return the JFace CellEditor
263      *
264      */

265     public abstract CellEditor getCellEditor();
266 }
267
Popular Tags