Source Code Cross Referenced for AntOutputPanel.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » ant » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.ant.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.kelp.ant.swing;
002:
003:        // AddinCore
004:        import org.enhydra.kelp.common.Constants;
005:        import org.enhydra.kelp.common.event.WriteEvent;
006:        import org.enhydra.kelp.common.event.WriteListener;
007:        import org.enhydra.kelp.common.node.OtterProject;
008:        import org.enhydra.kelp.common.swing.OutputPanel;
009:
010:        // ToolBox
011:        import org.enhydra.tool.common.ExtensionFilter;
012:        import org.enhydra.tool.common.PathHandle;
013:
014:        // JDK
015:        import javax.swing.*;
016:        import java.awt.*;
017:        import java.awt.event.*;
018:        import java.beans.Beans;
019:        import java.io.File;
020:        import java.util.ResourceBundle;
021:        import org.enhydra.kelp.ant.node.AntProject;
022:
023:        //
024:        public class AntOutputPanel extends JPanel implements  WriteListener {
025:
026:            //
027:            public static ResourceBundle res = ResourceBundle
028:                    .getBundle("org.enhydra.kelp.common.Res"); // nores
029:            private LocalButtonListener buttonListener = null;
030:            private LocalCheckListener checkListener = null;
031:            private OtterProject project = null;
032:            private JPanel panelFile;
033:            private JCheckBox checkSave;
034:            private OutputPanel outputPanel;
035:            private JTextField textFile;
036:            private JButton buttonBrowse;
037:            private GridBagLayout layoutFile;
038:            private GridBagLayout layoutMain;
039:
040:            /**
041:             * Constructor declaration
042:             *
043:             */
044:            public AntOutputPanel() {
045:                try {
046:                    jbInit();
047:                    pmInit();
048:                } catch (Exception e) {
049:                    e.printStackTrace();
050:                }
051:            }
052:
053:            /**
054:             * Method declaration
055:             *
056:             *
057:             * @param event
058:             */
059:            public void onWrite(WriteEvent event) {
060:                outputPanel.onWrite(event);
061:            }
062:
063:            /**
064:             * Method declaration
065:             *
066:             *
067:             * @return
068:             */
069:            public OtterProject getProject() {
070:                return project;
071:            }
072:
073:            /**
074:             * Method declaration
075:             *
076:             *
077:             * @param p
078:             */
079:            public void setProject(OtterProject p) {
080:                project = p;
081:                String outPath = project.getOutputFilename();
082:
083:                if ((outPath == null) || (outPath.trim().length() == 0)) {
084:                    checkSave.setSelected(false);
085:                    textFile.setText(new String());
086:                } else {
087:                    textFile.setText(PathHandle.createPathString(outPath));
088:                    checkSave.setSelected(true);
089:                }
090:                outputPanel.setProject(project);
091:            }
092:
093:            public void clearOutput() {
094:                outputPanel.clearOutput();
095:            }
096:
097:            //
098:            // PROTECTED
099:            //
100:
101:            /**
102:             * Method declaration
103:             *
104:             */
105:            protected void scrollToBottom() {
106:                outputPanel.scrollToBottom();
107:            }
108:
109:            //
110:            // PRIVATE
111:            //
112:            private void buttonFileAction() {
113:                JFileChooser chooser = null;
114:                ExtensionFilter filter = null;
115:                PathHandle path = null;
116:                File file = null;
117:                int choice = -1;
118:
119:                //
120:                filter = new ExtensionFilter();
121:                filter.addExtension(Constants.TYPE_TXT);
122:                filter.setDescriptionTitle(res.getString("Kelp_log"));
123:
124:                //
125:                chooser = new JFileChooser();
126:                if (textFile.getText().trim().length() == 0) {
127:                    file = new File(project.getRootPath() + File.separator
128:                            + Constants.FILE_KELP_TXT);
129:                } else {
130:                    file = new File(textFile.getText());
131:                }
132:                chooser.setSelectedFile(file);
133:                chooser.setFileFilter(filter);
134:                chooser.setDialogTitle(res.getString("Select_log"));
135:                chooser.setApproveButtonText(res.getString("OK"));
136:                choice = chooser.showOpenDialog(this );
137:
138:                //
139:                this .requestFocus();
140:                buttonBrowse.requestFocus();
141:
142:                //
143:                if (choice == JFileChooser.APPROVE_OPTION
144:                        && chooser.getSelectedFile() != null) {
145:                    path = PathHandle.createPathHandle(chooser
146:                            .getSelectedFile());
147:                    textFile.setText(path.getPath());
148:                    project.setOutputFilename(path.getPath());
149:                }
150:
151:                //
152:                chooser.removeAll();
153:                chooser = null;
154:            }
155:
156:            /**
157:             * Method declaration
158:             *
159:             */
160:            private void pmInit() {
161:                buttonListener = new LocalButtonListener();
162:                buttonBrowse.addActionListener(buttonListener);
163:                buttonBrowse.setEnabled(false);
164:                checkListener = new LocalCheckListener();
165:                checkSave.addItemListener(checkListener);
166:                checkSave.setSelected(false);
167:            }
168:
169:            /**
170:             * Method declaration
171:             *
172:             *
173:             * @throws Exception
174:             */
175:            private void jbInit() throws Exception {
176:                panelFile = (JPanel) Beans.instantiate(getClass()
177:                        .getClassLoader(), JPanel.class.getName());
178:                outputPanel = (OutputPanel) Beans.instantiate(getClass()
179:                        .getClassLoader(), OutputPanel.class.getName());
180:                checkSave = (JCheckBox) Beans.instantiate(getClass()
181:                        .getClassLoader(), JCheckBox.class.getName());
182:                textFile = (JTextField) Beans.instantiate(getClass()
183:                        .getClassLoader(), JTextField.class.getName());
184:                buttonBrowse = (JButton) Beans.instantiate(getClass()
185:                        .getClassLoader(), JButton.class.getName());
186:                layoutFile = (GridBagLayout) Beans.instantiate(getClass()
187:                        .getClassLoader(), GridBagLayout.class.getName());
188:                layoutMain = (GridBagLayout) Beans.instantiate(getClass()
189:                        .getClassLoader(), GridBagLayout.class.getName());
190:                buttonBrowse.setText(res.getString("Browse"));
191:                panelFile.setLayout(layoutFile);
192:                checkSave.setText(res.getString("Output_to_log"));
193:                textFile.setBackground(SystemColor.controlLtHighlight);
194:                textFile.setEnabled(false);
195:                textFile.setPreferredSize(new Dimension(150, 21));
196:                panelFile
197:                        .add(checkSave, new GridBagConstraints(0, 0, 1, 1, 0.0,
198:                                0.0, GridBagConstraints.WEST,
199:                                GridBagConstraints.BOTH,
200:                                new Insets(5, 5, 5, 5), 14, 0));
201:                panelFile.add(textFile, new GridBagConstraints(1, 0, 1, 1, 0.5,
202:                        0.5, GridBagConstraints.CENTER,
203:                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5),
204:                        14, 0));
205:                panelFile.add(buttonBrowse, new GridBagConstraints(2, 0, 1, 1,
206:                        0.5, 0.5, GridBagConstraints.WEST,
207:                        GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 6, 0));
208:                this .setLayout(layoutMain);
209:                this .add(outputPanel, new GridBagConstraints(0, 0, 1, 1, 0.75,
210:                        0.75, GridBagConstraints.WEST, GridBagConstraints.BOTH,
211:                        new Insets(8, 12, 0, 0), 0, 0));
212:                this 
213:                        .add(panelFile, new GridBagConstraints(0, 1, 1, 1,
214:                                0.25, 0.25, GridBagConstraints.CENTER,
215:                                GridBagConstraints.BOTH,
216:                                new Insets(0, 12, 0, 0), 0, 0));
217:            }
218:
219:            /**
220:             */
221:            private class LocalCheckListener implements  ItemListener {
222:                public void itemStateChanged(ItemEvent event) {
223:                    Object source = event.getSource();
224:
225:                    if (source == checkSave) {
226:                        if (checkSave.isSelected()) {
227:                            buttonBrowse.setEnabled(true);
228:                            ((AntProject) project).setOutputFileEnabled(true);
229:                        } else {
230:                            buttonBrowse.setEnabled(false);
231:                            textFile.setText(new String());
232:                            if (project == null) {
233:
234:                                // done
235:                            } else {
236:                                project.setOutputFilename(new String());
237:                                ((AntProject) project)
238:                                        .setOutputFileEnabled(false);
239:                            }
240:                        }
241:                    }
242:                }
243:
244:            }
245:
246:            /**
247:             */
248:            private class LocalButtonListener implements  ActionListener {
249:                public void actionPerformed(ActionEvent event) {
250:                    Object source = event.getSource();
251:
252:                    if (source == buttonBrowse) {
253:                        buttonFileAction();
254:                    }
255:                }
256:
257:            }
258:
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.