Source Code Cross Referenced for ResourceView.java in  » Project-Management » OpenProj » com » projity » pm » graphic » views » 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 » OpenProj » com.projity.pm.graphic.views 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        The contents of this file are subject to the Common Public Attribution License 
003:        Version 1.0 (the "License"); you may not use this file except in compliance with 
004:        the License. You may obtain a copy of the License at 
005:        http://www.projity.com/license . The License is based on the Mozilla Public 
006:        License Version 1.1 but Sections 14 and 15 have been added to cover use of 
007:        software over a computer network and provide for limited attribution for the 
008:        Original Developer. In addition, Exhibit A has been modified to be consistent 
009:        with Exhibit B.
010:
011:        Software distributed under the License is distributed on an "AS IS" basis, 
012:        WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
013:        specific language governing rights and limitations under the License. The 
014:        Original Code is OpenProj. The Original Developer is the Initial Developer and 
015:        is Projity, Inc. All portions of the code written by Projity are Copyright (c) 
016:        2006, 2007. All Rights Reserved. Contributors Projity, Inc.
017:
018:        Alternatively, the contents of this file may be used under the terms of the 
019:        Projity End-User License Agreeement (the Projity License), in which case the 
020:        provisions of the Projity License are applicable instead of those above. If you 
021:        wish to allow use of your version of this file only under the terms of the 
022:        Projity License and not to allow others to use your version of this file under 
023:        the CPAL, indicate your decision by deleting the provisions above and replace 
024:        them with the notice and other provisions required by the Projity  License. If 
025:        you do not delete the provisions above, a recipient may use your version of this 
026:        file under either the CPAL or the Projity License.
027:
028:        [NOTE: The text of this license may differ slightly from the text of the notices 
029:        in Exhibits A and B of the license at http://www.projity.com/license. You should 
030:        use the latest text at http://www.projity.com/license for your modifications.
031:        You may not remove this license text from the source files.]
032:
033:        Attribution Information: Attribution Copyright Notice: Copyright � 2006, 2007 
034:        Projity, Inc. Attribution Phrase (not exceeding 10 words): Powered by OpenProj, 
035:        an open source solution from Projity. Attribution URL: http://www.projity.com 
036:        Graphic Image as provided in the Covered Code as file:  openproj_logo.png with 
037:        alternatives listed on http://www.projity.com/logo
038:
039:        Display of Attribution Information is required in Larger Works which are defined 
040:        in the CPAL as a work which combines Covered Code or portions thereof with code 
041:        not governed by the terms of the CPAL. However, in addition to the other notice 
042:        obligations, all copies of the Covered Code in Executable and Source Code form 
043:        distributed must, as a form of attribution of the original author, include on 
044:        each user interface screen the "OpenProj" logo visible to all users.  The 
045:        OpenProj logo should be located horizontally aligned with the menu bar and left 
046:        justified on the top left of the screen adjacent to the File menu.  The logo 
047:        must be at least 100 x 25 pixels.  When users click on the "OpenProj" logo it 
048:        must direct them back to http://www.projity.com.  
049:         */
050:        package com.projity.pm.graphic.views;
051:
052:        import java.awt.Component;
053:        import java.util.Enumeration;
054:        import java.util.Iterator;
055:        import java.util.List;
056:
057:        import javax.swing.JScrollPane;
058:        import javax.swing.JViewport;
059:        import javax.swing.table.TableCellRenderer;
060:
061:        import com.projity.configuration.Dictionary;
062:        import com.projity.document.Document;
063:        import com.projity.field.FieldContext;
064:        import com.projity.graphic.configuration.CellStyle;
065:        import com.projity.graphic.configuration.SpreadSheetFieldArray;
066:        import com.projity.grouping.core.Node;
067:        import com.projity.grouping.core.model.NodeModel;
068:        import com.projity.help.HelpUtil;
069:        import com.projity.menu.MenuActionConstants;
070:        import com.projity.pm.graphic.model.cache.NodeModelCache;
071:        import com.projity.pm.graphic.model.cache.NodeModelCacheFactory;
072:        import com.projity.pm.graphic.model.cache.ReferenceNodeModelCache;
073:        import com.projity.pm.graphic.spreadsheet.SpreadSheet;
074:        import com.projity.pm.graphic.spreadsheet.SpreadSheetModel;
075:        import com.projity.pm.resource.Resource;
076:        import com.projity.pm.resource.ResourcePool;
077:        import com.projity.strings.Messages;
078:        import com.projity.undo.UndoController;
079:        import com.projity.util.Alert;
080:        import com.projity.workspace.WorkspaceSetting;
081:
082:        /**
083:         * Resource view with spreadsheet
084:         */
085:        public class ResourceView extends JScrollPane implements  BaseView {
086:            /**
087:             * 
088:             */
089:            private static final long serialVersionUID = 591334548533168582L;
090:            public static final String spreadsheetCategory = resourceSpreadsheetCategory;
091:            protected SpreadSheet spreadSheet;
092:            protected NodeModel model;
093:            protected NodeModelCache cache;
094:            Document document;
095:            FieldContext fieldContext;
096:            CellStyle cellStyle;
097:
098:            /**
099:             * 
100:             */
101:            public ResourceView(ReferenceNodeModelCache cache, NodeModel model,
102:                    Document document) {
103:                super ();
104:                HelpUtil.addDocHelp(this , "Resource_View");
105:                this .model = model;
106:                this .document = document;
107:                this .cache = NodeModelCacheFactory.getInstance()
108:                        .createFilteredCache((ReferenceNodeModelCache) cache,
109:                                getViewName(), null);
110:                fieldContext = new FieldContext();
111:                fieldContext.setLeftAssociation(false);
112:                /*cellStyle=new CellStyle(){
113:                	CellFormat cellProperties=new CellFormat();
114:                	public CellFormat getCellProperties(GraphicNode node){
115:                		cellProperties.setBold(node.isSummary());
116:                		cellProperties.setItalic(node.isAssignment());
117:                		//cellProperties.setBackground((node.isAssignment())?"NORMAL_LIGHT_YELLOW":"NORMAL_YELLOW");
118:                		cellProperties.setCompositeIcon(node.isComposite());
119:                		return cellProperties;
120:                	}
121:                	
122:                };*/
123:                createSpreadsheet();
124:                JViewport viewport = createViewport();
125:                viewport.setView(spreadSheet);
126:                setViewport(viewport);
127:
128:                cache.update(); //this is not required by certain views 
129:            }
130:
131:            public void cleanUp() {
132:                spreadSheet.cleanUp();
133:                spreadSheet = null;
134:                model = null;
135:                cache = null;
136:                document = null;
137:                fieldContext = null;
138:                cellStyle = null;
139:            }
140:
141:            public void createSpreadsheet() {
142:                spreadSheet = new SpreadSheet() {
143:
144:                    private Object getEntryInRow(int row) {
145:                        Node node = ((SpreadSheetModel) getModel())
146:                                .getNode(row).getNode();
147:                        if (node != null && !node.isVirtual())
148:                            return node.getImpl();
149:                        else
150:                            return null;
151:                    }
152:
153:                    public Component prepareRenderer(
154:                            TableCellRenderer renderer, int row, int column) {
155:                        Component component = super .prepareRenderer(renderer,
156:                                row, column);
157:                        //    			Object r = getEntryInRow(row);
158:                        //    			if (r instanceof ResourceImpl) {
159:                        //    				if (((ResourceImpl)r).isUser()) // make user resources have a special color
160:                        //    					component.setBackground(Colors.PALE_GREEN);
161:                        //    			}
162:                        //Done in cellstyle
163:                        return component;
164:                    }
165:
166:                    public boolean isNodeDeletable(Node node) {
167:                        if (node != null && node.getImpl() instanceof  Resource) {
168:                            Resource r = (Resource) node.getImpl();
169:                            if (r.isUser()) {
170:                                Alert
171:                                        .warn(Messages
172:                                                .getString("ResourceView.YouCannotDeleteTheResource") + r.getName() + Messages.getString("ResourceView.UsersCanOnlyBeRemoved")); //$NON-NLS-1$ //$NON-NLS-2$
173:                                return false;
174:                            }
175:                            if (r.isAssignedToSomeProject()) {
176:                                Alert
177:                                        .warn(Messages
178:                                                .getString("ResourceView.YouCannotDeleteTheResource") + r.getName() + Messages.getString("ResourceView.ThisResourceCurrentlyHasAssignments")); //$NON-NLS-1$ //$NON-NLS-2$
179:                                return false;
180:                            }
181:                            List children = node.getChildren();
182:                            if (children != null)
183:                                for (Iterator i = children.listIterator(); i
184:                                        .hasNext();) {
185:                                    Node child = (Node) i.next();
186:                                    if (!isNodeDeletable(child))
187:                                        return false;
188:                                }
189:                        }
190:                        return true;
191:                    }
192:
193:                    public boolean isNodeCuttable(Node node) {
194:                        if (node != null && node.getImpl() instanceof  Resource) {
195:                            Resource r = (Resource) node.getImpl();
196:                            if (r.isUser()) {
197:                                Alert
198:                                        .warn(Messages
199:                                                .getString("ResourceView.YouCannotDeleteTheResource") + r.getName() + Messages.getString("ResourceView.UsersCanOnlyBeRemoved") + "\n" + Messages.getString("ResourceView.ToMoveAProtectedResource")); //$NON-NLS-1$ //$NON-NLS-2$
200:                                return false;
201:                            }
202:                            if (r.isAssignedToSomeProject()) {
203:                                Alert
204:                                        .warn(Messages
205:                                                .getString("ResourceView.YouCannotDeleteTheResource") + r.getName() + Messages.getString("ResourceView.ThisResourceCurrentlyHasAssignments") + "\n" + Messages.getString("ResourceView.ToMoveAProtectedResource")); //$NON-NLS-1$ //$NON-NLS-2$
206:                                return false;
207:                            }
208:                            List children = node.getChildren();
209:                            if (children != null)
210:                                for (Iterator i = children.listIterator(); i
211:                                        .hasNext();) {
212:                                    Node child = (Node) i.next();
213:                                    if (!isNodeDeletable(child))
214:                                        return false;
215:                                }
216:                        }
217:                        return true;
218:                    }
219:
220:                };
221:                spreadSheet.setSpreadSheetCategory(spreadsheetCategory); // for columns - must do first
222:
223:                SpreadSheetFieldArray fields = getFields();
224:                if (((ResourcePool) document).isMaster()) {
225:                    fields = (SpreadSheetFieldArray) fields.clone();
226:                    fields.removeField("Field.userRole"); //$NON-NLS-1$
227:                }
228:                spreadSheet.setCache(cache, fields, fields.getCellStyle(),
229:                        fields.getActionList());
230:                ((SpreadSheetModel) spreadSheet.getModel())
231:                        .setFieldContext(fieldContext);
232:            }
233:
234:            //spreadsheet fields
235:            private static SpreadSheetFieldArray getFields() {
236:                return (SpreadSheetFieldArray) Dictionary
237:                        .get(
238:                                spreadsheetCategory,
239:                                Messages
240:                                        .getString("Spreadsheet.Resource.entryWorkResources")); //TODO don't hardcode //$NON-NLS-1$
241:            }
242:
243:            /**
244:             * @return Returns the spreadSheet.
245:             */
246:            public SpreadSheet getSpreadSheet() {
247:                return spreadSheet;
248:            }
249:
250:            public UndoController getUndoController() {
251:                return ((ResourcePool) document).getUndoController();
252:            }
253:
254:            public void zoomIn() {
255:            }
256:
257:            public void zoomOut() {
258:            }
259:
260:            public boolean canZoomIn() {
261:                return false;
262:            }
263:
264:            public boolean canZoomOut() {
265:                return false;
266:            }
267:
268:            public int getScale() {
269:                return -1;
270:            }
271:
272:            public boolean hasNormalMinWidth() {
273:                return true;
274:            }
275:
276:            public String getViewName() {
277:                return MenuActionConstants.ACTION_RESOURCES;
278:            }
279:
280:            public boolean showsTasks() {
281:                return false;
282:            }
283:
284:            public boolean showsResources() {
285:                return true;
286:            }
287:
288:            public void onActivate(boolean activate) {
289:            }
290:
291:            public boolean isPrintable() {
292:                return true;
293:            }
294:
295:            public void restoreWorkspace(WorkspaceSetting w, int context) {
296:                Workspace ws = (Workspace) w;
297:                spreadSheet.restoreWorkspace(ws.spreadSheet, context);
298:            }
299:
300:            public WorkspaceSetting createWorkspace(int context) {
301:                Workspace ws = new Workspace();
302:                ws.spreadSheet = spreadSheet.createWorkspace(context);
303:                return ws;
304:            }
305:
306:            public static class Workspace implements  WorkspaceSetting {
307:                private static final long serialVersionUID = -1251204386431239291L;
308:                WorkspaceSetting spreadSheet;
309:
310:                public WorkspaceSetting getSpreadSheet() {
311:                    return spreadSheet;
312:                }
313:
314:                public void setSpreadSheet(WorkspaceSetting spreadSheet) {
315:                    this .spreadSheet = spreadSheet;
316:                }
317:            }
318:
319:            public boolean canScrollToTask() {
320:                // TODO Auto-generated method stub
321:                return false;
322:            }
323:
324:            public void scrollToTask() {
325:                // TODO Auto-generated method stub
326:
327:            }
328:
329:            public NodeModelCache getCache() {
330:                return cache;
331:            }
332:
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.