Source Code Cross Referenced for DeployInnerPanel.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:        // Kelp imports
026:        import org.enhydra.kelp.common.event.WriteEvent;
027:        import org.enhydra.kelp.common.event.WriteListener;
028:        import org.enhydra.kelp.common.node.OtterNode;
029:        import org.enhydra.kelp.common.swing.AddinInnerPanel;
030:
031:        // ToolBox imports
032:        import org.enhydra.tool.common.DataValidationException;
033:        import org.enhydra.tool.common.ButtonPanel;
034:        import org.enhydra.tool.common.ToolException;
035:
036:        // Standard imports
037:        import java.awt.*;
038:        import java.lang.ref.WeakReference;
039:        import javax.swing.*;
040:        import javax.swing.event.*;
041:        import java.beans.*;
042:
043:        //
044:        public class DeployInnerPanel extends AddinInnerPanel {
045:            private int showIndex = 0;
046:            private JTabbedPane tab = null;
047:            private BorderLayout layoutMain = null;
048:            private GeneralPanel generalPanel = null;
049:            private InputPanel inputPanel = null;
050:            private ContentPanel contentPanel = null;
051:            private ArchivePanel archivePanel = null;
052:            private RunPanel runPanel = null;
053:            private TabChangeListener tabListener = null;
054:            private WeakReference backRef = null;
055:            private WeakReference nextRef = null;
056:
057:            public DeployInnerPanel() {
058:                super ();
059:                try {
060:                    jbInit();
061:                    pmInit();
062:                } catch (Exception ex) {
063:                    ex.printStackTrace();
064:                }
065:            }
066:
067:            // override AddinInnerPanel
068:            public void preShow() {
069:                Component back = getBack();
070:
071:                if (back != null) {
072:                    back.setEnabled(false);
073:                }
074:            }
075:
076:            // override AddinInnerPanel
077:            public void read(OtterNode node) {
078:                super .read(node);
079:                DeployStep[] steps = new DeployStep[0];
080:
081:                steps = getSteps();
082:                for (int i = 0; i < steps.length; i++) {
083:                    steps[i].read(getProject());
084:                }
085:            }
086:
087:            // override AddinInnerPanel
088:            public void write(OtterNode node) throws DataValidationException {
089:                super .write(node);
090:                DeployStep[] steps = new DeployStep[0];
091:
092:                steps = getSteps();
093:                for (int i = 0; i < steps.length; i++) {
094:                    steps[i].write(getProject());
095:                }
096:            }
097:
098:            // override AddinInnerPanel
099:            public void initPreferredSize() {
100:                Dimension d = new Dimension();
101:
102:                d.height = 425;
103:                d.width = 600;
104:                setPreferredSize(d);
105:            }
106:
107:            // override AddinInnerPanel
108:            public void clearAll() {
109:                super .clearAll();
110:                DeployStep[] steps = new DeployStep[0];
111:
112:                tab.removeChangeListener(tabListener);
113:                if (backRef != null) {
114:                    backRef.clear();
115:                }
116:                if (nextRef != null) {
117:                    nextRef.clear();
118:                }
119:                steps = getSteps();
120:                for (int i = 0; i < steps.length; i++) {
121:                    steps[i].clearAll();
122:                }
123:                backRef = null;
124:                nextRef = null;
125:                tabListener = null;
126:                generalPanel = null;
127:                inputPanel = null;
128:                contentPanel = null;
129:                archivePanel = null;
130:                runPanel = null;
131:            }
132:
133:            //
134:            private void refresh() {
135:                Component back = null;
136:                Component next = null;
137:                boolean backEnable = true;
138:                boolean nextEnable = true;
139:
140:                back = getBack();
141:                next = getNext();
142:                int index = tab.getSelectedIndex();
143:
144:                if (index == 0) {
145:                    backEnable = false;
146:                } else if (index == (tab.getTabCount() - 1)) {
147:                    nextEnable = false;
148:                }
149:                if (back != null) {
150:                    back.setEnabled(backEnable);
151:                }
152:                if (next != null) {
153:                    next.setEnabled(nextEnable);
154:                }
155:                getSelectedStep().refresh();
156:            }
157:
158:            private Component getNext() {
159:                Component comp = null;
160:
161:                if (nextRef == null) {
162:                    comp = ButtonPanel.findButton(getTopLevelAncestor(),
163:                            ButtonPanel.COMMAND_NEXT);
164:                    if (comp != null) {
165:                        nextRef = new WeakReference(comp);
166:                    }
167:                } else {
168:                    comp = (Component) nextRef.get();
169:                }
170:                return comp;
171:            }
172:
173:            private Component getBack() {
174:                Component comp = null;
175:
176:                if (backRef == null) {
177:                    comp = ButtonPanel.findButton(getTopLevelAncestor(),
178:                            ButtonPanel.COMMAND_BACK);
179:                    if (comp != null) {
180:                        backRef = new WeakReference(comp);
181:                    }
182:                } else {
183:                    comp = (Component) backRef.get();
184:                }
185:                return comp;
186:            }
187:
188:            protected void back() {
189:                int index = tab.getSelectedIndex();
190:
191:                if (index > 0) {
192:                    showIndex = --index;
193:                    tab.setSelectedIndex(showIndex);
194:                }
195:                refresh();
196:            }
197:
198:            protected boolean next() {
199:                int index = tab.getSelectedIndex();
200:                boolean valid = true;
201:                DeployStep step = getSelectedStep();
202:
203:                if (index < tab.getTabCount()) {
204:                    try {
205:                        step.validateData();
206:                        if (getProject() != null) {
207:                            step.write(getProject());
208:                            step.build(getProject(), getWriteListener());
209:                        }
210:                        showIndex = ++index;
211:                        tab.setSelectedIndex(showIndex);
212:                    } catch (DataValidationException e) {
213:                        valid = false;
214:                        JOptionPane.showMessageDialog(this , e
215:                                .getValidationMessage());
216:                    } catch (ToolException e) {
217:                        valid = false;
218:                        JOptionPane.showMessageDialog(this , e.getMessage());
219:                        e.printStackTrace(System.err);
220:                    }
221:                }
222:                refresh();
223:                return valid;
224:            }
225:
226:            private WriteListener getWriteListener() {
227:                return generalPanel.getWriteListener();
228:            }
229:
230:            protected void deploy(CoreDeployTool tool) {
231:                if (getProject() != null) {
232:                    DeployBuilder builder = null;
233:
234:                    try {
235:                        WriteEvent clear;
236:
237:                        clear = new WriteEvent(this , WriteEvent.CLEAR,
238:                                new String());
239:                        trySave();
240:                        builder = new DeployBuilder(getWriteListener());
241:                        builder.setProject(getProject());
242:                        builder.setEcho(true);
243:                        builder.addProgressListener(tool.getProgressMeter());
244:                        tool.getProgressMeter().addCancelListener(builder);
245:                        tool.openProgress();
246:                        getWriteListener().onWrite(clear);
247:                        if (tab.getSelectedIndex() > 0) {
248:                            builder.setOwner(getWindow());
249:                            builder.setDoneDialog(true);
250:                        }
251:                        builder.build();
252:                    } catch (DataValidationException e) {
253:                        JOptionPane.showMessageDialog(this , e
254:                                .getValidationMessage());
255:                    } catch (ToolException e) {
256:                        JOptionPane.showMessageDialog(this , e.getMessage());
257:                        e.printStackTrace(System.err);
258:                    }
259:                }
260:            }
261:
262:            // override InnerPanel
263:            protected Component[] getFirstFocusComponents() {
264:                Component[] comps = new Component[0];
265:                Component[] genComps = new Component[0];
266:
267:                genComps = generalPanel.getFirstFocusComponents();
268:                comps = new Component[genComps.length + 1];
269:                comps[0] = tab;
270:                for (int i = 0; i < genComps.length; i++) {
271:                    comps[i + 1] = genComps[i];
272:                }
273:                return comps;
274:            }
275:
276:            // override InnerPanel
277:            public void save() {
278:                if (getProject() == null) {
279:                    System.err
280:                            .println("DeployInnerPanel.save() - project null");
281:                } else {
282:                    try {
283:                        trySave();
284:                    } catch (DataValidationException e) {
285:                        System.err.println(e.getValidationMessage());
286:                    } catch (ToolException e) {
287:                        System.err.println(e.getMessage());
288:                    }
289:                }
290:            }
291:
292:            private void trySave() throws DataValidationException,
293:                    ToolException {
294:                try {
295:                    write(getProject());
296:                } catch (DataValidationException e) {
297:                    buildSteps();
298:                }
299:            }
300:
301:            private void buildSteps() throws DataValidationException,
302:                    ToolException {
303:                DeployStep[] steps = new DeployStep[0];
304:
305:                steps = getSteps();
306:                for (int i = 0; i < steps.length; i++) {
307:                    steps[i].build(getProject(), getWriteListener());
308:                }
309:            }
310:
311:            //
312:            private DeployStep getSelectedStep() {
313:                DeployStep[] steps = new DeployStep[5];
314:
315:                steps = getSteps();
316:                return steps[tab.getSelectedIndex()];
317:            }
318:
319:            private DeployStep[] getSteps() {
320:                DeployStep[] steps = new DeployStep[5];
321:
322:                steps[0] = generalPanel;
323:                steps[1] = inputPanel;
324:                steps[2] = contentPanel;
325:                steps[3] = archivePanel;
326:                steps[4] = runPanel;
327:                return steps;
328:            }
329:
330:            //
331:            private void pmInit() {
332:                tabListener = new TabChangeListener();
333:                tab.addChangeListener(tabListener);
334:                generalPanel = new GeneralPanel();
335:                inputPanel = new InputPanel();
336:                contentPanel = new ContentPanel();
337:                archivePanel = new ArchivePanel();
338:                runPanel = new RunPanel();
339:                addInstructor(generalPanel);
340:                addInstructor(inputPanel);
341:                addInstructor(contentPanel);
342:                addInstructor(archivePanel);
343:                addInstructor(runPanel);
344:            }
345:
346:            private void addInstructor(Instructor i) {
347:                InstructPanel ip = null;
348:
349:                if (i instanceof  JPanel) {
350:                    ip = new InstructPanel();
351:                    ip.addInstuctor(i);
352:                    tab.add(ip, i.getTab());
353:                } else {
354:                    throw new RuntimeException("Instructor not a JPanel: "
355:                            + i.getTitle());
356:                }
357:            }
358:
359:            private void jbInit() throws Exception {
360:                tab = (JTabbedPane) Beans.instantiate(getClass()
361:                        .getClassLoader(), JTabbedPane.class.getName());
362:                layoutMain = (BorderLayout) Beans.instantiate(getClass()
363:                        .getClassLoader(), BorderLayout.class.getName());
364:                this .setLayout(layoutMain);
365:                this .add(tab, BorderLayout.CENTER);
366:            }
367:
368:            private class TabChangeListener implements  ChangeListener {
369:                public void stateChanged(ChangeEvent e) {
370:                    if (!tab.getSelectedComponent().isShowing()) {
371:                        int selectIndex = tab.getSelectedIndex();
372:
373:                        if (selectIndex > showIndex) {
374:                            tab.setSelectedIndex(showIndex);
375:                            for (int i = showIndex; i < selectIndex; i++) {
376:                                if (!next()) {
377:                                    break;
378:                                }
379:                            }
380:                            showIndex = tab.getSelectedIndex();
381:                        } else if (selectIndex < showIndex) {
382:                            showIndex = selectIndex;
383:                        }
384:                    }
385:                    refresh();
386:                }
387:
388:            }
389:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.