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


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         * Paul Mahar
021:         *
022:         */
023:        package org.enhydra.kelp.common.deployer;
024:
025:        // AddinCore
026:        import org.enhydra.kelp.common.PathUtil;
027:        import org.enhydra.kelp.common.event.WriteListener;
028:        import org.enhydra.kelp.common.node.OtterProject;
029:
030:        // ToolBox
031:        import org.enhydra.tool.archive.ArchiveException;
032:        import org.enhydra.tool.archive.JarPlan;
033:        import org.enhydra.tool.common.DataValidationException;
034:        import org.enhydra.tool.common.PathHandle;
035:
036:        // JDK
037:        import java.awt.*;
038:        import java.awt.event.ActionEvent;
039:        import java.awt.event.ActionListener;
040:        import java.util.Arrays;
041:        import javax.swing.*;
042:        import java.beans.*;
043:
044:        //
045:        public class ArchivePanel extends JPanel implements  Instructor,
046:                DeployStep {
047:            private GridBagLayout layoutMain;
048:            private JScrollPane scroll;
049:            private ArchiveTablePanel archiveTable;
050:            private JPanel panelButton;
051:            private JButton buttonAdd;
052:            private JButton buttonRemove;
053:            private GridBagLayout layoutButton;
054:            private JButton buttonUp;
055:            private JButton buttonDown;
056:            private LocalButtonListener buttonListener = null;
057:            private boolean ran = false;
058:            private JButton buttonEdit;
059:
060:            public ArchivePanel() {
061:                try {
062:                    jbInit();
063:                    pmInit();
064:                } catch (Exception ex) {
065:                    ex.printStackTrace();
066:                }
067:            }
068:
069:            // implements Instructor
070:            public String getTab() {
071:                return "Archive";
072:            }
073:
074:            // implements Instructor
075:            public String getTitle() {
076:                return "Deployable archives";
077:            }
078:
079:            // implements Instructor
080:            public String getInstructions() {
081:                return "The deployer can recreate archives that you can auto-deploy "
082:                        + "to a running Enhydra application server.";
083:            }
084:
085:            // implements DeployStep
086:            public void refresh() {
087:
088:                // nothing to refresh
089:            }
090:
091:            // implements DeployStep
092:            public void clearAll() {
093:                archiveTable.clearAll();
094:                buttonAdd.removeActionListener(buttonListener);
095:                buttonRemove.removeActionListener(buttonListener);
096:                buttonUp.removeActionListener(buttonListener);
097:                buttonDown.removeActionListener(buttonListener);
098:                removeAll();
099:                buttonListener = null;
100:            }
101:
102:            // implements DeployStep
103:            public boolean isDataValid() {
104:                return DeployStepUtil.isDataValid(this );
105:            }
106:
107:            // implements DeployStep
108:            public boolean isDataEqual(OtterProject project) {
109:                boolean equal = true;
110:                JarPlan[] projectPlans = new JarPlan[0];
111:                JarPlan[] panelPlans = new JarPlan[0];
112:
113:                projectPlans = project.getArchivePlans(false);
114:                panelPlans = archiveTable.getPlans();
115:                if (!Arrays.equals(panelPlans, projectPlans)) {
116:                    equal = false;
117:                }
118:                return equal;
119:            }
120:
121:            // implements DeployStep
122:            public void validateData() throws DataValidationException {
123:                JarPlan[] plans = new JarPlan[0];
124:                PathHandle path = null;
125:
126:                plans = archiveTable.getPlans();
127:                for (int i = 0; i < plans.length; i++) {
128:                    path = PathHandle.createPathHandle(plans[i]
129:                            .getArchivePath());
130:                    if (path.isDirectory()) {
131:                        throw new DataValidationException("Invalid archive: "
132:                                + path.getPath());
133:                    }
134:                }
135:            }
136:
137:            // implements DeployStep
138:            public boolean isBuilt(OtterProject project) {
139:                ran = DeployStepUtil.isBuilt(this , ran, project);
140:                return ran;
141:            }
142:
143:            // implements DeployStep
144:            public boolean isSelectable(OtterProject project, DeployStep[] steps) {
145:                boolean able = false;
146:                boolean generalBuilt = false;
147:                boolean inputBuilt = false;
148:                boolean contentBuilt = false;
149:
150:                for (int i = 0; i < steps.length; i++) {
151:                    if (steps[i] instanceof  GeneralPanel) {
152:                        generalBuilt = steps[i].isBuilt(project);
153:                    } else if (steps[i] instanceof  InputPanel) {
154:                        inputBuilt = steps[i].isBuilt(project);
155:                    } else if (steps[i] instanceof  ContentPanel) {
156:                        contentBuilt = steps[i].isBuilt(project);
157:                    }
158:                }
159:                able = generalBuilt && inputBuilt && contentBuilt;
160:                return able;
161:            }
162:
163:            // implements DeployStep
164:            public void build(OtterProject project, WriteListener listener)
165:                    throws DataValidationException {
166:                ArchiveBuilder builder = null;
167:
168:                if (!isBuilt(project)) {
169:                    write(project);
170:                    builder = new ArchiveBuilder(listener);
171:                    builder.setEcho(true);
172:                    builder.setProject(project);
173:                    builder.buildInCurrentThread();
174:                    ran = true;
175:                }
176:            }
177:
178:            // implements DeployStep
179:            public void read(OtterProject project) {
180:                PathHandle ph = null;
181:                JarPlan[] plans = new JarPlan[0];
182:
183:                // TODO: Pass project root to reader for relitive path expansion.
184:                plans = project.getArchivePlans(false);
185:                archiveTable.setPlans(plans);
186:                ph = PathHandle.createPathHandle(PathUtil
187:                        .getDefaultDeployArchivePath(project));
188:                archiveTable.setDefWorkingRoot(ph.getParent().getPath());
189:            }
190:
191:            // implements DeployStep
192:            public void write(OtterProject project)
193:                    throws DataValidationException {
194:                JarPlan[] plans = new JarPlan[0];
195:
196:                validateData();
197:                if (!isDataEqual(project)) {
198:                    plans = archiveTable.getPlans();
199:                    project.setArchivePlans(plans);
200:                }
201:            }
202:
203:            //
204:            //
205:            private void pmInit() {
206:                buttonListener = new LocalButtonListener();
207:                buttonAdd.addActionListener(buttonListener);
208:                buttonEdit.addActionListener(buttonListener);
209:                buttonRemove.addActionListener(buttonListener);
210:                buttonUp.addActionListener(buttonListener);
211:                buttonDown.addActionListener(buttonListener);
212:            }
213:
214:            private void jbInit() throws Exception {
215:                scroll = (JScrollPane) Beans.instantiate(getClass()
216:                        .getClassLoader(), JScrollPane.class.getName());
217:                archiveTable = (ArchiveTablePanel) Beans.instantiate(getClass()
218:                        .getClassLoader(), ArchiveTablePanel.class.getName());
219:                panelButton = (JPanel) Beans.instantiate(getClass()
220:                        .getClassLoader(), JPanel.class.getName());
221:                buttonAdd = (JButton) Beans.instantiate(getClass()
222:                        .getClassLoader(), JButton.class.getName());
223:                buttonRemove = (JButton) Beans.instantiate(getClass()
224:                        .getClassLoader(), JButton.class.getName());
225:                layoutButton = (GridBagLayout) Beans.instantiate(getClass()
226:                        .getClassLoader(), GridBagLayout.class.getName());
227:                buttonUp = (JButton) Beans.instantiate(getClass()
228:                        .getClassLoader(), JButton.class.getName());
229:                buttonDown = (JButton) Beans.instantiate(getClass()
230:                        .getClassLoader(), JButton.class.getName());
231:                layoutMain = (GridBagLayout) Beans.instantiate(getClass()
232:                        .getClassLoader(), GridBagLayout.class.getName());
233:                buttonEdit = (JButton) Beans.instantiate(getClass()
234:                        .getClassLoader(), JButton.class.getName());
235:                buttonAdd.setMaximumSize(new Dimension(100, 27));
236:                buttonAdd.setMinimumSize(new Dimension(100, 27));
237:                buttonAdd.setPreferredSize(new Dimension(100, 27));
238:                buttonAdd.setText("Add...");
239:                buttonRemove.setMaximumSize(new Dimension(100, 27));
240:                buttonRemove.setMinimumSize(new Dimension(100, 27));
241:                buttonRemove.setPreferredSize(new Dimension(100, 27));
242:                buttonRemove.setText("Remove");
243:                panelButton.setLayout(layoutButton);
244:                buttonUp.setMaximumSize(new Dimension(100, 27));
245:                buttonUp.setMinimumSize(new Dimension(100, 27));
246:                buttonUp.setPreferredSize(new Dimension(100, 27));
247:                buttonUp.setText("Move Up");
248:                buttonDown.setMaximumSize(new Dimension(100, 27));
249:                buttonDown.setMinimumSize(new Dimension(100, 27));
250:                buttonDown.setPreferredSize(new Dimension(100, 27));
251:                buttonDown.setText("Move Down");
252:                buttonEdit.setMaximumSize(new Dimension(100, 27));
253:                buttonEdit.setMinimumSize(new Dimension(100, 27));
254:                buttonEdit.setPreferredSize(new Dimension(100, 27));
255:                buttonEdit.setText("Edit...");
256:                panelButton
257:                        .add(buttonAdd, new GridBagConstraints(0, 0, 1, 1, 0.1,
258:                                0.0, GridBagConstraints.CENTER,
259:                                GridBagConstraints.NONE,
260:                                new Insets(20, 5, 5, 5), 0, 0));
261:                panelButton.add(buttonRemove, new GridBagConstraints(0, 2, 1,
262:                        1, 0.1, 0.0, GridBagConstraints.CENTER,
263:                        GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
264:                panelButton.add(buttonUp, new GridBagConstraints(0, 3, 1, 1,
265:                        0.1, 0.0, GridBagConstraints.CENTER,
266:                        GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
267:                panelButton
268:                        .add(buttonDown, new GridBagConstraints(0, 4, 1, 1,
269:                                0.1, 0.0, GridBagConstraints.CENTER,
270:                                GridBagConstraints.NONE,
271:                                new Insets(5, 5, 20, 5), 0, 0));
272:                panelButton.add(buttonEdit, new GridBagConstraints(0, 1, 1, 1,
273:                        0.1, 0.0, GridBagConstraints.CENTER,
274:                        GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
275:                scroll.getViewport().add(archiveTable, null);
276:                this .setLayout(layoutMain);
277:                this .add(scroll, new GridBagConstraints(0, 0, 1, 1, 0.8, 0.0,
278:                        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
279:                        new Insets(5, 5, 5, 5), 0, 0));
280:                this .add(panelButton, new GridBagConstraints(1, 0, 1, 1, 0.1,
281:                        0.0, GridBagConstraints.CENTER,
282:                        GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
283:            }
284:
285:            //
286:            private class LocalButtonListener implements  ActionListener {
287:                public void actionPerformed(ActionEvent event) {
288:                    Object source = event.getSource();
289:
290:                    try {
291:                        if (source == buttonAdd) {
292:                            archiveTable.addRow();
293:                        } else if (source == buttonEdit) {
294:                            archiveTable.editRow();
295:                        } else if (source == buttonRemove) {
296:                            archiveTable.removeSelection();
297:                        } else if (source == buttonDown) {
298:                            archiveTable.moveSelectionDown();
299:                        } else if (source == buttonUp) {
300:                            archiveTable.moveSelectionUp();
301:                        }
302:                    } catch (ArchiveException e) {
303:                        JOptionPane.showMessageDialog(getTopLevelAncestor(), e
304:                                .getMessage());
305:                    }
306:                }
307:
308:            }
309:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.