Source Code Cross Referenced for SelectEditor.java in  » Web-Server » Jigsaw » org » w3c » jigadm » editors » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Jigsaw » org.w3c.jigadm.editors 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // SelectEditor.java
002:        // $Id: SelectEditor.java,v 1.7 2000/08/16 21:37:27 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1997.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigadm.editors;
007:
008:        import java.awt.BorderLayout;
009:        import java.awt.Button;
010:        import java.awt.Component;
011:        import java.awt.Container;
012:        import java.awt.Panel;
013:        import java.awt.TextComponent;
014:        import java.awt.TextField;
015:        import java.awt.Window;
016:
017:        import java.awt.event.ActionEvent;
018:        import java.awt.event.ActionListener;
019:        import java.awt.event.ItemEvent;
020:        import java.awt.event.ItemListener;
021:        import java.awt.event.TextEvent;
022:        import java.awt.event.TextListener;
023:
024:        import java.util.Hashtable;
025:        import java.util.Properties;
026:
027:        import org.w3c.tools.resources.Attribute;
028:
029:        import org.w3c.tools.widgets.ClosableFrame;
030:
031:        import org.w3c.jigadm.RemoteResourceWrapper;
032:
033:        import org.w3c.jigsaw.admin.RemoteAccessException;
034:
035:        /**
036:         * SelectEditor :
037:         * @author Benoit Mahe <bmahe@sophia.inria.fr>
038:         */
039:
040:        public class SelectEditor extends AttributeEditor {
041:
042:            class SelectPopup extends ClosableFrame implements  ItemListener {
043:
044:                SelectComponent parent = null;
045:                java.awt.List list = null;
046:                EditorFeeder feeder = null;
047:                EditorModifier modifier = null;
048:
049:                // ItemListener
050:                public void itemStateChanged(ItemEvent e) {
051:                    if (e.getStateChange() == ItemEvent.SELECTED) {
052:                        String selected = (String) list.getItem(((Integer) e
053:                                .getItem()).intValue());
054:                        if (modifier != null)
055:                            selected = modifier.modify(selected);
056:                        parent.setText(selected);
057:                        setVisible(false);
058:                    }
059:                }
060:
061:                protected void setDefaultItems() {
062:                    list.removeAll();
063:                    String items[] = feeder.getDefaultItems();
064:                    if (items != null) {
065:                        for (int i = 0; i < items.length; i++)
066:                            if (items[i] != null)
067:                                list.addItem(items[i]);
068:                    }
069:                }
070:
071:                protected void close() {
072:                    setVisible(false);
073:                }
074:
075:                SelectPopup(SelectComponent parent, EditorFeeder feeder,
076:                        EditorModifier modifier) {
077:                    super ("Select");
078:                    this .parent = parent;
079:                    this .feeder = feeder;
080:                    this .modifier = modifier;
081:                    setLayout(new BorderLayout());
082:                    list = new java.awt.List(20);
083:                    list.addItemListener(this );
084:                    setDefaultItems();
085:                    add(list);
086:                    setSize(170, 300);
087:                }
088:            }
089:
090:            class SelectComponent extends Panel implements  ActionListener,
091:                    TextListener {
092:
093:                protected TextField selected = null;
094:                protected SelectPopup popup = null;
095:                protected SelectEditor editor = null;
096:                EditorFeeder feeder = null;
097:                EditorModifier modifier = null;
098:
099:                public void textValueChanged(TextEvent e) {
100:                    setModified();
101:                }
102:
103:                public void actionPerformed(ActionEvent e) {
104:                    String command = e.getActionCommand();
105:                    if (command != null) {
106:                        if (command.equals("edit")) {
107:                            if (popup == null)
108:                                popup = new SelectPopup(this , feeder, modifier);
109:                            popup.show();
110:                        }
111:                    }
112:                }
113:
114:                public String getText() {
115:                    return selected.getText();
116:                }
117:
118:                public void setText(String text) {
119:                    selected.setText(text);
120:                    editor.setModified();
121:                }
122:
123:                SelectComponent(SelectEditor editor, EditorFeeder feeder,
124:                        EditorModifier modifier, String selected) {
125:                    super ();
126:                    this .feeder = feeder;
127:                    this .modifier = modifier;
128:                    this .editor = editor;
129:                    this .selected = new TextField(20);
130:                    this .selected.setText(selected);
131:                    this .selected.addTextListener(this );
132:                    Button editB = new Button("Change");
133:                    editB.setActionCommand("edit");
134:                    editB.addActionListener(this );
135:                    setLayout(new BorderLayout());
136:                    add(this .selected, "West");
137:                    add(editB, "Center");
138:                }
139:
140:            }
141:
142:            // The SelectEditor itself
143:
144:            /**
145:             * Properties - The feeder's class name.
146:             */
147:            public static final String FEEDER_CLASS_P = "feeder.class";
148:            public static final String MODIFIER_CLASS_P = "modifier.class";
149:
150:            protected SelectComponent comp = null;
151:            protected boolean hasChanged = false;
152:            protected String oldvalue = null;
153:
154:            protected void createComponent(EditorFeeder feeder,
155:                    EditorModifier modifier, String selected) {
156:                if (comp == null)
157:                    comp = new SelectComponent(this , feeder, modifier, selected);
158:            }
159:
160:            protected void setModified() {
161:                hasChanged = true;
162:            }
163:
164:            /**
165:             * Tells if the edited value has changed
166:             * @return true if the value changed.
167:             */
168:            public boolean hasChanged() {
169:                return hasChanged;
170:            }
171:
172:            /**
173:             * set the current value to be the original value, ie: changed
174:             * must return <strong>false</strong> after a reset.
175:             */
176:            public void clearChanged() {
177:                hasChanged = false;
178:            }
179:
180:            /**
181:             * reset the changes (if any)
182:             */
183:            public void resetChanges() {
184:                hasChanged = false;
185:                comp.setText(oldvalue);
186:            }
187:
188:            /**
189:             * Get the current value of the edited value
190:             * @return an object or <strong>null</strong> if the object was not
191:             * initialized
192:             */
193:            public Object getValue() {
194:                try {
195:                    return comp.getText();
196:                } catch (Exception ex) {
197:                    ex.printStackTrace();
198:                }
199:                return null;
200:            }
201:
202:            /**
203:             * Set the value of the edited value
204:             * @param o the new value.
205:             */
206:            public void setValue(Object o) {
207:                this .oldvalue = (String) o;
208:                comp.setText(oldvalue);
209:            }
210:
211:            /**
212:             * get the Component created by the editor.
213:             * @return a Component
214:             */
215:            public Component getComponent() {
216:                return comp;
217:            }
218:
219:            /**
220:             * Initialize the editor
221:             * @param w the ResourceWrapper father of the attribute
222:             * @param a the Attribute we are editing
223:             * @param o the value of the above attribute
224:             * @param p some Properties, used to fine-tune the editor
225:             * @exception RemoteAccessException if a remote access error occurs.
226:             */
227:            public void initialize(RemoteResourceWrapper w, Attribute a,
228:                    Object o, Properties p) throws RemoteAccessException {
229:                // Get the feeder class fromproperties:
230:                EditorFeeder feeder = null;
231:                EditorModifier modifier = null;
232:                String feederClass = null;
233:
234:                feederClass = (String) p.get(FEEDER_CLASS_P);
235:                if (feederClass == null)
236:                    throw new RuntimeException(
237:                            "SelectEditor mis-configuration: " + FEEDER_CLASS_P
238:                                    + " property undefined.");
239:                try {
240:                    Class c = Class.forName(feederClass);
241:                    feeder = (EditorFeeder) c.newInstance();
242:                    feeder.initialize(w, p);
243:                } catch (Exception ex) {
244:                    ex.printStackTrace();
245:                    throw new RuntimeException("SelectEditor mis-configured: "
246:                            + " unable to instantiate " + feederClass + ".");
247:                }
248:
249:                String modifierClass = (String) p.get(MODIFIER_CLASS_P);
250:                if (modifierClass != null) {
251:                    try {
252:                        Class cm = Class.forName(modifierClass);
253:                        modifier = (EditorModifier) cm.newInstance();
254:                    } catch (Exception ex) {
255:                        ex.printStackTrace();
256:                        throw new RuntimeException(
257:                                "SelectEditor mis-configured: "
258:                                        + " unable to instantiate "
259:                                        + modifierClass + ".");
260:                    }
261:                }
262:
263:                String selected = (String) o;
264:                createComponent(feeder, modifier, selected);
265:                if (selected != null)
266:                    oldvalue = new String(selected);
267:            }
268:
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.