1 /*
2 * Copyright (c) 2003-2008 by Cosylab d. d.
3 *
4 * This file is part of CosyBeans-Common.
5 *
6 * CosyBeans-Common is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CosyBeans-Common is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CosyBeans-Common. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package com.cosylab.gui.property.editors;
21
22 import java.beans.PropertyChangeListener;
23
24
25
26 /**
27 * description
28 *
29 * @author <a href="mailto:ales.pucelj@cosylab.com">Ales Pucelj</a>
30 * @version $id$
31 */
32 public interface PropertyEditor {
33 public static final String PROPERTY_VALUE_NAME="propertyValue";
34 /**
35 * Returns the value contained in this editor. To provide generic approach,
36 * value must be contained within Object, primitive types should be wrapped
37 * within appropriate classes (int - Integer). Return value of null should be
38 * used only to indicate, the value contained within this editor is invalid.
39 *
40 * @return Object
41 */
42 public Object getPropertyValue();
43
44 /**
45 * PropertyEditor should set the value specified and display it accordingly.
46 * Return value show whether the value could be set. Return value should be true
47 * only, it the editor was able to set and display value. If the value parameter
48 * does not match the editors expected type, is null or has invalid value,
49 * return value should be false.
50 *
51 * @param value Value to set
52 * @return boolean Indicates whether set was successful.
53 */
54 public boolean setPropertyValue(Object value);
55
56 /**
57 * Returns the description for this editor. This description will be
58 * used to describe the component in the GUI. Its actual implementation
59 * depends on the implementing class. <p>
60 * If editor is unable to display the description, it must return null. This will
61 * allow for automatic creation of description and properly wrap the methods.
62 * If editor can display description but its value has not yet been defined,
63 * this method should return empty string.
64 *
65 * @return String
66 */
67 public String getDescription();
68
69 public void setDescription(String description);
70
71 /**
72 * Returns the actual editor component. Since editors can be composed of more
73 * than one visual components, the actual editor the user edits may not be
74 * the same as the wrapper class. This method must return the true editor. If
75 * there is no need for that, it should return <code>this</code>.
76 *
77 * @return PropertyEditor
78 */
79 //public PropertyEditor getEditor();
80 /**
81 * Registers a PropertyChangeListener for this editor, which will be updated
82 * when a "propertyValue" property changes.
83 * @author Miha
84 */
85 public void addPropertyChangeListener(PropertyChangeListener l);
86
87 /**
88 * Deregisters a PropertyChangeListener from this editor.
89 * @author Miha
90 */
91 public void removePropertyChangeListener(PropertyChangeListener l);
92
93
94
95 }