Source Code Cross Referenced for SelectFileEditor.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:        // SelectFileEditor.java
002:        // $Id: SelectFileEditor.java,v 1.6 2000/08/16 21:37:28 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.Dialog;
013:        import java.awt.FileDialog;
014:        import java.awt.Frame;
015:        import java.awt.Panel;
016:        import java.awt.TextComponent;
017:        import java.awt.TextField;
018:
019:        import java.io.File;
020:
021:        import java.awt.event.ActionEvent;
022:        import java.awt.event.ActionListener;
023:
024:        import java.util.Properties;
025:
026:        import org.w3c.tools.resources.Attribute;
027:
028:        import org.w3c.jigsaw.admin.RemoteAccessException;
029:        import org.w3c.jigsaw.admin.RemoteResource;
030:
031:        import org.w3c.jigadm.RemoteResourceWrapper;
032:
033:        public class SelectFileEditor extends AttributeEditor {
034:
035:            class FComponent extends Panel implements  ActionListener {
036:                SelectFileEditor editor = null;
037:                TextField text = null;
038:                Button select = null;
039:
040:                public String getFile() {
041:                    return text.getText();
042:                }
043:
044:                public void setFile(String file) {
045:                    text.setText(file);
046:                }
047:
048:                public void actionPerformed(ActionEvent e) {
049:                    String command = e.getActionCommand();
050:                    if (command != null) {
051:                        if (command.equals("select")) {
052:                            FileDialog fileD = new FileDialog(new Frame(),
053:                                    "Select a file");
054:                            //FIXME
055:                            String file = getFile();
056:                            String dir = null;
057:                            if (file != null) {
058:                                dir = new File(file).getParent();
059:                                fileD.setDirectory(dir);
060:                            }
061:                            fileD.show();
062:                            file = fileD.getFile();
063:                            dir = fileD.getDirectory();
064:                            String selected = null;
065:                            if ((file != null) && (file.length() > 0)) {
066:                                selected = (new File(dir, file))
067:                                        .getAbsolutePath();
068:                                setFile(selected);
069:                            }
070:                        }
071:                    }
072:                }
073:
074:                FComponent(SelectFileEditor editor) {
075:                    this .editor = editor;
076:                    this .text = new TextField();
077:                    this .select = new Button("Select");
078:                    select.setActionCommand("select");
079:                    select.addActionListener(this );
080:                    setLayout(new BorderLayout());
081:                    add(text, "Center");
082:                    add(select, "East");
083:                }
084:            }
085:
086:            private String origs;
087:            protected FComponent widget;
088:
089:            /**
090:             * Tells if the edited value has changed
091:             * @return true if the value changed.
092:             */
093:
094:            public boolean hasChanged() {
095:                return !origs.equals(widget.getFile());
096:            }
097:
098:            /**
099:             * set the current value to be the original value, ie: changed
100:             * must return <strong>false</strong> after a reset.
101:             */
102:
103:            public void clearChanged() {
104:                origs = widget.getFile();
105:            }
106:
107:            /**
108:             * reset the changes (if any)
109:             */
110:
111:            public void resetChanges() {
112:                widget.setFile(origs);
113:            }
114:
115:            /**
116:             * Get the current value of the edited value
117:             * @return an object or <strong>null</strong> if the object was not
118:             * initialized
119:             */
120:
121:            public Object getValue() {
122:                return widget.getFile();
123:            }
124:
125:            /**
126:             * Set the value of the edited value
127:             * @param o the new value.
128:             */
129:
130:            public void setValue(Object o) {
131:                widget.setFile(o.toString());
132:            }
133:
134:            /**
135:             * get the Component created by the editor.
136:             * @return a Component
137:             */
138:
139:            public Component getComponent() {
140:                return widget;
141:            }
142:
143:            /**
144:             * Initialize the editor
145:             * @param w the ResourceWrapper father of the attribute
146:             * @param a the Attribute we are editing
147:             * @param o the value of the above attribute
148:             * @param p some Properties, used to fine-tune the editor
149:             * @exception RemoteAccessException if a remote access error occurs.
150:             */
151:
152:            public void initialize(RemoteResourceWrapper w, Attribute a,
153:                    Object o, Properties p) throws RemoteAccessException {
154:                RemoteResource r = w.getResource();
155:                if (o == null) {
156:                    String v = null;
157:                    // FIXME
158:                    v = (String) r.getValue(a.getName());
159:
160:                    if (v == null)
161:                        if (a.getDefault() != null)
162:                            v = a.getDefault().toString();
163:                    if (v != null) {
164:                        origs = v;
165:                        widget.setFile(origs);
166:                    }
167:                } else {
168:                    origs = o.toString();
169:                }
170:                widget.setFile(origs);
171:            }
172:
173:            public void createComponent() {
174:                widget = new FComponent(this );
175:            }
176:
177:            public SelectFileEditor() {
178:                createComponent();
179:                origs = "";
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.