Source Code Cross Referenced for AbstractParameter.java in  » Profiler » ejp » ejp » presenter » api » filters » parameters » 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 » Profiler » ejp » ejp.presenter.api.filters.parameters 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         $Id: AbstractParameter.java,v 1.6 2005/02/14 12:06:19 vauclair Exp $
003:
004:         Copyright (C) 2002-2005 Sebastien Vauclair
005:
006:         This file is part of Extensible Java Profiler.
007:
008:         Extensible Java Profiler is free software; you can redistribute it and/or
009:         modify it under the terms of the GNU General Public License as published by
010:         the Free Software Foundation; either version 2 of the License, or
011:         (at your option) any later version.
012:
013:         Extensible Java Profiler is distributed in the hope that it will be useful,
014:         but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         GNU General Public License for more details.
017:
018:         You should have received a copy of the GNU General Public License
019:         along with Extensible Java Profiler; if not, write to the Free Software
020:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
021:         */
022:
023:        package ejp.presenter.api.filters.parameters;
024:
025:        import java.awt.Dialog;
026:        import java.awt.Dimension;
027:        import java.awt.GridBagConstraints;
028:        import java.awt.GridBagLayout;
029:
030:        import javax.swing.JComponent;
031:        import javax.swing.JDialog;
032:        import javax.swing.JFrame;
033:        import javax.swing.JLabel;
034:        import javax.swing.JPanel;
035:        import javax.swing.border.TitledBorder;
036:
037:        import ejp.presenter.gui.Utils;
038:
039:        /**
040:         * Abstract super class of all parameters instances.
041:         * 
042:         * @author Sebastien Vauclair
043:         * @version <code>$Revision: 1.6 $<br>$Date: 2005/02/14 12:06:19 $</code>
044:         */
045:        public abstract class AbstractParameter {
046:            // ///////////////////////////////////////////////////////////////////////////
047:            // CONSTANTS
048:            // ///////////////////////////////////////////////////////////////////////////
049:
050:            /**
051:             * Width (in pixels) of a parameter's label.
052:             */
053:            public static final int LABEL_WIDTH = 150;
054:
055:            // ///////////////////////////////////////////////////////////////////////////
056:            // FIELDS
057:            // ///////////////////////////////////////////////////////////////////////////
058:
059:            /**
060:             * Parameter name.
061:             */
062:            public final String name;
063:
064:            /**
065:             * Parameter panel (graphical box).
066:             */
067:            protected final JPanel panel;
068:
069:            /**
070:             * Current row number in parameter's lines.
071:             */
072:            protected int y = 0;
073:
074:            /**
075:             * Dialog currently showing the parameter (<code>null</code> if none).
076:             */
077:            protected Dialog dialog = null;
078:
079:            // ///////////////////////////////////////////////////////////////////////////
080:            // CONSTRUCTOR
081:            // ///////////////////////////////////////////////////////////////////////////
082:
083:            /**
084:             * Creates a new parameter instance..
085:             * 
086:             * @param aName
087:             *          the parameter's unique name, as referenced in XML files.
088:             * @param aTitle
089:             *          the parameter's graphical title (free text value).
090:             * @param aToolTipText
091:             *          a tooltip text explaining the parameter's purpose.
092:             */
093:            public AbstractParameter(String aName, String aTitle,
094:                    String aToolTipText) {
095:                name = aName;
096:
097:                TitledBorder tbTemp = new TitledBorder(aTitle + " [" + aName
098:                        + "]");
099:                tbTemp.setTitleFont(Utils.FONT_11);
100:
101:                panel = new JPanel();
102:                panel.setDoubleBuffered(true);
103:                panel.setLayout(new GridBagLayout());
104:                panel.setToolTipText(aToolTipText);
105:                panel.setBorder(tbTemp);
106:            }
107:
108:            // ///////////////////////////////////////////////////////////////////////////
109:            // MEMBERS
110:            // ///////////////////////////////////////////////////////////////////////////
111:
112:            /**
113:             * Returns the parameter's graphical customization panel.
114:             * 
115:             * @return the panel.
116:             */
117:            public JPanel getPanel() {
118:                return panel;
119:            }
120:
121:            /**
122:             * Sets the parameter to be read-only, ie. no longer changeable.
123:             * 
124:             * Might be called at most once.
125:             */
126:            public abstract void setReadOnly();
127:
128:            /**
129:             * Sets current dialog showing the parameter's customization.
130:             * 
131:             * @param aDialog
132:             *          an initialized dialog.
133:             */
134:            public void setDialog(Dialog aDialog) {
135:                dialog = aDialog;
136:            }
137:
138:            /**
139:             * Adds a configuration line to the paramter.
140:             * 
141:             * Such a line is made of a title and one or two visual objects used to set
142:             * the value of the customization line.
143:             * 
144:             * @param aTitle
145:             *          the line's meaning.
146:             * @param aToolTipText
147:             *          a free tool-tip text.
148:             * @param aComponent1
149:             *          first component (might be <code>null</code> to skip it).
150:             * @param aComponent2
151:             *          second component (might be <code>null</code> to skip it).
152:             */
153:            protected final void addLine(String aTitle, String aToolTipText,
154:                    JComponent aComponent1, JComponent aComponent2) {
155:                // description
156:                JLabel jlTemp = new JLabel(aTitle);
157:                Utils.setCommonProperties(jlTemp);
158:                jlTemp.setPreferredSize(new Dimension(LABEL_WIDTH, (int) jlTemp
159:                        .getPreferredSize().getHeight()));
160:                GridBagConstraints gbcTemp = new GridBagConstraints();
161:                gbcTemp.anchor = GridBagConstraints.NORTHWEST;
162:                gbcTemp.gridx = 0;
163:                gbcTemp.gridy = y;
164:                gbcTemp.insets = Utils.INSETS_5;
165:                panel.add(jlTemp, gbcTemp);
166:
167:                // component 1
168:                if (aComponent1 != null) {
169:                    gbcTemp.fill = GridBagConstraints.BOTH;
170:                    gbcTemp.gridx = 1;
171:                    gbcTemp.weightx = 1;
172:                    panel.add(aComponent1, gbcTemp);
173:                }
174:
175:                // component 2
176:                if (aComponent2 != null) {
177:                    gbcTemp.gridx = 2;
178:                    panel.add(aComponent2, gbcTemp);
179:                }
180:
181:                ++y;
182:            }
183:
184:            /**
185:             * Returns current value of the parameter, as any object.
186:             * 
187:             * @return an <code>Object</code> value.
188:             */
189:            public abstract Object getValue();
190:
191:            /**
192:             * Returns current value of the parameter, as a text value.
193:             * 
194:             * The returned value will be used for XML storage.
195:             * 
196:             * @return a text value.
197:             */
198:            public abstract String getValueAsText();
199:
200:            /**
201:             * Sets current value of the parameter, from an object value.
202:             * 
203:             * This method should handle object values returned by the
204:             * <code>getValue()</code> method.
205:             * 
206:             * @param aObject
207:             *          an <code>Object</code> value.
208:             * @exception ClassCastException
209:             *              if the object is of an unknown type.
210:             */
211:            public abstract void setValue(Object aObject)
212:                    throws ClassCastException;
213:
214:            /**
215:             * Sets current value of the parameter, from a text value.
216:             * 
217:             * This method should parse text values returned by the
218:             * <code>getValueAsText()</code> method.
219:             * 
220:             * @param aTextValue
221:             *          a text value.
222:             * @exception IllegalArgumentException
223:             *              if the text is not parseable.
224:             */
225:            public abstract void setValueAsText(String aTextValue)
226:                    throws IllegalArgumentException;
227:
228:            // ///////////////////////////////////////////////////////////////////////////
229:            // TEST
230:            // ///////////////////////////////////////////////////////////////////////////
231:
232:            /**
233:             * Shows the parameter in a test frame.
234:             */
235:            public final void showInTestFrame() {
236:                JFrame jf = new JFrame("Test frame");
237:
238:                JDialog jd = new JDialog(jf, true);
239:                setDialog(jd);
240:                jd.getContentPane().add(panel);
241:                jd.pack();
242:                jd.setVisible(true);
243:            }
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.