Source Code Cross Referenced for MainFrame.java in  » Project-Management » lgantt » com » csa » lgantt » view » 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 » Project Management » lgantt » com.csa.lgantt.view 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *   Copyright 2004 Carlos Silva A.
003:         * 
004:         *   Licensed under the Apache License, Version 2.0 (the "License");
005:         *   you may not use this file except in compliance with the License. 
006:         *   You may obtain a copy of the License at  
007:         * 
008:         *   http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         *   Unless required by applicable law or agreed to in writing, software
011:         *   distributed under the License is distributed on an "AS IS" BASIS,
012:         *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *   See the License for the specific language governing permissions and
014:         *   limitations under the License.
015:         * 
016:         */package com.csa.lgantt.view;
017:
018:        import java.awt.BorderLayout;
019:        import java.awt.Dimension;
020:        import java.io.File;
021:        import java.util.Hashtable;
022:        import java.util.Iterator;
023:        import java.util.List;
024:
025:        import javax.swing.JFrame;
026:        import javax.swing.JMenu;
027:        import javax.swing.JMenuBar;
028:        import javax.swing.JMenuItem;
029:        import javax.swing.KeyStroke;
030:
031:        import com.csa.lgantt.LGanttMain;
032:        import com.csa.lgantt.MenuBuilder;
033:        import com.csa.lgantt.Messages;
034:        import com.csa.lgantt.model.IOManager;
035:        import com.csa.lgantt.model.Project;
036:        import com.csa.lgantt.model.ProjectChange;
037:        import com.csa.lgantt.model.ProjectListener;
038:        import com.csa.lgantt.view.adapters.ProjectViewModel;
039:        import com.csa.lgantt.view.adapters.ProjectViewModelChange;
040:        import com.csa.lgantt.view.adapters.ProjectViewModelListener;
041:
042:        /**
043:         * MainFrame, ventana principal
044:         * <p>
045:         * $Date: 2006/09/14 08:14:17 $
046:         * </p>
047:         * 
048:         * @version $Revision: 1.1 $
049:         * @author Carlos Silva
050:         */
051:        public class MainFrame extends JFrame implements  ProjectListener,
052:                ProjectViewModelListener {
053:
054:            private static final long serialVersionUID = 1L;
055:
056:            String WND_TITLE = Messages.getString("MainFrame.title");
057:
058:            // / Main display
059:            GanttDisplay ganttDisplay;
060:
061:            // / ViewModel
062:            ProjectViewModel pvModel = null;
063:
064:            /**
065:             * Acceso a los menues segun su nombre. Relaciona el string del commando con
066:             * el JMenuItem
067:             */
068:            protected Hashtable menues = new Hashtable();
069:
070:            /**
071:             * Crea una ventana para editar un proyecto nuevo
072:             */
073:            public MainFrame() {
074:                this (IOManager.createEmptyProject(), null);
075:            }
076:
077:            /**
078:             * Crea una ventana para editar un proyecto existente almacenado en un
079:             * archivo. Crear el display y asigna los listener.
080:             */
081:            public MainFrame(Project project, File file) {
082:                super ("");
083:                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
084:
085:                pvModel = new ProjectViewModel(project, file);
086:                ganttDisplay = new GanttDisplay(pvModel);
087:
088:                GanttActionListener mainListener = pvModel
089:                        .getMainActionListener();
090:
091:                mainListener.setup(this , ganttDisplay);
092:
093:                getContentPane().add(ganttDisplay, BorderLayout.CENTER);
094:
095:                JMenuBar menuBar = MenuBuilder.buildMenuBar(mainListener,
096:                        "menubar", menues);
097:                setJMenuBar(menuBar);
098:
099:                JMenu menu = (JMenu) menuBar.getComponent(0);
100:                menu.addSeparator();
101:                List list = LGanttMain.getLastUsed();
102:                for (int i = 0; i < list.size(); i++) {
103:                    File fn = (File) list.get(i);
104:                    String id = String.valueOf(i + 1);
105:                    JMenuItem mi = new JMenuItem(id);
106:                    mi.setActionCommand("lru." + id);
107:                    mi.setText(fn.getAbsolutePath());
108:                    mi.setMnemonic(fn.getAbsolutePath().charAt(0));
109:                    mi.addActionListener(mainListener);
110:                    menu.add(mi);
111:                    menues.put(id, mi);
112:                }
113:
114:                updateUndoRedo();
115:
116:                pvModel.addListener(this );
117:                project.addListener(this );
118:
119:                setSize(new Dimension(850, 500));
120:            }
121:
122:            /**
123:             * Obtiene una referencia al menu que representa un comando
124:             * 
125:             * @param cmd
126:             * @return
127:             */
128:            public JMenuItem getMenuItemForCommand(String cmd) {
129:                return (JMenuItem) menues.get(cmd);
130:            }
131:
132:            /**
133:             * Cuando hay un nuevo proyecto cargado... se debe reasignar el listener
134:             * 
135:             * @see com.csa.lgantt.view.adapters.ProjectViewModelListener#viewModelChanged(com.csa.lgantt.view.adapters.ProjectViewModelChange)
136:             */
137:            public void viewModelChanged(ProjectViewModelChange c) {
138:                if (c.getId() == ProjectViewModelChange.NEW_PROJECT_LOADED)
139:                    c.getProjectViewModel().getProject().addListener(this );
140:            }
141:
142:            /**
143:             * Cuando cambia el proyecto se debe habilitar/deshabilitar undo y redo
144:             * 
145:             * @see com.csa.lgantt.model.ProjectListener#projectChanged(com.csa.lgantt.model.ProjectChange)
146:             */
147:            public void projectChanged(ProjectChange c) {
148:                updateUndoRedo();
149:            }
150:
151:            /**
152:             * Habilita o deshabilita los menues de undo y redo
153:             */
154:            void updateUndoRedo() {
155:                Project project = pvModel.getProject();
156:
157:                JMenuItem undoItem = getMenuItemForCommand(GanttActionListener.CMD_EDIT_UNDO);
158:                undoItem.setEnabled(!project.isUndoEmpty());
159:
160:                updWindowTitle();
161:
162:                JMenuItem redoItem = getMenuItemForCommand(GanttActionListener.CMD_EDIT_REDO);
163:                redoItem.setEnabled(!project.isRedoEmpty());
164:            }
165:
166:            /**
167:             * Cambia el titulo de la ventana
168:             */
169:            public void updWindowTitle() {
170:                String fn;
171:                if (pvModel.getFile() != null)
172:                    fn = pvModel.getFile().getName();
173:                else
174:                    fn = "(not saved)";
175:
176:                String t = pvModel.getProject().getName() + " - " + fn + " - "
177:                        + WND_TITLE;
178:
179:                if (!pvModel.getProject().isUndoEmpty())
180:                    t = t + " * ";
181:
182:                if (!t.equals(getTitle()))
183:                    setTitle(t);
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.