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.components;
21
22 import java.beans.PropertyEditorSupport;
23
24 /**
25 * <code>SliderSetModePropertyEditor</code> is an implementation
26 * of the <code>PropertyEditor</code> which enables setting
27 * of the {@link Slider#setSetMode(SliderSetMode)} property.
28 *
29 * @see Slider
30 * @see Slider#setSetMode(SliderSetMode)
31 * @author <a href="mailto:jaka.bobnar@cosylab.com">Jaka Bobnar</a>
32 * @version $Id: SliderSetModePropertyEditor.java,v 1.4 2008-04-22 12:28:40 jbobnar Exp $
33 *
34 */
35 public class SliderSetModePropertyEditor extends PropertyEditorSupport {
36
37 @Override
38 public String getAsText() {
39 return ((SliderSetMode)getValue()).name();
40 }
41
42 /*
43 * (non-Javadoc)
44 * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
45 */
46 public void setAsText(String text) {
47 setValue(SliderSetMode.valueOf(text));
48 }
49
50 /*
51 * (non-Javadoc)
52 * @see java.beans.PropertyEditorSupport#getJavaInitializationString()
53 */
54 public String getJavaInitializationString() {
55 return "com.cosylab.gui.components.SliderSetMode."+getAsText();
56 }
57
58 /*
59 * (non-Javadoc)
60 * @see java.beans.PropertyEditorSupport#getTags()
61 */
62 @Override
63 public String[] getTags() {
64 SliderSetMode[] modes = SliderSetMode.values();
65
66 String[] tags = new String[modes.length];
67 for (int i = 0; i < tags.length; i++) {
68 tags[i] = modes[i].name();
69 }
70 return tags;
71 }
72
73 /*
74 * (non-Javadoc)
75 * @see java.beans.PropertyEditorSupport#supportsCustomEditor()
76 */
77 public boolean supportsCustomEditor() {
78 return false;
79 }
80 }