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:
054: import javax.swing.JComponent;
055: import javax.swing.JScrollPane;
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.association.AssociationList;
062: import com.projity.dialog.util.FieldComponentMap;
063: import com.projity.graphic.configuration.SpreadSheetCategories;
064: import com.projity.help.HelpUtil;
065: import com.projity.menu.MenuActionConstants;
066: import com.projity.pm.dependency.DependencyNodeModelDataFactory;
067: import com.projity.pm.graphic.frames.DocumentFrame;
068: import com.projity.pm.graphic.frames.DocumentSelectedEvent;
069: import com.projity.pm.graphic.frames.GraphicManager;
070: import com.projity.pm.graphic.model.cache.NodeModelCache;
071: import com.projity.pm.graphic.spreadsheet.SpreadSheet;
072: import com.projity.pm.graphic.spreadsheet.SpreadSheetModel;
073: import com.projity.pm.graphic.spreadsheet.SpreadSheetUtils;
074: import com.projity.pm.graphic.views.UsageDetailView;
075: import com.projity.pm.task.NormalTask;
076: import com.projity.pm.task.Task;
077: import com.projity.strings.Messages;
078:
079: /**
080: *
081: */
082: public class TaskInformationDialog extends InformationDialog {
083: private static final long serialVersionUID = 1L;
084:
085: public static TaskInformationDialog getInstance(Frame owner,
086: Task task, boolean notes) {
087: return new TaskInformationDialog(owner, task, notes);
088: }
089:
090: private TaskInformationDialog(Frame owner, Task task, boolean notes) {
091: super (owner, Messages
092: .getString("TaskInformationDialog.TaskInformation")); //$NON-NLS-1$
093: setObjectClass(Task.class);
094: setObject(task);
095: addDocHelp("Task_Information_Dialog");
096: }
097:
098: private JTabbedPane taskTabbedPane;
099: private int notesTabIndex;
100: private int resourcesTabIndex;
101:
102: public JComponent createContentPanel() {
103:
104: FormLayout layout = new FormLayout(
105: "350dlu:grow", "fill:250dlu:grow"); //$NON-NLS-1$ //$NON-NLS-2$
106: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
107: builder.setDefaultDialogBorder();
108: CellConstraints cc = new CellConstraints();
109:
110: taskTabbedPane = new JTabbedPane();
111: taskTabbedPane
112: .addTab(
113: Messages
114: .getString("TaskInformationDialog.General"), createGeneralPanel()); //$NON-NLS-1$
115: taskTabbedPane
116: .addTab(
117: Messages
118: .getString("TaskInformationDialog.Predecessors"), createPredecessorsPanel()); //$NON-NLS-1$
119: taskTabbedPane
120: .addTab(
121: Messages
122: .getString("TaskInformationDialog.Successors"), createSuccessorsPanel()); //$NON-NLS-1$
123: String resources = Messages
124: .getString("TaskInformationDialog.Resources"); //$NON-NLS-1$
125: taskTabbedPane.addTab(resources, createResourcesPanel());
126: resourcesTabIndex = taskTabbedPane.indexOfTab(resources);
127:
128: taskTabbedPane
129: .addTab(
130: Messages
131: .getString("TaskInformationDialog.Advanced"), createAdvancedPanel()); //$NON-NLS-1$
132:
133: String notes = Messages
134: .getString("TaskInformationDialog.Notes"); //$NON-NLS-1$
135: taskTabbedPane.addTab(notes, createNotesPanel());
136: notesTabIndex = taskTabbedPane.indexOfTab(notes);
137: builder.add(taskTabbedPane);
138: mainComponent = taskTabbedPane;
139:
140: return builder.getPanel();
141: }
142:
143: public void showNotes() {
144: taskTabbedPane.setSelectedIndex(notesTabIndex);
145: }
146:
147: public void showResources() {
148: taskTabbedPane.setSelectedIndex(resourcesTabIndex);
149: }
150:
151: protected JComponent createHeaderFieldsPanel(FieldComponentMap map) {
152: // Repeat of fields from general tab (MS Project does this)
153: FormLayout layout = new FormLayout(
154: "p, 8dlu, 140dlu, 12dlu, p, 3dlu, 60dlu, 3dlu, p" //$NON-NLS-1$
155: , "p,3dlu"); //$NON-NLS-1$
156: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
157: map.append(builder, "Field.name"); //$NON-NLS-1$
158: map.appendSometimesReadOnly(builder, "Field.duration"); //$NON-NLS-1$
159: map.append(builder, "Field.estimated"); //$NON-NLS-1$
160: builder.nextLine(); // border at bottom
161: return builder.getPanel();
162: }
163:
164: private JComponent createGeneralPanel() {
165: FieldComponentMap map = createMap();
166: FormLayout layout = new FormLayout(
167: "max(50dlu;pref), 3dlu, 90dlu 10dlu, p, 3dlu,90dlu,60dlu", // extra padding on right is for estimated field //$NON-NLS-1$
168: "p, 3dlu,p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, fill:50dlu:grow"); //$NON-NLS-1$
169:
170: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
171: CellConstraints cc = new CellConstraints();
172: builder.setDefaultDialogBorder();
173: builder.add(createHeaderFieldsPanel(map), cc.xyw(builder
174: .getColumn(), builder.getRow(), 8));
175:
176: builder.nextLine(2);
177: map.appendSometimesReadOnly(builder, "Field.percentComplete"); //$NON-NLS-1$
178: map.append(builder, "Field.priority"); //$NON-NLS-1$
179: builder.nextLine(4);
180:
181: builder.addSeparator(Messages
182: .getString("TaskInformationDialog.Dates")); //$NON-NLS-1$
183: builder.nextLine(2);
184: map.append(builder, "Field.start"); //$NON-NLS-1$
185: map.append(builder, "Field.finish"); //$NON-NLS-1$
186: builder.nextLine();
187: return builder.getPanel();
188: }
189:
190: private JComponent createAdvancedPanel() {
191: FieldComponentMap map = createMap();
192: FormLayout layout = new FormLayout(
193: "max(50dlu;pref), 3dlu, 90dlu, 10dlu, p, 3dlu,90dlu,30dlu", // extra padding on right is for estimated field //$NON-NLS-1$
194: "p,3dlu,p,3dlu,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"); //$NON-NLS-1$
195:
196: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
197: builder.setDefaultDialogBorder();
198: CellConstraints cc = new CellConstraints();
199:
200: builder.add(createHeaderFieldsPanel(map), cc.xyw(builder
201: .getColumn(), builder.getRow(), 8));
202: builder.nextLine(2);
203: builder.addSeparator(Messages
204: .getString("TaskInformationDialog.ConstrainTask")); //$NON-NLS-1$
205: builder.nextLine(2);
206: map.append(builder, "Field.deadline"); //$NON-NLS-1$
207: builder.nextLine(2);
208: builder.addSeparator(" "); //$NON-NLS-1$
209: builder.nextLine(2);
210: map.append(builder, "Field.constraintType"); //$NON-NLS-1$
211: map.appendSometimesReadOnly(builder, "Field.constraintDate"); //$NON-NLS-1$
212: builder.nextLine(4);
213: builder.addSeparator(" "); //$NON-NLS-1$
214: builder.nextLine(2);
215: map.append(builder, "Field.taskType"); //$NON-NLS-1$
216: map.append(builder, "Field.effortDriven", 3); //$NON-NLS-1$
217: builder.nextLine(2);
218: map.append(builder, "Field.taskCalendar"); //$NON-NLS-1$
219: map.append(builder, "Field.ignoreResourceCalendar", 3); //$NON-NLS-1$
220: builder.nextLine(2);
221: map.append(builder, "Field.wbs"); //$NON-NLS-1$
222: builder.nextLine(2);
223: map.append(builder, "Field.earnedValueMethod"); //$NON-NLS-1$
224: builder.nextLine(2);
225: map.append(builder, "Field.markTaskAsMilestone", 5); //$NON-NLS-1$
226:
227: return builder.getPanel();
228: }
229:
230: public JComponent createPredecessorsPanel() {
231: FieldComponentMap map = createMap();
232: FormLayout layout = new FormLayout(
233: "p:grow", "p,3dlu,p,3dlu,fill:150dlu:grow"); //$NON-NLS-1$ //$NON-NLS-2$
234:
235: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
236: builder.setDefaultDialogBorder();
237: CellConstraints cc = new CellConstraints();
238: builder.add(createHeaderFieldsPanel(map), cc.xyw(builder
239: .getColumn(), builder.getRow(), 1));
240: builder.nextLine(2);
241: builder
242: .append(Messages
243: .getString("Spreadsheet.Dependency.predecessors") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
244: builder.nextLine(2);
245: builder.add(createPredecessorsSpreadsheet());
246: JComponent pred = builder.getPanel();
247: HelpUtil.addDocHelp(pred, "Linking");
248: return pred;
249: }
250:
251: protected SpreadSheet predecessorsSpreadSheet;
252: public static final String DEPENDENCY_SPREADSHEET = SpreadSheetCategories.dependencySpreadsheetCategory;
253:
254: protected JScrollPane createPredecessorsSpreadsheet() {
255: predecessorsSpreadSheet = new SpreadSheet() {
256: public void doDoubleClick(int row, int col) {
257: }
258: };
259: predecessorsSpreadSheet
260: .setSpreadSheetCategory(DEPENDENCY_SPREADSHEET);
261: predecessorsSpreadSheet.setCanModifyColumns(false);
262: predecessorsSpreadSheet.setCanSelectFieldArray(false);
263: predecessorsSpreadSheet
264: .setActions(new String[] { MenuActionConstants.ACTION_DELETE });
265: SpreadSheetUtils.createCollectionSpreadSheet(
266: predecessorsSpreadSheet,
267: (object == null) ? new AssociationList()
268: : ((Task) object).getPredecessorList()
269: //,(object==null)?null:((NormalTask)object).getDocument()
270: ,
271: "View.TaskInformation.Predecessors" //$NON-NLS-1$
272: , DEPENDENCY_SPREADSHEET,
273: "Spreadsheet.Dependency.predecessors" //$NON-NLS-1$
274: , true, new DependencyNodeModelDataFactory(), 0
275: // ,false
276: // ,true
277: );
278: return SpreadSheetUtils
279: .makeSpreadsheetScrollPane(predecessorsSpreadSheet);
280:
281: }
282:
283: //cache reconstructed because the main cache holding edges isn't ordered
284: protected void updatePredecessorsSpreadsheet() {
285: SpreadSheetUtils.updateCollectionSpreadSheet(
286: predecessorsSpreadSheet,
287: (object == null) ? new AssociationList()
288: : ((Task) object).getPredecessorList(),
289: new DependencyNodeModelDataFactory(), 0);
290: }
291:
292: public JComponent createSuccessorsPanel() {
293: FieldComponentMap map = createMap();
294: FormLayout layout = new FormLayout(
295: "p:grow", "p,3dlu,p,3dlu,fill:150dlu:grow"); //$NON-NLS-1$ //$NON-NLS-2$
296:
297: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
298: builder.setDefaultDialogBorder();
299: CellConstraints cc = new CellConstraints();
300: builder.add(createHeaderFieldsPanel(map), cc.xyw(builder
301: .getColumn(), builder.getRow(), 1));
302: builder.nextLine(2);
303: builder.append(Messages
304: .getString("Spreadsheet.Dependency.successors") + ":"); //$NON-NLS-1$ //$NON-NLS-2$
305: builder.nextLine(2);
306: builder.add(createSuccessorsSpreadsheet());
307: JComponent succ = builder.getPanel();
308: HelpUtil.addDocHelp(succ, "Linking");
309: return succ;
310: }
311:
312: protected SpreadSheet successorsSpreadSheet;
313:
314: protected JScrollPane createSuccessorsSpreadsheet() {
315: successorsSpreadSheet = new SpreadSheet() {
316: public void doDoubleClick(int row, int col) {
317: }
318: };
319: successorsSpreadSheet
320: .setSpreadSheetCategory(DEPENDENCY_SPREADSHEET);
321: successorsSpreadSheet.setCanModifyColumns(false);
322: successorsSpreadSheet.setCanSelectFieldArray(false);
323: successorsSpreadSheet
324: .setActions(new String[] { MenuActionConstants.ACTION_DELETE });
325:
326: SpreadSheetUtils.createCollectionSpreadSheet(
327: successorsSpreadSheet,
328: (object == null) ? new AssociationList()
329: : ((Task) object).getSuccessorList()
330: //,(object==null)?null:((NormalTask)object).getDocument()
331: ,
332: "View.TaskInformation.Successors" //$NON-NLS-1$
333: , DEPENDENCY_SPREADSHEET,
334: "Spreadsheet.Dependency.successors" //$NON-NLS-1$
335: , false, new DependencyNodeModelDataFactory(), 0
336: // ,false
337: // ,true
338: );
339:
340: return SpreadSheetUtils
341: .makeSpreadsheetScrollPane(successorsSpreadSheet);
342:
343: }
344:
345: //cache reconstructed because the main cache holding edges isn't ordered
346: protected void updateSuccessorsSpreadsheet() {
347: SpreadSheetUtils.updateCollectionSpreadSheet(
348: successorsSpreadSheet,
349: (object == null) ? new AssociationList()
350: : ((Task) object).getSuccessorList(),
351: new DependencyNodeModelDataFactory(), 0);
352: }
353:
354: public JComponent createResourcesPanel() {
355: FieldComponentMap map = createMap();
356:
357: FormLayout layout = new FormLayout(
358: "p:grow,0dlu,right:p", "p,3dlu,p,3dlu,fill:150dlu:grow"); //$NON-NLS-1$ //$NON-NLS-2$
359:
360: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
361: builder.setDefaultDialogBorder();
362: CellConstraints cc = new CellConstraints();
363: builder.add(createHeaderFieldsPanel(map), cc.xyw(builder
364: .getColumn(), builder.getRow(), 3));
365: builder.nextLine(2);
366: builder
367: .append(
368: Messages
369: .getString("TaskInformationDialog.Resources") + ":", getAssignResourceButton()); //$NON-NLS-1$
370: builder.nextLine(2);
371: builder.add(createAssignmentSpreadsheet(), cc.xyw(builder
372: .getColumn(), builder.getRow(), 3));
373: JComponent panel = builder.getPanel();
374: HelpUtil.addDocHelp(panel, "Assign_Resources");
375: return panel;
376: }
377:
378: protected SpreadSheet assignmentSpreadSheet;
379:
380: protected JScrollPane createAssignmentSpreadsheet() {
381: assignmentSpreadSheet = SpreadSheetUtils
382: .createFilteredSpreadsheet(
383: GraphicManager.getInstance(this )
384: .getCurrentFrame(),
385: false,
386: "View.TaskInformation.Assignments" //$NON-NLS-1$
387: ,
388: UsageDetailView.resourceAssignmentSpreadsheetCategory,
389: "Spreadsheet.Assignment.resourceUsage" //$NON-NLS-1$
390: ,
391: true
392: //, 0
393: ,
394: new String[] { MenuActionConstants.ACTION_DELETE }
395: /*, new int[] {SpreadSheet.DELETE}*/);
396: assignmentSpreadSheet
397: .setActions(new String[] { MenuActionConstants.ACTION_DELETE });
398:
399: updateAssignmentSpreadsheet();
400: return SpreadSheetUtils
401: .makeSpreadsheetScrollPane(assignmentSpreadSheet);
402:
403: }
404:
405: protected void updateAssignmentSpreadsheet() {
406: SpreadSheetUtils.updateFilteredSpreadsheet(
407: assignmentSpreadSheet,
408: (object == null) ? new AssociationList()
409: : ((NormalTask) object).getAssignments());
410: ((SpreadSheetModel) assignmentSpreadSheet.getModel())
411: .fireUpdateAll();
412: }
413:
414: public void updateAll() {
415: activateListeners();
416: super .updateAll();
417: updatePredecessorsSpreadsheet();
418: updateSuccessorsSpreadsheet();
419: updateAssignmentSpreadsheet();
420: }
421:
422: public void documentSelected(DocumentSelectedEvent evt) {
423: if (assignmentSpreadSheet == null)
424: return;
425: DocumentFrame df = evt.getCurrent();
426: if (df != null) {
427: // List impls=df.getSelectedImpls();
428: // if (impls!=null&&impls.size()>0) setObject(impls.get(0));
429: NodeModelCache cache = df.createCache(false, Messages
430: .getString("View.TaskInformation.Assignments")); //$NON-NLS-1$
431: assignmentSpreadSheet.setCache(cache);
432: }
433: }
434:
435: protected void activateListeners() {
436: super .activateListeners();
437: predecessorsSpreadSheet.getCache().setReceiveEvents(true);
438: successorsSpreadSheet.getCache().setReceiveEvents(true);
439: //assignmentSpreadSheet.getCache().setReceiveEvents(true);
440: }
441:
442: protected void desactivateListeners() {
443: super .desactivateListeners();
444: predecessorsSpreadSheet.getCache().setReceiveEvents(false);
445: successorsSpreadSheet.getCache().setReceiveEvents(false);
446: //assignmentSpreadSheet.getCache().setReceiveEvents(false);
447: //causes an update problem of the filtered cache
448: }
449:
450: }
|