Source Code Cross Referenced for JaWEFrame.java in  » Workflow-Engines » JaWE » org » enhydra » jawe » base » controller » 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 » JaWE » org.enhydra.jawe.base.controller 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.jawe.base.controller;
002:
003:        import java.awt.BorderLayout;
004:        import java.awt.Color;
005:        import java.awt.Container;
006:        import java.awt.Dimension;
007:        import java.awt.GraphicsEnvironment;
008:        import java.awt.Rectangle;
009:        import java.awt.event.WindowAdapter;
010:        import java.awt.event.WindowEvent;
011:
012:        import javax.swing.JComponent;
013:        import javax.swing.JFileChooser;
014:        import javax.swing.JFrame;
015:        import javax.swing.JMenuBar;
016:        import javax.swing.JOptionPane;
017:        import javax.swing.JPanel;
018:        import javax.swing.JSplitPane;
019:        import javax.swing.JToolBar;
020:        import javax.swing.ToolTipManager;
021:        import javax.swing.WindowConstants;
022:
023:        import org.enhydra.jawe.BarFactory;
024:        import org.enhydra.jawe.JaWEComponent;
025:        import org.enhydra.jawe.JaWEComponentView;
026:        import org.enhydra.jawe.JaWEManager;
027:        import org.enhydra.jawe.JaWETabbedPane;
028:        import org.enhydra.jawe.JaWEXMLUtil;
029:        import org.enhydra.jawe.ResourceManager;
030:        import org.enhydra.jawe.Utils;
031:
032:        /**
033:         *  Used to handle JaWE.
034:         *
035:         *  @author Sasa Bojanic
036:         */
037:        public class JaWEFrame extends JFrame implements  JaWEComponentView {
038:
039:            protected JaWEController controller;
040:
041:            protected JMenuBar menubar = new JMenuBar();
042:            protected JToolBar toolbar;
043:
044:            protected JPanel menubarAndToolbar = new JPanel();
045:            protected JPanel workingArea = new JPanel();
046:            protected JSplitPane bigSplit;
047:            protected JSplitPane smallSplit1;
048:            protected JSplitPane smallSplit2;
049:            protected JaWETabbedPane treeComponents = new JaWETabbedPane();
050:            protected JaWETabbedPane specialComponents = new JaWETabbedPane();
051:            protected JaWETabbedPane mainComponents = new JaWETabbedPane();
052:            protected JaWETabbedPane otherComponents = new JaWETabbedPane();
053:            protected JaWETabbedPane buttonComponents = new JaWETabbedPane();
054:
055:            //   protected XPDLPreview xpdlPreview;
056:            protected String appTitle;
057:            //   protected ImageIcon appIcon, logoIcon;
058:
059:            // attributes for maximizing
060:            private Rectangle oldBounds;
061:            private JComponent maxComponent;
062:            private Container maxCompParent;
063:
064:            public JaWEFrame(JaWEController controller) {
065:                this .controller = controller;
066:                setLocale(ResourceManager.getChoosenLocale());
067:                JOptionPane
068:                        .setDefaultLocale(ResourceManager.getChoosenLocale());
069:                JFileChooser.setDefaultLocale(ResourceManager
070:                        .getChoosenLocale());
071:            }
072:
073:            public void configure() {
074:                init();
075:            }
076:
077:            public void maximizeComponent(JComponent com) {
078:                workingArea.removeAll();
079:
080:                oldBounds = new Rectangle(com.getBounds());
081:                com.setBounds(0, 0, workingArea.getWidth(), workingArea
082:                        .getHeight());
083:
084:                maxComponent = com;
085:                maxCompParent = maxComponent.getParent();
086:
087:                workingArea.add(com, BorderLayout.CENTER);
088:
089:                com.setVisible(true);
090:            }
091:
092:            public void restoreWorkingArea() {
093:                maxComponent.setBounds(oldBounds);
094:                workingArea.remove(maxComponent);
095:
096:                workingArea.removeAll();
097:                maxCompParent.add(maxComponent);
098:
099:                workingArea.add(bigSplit, BorderLayout.CENTER);
100:            }
101:
102:            public void init() {
103:                mainComponents.setName(JaWEComponent.MAIN_COMPONENT);
104:                specialComponents.setName(JaWEComponent.SPECIAL_COMPONENT);
105:                treeComponents.setName(JaWEComponent.TREE_COMPONENT);
106:                otherComponents.setName(JaWEComponent.OTHER_COMPONENT);
107:
108:                menubar = BarFactory.createMainMenu(controller);
109:                toolbar = BarFactory
110:                        .createToolbar("defaultToolbar", controller);
111:                toolbar.setFloatable(false);
112:
113:                // application title
114:                appTitle = controller.getSettings().getLanguageDependentString(
115:                        "DialogTitle");
116:
117:                // Logo      
118:                setIconImage(controller.getControllerSettings()
119:                        .getApplicationIcon().getImage());
120:
121:                setBackground(Color.lightGray);
122:                getContentPane().setLayout(new BorderLayout());
123:                setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
124:
125:                workingArea.setLayout(new BorderLayout());
126:
127:                // menubar and toolbar
128:                menubarAndToolbar.setLayout(new BorderLayout());
129:                menubarAndToolbar.add(menubar, BorderLayout.NORTH);
130:                menubarAndToolbar.add(toolbar, BorderLayout.CENTER);
131:
132:                arrangeFrame();
133:
134:                getContentPane().add(menubarAndToolbar, BorderLayout.NORTH);
135:                workingArea.add(bigSplit, BorderLayout.CENTER);
136:                getContentPane().add(workingArea, BorderLayout.CENTER);
137:                getContentPane().add(buttonComponents, BorderLayout.SOUTH);
138:
139:                addWindowListener(createAppCloser());
140:                pack();
141:                // set default location to be centered and size to be almost maximized
142:                Dimension screenSize = GraphicsEnvironment
143:                        .getLocalGraphicsEnvironment().getDefaultScreenDevice()
144:                        .getDefaultConfiguration().getBounds().getSize();
145:                int xMinus = 24, yMinus = 50;
146:                setBounds(xMinus / 2, yMinus / 2, screenSize.width - xMinus,
147:                        screenSize.height - yMinus);
148:
149:                if (controller.getControllerSettings().shoudStartMaximized()) {
150:                    setExtendedState(MAXIMIZED_BOTH);
151:                }
152:
153:                ToolTipManager.sharedInstance().setEnabled(
154:                        controller.getControllerSettings().showTooltip());
155:            }
156:
157:            public JaWEComponent getJaWEComponent() {
158:                return controller;
159:            }
160:
161:            public JComponent getDisplay() {
162:                return null;
163:            }
164:
165:            public String getAppTitle() {
166:                return appTitle;
167:            }
168:
169:            public void addMainComponent(String name, JComponent c) {
170:                String lanName = controller.getSettings()
171:                        .getLanguageDependentString(name + "Label");
172:                JaWEManager.getInstance().getLoggingManager().debug(
173:                        "Added Main component " + lanName);
174:                String tip = controller.getSettings()
175:                        .getLanguageDependentString("DoubleClickToMaximize")
176:                        + " "
177:                        + lanName
178:                        + ". "
179:                        + controller.getSettings().getLanguageDependentString(
180:                                "RightClickToAdd");
181:                mainComponents.insertTab(lanName, null, c, tip, mainComponents
182:                        .getComponentCount());
183:            }
184:
185:            public void removeMainComponent(JComponent c) {
186:                mainComponents.remove(c);
187:            }
188:
189:            public void addToTreeComponents(String name, JComponent c) {
190:                String lanName = controller.getSettings()
191:                        .getLanguageDependentString(name + "Label");
192:                JaWEManager.getInstance().getLoggingManager().debug(
193:                        "Added tree component " + lanName);
194:                String tip = controller.getSettings()
195:                        .getLanguageDependentString("DoubleClickToMaximize")
196:                        + " "
197:                        + lanName
198:                        + ". "
199:                        + controller.getSettings().getLanguageDependentString(
200:                                "RightClickToAdd");
201:                treeComponents.insertTab(lanName, null, c, tip, treeComponents
202:                        .getComponentCount());
203:            }
204:
205:            public void removeTreeComponent(JComponent c) {
206:                treeComponents.remove(c);
207:            }
208:
209:            public void addToSpecialComponents(String name, JComponent c) {
210:                String lanName = controller.getSettings()
211:                        .getLanguageDependentString(name + "Label");
212:                JaWEManager.getInstance().getLoggingManager().debug(
213:                        "Added special component " + lanName);
214:                String tip = controller.getSettings()
215:                        .getLanguageDependentString("DoubleClickToMaximize")
216:                        + " "
217:                        + lanName
218:                        + ". "
219:                        + controller.getSettings().getLanguageDependentString(
220:                                "RightClickToAdd");
221:                specialComponents.insertTab(lanName, null, c, tip,
222:                        specialComponents.getComponentCount());
223:            }
224:
225:            public void removeSpecialComponent(JComponent c) {
226:                specialComponents.remove(c);
227:            }
228:
229:            public void addToOtherComponents(String name, JComponent c) {
230:                String lanName = controller.getSettings()
231:                        .getLanguageDependentString(name + "Label");
232:                JaWEManager.getInstance().getLoggingManager().debug(
233:                        "Added other component " + lanName);
234:                String tip = controller.getSettings()
235:                        .getLanguageDependentString("DoubleClickToMaximize")
236:                        + " "
237:                        + lanName
238:                        + ". "
239:                        + controller.getSettings().getLanguageDependentString(
240:                                "RightClickToAdd");
241:                otherComponents.insertTab(lanName, null, c, tip,
242:                        otherComponents.getComponentCount());
243:            }
244:
245:            public void removeOtherComponent(JComponent c) {
246:                otherComponents.remove(c);
247:            }
248:
249:            public void addUpperStatusComponent(String name, JComponent c) {
250:                String lanName = controller.getSettings()
251:                        .getLanguageDependentString(name + "Label");
252:                JaWEManager.getInstance().getLoggingManager().debug(
253:                        "Added upper status  component " + lanName);
254:                menubarAndToolbar.add(c, BorderLayout.SOUTH);
255:            }
256:
257:            public void removeUpperStatusComponent(JComponent c) {
258:                menubarAndToolbar.remove(c);
259:            }
260:
261:            public void addLowerStatusComponent(String name, JComponent c) {
262:                String lanName = controller.getSettings()
263:                        .getLanguageDependentString(name + "Label");
264:                JaWEManager.getInstance().getLoggingManager().debug(
265:                        "Added lower status  component " + lanName);
266:                workingArea.add(c, BorderLayout.SOUTH);
267:            }
268:
269:            public void removeLowerStatusComponent(JComponent c) {
270:                workingArea.remove(c);
271:            }
272:
273:            // ********************************** DIALOGS *********************************
274:            /* Show a file open dialog and return the filename. */
275:            public String openDialog(String message, String initialName) {
276:                return JaWEXMLUtil.dialog(this , message, 0, 0, initialName);
277:            }
278:
279:            /* Show a file save dialog and return the filename. */
280:            public String saveDialog(String message, int filteringMode,
281:                    String initialName) {
282:                return JaWEXMLUtil.dialog(this , message, 1, filteringMode,
283:                        initialName);
284:            }
285:
286:            /* Show a dialog with the given error message. */
287:            public void message(String message, int type) {
288:                JOptionPane.showMessageDialog(this , message, getAppTitle(),
289:                        type);
290:            }
291:
292:            // ********************************** END OF DIALOGS *****************************
293:
294:            /**
295:             * Creates AppCloser object.
296:             */
297:            protected WindowAdapter createAppCloser() {
298:                return new JaWEFrame.AppCloser();
299:            }
300:
301:            //************** APPCLOSER CLASS FOR CLOSING APPLICATION WINDOW ***************
302:            /**
303:             * To shutdown when run as an application.
304:             */
305:            public final class AppCloser extends WindowAdapter {
306:                public void windowClosing(WindowEvent e) {
307:                    JaWEManager.getInstance().getJaWEController().getSettings()
308:                            .getAction("Exit").getAction()
309:                            .actionPerformed(null);
310:                }
311:            }
312:
313:            public void arrangeFrame() {
314:                String splitString = controller.getControllerSettings()
315:                        .getFrameSettings();
316:                int divLoc1 = controller.getControllerSettings()
317:                        .getFirstSmallDividerLocation();
318:                int divLoc2 = controller.getControllerSettings()
319:                        .getSecondSmallDividerLocation();
320:                int divLoc3 = controller.getControllerSettings()
321:                        .getMainDividerLocation();
322:
323:                try {
324:                    String[] temp = Utils.tokenize(splitString, ";");
325:                    String bigSplitString = temp[0];
326:
327:                    if (temp.length == 1) {
328:                        String[] smallSplitData = Utils.tokenize(
329:                                bigSplitString, " ");
330:
331:                        // without split
332:                        if (smallSplitData.length == 1) {
333:                            bigSplit = new JSplitPane(
334:                                    JSplitPane.HORIZONTAL_SPLIT);
335:                            bigSplit
336:                                    .add(getFrameComponentByName(smallSplitData[0]));
337:                            // one split
338:                        } else {
339:                            int splitType = JSplitPane.HORIZONTAL_SPLIT;
340:                            JComponent firstC = getFrameComponentByName(smallSplitData[0]);
341:                            JComponent secondC = getFrameComponentByName(smallSplitData[2]);
342:                            if (smallSplitData[1].equals("H"))
343:                                splitType = JSplitPane.VERTICAL_SPLIT;
344:
345:                            bigSplit = new JSplitPane(splitType, firstC,
346:                                    secondC);
347:                            bigSplit.setDividerLocation(divLoc1);
348:                        }
349:                        // many splits
350:                    } else {
351:                        String smallSplit1String = temp[1];
352:                        String smallSplit2String = temp[2];
353:
354:                        String[] smallSplit1Data = Utils.tokenize(
355:                                smallSplit1String, " ");
356:                        int splitType = JSplitPane.HORIZONTAL_SPLIT;
357:                        JComponent firstC = getFrameComponentByName(smallSplit1Data[0]);
358:                        JComponent secondC = null;
359:                        if (smallSplit1Data.length != 1) {
360:                            if (smallSplit1Data[1].equals("H"))
361:                                splitType = JSplitPane.VERTICAL_SPLIT;
362:                            secondC = getFrameComponentByName(smallSplit1Data[2]);
363:                        }
364:
365:                        smallSplit1 = new JSplitPane(splitType);
366:                        smallSplit1.add(firstC);
367:                        if (smallSplit1Data.length != 1) {
368:                            smallSplit1.add(secondC);
369:                            smallSplit1.setDividerLocation(divLoc1);
370:                        }
371:
372:                        String[] smallSplit2Data = Utils.tokenize(
373:                                smallSplit2String, " ");
374:                        splitType = JSplitPane.HORIZONTAL_SPLIT;
375:                        firstC = getFrameComponentByName(smallSplit2Data[0]);
376:                        secondC = null;
377:                        if (smallSplit2Data.length != 1) {
378:                            if (smallSplit2Data[1].equals("H"))
379:                                splitType = JSplitPane.VERTICAL_SPLIT;
380:                            secondC = getFrameComponentByName(smallSplit2Data[2]);
381:                        }
382:
383:                        smallSplit2 = new JSplitPane(splitType);
384:                        smallSplit2.add(firstC);
385:                        if (smallSplit2Data.length != 1) {
386:                            smallSplit2.add(secondC);
387:                            smallSplit2.setDividerLocation(divLoc2);
388:                        }
389:
390:                        splitType = JSplitPane.HORIZONTAL_SPLIT;
391:                        if (bigSplitString.equals("H"))
392:                            splitType = JSplitPane.VERTICAL_SPLIT;
393:
394:                        bigSplit = new JSplitPane(splitType, smallSplit1,
395:                                smallSplit2);
396:                        bigSplit.setDividerLocation(divLoc3);
397:                    }
398:                } catch (Exception e) {
399:                    JaWEManager
400:                            .getInstance()
401:                            .getLoggingManager()
402:                            .error(
403:                                    "JaWEFrame -> Can't customize frame! Using default!");
404:
405:                    smallSplit1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
406:                            specialComponents, treeComponents);
407:                    smallSplit1.setDividerLocation(180);
408:
409:                    smallSplit2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
410:                            mainComponents, otherComponents);
411:                    smallSplit2.setDividerLocation(400);
412:
413:                    bigSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
414:                            smallSplit1, smallSplit2);
415:                    bigSplit.setDividerLocation(180);
416:                }
417:            }
418:
419:            public void rearrangeFrame() {
420:                int mcc = mainComponents.getComponentCount();
421:                if (mcc == 0) {
422:                    mainComponents.getParent().remove(mainComponents);
423:                }
424:                int tcc = treeComponents.getComponentCount();
425:                if (tcc == 0) {
426:                    treeComponents.getParent().remove(treeComponents);
427:                }
428:                int scc = specialComponents.getComponentCount();
429:                if (scc == 0) {
430:                    specialComponents.getParent().remove(specialComponents);
431:                }
432:                int occ = otherComponents.getComponentCount();
433:                if (occ == 0) {
434:                    otherComponents.getParent().remove(otherComponents);
435:                }
436:            }
437:
438:            private JComponent getFrameComponentByName(String name) {
439:                if (name.equals("main"))
440:                    return mainComponents;
441:                else if (name.equals("tree"))
442:                    return treeComponents;
443:                else if (name.equals("special"))
444:                    return specialComponents;
445:                else if (name.equals("other"))
446:                    return otherComponents;
447:
448:                return null;
449:            }
450:
451:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.