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.Date;
056:
057: import javax.swing.ButtonGroup;
058: import javax.swing.JComponent;
059: import javax.swing.JRadioButton;
060:
061: import com.jgoodies.forms.builder.DefaultFormBuilder;
062: import com.jgoodies.forms.layout.CellConstraints;
063: import com.jgoodies.forms.layout.FormLayout;
064: import com.projity.dialog.util.ComponentFactory;
065: import com.projity.dialog.util.ExtDateField;
066: import com.projity.options.CalendarOption;
067: import com.projity.strings.Messages;
068:
069: /**
070: *
071: */
072: public class UpdateProjectDialogBox extends AbstractDialog {
073: private static final long serialVersionUID = 1L;
074:
075: public static class Form {
076: Boolean update;
077: Boolean progress;
078: Boolean entireProject;
079: Date updateDate = new Date(CalendarOption.getInstance()
080: .makeValidStart(System.currentTimeMillis(), true));
081: Date rescheduleDate = new Date(CalendarOption.getInstance()
082: .makeValidStart(System.currentTimeMillis(), true));
083:
084: public Date getActiveDate() {
085: return update.booleanValue() ? updateDate : rescheduleDate;
086: }
087:
088: public Boolean getEntireProject() {
089: return entireProject;
090: }
091:
092: public void setEntireProject(Boolean entireProject) {
093: this .entireProject = entireProject;
094: }
095:
096: public Boolean getProgress() {
097: return progress;
098: }
099:
100: public void setProgress(Boolean progress) {
101: this .progress = progress;
102: }
103:
104: public Date getRescheduleDate() {
105: return rescheduleDate;
106: }
107:
108: public void setRescheduleDate(Date rescheduleDate) {
109: this .rescheduleDate = rescheduleDate;
110: }
111:
112: public Boolean getUpdate() {
113: return update;
114: }
115:
116: public void setUpdate(Boolean update) {
117: this .update = update;
118: }
119:
120: public Date getUpdateDate() {
121: return updateDate;
122: }
123:
124: public void setUpdateDate(Date updateDate) {
125: this .updateDate = updateDate;
126: }
127: }
128:
129: private Form form;
130: boolean hasTasksSelected;
131: JRadioButton entireProject;
132: JRadioButton selectedTask;
133: ButtonGroup projectOrTask;
134: JRadioButton update;
135: JRadioButton reschedule;
136: ButtonGroup updateOrReschedule;
137: ExtDateField updateDateChooser;
138: ExtDateField rescheduleDateChooser;
139: JRadioButton progress;
140: JRadioButton completeOrNotOnly;
141: ButtonGroup progressCalculationType;
142:
143: public static UpdateProjectDialogBox getInstance(Frame owner,
144: Form project, boolean hasTasksSelected) {
145: return new UpdateProjectDialogBox(owner, project,
146: hasTasksSelected);
147: }
148:
149: private UpdateProjectDialogBox(Frame owner, Form project,
150: boolean hasTasksSelected) {
151: super (
152: owner,
153: Messages
154: .getString("UpdateProjectDialogBox.UpdateProject"), true); //$NON-NLS-1$
155: this .hasTasksSelected = hasTasksSelected;
156: if (project != null)
157: this .form = project;
158: else
159: this .form = new Form();
160: }
161:
162: protected void initControls() {
163: entireProject = new JRadioButton(Messages
164: .getString("UpdateProjectDialogBox.EntireProject")); //$NON-NLS-1$
165: entireProject.setSelected(true);
166: selectedTask = new JRadioButton(Messages
167: .getString("UpdateProjectDialogBox.SelectedTasks")); //$NON-NLS-1$
168: if (!hasTasksSelected)
169: selectedTask.setEnabled(false);
170: projectOrTask = new ButtonGroup();
171: projectOrTask.add(entireProject);
172: projectOrTask.add(selectedTask);
173:
174: update = new JRadioButton();
175: update.setSelected(true);
176: reschedule = new JRadioButton();
177: updateOrReschedule = new ButtonGroup();
178: updateOrReschedule.add(update);
179: updateOrReschedule.add(reschedule);
180:
181: updateDateChooser = ComponentFactory.createDateField();
182: rescheduleDateChooser = ComponentFactory.createDateField();
183: rescheduleDateChooser.setEnabled(false);
184:
185: progress = new JRadioButton(Messages
186: .getString("UpdateProjectDialogBox.SetZeroHundred")); //$NON-NLS-1$
187: progress.setSelected(true);
188: completeOrNotOnly = new JRadioButton(
189: Messages
190: .getString("UpdateProjectDialogBox.SetZeroOrHundredOnly")); //$NON-NLS-1$
191: progressCalculationType = new ButtonGroup();
192: ;
193: progressCalculationType.add(progress);
194: progressCalculationType.add(completeOrNotOnly);
195:
196: update.addActionListener(new ActionListener() {
197: public void actionPerformed(ActionEvent e) {
198: progress.setEnabled(true);
199: completeOrNotOnly.setEnabled(true);
200: updateDateChooser.setEnabled(true);
201: rescheduleDateChooser.setEnabled(false);
202: }
203: });
204: reschedule.addActionListener(new ActionListener() {
205: public void actionPerformed(ActionEvent e) {
206: progress.setEnabled(false);
207: completeOrNotOnly.setEnabled(false);
208: updateDateChooser.setEnabled(false);
209: rescheduleDateChooser.setEnabled(true);
210: }
211: });
212:
213: }
214:
215: protected boolean bind(boolean get) {
216: if (form == null)
217: return false;
218: if (get) {
219: entireProject.setSelected((form.getEntireProject())
220: .booleanValue());
221: update.setSelected((form.getUpdate()).booleanValue());
222: progress.setSelected(form.getProgress().booleanValue());
223: updateDateChooser.setValue(form.getUpdateDate());
224: rescheduleDateChooser.setValue(form.getRescheduleDate());
225: } else {
226: Boolean b1 = new Boolean(entireProject.isSelected());
227: form.setEntireProject(b1);
228: Boolean b2 = new Boolean(update.isSelected());
229: form.setUpdate(b2);
230: Boolean b3 = new Boolean(progress.isSelected());
231: form.setProgress(b3);
232: long d1 = updateDateChooser.getDateValue().getTime();
233: d1 = CalendarOption.getInstance().makeValidStart(d1, true);
234: form.setUpdateDate(new Date(d1));
235: long d2 = rescheduleDateChooser.getDateValue().getTime();
236: d2 = CalendarOption.getInstance().makeValidStart(d2, true);
237: form.setRescheduleDate(new Date(d2));
238: }
239: return true;
240: }
241:
242: public JComponent createContentPanel() {
243:
244: initControls();
245:
246: FormLayout layout = new FormLayout(
247: "20dlu,3dlu,150dlu, 3dlu,80dlu,3dlu,60dlu ", //$NON-NLS-1$
248: "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$
249:
250: DefaultFormBuilder builder = new DefaultFormBuilder(layout);
251: builder.setDefaultDialogBorder();
252: CellConstraints cc = new CellConstraints();
253:
254: builder.append(update);
255: builder
256: .append(Messages
257: .getString("UpdateProjectDialogBox.UpdateWorkAsCompleteThrough")); //$NON-NLS-1$
258: builder.append(updateDateChooser);
259: builder.nextLine(2);
260: builder.nextColumn(2);
261: builder.append(progress);
262: builder.nextLine(2);
263: builder.nextColumn(2);
264: builder.append(completeOrNotOnly);
265: builder.nextLine(2);
266: builder.append(reschedule);
267: builder
268: .append(Messages
269: .getString("UpdateProjectDialogBox.RescheduleCompletedWorkToStartAfter")); //$NON-NLS-1$
270: builder.append(rescheduleDateChooser);
271: builder.nextLine(8);
272: builder.addSeparator(""); //$NON-NLS-1$
273: builder.nextLine(2);
274: builder
275: .append(Messages
276: .getString("UpdateProjectDialogBox.For")); //$NON-NLS-1$
277: builder.nextLine(2);
278: builder.nextColumn(2);
279: builder.append(entireProject);
280: builder.append(selectedTask);
281:
282: return builder.getPanel();
283: }
284:
285: public Form getForm() {
286: return form;
287: }
288:
289: public Object getBean() {
290: return form;
291: }
292:
293: }
|