Source Code Cross Referenced for ProjectDialog.java in  » Project-Management » OpenProj » com » projity » dialog » 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.dialog 
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.dialog;
051:
052:        import java.awt.Frame;
053:        import java.awt.event.ActionEvent;
054:        import java.awt.event.ActionListener;
055:        import java.util.ArrayList;
056:        import java.util.Collection;
057:        import java.util.Date;
058:
059:        import javax.swing.JCheckBox;
060:        import javax.swing.JComboBox;
061:        import javax.swing.JComponent;
062:        import javax.swing.JLabel;
063:        import javax.swing.JScrollPane;
064:        import javax.swing.JTextField;
065:        import javax.swing.JTextPane;
066:
067:        import net.sf.nachocalendar.CalendarFactory;
068:        import net.sf.nachocalendar.components.DateField;
069:
070:        import com.jgoodies.forms.builder.DefaultFormBuilder;
071:        import com.jgoodies.forms.layout.CellConstraints;
072:        import com.jgoodies.forms.layout.FormLayout;
073:        import com.projity.configuration.Configuration;
074:        import com.projity.configuration.FieldDictionary;
075:        import com.projity.configuration.Settings;
076:        import com.projity.dialog.util.FieldComponentMap;
077:        import com.projity.field.HasExtraFields;
078:        import com.projity.field.HasExtraFieldsImpl;
079:        import com.projity.help.HelpUtil;
080:        import com.projity.options.CalendarOption;
081:        import com.projity.pm.resource.ResourcePool;
082:        import com.projity.pm.resource.ResourcePoolFactory;
083:        import com.projity.strings.Messages;
084:        import com.projity.util.Alert;
085:        import com.projity.util.DateTime;
086:        import com.projity.util.Environment;
087:
088:        public final class ProjectDialog extends FieldDialog { // extends FieldDialog for extra fields handling
089:            private static final long serialVersionUID = 1L;
090:
091:            public static class Form {
092:                String notes;
093:                String manager;
094:                String name;
095:                long startDate = CalendarOption.getInstance().makeValidStart(
096:                        System.currentTimeMillis(), true);
097:                ResourcePool resourcePool = null;
098:                boolean forward = true;
099:                boolean local = Environment.getStandAlone();
100:                int projectType;
101:                int projectStatus;
102:                int expenseType;
103:                String group;
104:                String division;
105:                HasExtraFields extra = new HasExtraFieldsImpl();
106:                int accessControlType;
107:
108:                /**
109:                 * @return Returns the manager.
110:                 */
111:                public String getManager() {
112:                    return manager;
113:                }
114:
115:                /**
116:                 * @param manager
117:                 *            The manager to set.
118:                 */
119:                public void setManager(String manager) {
120:                    this .manager = manager;
121:                }
122:
123:                /**
124:                 * @return Returns the name.
125:                 */
126:                public String getName() {
127:                    return name;
128:                }
129:
130:                /**
131:                 * @param name
132:                 *            The name to set.
133:                 */
134:                public void setName(String name) {
135:                    this .name = name;
136:                }
137:
138:                /**
139:                 * @return Returns the notes.
140:                 */
141:                public String getNotes() {
142:                    return notes;
143:                }
144:
145:                /**
146:                 * @param notes
147:                 *            The notes to set.
148:                 */
149:                public void setNotes(String notes) {
150:                    this .notes = notes;
151:                }
152:
153:                /**
154:                 * @return Returns the start.
155:                 */
156:                public long getStartDate() {
157:                    return startDate;
158:                }
159:
160:                /**
161:                 * @param start
162:                 *            The start to set.
163:                 */
164:                public void setStartDate(long startDate) {
165:                    this .startDate = startDate;
166:                }
167:
168:                /**
169:                 * @return Returns the resourcePool.
170:                 */
171:                public ResourcePool getResourcePool() {
172:                    return resourcePool;
173:                }
174:
175:                /**
176:                 * @param resourcePool The resourcePool to set.
177:                 */
178:                public void setResourcePool(ResourcePool resourcePool) {
179:                    this .resourcePool = resourcePool;
180:                }
181:
182:                /**
183:                 * @return Returns the forward.
184:                 */
185:                public final boolean isForward() {
186:                    return forward;
187:                }
188:
189:                /**
190:                 * @param forward The forward to set.
191:                 */
192:                public final void setForward(boolean forwardScheduled) {
193:                    this .forward = forwardScheduled;
194:                }
195:
196:                public boolean isLocal() {
197:                    return local;
198:                }
199:
200:                public void setLocal(boolean local) {
201:                    this .local = local;
202:                }
203:
204:                public final HasExtraFields getExtra() {
205:                    return extra;
206:                }
207:
208:                public int getExpenseType() {
209:                    return expenseType;
210:                }
211:
212:                public void setExpenseType(int expenseType) {
213:                    this .expenseType = expenseType;
214:                }
215:
216:                public int getProjectType() {
217:                    return projectType;
218:                }
219:
220:                public void setProjectType(int projectType) {
221:                    this .projectType = projectType;
222:                }
223:
224:                public String getDivision() {
225:                    return division;
226:                }
227:
228:                public void setDivision(String division) {
229:                    this .division = division;
230:                }
231:
232:                public String getGroup() {
233:                    return group;
234:                }
235:
236:                public void setGroup(String group) {
237:                    this .group = group;
238:                }
239:
240:                public int getProjectStatus() {
241:                    return projectStatus;
242:                }
243:
244:                public void setProjectStatus(int projectStatus) {
245:                    this .projectStatus = projectStatus;
246:                }
247:
248:                public int getAccessControlType() {
249:                    return accessControlType;
250:                }
251:
252:                public void setAccessControlType(int accessControlType) {
253:                    this .accessControlType = accessControlType;
254:                }
255:
256:            }
257:
258:            private Form form;
259:            // use property utils to copy to project like struts
260:
261:            JTextPane notes;
262:            //	DateComboBox startDateChooser;
263:            DateField startDateChooser;// = CalendarFactory.createDateField();
264:            JTextField manager;
265:            JTextField name;
266:            JComboBox resourcePool;
267:            JCheckBox forward, remote;
268:            JLabel dateLabel;
269:            JComboBox projectType;
270:            JComboBox projectStatus;
271:            JComboBox expenseType;
272:            JTextField group;
273:            JTextField division;
274:            JComboBox accessControl;
275:
276:            public static ProjectDialog getInstance(Frame owner, Form project) {
277:                return new ProjectDialog(owner, project);
278:            }
279:
280:            private ProjectDialog(Frame owner, Form project) {
281:                super (
282:                        owner,
283:                        Messages.getString("ProjectDialog.NewProject"), true, false); //$NON-NLS-1$
284:                addDocHelp("Creating_a_Project");
285:                if (project != null)
286:                    this .form = project;
287:                else
288:                    this .form = new Form();
289:                setObjectClass(HasExtraFieldsImpl.class);
290:                setObject(form.extra);
291:
292:            }
293:
294:            // Component Creation and Initialization **********************************
295:
296:            /**
297:             * Creates, intializes and configures the UI components. Real applications
298:             * may further bind the components to underlying models.
299:             */
300:            protected void initControls() {
301:                notes = new JTextPane(); //TODO add scrollbars
302:                notes.setAutoscrolls(true);
303:                //		startDateChooser = ComponentFactory.createDateComboBox();
304:                startDateChooser = CalendarFactory.createDateField();
305:                manager = new JTextField();
306:                name = new JTextField();
307:                ArrayList choices = new ArrayList();
308:                choices.add(new String());
309:                choices.addAll(ResourcePoolFactory.getInstance()
310:                        .getResourcePools());
311:                resourcePool = new JComboBox(choices.toArray());
312:                forward = new JCheckBox(Messages.getString("Field.forward")); //$NON-NLS-1$
313:                dateLabel = new JLabel();
314:                forward.addActionListener(new ActionListener() {
315:                    public void actionPerformed(ActionEvent e) {
316:                        setDateLabel();
317:                    }
318:                });
319:
320:                //		remote = new JCheckBox(Messages.getString("Text.newServerProject"));
321:                if (!Environment.getStandAlone()) {
322:                    accessControl = new JComboBox(
323:                            new Object[] {
324:                                    Messages
325:                                            .getString("ProjectDialog.AllResourcesExceptCustomerPartner"), Messages.getString("ProjectDialog.BasedOnProjectRole") }); //$NON-NLS-1$ //$NON-NLS-2$
326:                    HelpUtil.addDocHelp(accessControl, "Project_Team");
327:                }
328:                //		remote.addItemListener(new ItemListener(){
329:                //			public void itemStateChanged(ItemEvent e) {
330:                //				accessControl.setEnabled(!accessControl.isEnabled());
331:                //			}
332:                //		});
333:
334:                projectType = new JComboBox(Configuration.getFieldFromId(
335:                        "Field.projectType").getOptions(null)); //$NON-NLS-1$
336:                projectStatus = new JComboBox(Configuration.getFieldFromId(
337:                        "Field.projectStatus").getOptions(null)); //$NON-NLS-1$
338:                expenseType = new JComboBox(Configuration.getFieldFromId(
339:                        "Field.expenseType").getOptions(null)); //$NON-NLS-1$
340:                group = new JTextField();
341:                division = new JTextField();
342:                bind(true);
343:            }
344:
345:            private void setDateLabel() {
346:                if (forward.isSelected())
347:                    dateLabel.setText(Messages
348:                            .getString("ProjectDialog.StartDate")); //$NON-NLS-1$
349:                else
350:                    dateLabel.setText(Messages
351:                            .getString("ProjectDialog.FinishDate")); //$NON-NLS-1$
352:            }
353:
354:            protected boolean bind(boolean get) {
355:                if (form == null)
356:                    return false;
357:                if (get) {
358:                    notes.setText(form.getNotes());
359:                    manager.setText(form.getManager());
360:                    name.setText(form.getName());
361:                    //			startDateChooser.setDate(new Date(form.getStartDate()));
362:                    startDateChooser.setValue(new Date(form.getStartDate()));
363:                    forward.setSelected(form.isForward());
364:                    //			remote.setSelected(!form.isLocal());
365:                    projectType.setSelectedItem(new Integer(form
366:                            .getProjectType()));
367:                    projectStatus.setSelectedItem(new Integer(form
368:                            .getProjectStatus()));
369:                    expenseType.setSelectedItem(new Integer(form
370:                            .getExpenseType()));
371:                    group.setText(form.getGroup());
372:                    division.setText(form.getDivision());
373:                    setDateLabel();
374:
375:                    if (!Environment.getStandAlone())
376:                        accessControl.setSelectedIndex(0);
377:                } else {
378:                    form.setNotes(notes.getText());
379:                    form.setManager(manager.getText());
380:                    if (name.getText().length() == 0) {
381:                        Alert
382:                                .error(
383:                                        Messages
384:                                                .getString("Message.projectMustHaveName"), this ); //$NON-NLS-1$
385:                        return false;
386:                    }
387:                    form.setName(name.getText());
388:                    // make valid start
389:                    //			long d = DateTime.gmt(startDateChooser.getDate()); // + startDateChooser.getDate().getTimezoneOffset() * 60000;
390:                    long d = DateTime.gmt((Date) startDateChooser.getValue()); // + startDateChooser.getDate().getTimezoneOffset() * 60000;
391:                    if (forward.isSelected()) {
392:                        d = CalendarOption.getInstance()
393:                                .makeValidStart(d, true);
394:                    } else {
395:                        d = CalendarOption.getInstance().makeValidEnd(d, true);
396:                    }
397:                    form.setStartDate(d);
398:                    //			Object pool = resourcePool.getSelectedItem();
399:                    //			if (pool instanceof ResourcePool)
400:                    //				form.setResourcePool((ResourcePool) pool);
401:                    form.setForward(forward.isSelected());
402:                    //			form.setLocal(!remote.isSelected());
403:                    form.setProjectType(projectType.getSelectedIndex()); // caution ids must be sequential
404:                    form.setProjectStatus(projectStatus.getSelectedIndex()); // caution ids must be sequential
405:                    form.setExpenseType(expenseType.getSelectedIndex());// caution ids must be sequential
406:                    form.setGroup(group.getText());
407:                    form.setDivision(division.getText());
408:                    if (!Environment.getStandAlone())
409:                        form.setAccessControlType(accessControl
410:                                .getSelectedIndex());
411:                }
412:                return true;
413:            }
414:
415:            // Building *************************************************************
416:
417:            /**
418:             * Builds the panel. Initializes and configures components first, then
419:             * creates a FormLayout, configures the layout, creates a builder, sets a
420:             * border, and finally adds the components.
421:             * 
422:             * @return the built panel
423:             */
424:
425:            public JComponent createContentPanel() {
426:                // Separating the component initialization and configuration
427:                // from the layout code makes both parts easier to read.
428:                initControls();
429:                //TODO set minimum size
430:                FormLayout layout = new FormLayout(
431:                        "default, 3dlu, 220dlu:grow", // cols //$NON-NLS-1$
432:                        // with commented fields			"p, 3dlu,p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 3dlu,p, 3dlu,p, 3dlu,p,3dlu,p 3dlu, p, 3dlu, fill:50dlu:grow"); // rows
433:                        "p, 3dlu,p, 3dlu,p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 3dlu, fill:50dlu:grow"); // rows //$NON-NLS-1$
434:
435:                // Create a builder that assists in adding components to the container.
436:                // Wrap the panel with a standardized border.
437:                DefaultFormBuilder builder = new DefaultFormBuilder(layout);
438:                builder.setDefaultDialogBorder();
439:                CellConstraints cc = new CellConstraints();
440:                builder.append(
441:                        Messages.getString("ProjectDialog.ProjectName"), name); //$NON-NLS-1$
442:                builder.nextLine(2);
443:                builder.append(
444:                        Messages.getString("ProjectDialog.Manager"), manager); //$NON-NLS-1$
445:                builder.nextLine(2);
446:                builder.append(dateLabel);
447:                builder.append(startDateChooser);
448:                builder.nextLine(2);
449:                builder.append(forward);
450:                //		builder.append(remote);
451:                builder.nextLine(2);
452:
453:                if (!Environment.getStandAlone()) {
454:                    builder.append(Messages
455:                            .getString("ProjectDialog.ProjectTeam")); //$NON-NLS-1$
456:                    builder.add(accessControl, cc.xy(builder.getColumn(),
457:                            builder.getRow(), "left,default")); //$NON-NLS-1$
458:                }
459:                HelpUtil.addDocHelp(accessControl, "Project_Team");
460:                //		builder.nextLine(2);
461:                //		builder.append("Project Status:",projectStatus);
462:                //		builder.nextLine(2);
463:                //		builder.append("Project Type:",projectType);
464:                //		builder.nextLine(2);
465:                //		builder.append("Expense Type:",expenseType);
466:                //		builder.nextLine(2);
467:                //		builder.append("Division:",division);
468:                //		builder.nextLine(2);
469:                //		builder.append("Group:",group);
470:                builder.nextLine(2);
471:
472:                FieldComponentMap map = createMap();
473:                Collection extraFields = FieldDictionary.extractExtraFields(
474:                        FieldDictionary.getInstance().getProjectFields(), true);
475:                JComponent extra = createFieldsPanel(map, extraFields);
476:                if (extra != null) {
477:                    builder.add(extra, cc.xyw(builder.getColumn(), builder
478:                            .getRow(), 3));
479:                }
480:                builder.nextLine(2);
481:
482:                //		builder.append("Shared resource Pool:", resourcePool);
483:                //		builder.nextLine(2);
484:                builder.append(Messages.getString("ProjectDialog.Notes")); //$NON-NLS-1$
485:                builder.nextLine(2);
486:                builder.add(new JScrollPane(notes), cc.xyw(builder.getColumn(),
487:                        builder.getRow(), 3)); // allow spanning 3 cols
488:                return builder.getPanel();
489:            }
490:
491:            /**
492:             * @return Returns the form.
493:             */
494:            public Form getForm() {
495:                return form;
496:            }
497:
498:            public Object getBean() {
499:                return form;
500:            }
501:
502:            protected void onCancel() {
503:                setVisible(false);
504:            }
505:
506:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.