Source Code Cross Referenced for GanttDisplay.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.awt.Image;
021:        import java.awt.Insets;
022:        import java.awt.MediaTracker;
023:        import java.awt.Toolkit;
024:        import java.awt.event.ItemEvent;
025:        import java.awt.event.ItemListener;
026:        import java.net.URL;
027:        import java.util.Iterator;
028:
029:        import javax.swing.Box;
030:        import javax.swing.BoxLayout;
031:        import javax.swing.ImageIcon;
032:        import javax.swing.JButton;
033:        import javax.swing.JComboBox;
034:        import javax.swing.JComponent;
035:        import javax.swing.JPanel;
036:        import javax.swing.JSplitPane;
037:
038:        import com.csa.lgantt.Messages;
039:        import com.csa.lgantt.model.Project;
040:        import com.csa.lgantt.model.ProjectChange;
041:        import com.csa.lgantt.model.ProjectListener;
042:        import com.csa.lgantt.view.adapters.ProjectViewModel;
043:        import com.csa.lgantt.view.adapters.ProjectViewModelChange;
044:        import com.csa.lgantt.view.adapters.ProjectViewModelListener;
045:        import com.csa.lgantt.view.gantt.GanttGraph;
046:        import com.csa.lgantt.view.tree.TaskTree;
047:
048:        public class GanttDisplay extends JPanel implements  ProjectListener,
049:                ProjectViewModelListener {
050:            private static final long serialVersionUID = 3257283630241165369L;
051:            TaskTree tasksTree;
052:            GanttGraph ganttGraph;
053:            JComboBox snapShotList;
054:            public ProjectViewModel pvModel;
055:            public Project project;
056:            JSplitPane splitPane;
057:
058:            public boolean isFocusTraversable() {
059:                return false;
060:            }
061:
062:            /**
063:             * Constructor for GanttDisplay
064:             */
065:
066:            public GanttDisplay(ProjectViewModel projectViewModel) {
067:                super ();
068:                pvModel = projectViewModel;
069:                pvModel.addListener(this );
070:
071:                setLayout(new BorderLayout());
072:
073:                tasksTree = new TaskTree(pvModel);
074:                ganttGraph = new GanttGraph(pvModel);
075:
076:                splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
077:                        tasksTree, ganttGraph);
078:                //splitPane.setDividerSize(12);
079:                splitPane.setOneTouchExpandable(true);
080:                splitPane
081:                        .setDividerLocation(tasksTree.getPreferredSize().width);
082:
083:                add(splitPane, BorderLayout.CENTER);
084:
085:                JPanel buttonPane = new JPanel();
086:                buttonPane
087:                        .setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
088:
089:                buttonPane.add(createButton(null, GanttActionListener.CMD_NEW,
090:                        Messages.getString("GanttDisplay.newproject.hint"),
091:                        Messages.getString("GanttDisplay.newproject.img")));
092:                buttonPane.add(createButton(null, GanttActionListener.CMD_OPEN,
093:                        Messages.getString("GanttDisplay.open.hint"), Messages
094:                                .getString("GanttDisplay.open.img")));
095:
096:                buttonPane.add(Box.createRigidArea(new Dimension(10, 10)));
097:                buttonPane.add(createButton(null, GanttActionListener.CMD_SAVE,
098:                        Messages.getString("GanttDisplay.save.hint"), Messages
099:                                .getString("GanttDisplay.save.img")));
100:                buttonPane.add(createButton(null,
101:                        GanttActionListener.CMD_SAVE_AS, Messages
102:                                .getString("GanttDisplay.saveas.hint"),
103:                        Messages.getString("GanttDisplay.saveas.img")));
104:
105:                buttonPane.add(Box.createRigidArea(new Dimension(10, 10)));
106:                buttonPane.add(createButton(null,
107:                        GanttActionListener.CMD_INSERT_TASK, Messages
108:                                .getString("GanttDisplay.insert.hint"),
109:                        Messages.getString("GanttDisplay.insert.img")));
110:                buttonPane.add(createButton(null,
111:                        GanttActionListener.CMD_APPEND_TASK, Messages
112:                                .getString("GanttDisplay.append.hint"),
113:                        Messages.getString("GanttDisplay.append.img")));
114:                buttonPane.add(createButton(null,
115:                        GanttActionListener.CMD_DELETE_TASK, Messages
116:                                .getString("GanttDisplay.delete.hint"),
117:                        Messages.getString("GanttDisplay.delete.img")));
118:
119:                buttonPane.add(Box.createRigidArea(new Dimension(10, 10)));
120:                buttonPane.add(createButton(null, "indentl", Messages
121:                        .getString("GanttDisplay.indentLeft.hint"), Messages
122:                        .getString("GanttDisplay.indentLeft.img")));
123:                buttonPane.add(createButton(null, "indentr", Messages
124:                        .getString("GanttDisplay.indentRight.hint"), Messages
125:                        .getString("GanttDisplay.indentRight.img")));
126:
127:                buttonPane.add(Box.createRigidArea(new Dimension(5, 5)));
128:                buttonPane.add(createButton(null, "movedn", Messages
129:                        .getString("GanttDisplay.moveDown.hint"), Messages
130:                        .getString("GanttDisplay.moveDown.img")));
131:                buttonPane.add(createButton(null, "moveup", Messages
132:                        .getString("GanttDisplay.moveUp.hint"), Messages
133:                        .getString("GanttDisplay.moveUp.img")));
134:
135:                buttonPane.add(Box.createRigidArea(new Dimension(5, 5)));
136:                buttonPane.add(createButton(null,
137:                        GanttActionListener.CMD_EDIT_ASIGNATIONS, Messages
138:                                .getString("GanttDisplay.asignments.hint"),
139:                        Messages.getString("GanttDisplay.asignments.img")));
140:
141:                snapShotList = new JComboBox();
142:                snapShotList.addItemListener(new SnapItemListener());
143:
144:                buttonPane.add(snapShotList);
145:
146:                add(buttonPane, BorderLayout.NORTH);
147:
148:                assignViewModel(pvModel);
149:            }
150:
151:            /**
152:             * Genera un boton para ser anexado al panel
153:             * @param label
154:             * @param action
155:             * @param tooltip
156:             * @param imgFn
157:             * @return
158:             */
159:            public JButton createButton(String label, String action,
160:                    String tooltip, String imgFn) {
161:                try {
162:                    URL res = getClass().getClassLoader().getResource(imgFn);
163:                    Image img = Toolkit.getDefaultToolkit().getImage(res);
164:                    MediaTracker m = new MediaTracker(this );
165:                    m.addImage(img, 0);
166:                    m.waitForAll();
167:                    ImageIcon icon = new ImageIcon(img);
168:                    JButton b = new JButton(label, icon);
169:                    b.setActionCommand(action);
170:                    b.setToolTipText(tooltip);
171:                    //b.setContentAreaFilled(false);
172:                    b.setMargin(new Insets(0, 0, 0, 0));
173:                    //			Dimension d = new Dimension(26,26);
174:                    //			b.setPreferredSize(d);
175:                    //			b.setSize(d);
176:                    //			b.setMinimumSize(d);
177:                    b.addActionListener(pvModel.getMainActionListener());
178:                    return b;
179:                } catch (Exception e) {
180:                    e.printStackTrace();
181:                    JButton b = new JButton(label);
182:                    b.setActionCommand(action);
183:                    b.setToolTipText(tooltip);
184:                    b.setContentAreaFilled(false);
185:                    b.setMargin(new Insets(0, 0, 0, 0));
186:                    b.addActionListener(pvModel.getMainActionListener());
187:                    return b;
188:                }
189:            }
190:
191:            /**
192:             * Carga una imagen desde el paquete de la clase
193:             * 
194:             * @param imgName
195:             * @return Image
196:             */
197:            Image loadImage(String imgName) {
198:                URL imgURL = getClass().getResource(imgName);
199:                Toolkit tk = Toolkit.getDefaultToolkit();
200:                Image img = null;
201:                try {
202:                    MediaTracker m = new MediaTracker(this );
203:                    img = tk.getImage(imgURL);
204:                    m.addImage(img, 0);
205:                    m.waitForAll();
206:                } catch (Exception e) {
207:                    e.printStackTrace();
208:                }
209:                return img;
210:            }
211:
212:            public JComponent getTaskTree() {
213:                return tasksTree;
214:            }
215:
216:            public ProjectViewModel getProjectViewModel() {
217:                return pvModel;
218:            }
219:
220:            public Object getSelectedObject() {
221:                return ganttGraph.getViewer().lastSelectedObject();
222:            }
223:
224:            /* (non-Javadoc)
225:             * @see jgantt.view.adapters.ProjectViewModelListener#viewModelChanged(jgantt.view.adapters.ProjectViewModelChange)
226:             */
227:            public void viewModelChanged(ProjectViewModelChange c) {
228:                if (c.getId() == ProjectViewModelChange.NEW_PROJECT_LOADED)
229:                    assignViewModel(c.getProjectViewModel());
230:            }
231:
232:            public void assignViewModel(ProjectViewModel pvm) {
233:                if (project != null)
234:                    project.removeListener(this );
235:                project = pvm.getProject();
236:                project.addListener(this );
237:                pvModel = pvm;
238:                loadSnapShots(pvm.getProject());
239:            }
240:
241:            public void loadSnapShots(Project p) {
242:                snapShotList.removeAllItems();
243:                snapShotList.addItem("Snapshot");
244:                for (Iterator i = p.getSnapshots().iterator(); i.hasNext();) {
245:                    Project.SnapShot ss = (Project.SnapShot) i.next();
246:                    snapShotList.addItem(ss);
247:                }
248:            }
249:
250:            class SnapItemListener implements  ItemListener {
251:                public void itemStateChanged(ItemEvent ev) {
252:                    if (ev.getStateChange() == ItemEvent.SELECTED) {
253:                        Object item = ev.getItem();
254:                        if (item instanceof  String)
255:                            pvModel.setCurrentSnapShot(null);
256:                        else {
257:                            Project.SnapShot ss = (Project.SnapShot) item;
258:                            pvModel.setCurrentSnapShot(ss.date);
259:                        }
260:                    }
261:                }
262:            }
263:
264:            public void projectChanged(ProjectChange change) {
265:                switch (change.getId()) {
266:                case ProjectChange.SNAPSHOT_ADDED:
267:                case ProjectChange.SNAPSHOT_REMOVED:
268:                    loadSnapShots(pvModel.getProject());
269:                    break;
270:                default:
271:                    ;
272:                }
273:            }
274:
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.