Source Code Cross Referenced for FileField.java in  » Workflow-Engines » OSWorkflow » com » opensymphony » workflow » designer » swing » 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 » Workflow Engines » OSWorkflow » com.opensymphony.workflow.designer.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.opensymphony.workflow.designer.swing;
002:
003:        import java.awt.*;
004:        import java.awt.event.ActionEvent;
005:        import java.awt.event.ActionListener;
006:        import java.io.File;
007:        import javax.swing.*;
008:        import javax.swing.event.EventListenerList;
009:
010:        import com.opensymphony.workflow.designer.Utils;
011:
012:        public class FileField extends JPanel {
013:            private final JTextField field = new JTextField();
014:            private final FixedButton button = new FixedButton(field);
015:            private String suffix;
016:            private String description;
017:            private final int type;
018:            private boolean isSave;
019:            private boolean buttonEnabled;
020:            private File file;
021:            protected EventListenerList listenerList = new EventListenerList();
022:
023:            /**
024:             * Only one <code>ActionEvent</code> is needed per field instance since the event's only state is the source property.
025:             * The source of events generated is always "this".
026:             */
027:            protected transient ActionEvent actionEvent;
028:
029:            public void actionPerformed(ActionEvent e) {
030:            }
031:
032:            public FileField(int type, boolean save, String suffix,
033:                    String description) {
034:                super (new BorderLayout());
035:                this .type = type;
036:                this .isSave = save;
037:                this .suffix = suffix;
038:                this .description = description;
039:                buttonEnabled = true;
040:                add(field, BorderLayout.CENTER);
041:                add(button, BorderLayout.EAST);
042:                button.addActionListener(new ActionListener() {
043:                    public void actionPerformed(ActionEvent e) {
044:                        File file = Utils.promptUserForFile(FileField.this ,
045:                                FileField.this .type, FileField.this .isSave,
046:                                FileField.this .suffix,
047:                                FileField.this .description);
048:                        if (file != null) {
049:                            field.setText(file.getAbsolutePath());
050:                            FileField.this .file = file;
051:                            fireStateChanged();
052:                        }
053:                    }
054:                });
055:            }
056:
057:            /**
058:             * Adds an <code>ActionListener</code> to the field.
059:             *
060:             * @param l the <code>ActionListener</code> to be added
061:             */
062:            public void addActionListener(ActionListener l) {
063:                listenerList.add(ActionListener.class, l);
064:            }
065:
066:            /**
067:             * Notifies all listeners that have registered interest for
068:             * notification on this event type.  The event instance
069:             * is lazily created.
070:             *
071:             * @see EventListenerList
072:             */
073:            protected void fireStateChanged() {
074:                // Guaranteed to return a non-null array
075:                Object[] listeners = listenerList.getListenerList();
076:                // Process the listeners last to first, notifying
077:                // those that are interested in this event
078:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
079:                    if (listeners[i] == ActionListener.class) {
080:                        // Lazily create the event:
081:                        if (actionEvent == null)
082:                            actionEvent = new ActionEvent(this ,
083:                                    ActionEvent.ACTION_PERFORMED,
084:                                    "fileselected");
085:                        ((ActionListener) listeners[i + 1])
086:                                .actionPerformed(actionEvent);
087:                    }
088:                }
089:            }
090:
091:            /**
092:             * Removes an <code>ActionListener</code> from the field.
093:             *
094:             * @param l the listener to be removed
095:             */
096:            public void removeActionListener(ActionListener l) {
097:                listenerList.remove(ActionListener.class, l);
098:            }
099:
100:            /**
101:             * Returns an array of all the <code>ActionListener</code>s added
102:             * to this FileField with addActionListener().
103:             *
104:             * @return all of the <code>ActionListener</code>s added or an empty
105:             *         array if no listeners have been added
106:             */
107:            public ActionListener[] getActionListeners() {
108:                return (ActionListener[]) (listenerList
109:                        .getListeners(ActionListener.class));
110:            }
111:
112:            public void setButtonIcon(Icon icon) {
113:                button.setIcon(icon);
114:            }
115:
116:            public void setButtonEnabled(boolean flag) {
117:                buttonEnabled = flag;
118:                setEnabled(isEnabled());
119:            }
120:
121:            public void setEnabled(boolean enabled) {
122:                super .setEnabled(enabled);
123:                button.setEnabled(enabled && buttonEnabled);
124:                field.setEnabled(enabled);
125:            }
126:
127:            public FixedButton getButton() {
128:                return button;
129:            }
130:
131:            public JTextField getTextField() {
132:                return field;
133:            }
134:
135:            public String getText() {
136:                return field.getText().trim();
137:            }
138:
139:            public void setText(String s) {
140:                field.setText(s);
141:            }
142:
143:            public File getFile() {
144:                return file;
145:            }
146:
147:            public void setTextFieldPreferredWidth(int i) {
148:                Dimension dimension = field.getPreferredSize();
149:                FontMetrics fontmetrics = field.getFontMetrics(field.getFont());
150:                dimension.width = fontmetrics.charWidth('a') * i;
151:                field.setPreferredSize(dimension);
152:            }
153:
154:            public boolean isEditable() {
155:                return field.isEditable();
156:            }
157:
158:            public void setEditable(boolean flag) {
159:                field.setEditable(flag);
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.