Source Code Cross Referenced for GUIWorkspace.java in  » Code-Analyzer » beautyJ » de » gulden » framework » amoda » environment » gui » 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 » Code Analyzer » beautyJ » de.gulden.framework.amoda.environment.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Project: AMODA - Abstract Modeled Application
003:         * Class:   de.gulden.framework.amoda.environment.gui.GUIWorkspace
004:         * Version: snapshot-beautyj-1.1
005:         *
006:         * Date:    2004-09-29
007:         *
008:         * This is a snapshot version of the AMODA 0.2 development branch,
009:         * it is not released as a seperate version.
010:         * For AMODA, see http://amoda.berlios.de/.
011:         *  
012:         * This is licensed under the GNU Lesser General Public License (LGPL)
013:         * and comes with NO WARRANTY.
014:         *
015:         * Author:  Jens Gulden
016:         * Email:   amoda@jensgulden.de
017:         */
018:
019:        package de.gulden.framework.amoda.environment.gui;
020:
021:        import de.gulden.framework.amoda.environment.commandline.*;
022:        import de.gulden.framework.amoda.generic.core.GenericWorkspaceAbstract;
023:        import de.gulden.framework.amoda.model.document.*;
024:        import java.awt.*;
025:        import java.awt.event.*;
026:        import java.awt.event.ItemListener;
027:        import java.util.*;
028:        import java.util.List;
029:        import javax.swing.*;
030:        import javax.swing.event.*;
031:        import javax.swing.event.InternalFrameListener;
032:
033:        /**
034:         * Class GUIWorkspace.
035:         *  
036:         * @author  Jens Gulden
037:         * @version  snapshot-beautyj-1.1
038:         */
039:        public class GUIWorkspace extends GenericWorkspaceAbstract implements 
040:                ItemListener, InternalFrameListener {
041:
042:            // ------------------------------------------------------------------------
043:            // --- fields                                                           ---
044:            // ------------------------------------------------------------------------
045:
046:            protected Hashtable viewsByFrames = new Hashtable();
047:
048:            protected Hashtable framesByViews = new Hashtable();
049:
050:            protected List recentActiveViews = new ArrayList();
051:
052:            protected ButtonGroup menuButtonGroup = new ButtonGroup();
053:
054:            protected Hashtable viewsByMenus = new Hashtable();
055:
056:            protected Hashtable menusByViews = new Hashtable();
057:
058:            protected Point newFrameLocation = new Point(30, 30);
059:
060:            protected Hashtable titleNrsCollectionsByDocuments = new Hashtable();
061:
062:            protected Hashtable titleNrsByFrames = new Hashtable();
063:
064:            // ------------------------------------------------------------------------
065:            // --- methods                                                          ---
066:            // ------------------------------------------------------------------------
067:
068:            public DocumentView getActiveView() {
069:                JInternalFrame frame = getDesktopPane().getSelectedFrame();
070:                if (frame != null) {
071:                    return (DocumentView) viewsByFrames.get(frame);
072:                } else {
073:                    return null;
074:                }
075:            }
076:
077:            public void setActiveView(DocumentView view) {
078:                if (view != null) {
079:                    // may not actually set the view active, see PropertyVetoException below
080:                    JInternalFrame frame = (JInternalFrame) framesByViews
081:                            .get(view);
082:                    JRadioButtonMenuItem menu = (JRadioButtonMenuItem) menusByViews
083:                            .get(view);
084:                    try {
085:                        frame.setSelected(true);
086:                        recentActiveViews.remove(view);
087:                        recentActiveViews.add(0, view);
088:                        menu.setSelected(true);
089:                    } catch (java.beans.PropertyVetoException pve) {
090:                        //nop
091:                    }
092:                }
093:            }
094:
095:            public void addView(DocumentView view) {
096:                super .addView(view);
097:                GUIApplicationEnvironment environment = ((GUIApplicationEnvironment) getEnvironment());
098:                Collection titleNrs = (Collection) titleNrsCollectionsByDocuments
099:                        .get(view.getDocument());
100:                if (titleNrs == null) { // first view of this document
101:                    titleNrs = new ArrayList();
102:                    titleNrsCollectionsByDocuments.put(view.getDocument(),
103:                            titleNrs);
104:                }
105:                int titleNr = 0;
106:                Integer titleNrInteger;
107:                do {
108:                    titleNrInteger = new Integer(++titleNr);
109:                } while (titleNrs.contains(titleNrInteger));
110:                titleNrs.add(titleNrInteger);
111:                String title = view.getDocument().getTitle() + " [" + titleNr
112:                        + "]";
113:                JInternalFrame frame = new JInternalFrame(title, true, true,
114:                        true, true);
115:                titleNrsByFrames.put(frame, titleNrInteger);
116:                frame
117:                        .setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE);
118:                frame.addInternalFrameListener(this );
119:                JComponent component = view.createGUIEditor();
120:                frame.getContentPane().add(component);
121:                viewsByFrames.put(frame, view);
122:                framesByViews.put(view, frame);
123:                frame.pack();
124:                frame.setLocation(newFrameLocation);
125:                newFrameLocation.x += 30;
126:                newFrameLocation.y += 30;
127:                if (newFrameLocation.x > 150) {
128:                    newFrameLocation.x = 30;
129:                    newFrameLocation.y = 30;
130:                }
131:                getDesktopPane().add(frame);
132:                JRadioButtonMenuItem menu = new JRadioButtonMenuItem(title);
133:                menu.setFont(environment
134:                        .getFont(GUIApplicationEnvironment.FONT_MENU));
135:                menuButtonGroup.add(menu);
136:                menu.addItemListener(this );
137:                viewsByMenus.put(menu, view);
138:                menusByViews.put(view, menu);
139:                if (menusByViews.size() == 1) {
140:                    environment.getWindowMenu().addSeparator();
141:                }
142:                environment.getWindowMenu().add(menu);
143:                frame.setVisible(true);
144:                setActiveView(view);
145:            }
146:
147:            public void removeView(DocumentView view) {
148:                super .removeView(view);
149:                JInternalFrame frame = (JInternalFrame) framesByViews.get(view);
150:                JRadioButtonMenuItem menu = (JRadioButtonMenuItem) menusByViews
151:                        .get(view);
152:                frame.dispose();
153:                getDesktopPane().remove(frame);
154:                viewsByFrames.remove(frame);
155:                framesByViews.remove(view);
156:                ((GUIApplicationEnvironment) getEnvironment()).getWindowMenu()
157:                        .remove(menu);
158:                viewsByMenus.remove(menu);
159:                menusByViews.remove(view);
160:                menuButtonGroup.remove(menu);
161:                Object titleNr = titleNrsByFrames.remove(frame);
162:                Collection titleNrs = (Collection) titleNrsCollectionsByDocuments
163:                        .get(view.getDocument());
164:                titleNrs.remove(titleNr);
165:                if (titleNrs.isEmpty()) {
166:                    titleNrsCollectionsByDocuments.remove(view.getDocument());
167:                }
168:
169:                recentActiveViews.remove(view);
170:                if (!recentActiveViews.isEmpty()) {
171:                    setActiveView((DocumentView) recentActiveViews.get(0));
172:                } else if (!viewsByFrames.isEmpty()) {
173:                    setActiveView((DocumentView) viewsByFrames.values()
174:                            .iterator().next());
175:                } else {
176:                    setActiveView(null);
177:                }
178:            }
179:
180:            public void internalFrameActivated(InternalFrameEvent e) {
181:                DocumentView view = (DocumentView) viewsByFrames.get(e
182:                        .getInternalFrame());
183:                setActiveView(view);
184:            }
185:
186:            public void internalFrameClosed(InternalFrameEvent e) {
187:                //nop
188:            }
189:
190:            public void internalFrameClosing(InternalFrameEvent e) {
191:                JInternalFrame frame = e.getInternalFrame();
192:                DocumentView view = (DocumentView) viewsByFrames.get(frame);
193:                removeView(view);
194:            }
195:
196:            public void internalFrameDeactivated(InternalFrameEvent e) {
197:                //nop
198:            }
199:
200:            public void internalFrameDeiconified(InternalFrameEvent e) {
201:                //nop
202:            }
203:
204:            public void internalFrameIconified(InternalFrameEvent e) {
205:                //nop
206:            }
207:
208:            public void internalFrameOpened(InternalFrameEvent e) {
209:                //nop
210:            }
211:
212:            public void itemStateChanged(ItemEvent e) {
213:                if (e.getStateChange() == ItemEvent.SELECTED) {
214:                    JRadioButtonMenuItem menu = (JRadioButtonMenuItem) e
215:                            .getItem();
216:                    DocumentView view = (DocumentView) viewsByMenus.get(menu);
217:                    setActiveView(view);
218:                }
219:            }
220:
221:            public JComponent getGUIEditor(DocumentView view) {
222:                JInternalFrame frame = (JInternalFrame) framesByViews.get(view);
223:                if (frame != null) {
224:                    return (JComponent) frame.getContentPane().getComponent(0);
225:                } else {
226:                    return null;
227:                }
228:            }
229:
230:            public void updateWindowTitles() {
231:                for (Iterator it = getAllViews().iterator(); it.hasNext();) {
232:                    de.gulden.framework.amoda.model.document.DocumentView view = (DocumentView) it
233:                            .next();
234:                    de.gulden.framework.amoda.model.document.Document document = view
235:                            .getDocument();
236:                    javax.swing.JInternalFrame frame = (javax.swing.JInternalFrame) framesByViews
237:                            .get(view);
238:                    Integer nr = (Integer) titleNrsByFrames.get(frame);
239:                    frame.setTitle(document.getTitle() + " [" + nr.toString()
240:                            + "]");
241:                }
242:            }
243:
244:            protected JDesktopPane getDesktopPane() {
245:                return ((de.gulden.framework.amoda.environment.gui.component.GUIFrame) (((GUIApplicationEnvironment) getEnvironment())
246:                        .getFrame())).getDesktopPane();
247:            }
248:
249:        } // end GUIWorkspace
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.