1.1 --- a/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/Bundle.properties Tue Feb 10 17:12:29 2004 +0000
1.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/Bundle.properties Tue Feb 10 17:50:40 2004 +0000
1.3 @@ -125,9 +125,6 @@
1.4 TaskDueLabel=Task due
1.5 ACSD_DuePanel=Panel showing tasks now due
1.6
1.7 -#Task's progress will be computed
1.8 -Computed=Computed
1.9 -
1.10 #Ask the user if he wants to delete completed tasks
1.11 PurgeTasks=Do you want to permanently delete all completed tasks?
1.12
1.13 @@ -142,8 +139,6 @@
1.14 #yes for done property
1.15 Yes=yes
1.16
1.17 -IllegalDateValue=Not a valid date\: {0}
1.18 -
1.19 LBL_NewSubtask=New Subtask...
1.20
1.21 #Summary for the root task of a task list
1.22 @@ -173,8 +168,10 @@
1.23
1.24 ## UserTaskNode
1.25 Effort2=Effort
1.26 -EffortHint=Effort in minutes
1.27 +EffortHint=Effort
1.28 EffortFormat={0,choice,0#|1#1 day|1<{0} days}{1,choice,0#|1# 1 hour|1< {1} hours}{2,choice,0#|1# 1 minute|1< {2} minutes}
1.29 +RestEffort=Rest Effort
1.30 +RestEffortHint=Remaining Effort
1.31
1.32 ## DurationPanel
1.33 Minutes=Minutes
2.1 --- a/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/UserTaskNode.java Tue Feb 10 17:12:29 2004 +0000
2.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/UserTaskNode.java Tue Feb 10 17:50:40 2004 +0000
2.3 @@ -38,6 +38,8 @@
2.4 import org.netbeans.modules.tasklist.core.editors.LineNumberPropertyEditor;
2.5 import org.netbeans.modules.tasklist.core.editors.PriorityPropertyEditor;
2.6 import org.netbeans.modules.tasklist.core.editors.StringPropertyEditor;
2.7 +import org.netbeans.modules.tasklist.usertasks.editors.DurationPropertyEditor;
2.8 +import org.netbeans.modules.tasklist.usertasks.editors.PercentsPropertyEditor;
2.9 import org.openide.ErrorManager;
2.10 import org.openide.actions.CopyAction;
2.11 import org.openide.actions.CutAction;
2.12 @@ -82,7 +84,7 @@
2.13 static {
2.14 PropertyEditorManager.registerEditor(
2.15 getKlass("java.util.Date"),
2.16 - getKlass("org.netbeans.modules.tasklist.usertasks.DateEditor"));
2.17 + getKlass("org.netbeans.modules.tasklist.usertasks.editors.DateEditor"));
2.18 }
2.19
2.20 // From NonGui.java - supports the above hack, please read its comment:
2.21 @@ -95,10 +97,6 @@
2.22 }
2.23 }
2.24
2.25 - private static final MessageFormat EFFORT_FORMAT =
2.26 - new MessageFormat(NbBundle.getMessage(UserTaskNode.class,
2.27 - "EffortFormat")); // NOI18N
2.28 -
2.29 // Leaf
2.30 UserTaskNode(UserTask item) {
2.31 super(item);
2.32 @@ -232,24 +230,20 @@
2.33 p.setShortDescription(NbBundle.getMessage(UserTaskNode.class, "PercentHint")); // NOI18N
2.34 ss.put(p);
2.35
2.36 - p = new Reflection(item, Integer.TYPE, "getEffort", null) { // NOI18N
2.37 - public Object getValue() {
2.38 - UserTask task = (UserTask) instance;
2.39 - int[] d = UserTask.splitDuration(task.getEffort(),
2.40 - Settings.getDefault().getHoursPerDay());
2.41 -
2.42 - String s = EFFORT_FORMAT.format(new Object[] {
2.43 - new Integer(d[2]), new Integer(d[1]), new Integer(d[0])
2.44 - }).trim();
2.45 - LOGGER.fine("computed value " + s);
2.46 - return s;
2.47 - }
2.48 - };
2.49 + p = new Reflection(item, Integer.TYPE, "getEffort", null);
2.50 p.setName("effort");
2.51 p.setDisplayName(NbBundle.getMessage(UserTaskNode.class, "Effort2")); // NOI18N
2.52 p.setShortDescription(NbBundle.getMessage(UserTaskNode.class, "EffortHint")); // NOI18N
2.53 p.setValue("suppressCustomEditor", Boolean.TRUE);
2.54 - p.setPropertyEditorClass(StringPropertyEditor.class);
2.55 + p.setPropertyEditorClass(DurationPropertyEditor.class);
2.56 + ss.put(p);
2.57 +
2.58 + p = new Reflection(item, Integer.TYPE, "getRestEffort", null);
2.59 + p.setName("restEffort");
2.60 + p.setDisplayName(NbBundle.getMessage(UserTaskNode.class, "RestEffort")); // NOI18N
2.61 + p.setShortDescription(NbBundle.getMessage(UserTaskNode.class, "RestEffortHint")); // NOI18N
2.62 + p.setValue("suppressCustomEditor", Boolean.TRUE);
2.63 + p.setPropertyEditorClass(DurationPropertyEditor.class);
2.64 ss.put(p);
2.65
2.66 p = new Reflection(item, String.class, "getDetails", "setDetails"); // NOI18N
3.1 --- a/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/UserTaskView.java Tue Feb 10 17:12:29 2004 +0000
3.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/UserTaskView.java Tue Feb 10 17:50:40 2004 +0000
3.3 @@ -241,6 +241,7 @@
3.4 public static final String PROP_TASK_EDITED = "edited"; // NOI18N
3.5 public static final String PROP_TASK_PERCENT = "percentComplete"; // NOI18N
3.6 public static final String PROP_EFFORT = "effort"; // NOI18N
3.7 + public static final String PROP_REST_EFFORT = "restEffort"; // NOI18N
3.8
3.9 protected ColumnProperty[] createColumns() {
3.10 return new ColumnProperty[] {
3.11 @@ -255,7 +256,8 @@
3.12 getDueColumn(false, 150),
3.13 getDoneColumn(true, 40),
3.14 getPercentColumn(false, 100),
3.15 - getEffortColumn(false, 50)
3.16 + getEffortColumn(false, 50),
3.17 + getRestEffortColumn(false, 50)
3.18
3.19 // When adding more columns here, also remember to go to the
3.20 // constructor and add a column width setting
3.21 @@ -413,6 +415,19 @@
3.22 );
3.23 }
3.24
3.25 + public ColumnProperty getRestEffortColumn(boolean visible, int width) {
3.26 + return new ColumnProperty(
3.27 + 11, // UID -- never change (part of serialization
3.28 + PROP_REST_EFFORT,
3.29 + Integer.TYPE,
3.30 + NbBundle.getMessage(UserTaskView.class, "RestEffort"), // NOI18N
3.31 + NbBundle.getMessage(UserTaskView.class, "RestEffortHint"), // NOI18N
3.32 + true,
3.33 + visible,
3.34 + width
3.35 + );
3.36 + }
3.37 +
3.38 private static UserTaskView defview = null;
3.39
3.40 static UserTaskView getDefault() {
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/editors/Bundle.properties Tue Feb 10 17:50:40 2004 +0000
4.3 @@ -0,0 +1,20 @@
4.4 +# Sun Public License Notice
4.5 +#
4.6 +# The contents of this file are subject to the Sun Public License
4.7 +# Version 1.0 (the "License"). You may not use this file except in
4.8 +# compliance with the License. A copy of the License is available at
4.9 +# http://www.sun.com/
4.10 +#
4.11 +# The Original Code is NetBeans. The Initial Developer of the Original
4.12 +# Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
4.13 +# Microsystems, Inc. All Rights Reserved.
4.14 +
4.15 +## DurationPropertyEditor
4.16 +EffortFormat={0,choice,0#|1#1 day|1<{0} days}{1,choice,0#|1# 1 hour|1< {1} hours}{2,choice,0#|1# 1 minute|1< {2} minutes}
4.17 +
4.18 +## DateEditor
4.19 +IllegalDateValue=Not a valid date\: {0}
4.20 +
4.21 +## PercentsPropertyEditor
4.22 +Computed=Computed
4.23 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/editors/DateEditor.java Tue Feb 10 17:50:40 2004 +0000
5.3 @@ -0,0 +1,113 @@
5.4 +/*
5.5 + * Sun Public License Notice
5.6 + *
5.7 + * The contents of this file are subject to the Sun Public License
5.8 + * Version 1.0 (the "License"). You may not use this file except in
5.9 + * compliance with the License. A copy of the License is available at
5.10 + * http://www.sun.com/
5.11 + *
5.12 + * The Original Code is NetBeans. The Initial Developer of the Original
5.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
5.14 + * Microsystems, Inc. All Rights Reserved.
5.15 + */
5.16 +
5.17 +// HACK - read the comment at the beginning of the Task class
5.18 +
5.19 +// Also see core/src/org/netbeans/beaninfo/editors and
5.20 +// openide/src/org/openide/explorer/propertysheet/editors
5.21 +
5.22 +package org.netbeans.modules.tasklist.usertasks.editors;
5.23 +
5.24 +import java.util.Date;
5.25 +import java.text.ParseException;
5.26 +import java.text.SimpleDateFormat;
5.27 +import java.awt.Component;
5.28 +import java.beans.FeatureDescriptor;
5.29 +import java.beans.PropertyEditorSupport;
5.30 +import org.netbeans.modules.tasklist.usertasks.DateSelectionPanel;
5.31 +import org.openide.ErrorManager;
5.32 +import org.openide.explorer.propertysheet.ExPropertyEditor;
5.33 +import org.openide.explorer.propertysheet.PropertyEnv;
5.34 +
5.35 +// bugfix# 9219 for attachEnv() method
5.36 +import org.openide.nodes.Node;
5.37 +import org.openide.util.NbBundle;
5.38 +
5.39 +
5.40 +/**
5.41 + * A property editor for the Date class.
5.42 + *
5.43 + * @author Tor Norbye
5.44 + * @author Trond Norbye
5.45 + * @author Tim Lebedkov
5.46 + */
5.47 +public class DateEditor extends PropertyEditorSupport
5.48 +implements ExPropertyEditor {
5.49 + private static SimpleDateFormat format = new SimpleDateFormat();
5.50 +
5.51 + // bugfix# 9219 added editable field and isEditable() "getter" to be used
5.52 + // in StringCustomEditor
5.53 + private boolean editable = true;
5.54 +
5.55 + /**
5.56 + * gets information if the text in editor should be editable or not
5.57 + *
5.58 + * @return true = editable
5.59 + */
5.60 + public boolean isEditable(){
5.61 + return editable;
5.62 + }
5.63 +
5.64 + public void setAsText(String s) throws java.lang.IllegalArgumentException {
5.65 + if (s.trim().length() == 0) {
5.66 + setValue(null);
5.67 + return;
5.68 + }
5.69 + try {
5.70 + setValue(format.parse(s));
5.71 + } catch (ParseException e) {
5.72 + String msg = NbBundle.getMessage(DateEditor.class,
5.73 + "IllegalDateValue", new Object[] {s}); //NOI18N
5.74 + RuntimeException iae = new IllegalArgumentException(msg);
5.75 + ErrorManager.getDefault().annotate(iae, ErrorManager.USER, msg,
5.76 + msg, e, new java.util.Date());
5.77 + throw iae;
5.78 + }
5.79 + }
5.80 +
5.81 + public String getAsText() {
5.82 + Object val = getValue();
5.83 + if (val instanceof Date) {
5.84 + return format.format((Date) val);
5.85 + } else if (val instanceof Long) {
5.86 + return format.format(new Date(((Long) val).longValue()));
5.87 + } else {
5.88 + return ""; // NOI18N
5.89 + }
5.90 + }
5.91 +
5.92 + public boolean supportsCustomEditor () {
5.93 + return true;
5.94 + }
5.95 +
5.96 + public Component getCustomEditor() {
5.97 + Date d;
5.98 + if (getValue() instanceof Date) {
5.99 + d = (Date) getValue();
5.100 + } else if (getValue() instanceof Long) {
5.101 + d = new Date(((Long) getValue()).longValue());
5.102 + } else {
5.103 + d = new Date();
5.104 + setValue(d);
5.105 + }
5.106 + return new DateSelectionPanel(d);
5.107 + }
5.108 +
5.109 + public void attachEnv(PropertyEnv env) {
5.110 + FeatureDescriptor desc = env.getFeatureDescriptor();
5.111 + if (desc instanceof Node.Property){
5.112 + Node.Property prop = (Node.Property)desc;
5.113 + editable = prop.canWrite();
5.114 + }
5.115 + }
5.116 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/editors/DurationPropertyEditor.java Tue Feb 10 17:50:40 2004 +0000
6.3 @@ -0,0 +1,43 @@
6.4 +/*
6.5 + * Sun Public License Notice
6.6 + *
6.7 + * The contents of this file are subject to the Sun Public License
6.8 + * Version 1.0 (the "License"). You may not use this file except in
6.9 + * compliance with the License. A copy of the License is available at
6.10 + * http://www.sun.com/
6.11 + *
6.12 + * The Original Code is NetBeans. The Initial Developer of the Original
6.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
6.14 + * Microsystems, Inc. All Rights Reserved.
6.15 + */
6.16 +
6.17 +package org.netbeans.modules.tasklist.usertasks.editors;
6.18 +
6.19 +import java.text.MessageFormat;
6.20 +import org.netbeans.modules.tasklist.core.editors.StringPropertyEditor;
6.21 +import org.netbeans.modules.tasklist.usertasks.Settings;
6.22 +import org.netbeans.modules.tasklist.usertasks.UserTask;
6.23 +import org.openide.filesystems.FileObject;
6.24 +import org.openide.util.NbBundle;
6.25 +
6.26 +/**
6.27 + * PropertyEditor for duration in minutes.
6.28 + *
6.29 + * @author Tim Lebedkov
6.30 + */
6.31 +public class DurationPropertyEditor extends StringPropertyEditor {
6.32 + private static final MessageFormat EFFORT_FORMAT =
6.33 + new MessageFormat(NbBundle.getMessage(DurationPropertyEditor.class,
6.34 + "EffortFormat")); // NOI18N
6.35 +
6.36 + public String getAsText() {
6.37 + int duration = ((Integer) getValue()).intValue();
6.38 + int[] d = UserTask.splitDuration(duration,
6.39 + Settings.getDefault().getHoursPerDay());
6.40 +
6.41 + String s = EFFORT_FORMAT.format(new Object[] {
6.42 + new Integer(d[2]), new Integer(d[1]), new Integer(d[0])
6.43 + }).trim();
6.44 + return s;
6.45 + }
6.46 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/tasklist.usertasks/src/org/netbeans/modules/tasklist/usertasks/editors/PercentsPropertyEditor.java Tue Feb 10 17:50:40 2004 +0000
7.3 @@ -0,0 +1,102 @@
7.4 +/*
7.5 + * Sun Public License Notice
7.6 + *
7.7 + * The contents of this file are subject to the Sun Public License
7.8 + * Version 1.0 (the "License"). You may not use this file except in
7.9 + * compliance with the License. A copy of the License is available at
7.10 + * http://www.sun.com/
7.11 + *
7.12 + * The Original Code is NetBeans. The Initial Developer of the Original
7.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
7.14 + * Microsystems, Inc. All Rights Reserved.
7.15 + */
7.16 +
7.17 +package org.netbeans.modules.tasklist.usertasks.editors;
7.18 +
7.19 +import java.awt.Component;
7.20 +import java.beans.PropertyEditorSupport;
7.21 +import javax.swing.JProgressBar;
7.22 +import javax.swing.UIManager;
7.23 +import org.openide.util.NbBundle;
7.24 +
7.25 +/**
7.26 + * PropertyEditor for done field.
7.27 + *
7.28 + * @author Tim Lebedkov
7.29 + */
7.30 +public class PercentsPropertyEditor extends PropertyEditorSupport {
7.31 + private static final String COMPUTED =
7.32 + NbBundle.getMessage(PercentsPropertyEditor.class, "Computed"); // NOI18N
7.33 +
7.34 + private static String[] TAGS = {
7.35 + COMPUTED,
7.36 + "0%", "5%", "10%", "15%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", // NOI18N
7.37 + "55%", "60%", "65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%" // NOI18N
7.38 + };
7.39 +
7.40 + /**
7.41 + * Used to combine 2 properties: percentComplete and progressComputed
7.42 + */
7.43 + public static final class Value {
7.44 + /** 0..100 progress of a task in percents */
7.45 + public int progress;
7.46 +
7.47 + /** true = value is computed*/
7.48 + public boolean computed;
7.49 + }
7.50 +
7.51 + private static JProgressBar progressBar;
7.52 +
7.53 + static {
7.54 + progressBar = new JProgressBar();
7.55 + progressBar.setStringPainted(true);
7.56 + progressBar.setBackground(UIManager.getColor("Table.background")); // NOI18N
7.57 + }
7.58 +
7.59 + public String[] getTags() {
7.60 + return TAGS;
7.61 + }
7.62 +
7.63 + public String getAsText() {
7.64 + Value v = (Value) getValue();
7.65 + if (v.computed)
7.66 + return COMPUTED;
7.67 + else
7.68 + return Integer.toString(v.progress);
7.69 + }
7.70 +
7.71 + public void setAsText(String text) throws java.lang.IllegalArgumentException {
7.72 + Value v = new Value();
7.73 + if (text.equals(COMPUTED)) {
7.74 + v.computed = true;
7.75 + } else {
7.76 + text = text.trim();
7.77 + if (text.endsWith("%")) // NOI18N
7.78 + text = text.substring(0, text.length() - 1);
7.79 + try {
7.80 + v.progress = Integer.parseInt(text);
7.81 + } catch(NumberFormatException e) {
7.82 + throw new IllegalArgumentException(e.getMessage());
7.83 + }
7.84 + }
7.85 + setValue(v);
7.86 + }
7.87 +
7.88 + public boolean isPaintable() {
7.89 + return true;
7.90 + }
7.91 +
7.92 + public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) {
7.93 + int n = ((Value) getValue()).progress;
7.94 + progressBar.setValue(n);
7.95 + progressBar.setString(n + "%"); // NOI18N
7.96 + int height = box.height > 15 ? 15 : box.height;
7.97 + int width = box.width > 100 ? 100 : box.width;
7.98 + int y = (box.height - height) / 2;
7.99 + progressBar.setSize(width, height);
7.100 +
7.101 + gfx.translate(box.x, box.y + y);
7.102 + progressBar.paint(gfx);
7.103 + gfx.translate(-box.x, -box.y - y);
7.104 + }
7.105 +}