• R/O
  • SSH
  • HTTPS

freegantt: Commit


Commit MetaInfo

Révision128 (tree)
l'heure2012-09-18 15:48:50
Auteurmonolith52

Message de Log

グループタスクの概念を変更
undo/redoについて再整理/リファクタリング中

Change Summary

Modification

--- trunk/locale/language.en.xml (revision 127)
+++ trunk/locale/language.en.xml (revision 128)
@@ -66,8 +66,8 @@
6666
6767 <listRemoveTask>Remove</listRemoveTask>
6868 <listInsertTask>Insert</listInsertTask>
69-<listLevelUp>Level Up</listLevelUp>
70-<listLevelDown>Level Down</listLevelDown>
69+<listLevelUp>Indent</listLevelUp>
70+<listLevelDown>Outdent</listLevelDown>
7171 <listColumnName>Name</listColumnName>
7272 <listColumnResource>Resource</listColumnResource>
7373 <listColumnPeriod>Duration</listColumnPeriod>
--- trunk/locale/language.ja.xml (revision 127)
+++ trunk/locale/language.ja.xml (revision 128)
@@ -66,8 +66,8 @@
6666
6767 <listRemoveTask>削除</listRemoveTask>
6868 <listInsertTask>挿入</listInsertTask>
69-<listLevelUp>レベルを上げる</listLevelUp>
70-<listLevelDown>レベルを下げる</listLevelDown>
69+<listLevelUp>インデント</listLevelUp>
70+<listLevelDown>アウトデント</listLevelDown>
7171 <listColumnName>タスク名</listColumnName>
7272 <listColumnResource>リソース</listColumnResource>
7373 <listColumnPeriod>工期</listColumnPeriod>
--- trunk/src/jp/sourceforge/freegantt/swing/HolidayRootPane.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/swing/HolidayRootPane.java (revision 128)
@@ -22,6 +22,7 @@
2222 import javax.swing.event.TableModelEvent;
2323 import javax.swing.event.TableModelListener;
2424 import javax.swing.table.TableModel;
25+import javax.swing.undo.CompoundEdit;
2526
2627 import jp.sourceforge.freegantt.locale.Resource;
2728 import jp.sourceforge.freegantt.util.WrapLayout;
@@ -78,9 +79,15 @@
7879 tableModel.addTableModelListener(new TableModelListener(){
7980 @Override
8081 public void tableChanged(TableModelEvent e) {
81- HolidayRootPane.this.app.getProject().update();
82- HolidayRootPane.this.app.getProject().getTaskTableModel().fireTableChanged();
83- additionalTable.repaint();
82+ CompoundEdit compound = new CompoundEdit();
83+ app.getProject().getUndoManager().addEdit(compound);
84+ try {
85+ HolidayRootPane.this.app.getProject().update();
86+ HolidayRootPane.this.app.getProject().getTaskTableModel().fireTableChanged();
87+ } finally {
88+ compound.end();
89+ additionalTable.repaint();
90+ }
8491 }
8592 });
8693
--- trunk/src/jp/sourceforge/freegantt/swing/TaskListTable.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/swing/TaskListTable.java (revision 128)
@@ -20,6 +20,7 @@
2020 import java.util.ArrayList;
2121 import java.util.List;
2222
23+import javax.swing.AbstractAction;
2324 import javax.swing.DefaultCellEditor;
2425 import javax.swing.JComponent;
2526 import javax.swing.JMenuItem;
@@ -223,12 +224,23 @@
223224 repaint();
224225 }
225226
226- final Task task = project.getTaskAtRow(row);
227- boolean isAvailableLevelUp = (task != null);
228- boolean isAvailableLevelDown = (task != null && task.getLevel() > 0);
227+// final Task task = project.getTaskAtRow(row);
228+// boolean isAvailableLevelUp = (task != null);
229+// boolean isAvailableLevelDown = (task != null && task.getLevel() > 0);
230+ boolean isAvailableLevelUp = true;
231+ boolean isAvailableLevelDown = true;
229232
230233 JPopupMenu menu = new JPopupMenu();
231- JMenuItem item = new JMenuItem(Resource.get("listRemoveTask"));
234+ JMenuItem item = new JMenuItem(Resource.get("listLevelUp"));
235+ item.setEnabled(isAvailableLevelUp);
236+ item.addActionListener(new LevelUpAction());
237+ menu.add(item);
238+ item = new JMenuItem(Resource.get("listLevelDown"));
239+ item.setEnabled(isAvailableLevelDown);
240+ item.addActionListener(new LevelDownAction());
241+ menu.add(item);
242+ menu.addSeparator();
243+ item = new JMenuItem(Resource.get("listRemoveTask"));
232244 item.addActionListener(new ActionListener(){
233245 @Override
234246 public void actionPerformed(ActionEvent e) {
@@ -253,29 +265,6 @@
253265 item = new JMenuItem(Resource.get("menuEditPaste"));
254266 item.addActionListener(app.getMenu().getPasteAction());
255267 menu.add(item);
256- menu.addSeparator();
257- item = new JMenuItem(Resource.get("listLevelUp"));
258- item.setEnabled(isAvailableLevelUp);
259- item.addActionListener(new ActionListener(){
260- @Override
261- public void actionPerformed(ActionEvent e) {
262- project.getController().levelUpTask(task);
263- project.update();
264- tableModel.fireTableChanged();
265- }
266- });
267- menu.add(item);
268- item = new JMenuItem(Resource.get("listLevelDown"));
269- item.setEnabled(isAvailableLevelDown);
270- item.addActionListener(new ActionListener(){
271- @Override
272- public void actionPerformed(ActionEvent e) {
273- project.getController().levelDownTask(task);
274- project.update();
275- tableModel.fireTableChanged();
276- }
277- });
278- menu.add(item);
279268 menu.show(this, e.getX(), e.getY());
280269 }
281270
@@ -539,6 +528,46 @@
539528 }
540529 }
541530
531+ class LevelUpAction extends AbstractAction {
532+ private static final long serialVersionUID = 785583037631700955L;
533+
534+ @Override
535+ public void actionPerformed(ActionEvent e) {
536+ CompoundEdit compound = new CompoundEdit();
537+ project.getUndoManager().addEdit(compound);
538+
539+ try {
540+ int[] rows = getSelectedRows();
541+ for (int row: rows) {
542+ project.getController().levelUpTask(project.getTaskAtRow(row));
543+ }
544+ } finally {
545+ compound.end();
546+ tableModel.fireTableChanged();
547+ }
548+ }
549+ }
550+
551+ class LevelDownAction extends AbstractAction {
552+ private static final long serialVersionUID = 785583037631700955L;
553+
554+ @Override
555+ public void actionPerformed(ActionEvent e) {
556+ CompoundEdit compound = new CompoundEdit();
557+ project.getUndoManager().addEdit(compound);
558+
559+ try {
560+ int[] rows = getSelectedRows();
561+ for (int row: rows) {
562+ project.getController().levelDownTask(project.getTaskAtRow(row));
563+ }
564+ } finally {
565+ compound.end();
566+ tableModel.fireTableChanged();
567+ }
568+ }
569+ }
570+
542571 class ProjectViewChangedHandler implements ProjectViewChangedListener {
543572
544573 @Override
--- trunk/src/jp/sourceforge/freegantt/swing/TaskLineDataPane.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/swing/TaskLineDataPane.java (revision 128)
@@ -558,7 +558,6 @@
558558
559559 dragOperation = OPERATION_NONE;
560560 floatingTask = null;
561- project.update();
562561 repaintProject();
563562 return true;
564563 } else if (dragOperation == OPERATION_TASK_PERIOD) {
@@ -572,7 +571,6 @@
572571
573572 dragOperation = OPERATION_NONE;
574573 floatingTask = null;
575- project.update();
576574 repaintProject();
577575 return true;
578576 } else if (dragOperation == OPERATION_TASK_COMPLETION) {
@@ -586,7 +584,6 @@
586584
587585 dragOperation = OPERATION_NONE;
588586 floatingTask = null;
589- project.update();
590587 repaintProject();
591588 return true;
592589 }
@@ -596,7 +593,7 @@
596593 public Pair<Integer, Task> getOperation(MouseEvent e) {
597594 int row = getRowAtPoint(e.getPoint());
598595 Task task = project.getTaskAtRow(row);
599- if (task != null && task.isParent())
596+ if (task != null && task.isGroup())
600597 return new Pair<Integer, Task>(OPERATION_NONE, null);
601598 if (task == null || task.getStartDate() == null)
602599 return new Pair<Integer, Task>(OPERATION_TASK_CREATE, null);
@@ -659,7 +656,7 @@
659656
660657 if (task.isMilestone()) {
661658 drawMilestone(g, task, false);
662- } else if (task.isParent()) {
659+ } else if (task.isGroup()) {
663660 drawParentTask(g, task);
664661 } else {
665662 drawBasicTask(g, task, false);
@@ -831,9 +828,9 @@
831828 project.getUndoManager().addEdit(compound);
832829 try {
833830 project.getController().addRestriction(targetTask, detTask);
831+ project.update();
834832 } finally {
835833 compound.end();
836- project.update();
837834 repaintProject();
838835 }
839836 }
--- trunk/src/jp/sourceforge/freegantt/swing/TaskNameCellRenderer.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/swing/TaskNameCellRenderer.java (revision 128)
@@ -57,7 +57,7 @@
5757 }
5858
5959 public Rectangle getFoldRect() {
60- if (!task.isParent()) return null;
60+ if (!task.isGroup()) return null;
6161
6262 int offsetLeft = getBorderInsets(component).left;
6363 return new Rectangle(
@@ -79,8 +79,8 @@
7979 @Override
8080 public Insets getBorderInsets(Component c) {
8181 Insets result = (Insets)insets.clone();
82- if (task.isParent()) result.left += 15;
83- result.left += (project.getMaxLevel() - task.getLevel()) * INDENT_WIDTH;
82+ if (task.isGroup()) result.left += 15;
83+ result.left += task.getLevel() * INDENT_WIDTH;
8484 return result;
8585 }
8686
--- trunk/src/jp/sourceforge/freegantt/data/model/TaskListTableModel.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/data/model/TaskListTableModel.java (revision 128)
@@ -85,7 +85,7 @@
8585 if (columnIndex == 0) return false;
8686
8787 Task task = project.getTaskAtRow(rowIndex);
88- if (task != null && task.isParent()) {
88+ if (task != null && task.isGroup()) {
8989 if (PARENT_UNEDITABLE.contains(columnIndex)) return false;
9090 } else if (task != null && task.isMilestone()) {
9191 if (MILESTONE_UNEDITABLE.contains(columnIndex)) return false;
@@ -174,9 +174,9 @@
174174 }
175175
176176 project.getController().setTaskAtRow(newTask, rowIndex);
177+ project.update();
177178 } finally {
178179 compound.end();
179- project.update();
180180
181181 for (TableModelListener listener: tableModelListeners) {
182182 TableModelEvent e = new TableModelEvent(this, rowIndex, rowIndex, columnIndex, TableModelEvent.UPDATE);
--- trunk/src/jp/sourceforge/freegantt/data/Task.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/data/Task.java (revision 128)
@@ -29,6 +29,8 @@
2929 Integer realPeriod;
3030 /** クリティカルパスフラグ */
3131 boolean criticalPath = false;
32+ /** グループタスクフラグ */
33+ boolean group = false;
3234
3335 public Task clone() {
3436 try {
@@ -106,9 +108,12 @@
106108 public void setCompletion(int completion) {
107109 this.completion = Math.min(Math.max(completion, 0), 100);
108110 }
109- public boolean isParent() {
110- return level > 0;
111+ public boolean isGroup() {
112+ return group;
111113 }
114+ public void setGroup(boolean flag) {
115+ this.group = flag;
116+ }
112117 public boolean isMilestone() {
113118 return (period == null || period == 0) && (realPeriod == null || realPeriod == 0);
114119 }
@@ -145,4 +150,9 @@
145150 }
146151 }
147152
153+
154+ public void removeRestriction(Task targetTask) {
155+ restrictions.remove(targetTask);
156+ }
157+
148158 }
--- trunk/src/jp/sourceforge/freegantt/data/controller/ProjectController.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/data/controller/ProjectController.java (revision 128)
@@ -74,9 +74,9 @@
7474 removeDestRestrictions(targetTask);
7575 compound.addEdit(new RemoveTaskEdit(project, row));
7676 if (targetTask != null) project.getTasks().remove(targetTask);
77+ project.update();
7778 } finally {
7879 compound.end();
79- project.update();
8080 project.getTaskTableModel().fireTableChanged();
8181 }
8282 }
@@ -94,14 +94,13 @@
9494
9595 getUndoManager().addEdit(new InsertTaskEdit(project, newTask, row));
9696 project.getTasks().add(project.getIndexFromRow(row), newTask);
97+ project.update();
9798 } finally {
9899 compound.end();
99- project.update();
100100 project.getTaskTableModel().fireTableChanged();
101101 }
102102 }
103103
104-
105104 /**
106105 * 指定した行のタスクを差し替える
107106 * 必要があれば指定行までのパディングを行う
@@ -109,7 +108,7 @@
109108 * @param task
110109 * @param row
111110 */
112- public void setTaskAtRow(Task newTask, int row) {
111+ public void setTaskAtRow(Task newTask, int row, boolean isOnUpdate) {
113112 if (newTask == null) newTask = new Task();
114113 CompoundEdit compound = new CompoundEdit();
115114 getUndoManager().addEdit(compound);
@@ -131,11 +130,16 @@
131130 newTask,
132131 row));
133132 project.getTasks().set(index, newTask);
133+ if (!isOnUpdate) project.update();
134134 } finally {
135135 compound.end();
136136 }
137137 }
138138
139+ public void setTaskAtRow(Task newTask, int row) {
140+ setTaskAtRow(newTask, row, false);
141+ }
142+
139143 /**
140144 * 指定行まで空タスクで埋める
141145 * @param row
@@ -175,6 +179,8 @@
175179 project.getRowByTask(src),
176180 project.getRowByTask(dst)));
177181 src.addRestriction(dst);
182+ project.update();
183+ project.getTaskTableModel().fireTableChanged();
178184 } finally {
179185 compound.end();
180186 }
@@ -181,6 +187,28 @@
181187 }
182188
183189 /**
190+ * 制約を削除する
191+ * @param src
192+ * @param dst
193+ */
194+ public void removeRestriction(Task src, Task dst) {
195+ CompoundEdit compound = new CompoundEdit();
196+ project.getUndoManager().addEdit(compound);
197+ try {
198+ setModified(true);
199+
200+ compound.addEdit(new RemoveRestrictioinEdit(project,
201+ project.getRowByTask(src),
202+ project.getRowByTask(dst)));
203+ src.removeRestriction(dst);
204+ project.update();
205+ project.getTaskTableModel().fireTableChanged();
206+ } finally {
207+ compound.end();
208+ }
209+ }
210+
211+ /**
184212 * 全ての制約先から対象タスクを削除する
185213 * @param task
186214 */
@@ -196,9 +224,9 @@
196224 project.getRowByTask(src), project.getRowByTask(task)));
197225 src.getRestrictions().remove(task);
198226 }
227+ project.update();
199228 } finally {
200229 compound.end();
201- project.update();
202230 }
203231 }
204232
@@ -217,9 +245,9 @@
217245 project.getRowByTask(task), project.getRowByTask(dst)));
218246 }
219247 task.getRestrictions().clear();
248+ project.update();
220249 } finally {
221250 compound.end();
222- project.update();
223251 }
224252 }
225253
@@ -235,14 +263,10 @@
235263 setModified(true);
236264
237265 int row = project.getRowByTask(task);
238- int index = project.getIndexByTask(task);
239266 Task newTask = task.clone();
240267 newTask.setLevel(task.getLevel() + 1);
241-
242- compound.addEdit(new UpdateTaskEdit(project,
243- newTask,
244- row));
245- project.getTasks().set(index, newTask);
268+
269+ setTaskAtRow(newTask, row);
246270 } finally {
247271 compound.end();
248272 }
@@ -261,14 +285,12 @@
261285 setModified(true);
262286
263287 int row = project.getRowByTask(task);
264- int index = project.getIndexByTask(task);
265288 Task newTask = task.clone();
266289 newTask.setLevel(task.getLevel() - 1);
267-
268- compound.addEdit(new UpdateTaskEdit(project,
269- newTask,
270- row));
271- project.getTasks().set(index, newTask);
290+
291+ setTaskAtRow(newTask, row);
292+
293+ project.update();
272294 } finally {
273295 compound.end();
274296 }
@@ -308,9 +330,9 @@
308330 } else {
309331 project.getFixedHolidays().remove(new Integer(week));
310332 }
333+ project.update();
311334 } finally {
312335 compound.end();
313- project.update();
314336 project.getTaskTableModel().fireTableChanged();
315337 project.getHolidayTableModel().fireTableChanged();
316338 }
@@ -329,9 +351,9 @@
329351
330352 compound.addEdit(new CreateAdditionalHolidayEdit(project, calendar, row));
331353 project.getAdditionalHolidays().add(row, calendar);
354+ project.update();
332355 } finally {
333356 compound.end();
334- project.update();
335357 project.getTaskTableModel().fireTableChanged();
336358 project.getHolidayTableModel().fireTableChanged();
337359 }
@@ -354,9 +376,9 @@
354376
355377 compound.addEdit(new RemoveAdditionalHolidayEdit(project, row));
356378 project.getAdditionalHolidays().remove(row);
379+ project.update();
357380 } finally {
358381 compound.end();
359- project.update();
360382 project.getTaskTableModel().fireTableChanged();
361383 project.getHolidayTableModel().fireTableChanged();
362384 }
@@ -385,9 +407,9 @@
385407
386408 compound.addEdit(new UpdateAdditionalHolidayEdit(project, calendar, row));
387409 project.getAdditionalHolidays().get(row).setTime(calendar.getTime());
410+ project.update();
388411 } finally {
389412 compound.end();
390- project.update();
391413 project.getTaskTableModel().fireTableChanged();
392414 project.getHolidayTableModel().fireTableChanged();
393415 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/CreateRestrictionEdit.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/CreateRestrictionEdit.java (revision 128)
@@ -26,9 +26,7 @@
2626 super.undo();
2727 Task srcTask = project.getTaskAtRow(srcRow);
2828 Task dstTask = project.getTaskAtRow(dstRow);
29- srcTask.getRestrictions().remove(dstTask);
30- project.update();
31- project.getTaskTableModel().fireTableChanged();
29+ project.getController().removeRestriction(srcTask, dstTask);
3230 }
3331
3432 @Override
@@ -36,9 +34,7 @@
3634 super.redo();
3735 Task srcTask = project.getTaskAtRow(srcRow);
3836 Task dstTask = project.getTaskAtRow(dstRow);
39- srcTask.getRestrictions().add(dstTask);
40- project.update();
41- project.getTaskTableModel().fireTableChanged();
37+ project.getController().addRestriction(srcTask, dstTask);
4238 }
4339
4440 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskEdit.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskEdit.java (revision 128)
@@ -1,5 +1,8 @@
11 package jp.sourceforge.freegantt.data.undo;
22
3+import java.util.ArrayList;
4+import java.util.List;
5+
36 import javax.swing.undo.AbstractUndoableEdit;
47 import javax.swing.undo.CannotRedoException;
58 import javax.swing.undo.CannotUndoException;
@@ -14,7 +17,9 @@
1417
1518 int row;
1619 Task oldTask;
20+ List<Integer> oldRestrictionRows;
1721 Task newTask;
22+ List<Integer> newRestrictionRows;
1823
1924 public UpdateTaskEdit(Project project, Task newTask, int row) {
2025 this.project = project;
@@ -22,11 +27,33 @@
2227 this.row = row;
2328 this.oldTask = project.getTaskAtRow(row).clone();
2429 this.newTask = newTask.clone();
30+ oldRestrictionRows = collectRestrictionRows(oldTask);
31+ newRestrictionRows = collectRestrictionRows(newTask);
2532 }
33+
34+ protected List<Integer> collectRestrictionRows(Task targetTask) {
35+ List<Integer> list = new ArrayList<Integer>();
36+ if (targetTask == null) return list;
37+ for (Task task: targetTask.getRestrictions()) {
38+ int row = project.getRowByTask(task);
39+ if (row >= 0) list.add(row);
40+ }
41+ return list;
42+ }
43+
44+ protected List<Task> collectTasksAtRows(List<Integer> rows) {
45+ List<Task> tasks = new ArrayList<Task>();
46+ for (int row: rows) {
47+ Task task = project.getTaskAtRow(row);
48+ if (task != null) tasks.add(task);
49+ }
50+ return tasks;
51+ }
2652
2753 @Override
2854 public void undo() throws CannotUndoException {
2955 super.undo();
56+ oldTask.setRestrictions(collectTasksAtRows(oldRestrictionRows));
3057 project.getController().setTaskAtRow(oldTask, row);
3158 project.update();
3259 project.getTaskTableModel().fireTableChanged();
@@ -35,6 +62,7 @@
3562 @Override
3663 public void redo() throws CannotRedoException {
3764 super.redo();
65+ newTask.setRestrictions(collectTasksAtRows(newRestrictionRows));
3866 project.getController().setTaskAtRow(newTask, row);
3967 project.update();
4068 project.getTaskTableModel().fireTableChanged();
--- trunk/src/jp/sourceforge/freegantt/data/Project.java (revision 127)
+++ trunk/src/jp/sourceforge/freegantt/data/Project.java (revision 128)
@@ -239,7 +239,7 @@
239239 public int compare(Task lhs, Task rhs) {
240240 if (lhs == null || rhs == null) return -1;
241241 if (lhs.getLevel() == rhs.getLevel()) return 0;
242- return (lhs.getLevel() > rhs.getLevel()) ? 1 : -1;
242+ return (lhs.getLevel() > rhs.getLevel()) ? -1 : 1;
243243 }
244244 });
245245
@@ -246,7 +246,8 @@
246246
247247 // 階層の深いものから実質工期を求める
248248 for (Task task: sortedTasks) {
249- if (task.isParent()) {
249+ task.setGroup(!getChildTasks(task).isEmpty());
250+ if (task.isGroup()) {
250251 updateParentPeriod(task);
251252 } else if (task.isMilestone()) {
252253 updateMilestone(task);
@@ -285,7 +286,7 @@
285286 }
286287
287288 public void updateChildrenPeriod(Task task) {
288- if (task.isParent()) return;
289+ if (task.isGroup()) return;
289290
290291 if (task.getStartDate() == null) return;
291292 if (task.getPeriod() == null) task.setPeriod(0);
@@ -305,6 +306,7 @@
305306
306307 task.setRealPeriod(realPeriod);
307308 }
309+
308310
309311 /**
310312 * 子タスクを集めて返す
@@ -312,20 +314,15 @@
312314 */
313315 public List<Task> getChildTasks(Task targetTask) {
314316 List<Task> childTasks = new ArrayList<Task>();
315- if (targetTask.getLevel() == 0) return childTasks;
316-
317- boolean found = false;
318- for (Task task: tasks) {
319- if (targetTask == task) {
320- found = true;
321- continue;
322- }
323- if (!found) continue;
324- if (task.getLevel() >= targetTask.getLevel()) break;
325-
317+ int index = getIndexByTask(targetTask);
318+ index ++;
319+
320+ while (index < tasks.size()) {
321+ Task task = getTaskAtIndex(index);
322+ if (task.getLevel() <= targetTask.getLevel()) return childTasks;
326323 childTasks.add(task);
324+ index++;
327325 }
328-
329326 return childTasks;
330327 }
331328
@@ -335,18 +332,17 @@
335332 * @return
336333 */
337334 private Task getParentTask(Task targetTask) {
338- if (targetTask.getLevel() == maxLevel) return null;
335+ if (targetTask.getLevel() == 0) return null;
339336
340- Task parentTask = null;
341- for (Task task: tasks) {
342- if (task == targetTask) break;
343-
344- if (task.getLevel() > targetTask.getLevel()) {
345- parentTask = task;
346- }
337+ int index = getIndexByTask(targetTask);
338+ index--;
339+ while (index >= 0) {
340+ Task task = getTaskAtIndex(index);
341+ if (task.getLevel() < targetTask.getLevel()) return task;
342+ index--;
347343 }
348344
349- return parentTask;
345+ return null;
350346 }
351347
352348 /**
@@ -356,10 +352,11 @@
356352 * @param task
357353 */
358354 public void updateParentPeriod(Task task) {
359- if (!task.isParent()) return;
360- task.setStartDate(null);
361- task.setPeriod(null);
362- task.setRealPeriod(null);
355+ if (!task.isGroup()) return;
356+ Task updateTask = task.clone();
357+ updateTask.setStartDate(null);
358+ updateTask.setPeriod(null);
359+ updateTask.setRealPeriod(null);
363360
364361 { // 工期の計算
365362 long from = Long.MAX_VALUE;
@@ -382,9 +379,9 @@
382379
383380 Calendar startDate = Calendar.getInstance();
384381 startDate.setTimeInMillis(from);
385- task.setStartDate(startDate);
386- task.setPeriod(CalendarUtil.subDate(CalendarUtil.toDateCalendar(to), CalendarUtil.toDateCalendar(from)));
387- task.setRealPeriod(task.getPeriod());
382+ updateTask.setStartDate(startDate);
383+ updateTask.setPeriod(CalendarUtil.subDate(CalendarUtil.toDateCalendar(to), CalendarUtil.toDateCalendar(from)));
384+ updateTask.setRealPeriod(updateTask.getPeriod());
388385 }
389386
390387 { // 達成率の計算
@@ -392,14 +389,19 @@
392389 double completePeriod = 0;
393390 List<Task> children = getChildTasks(task);
394391 for (Task child: children) {
395- if (child.isParent()) continue;
392+ if (child.isGroup()) continue;
396393 if (child.getPeriod() == null || child.getPeriod() <= 0) continue;
397394 wholePeriod += child.getPeriod();
398395 completePeriod += (double)(child.getPeriod() * child.getCompletion()) / 100.0;
399396 }
400- task.setCompletion((int)(completePeriod * 100.0 / wholePeriod));
397+ updateTask.setCompletion((int)(completePeriod * 100.0 / wholePeriod));
401398 }
402399
400+ if (!updateTask.equals(task)) {
401+ System.out.println("Group Task updated: " + updateTask.getName());
402+ // この仲ではupdateが呼ばれない
403+ getController().setTaskAtRow(updateTask, getRowByTask(task), true);
404+ }
403405 }
404406
405407 /**
@@ -542,19 +544,6 @@
542544 }
543545
544546 /**
545- * 個別休日を削除し、関連したタスクの実質期間を再計算する
546- * @param index
547- */
548- public void removeAdditionalHoliday(int index) {
549- if (index >= additionalHolidays.size()) return;
550-
551- additionalHolidays.remove(index);
552- update();
553- getHolidayTableModel().fireTableChanged();
554- getTaskTableModel().fireTableChanged();
555- }
556-
557- /**
558547 * 現在のタスクデータから描画するべき範囲の初期値を決める
559548 * タスクが空であれば本日を基準とする。
560549 */
Afficher sur ancien navigateur de dépôt.