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.util.Collection;
054:
055: import javax.swing.JComponent;
056: import javax.swing.JTabbedPane;
057:
058: import com.jgoodies.forms.builder.DefaultFormBuilder;
059: import com.jgoodies.forms.layout.CellConstraints;
060: import com.jgoodies.forms.layout.FormLayout;
061: import com.projity.configuration.FieldDictionary;
062: import com.projity.dialog.util.FieldComponentMap;
063: import com.projity.document.ObjectEvent;
064: import com.projity.pm.graphic.frames.DocumentSelectedEvent;
065: import com.projity.pm.graphic.spreadsheet.selection.event.SelectionNodeEvent;
066: import com.projity.pm.resource.Resource;
067: import com.projity.pm.task.Project;
068: import com.projity.pm.task.Task;
069: import com.projity.strings.Messages;
070: import com.projity.util.Environment;
071:
072: /**
073: *
074: */
075: public class ProjectInformationDialog extends InformationDialog {
076: private static final long serialVersionUID = 1L;
077:
078: public static ProjectInformationDialog getInstance(Frame owner,
079: Project project) {
080: return new ProjectInformationDialog(owner, project);
081: }
082:
083: private ProjectInformationDialog(Frame owner, Project project) {
084: super (
085: owner,
086: Messages
087: .getString("ProjectInformationDialog.ProjectInformation")); //$NON-NLS-1$
088: setObjectClass(Project.class);
089: setObject(project);
090: addDocHelp("Project_Information_Dialog");
091:
092: }
093:
094: private JTabbedPane tabbedPane;
095:
096: public JComponent createContentPanel() {
097:
098: FormLayout layout = new FormLayout(
099: "350dlu:grow", "fill:250dlu:grow"); //$NON-NLS-1$ //$NON-NLS-2$
100: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
101: builder.setDefaultDialogBorder();
102: CellConstraints cc = new CellConstraints();
103:
104: tabbedPane = new JTabbedPane();
105: tabbedPane
106: .addTab(
107: Messages
108: .getString("ProjectInformationDialog.General"), createGeneralPanel()); //$NON-NLS-1$
109: tabbedPane
110: .addTab(
111: Messages
112: .getString("ProjectInformationDialog.Statistics"), createStatisticsPanel()); //$NON-NLS-1$
113: tabbedPane
114: .addTab(
115: Messages
116: .getString("ProjectInformationDialog.Notes"), createNotesPanel()); //$NON-NLS-1$
117: builder.add(tabbedPane);
118: mainComponent = tabbedPane;
119: return builder.getPanel();
120: }
121:
122: private JComponent createGeneralPanel() {
123: FieldComponentMap map = createMap();
124: FormLayout layout = new FormLayout(
125: "max(50dlu;pref), 3dlu, 90dlu, 10dlu, p, 3dlu,max(90dlu;pref),60dlu", // extra padding on right is for estimated field //$NON-NLS-1$
126: "p,3dlu,p, 3dlu,p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu,p, 3dlu,p,3dlu,p, 6dlu, fill:50dlu:grow"); //$NON-NLS-1$
127:
128: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
129: CellConstraints cc = new CellConstraints();
130: builder.setDefaultDialogBorder();
131: builder.add(createHeaderFieldsPanel(map), cc.xyw(builder
132: .getColumn(), builder.getRow(), 8));
133: builder.nextLine(2);
134: map.append(builder, "Field.manager"); //$NON-NLS-1$
135: builder.nextLine(2);
136:
137: map.appendSometimesReadOnly(builder, "Field.startDate"); //$NON-NLS-1$
138: map.append(builder, "Field.currentDate"); //$NON-NLS-1$
139: builder.nextLine(2);
140: map.appendSometimesReadOnly(builder, "Field.finishDate"); //$NON-NLS-1$
141: map.append(builder, "Field.statusDate"); //$NON-NLS-1$
142:
143: builder.nextLine(2);
144: map.append(builder, "Field.forward"); //$NON-NLS-1$
145: builder.nextColumn(2);
146: map.append(builder, "Field.baseCalendar"); //$NON-NLS-1$
147: builder.nextLine(2);
148: map.append(builder, "Field.priority"); //$NON-NLS-1$
149: map.append(builder, "Field.projectStatus"); //$NON-NLS-1$
150: builder.nextLine(2);
151: map.append(builder, "Field.projectType"); //$NON-NLS-1$
152: map.append(builder, "Field.expenseType"); //$NON-NLS-1$
153: builder.nextLine(2);
154: map.append(builder, "Field.projectDivision"); //$NON-NLS-1$
155: map.append(builder, "Field.projectGroup"); //$NON-NLS-1$
156: builder.nextLine(2);
157: if (!Environment.getStandAlone()) {
158: map.append(builder, "Field.accessControlPolicy", 3); //$NON-NLS-1$
159: builder.nextLine(2);
160: }
161: Collection extraFields = FieldDictionary
162: .extractExtraFields(FieldDictionary.getInstance()
163: .getProjectFields(), false);
164: JComponent extra = createFieldsPanel(map, extraFields);
165: if (extra != null) {
166: builder.add(extra, cc.xyw(builder.getColumn(), builder
167: .getRow(), 7));
168: }
169: return builder.getPanel();
170: }
171:
172: private JComponent createStatisticsPanel() {
173: FieldComponentMap map = createMap();
174: FormLayout layout = new FormLayout(
175: "p, 3dlu, 50dlu, 20dlu, p, 3dlu, 50dlu", //$NON-NLS-1$
176: "p, 3dlu, p, 3dlu,p, 3dlu, p, 10dlu, p,3dlu,p, 10dlu, p, 3dlu, p, 10dlu, p, 3dlu, p"); //$NON-NLS-1$
177:
178: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
179: builder.setDefaultDialogBorder();
180: CellConstraints cc = new CellConstraints();
181: builder.setDefaultDialogBorder();
182: builder.add(createHeaderFieldsPanel(map), cc.xyw(builder
183: .getColumn(), builder.getRow(), 7));
184: builder.nextLine(2);
185: map.appendReadOnly(builder, "Field.startDate"); //$NON-NLS-1$
186: map.appendReadOnly(builder, "Field.finishDate"); //$NON-NLS-1$
187: builder.nextLine(2);
188: map.appendReadOnly(builder, "Field.baselineStart"); //$NON-NLS-1$
189: map.appendReadOnly(builder, "Field.baselineFinish"); //$NON-NLS-1$
190: builder.nextLine(2);
191: map.appendReadOnly(builder, "Field.actualStart"); //$NON-NLS-1$
192: map.appendReadOnly(builder, "Field.actualFinish"); //$NON-NLS-1$
193:
194: builder.nextLine(2);
195: map.appendReadOnly(builder, "Field.duration"); //$NON-NLS-1$
196: map.appendReadOnly(builder, "Field.baselineDuration"); //$NON-NLS-1$
197: builder.nextLine(2);
198: map.appendReadOnly(builder, "Field.actualDuration"); //$NON-NLS-1$
199: map.appendReadOnly(builder, "Field.remainingDuration"); //$NON-NLS-1$
200:
201: builder.nextLine(2);
202: map.appendReadOnly(builder, "Field.work"); //$NON-NLS-1$
203: map.appendReadOnly(builder, "Field.baselineWork"); //$NON-NLS-1$
204: builder.nextLine(2);
205: map.appendReadOnly(builder, "Field.actualWork"); //$NON-NLS-1$
206: map.appendReadOnly(builder, "Field.remainingWork"); //$NON-NLS-1$
207:
208: builder.nextLine(2);
209: map.appendReadOnly(builder, "Field.cost"); //$NON-NLS-1$
210: map.appendReadOnly(builder, "Field.baselineCost"); //$NON-NLS-1$
211: builder.nextLine(2);
212: map.appendReadOnly(builder, "Field.actualCost"); //$NON-NLS-1$
213: map.appendReadOnly(builder, "Field.remainingCost"); //$NON-NLS-1$
214: return builder.getPanel();
215: }
216:
217: /* (non-Javadoc)
218: * @see com.projity.dialog.InformationDialog#createHeaderFieldsPanel(com.projity.dialog.util.FieldComponentMap)
219: */
220: protected JComponent createHeaderFieldsPanel(FieldComponentMap map) {
221: FormLayout layout = new FormLayout("p, 3dlu, 160dlu", //$NON-NLS-1$
222: "p"); //$NON-NLS-1$
223: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
224: map.append(builder, "Field.name"); //$NON-NLS-1$
225: return builder.getPanel();
226: }
227:
228: public void documentSelected(DocumentSelectedEvent evt) {
229: setObject(evt.getCurrent().getProject());
230: updateAll();
231: }
232:
233: public void selectionChanged(SelectionNodeEvent e) {
234:
235: }
236:
237: public void objectChanged(ObjectEvent objectEvent) {
238: if (!isVisible())
239: return;
240: Object obj = objectEvent.getObject();
241: Project project = (Project) getObject();
242: boolean update = false;
243: if (obj == getObject()) {
244: update = true;
245: } else if (obj instanceof Task) {
246: if (((Task) obj).getProject() == project)
247: update = true;
248:
249: } else if (obj instanceof Resource) {
250: if (((Resource) obj).getDocument() == project
251: .getResourcePool())
252: update = true;
253: }
254: if (update)
255: updateAll();
256: }
257:
258: public void setObject(Object object) {
259: super.setObject(object);
260: if (object != null)
261: updateAll();
262: }
263:
264: }
|