• R/O
  • SSH
  • HTTPS

freegantt: Commit


Commit MetaInfo

Révision131 (tree)
l'heure2012-09-18 20:37:08
Auteurmonolith52

Message de Log

リファクタリングここまで
Undo/Redoを全体的に整理

Change Summary

Modification

--- trunk/src/jp/sourceforge/freegantt/swing/HolidayRootPane.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/swing/HolidayRootPane.java (revision 131)
@@ -63,7 +63,14 @@
6363 checkBox.addActionListener(new ActionListener(){
6464 @Override
6565 public void actionPerformed(ActionEvent e) {
66- app.getProject().getController().setFixedHoliday(week, checkBox.isSelected());
66+ CompoundEdit compound = new CompoundEdit();
67+ app.getProject().getUndoManager().addEdit(compound);
68+ try {
69+ app.getProject().getController().setFixedHoliday(week, checkBox.isSelected());
70+ app.getProject().update();
71+ } finally {
72+ compound.end();
73+ }
6774 }
6875 });
6976 fixedList.add(checkBox);
--- trunk/src/jp/sourceforge/freegantt/swing/HolidayTable.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/swing/HolidayTable.java (revision 131)
@@ -51,6 +51,7 @@
5151 app.getProject().getController().removeAdditionalHoliday(row - deleted);
5252 deleted ++;
5353 }
54+ app.getProject().update();
5455 } finally {
5556 compound.end();
5657 }
--- trunk/src/jp/sourceforge/freegantt/swing/TaskListTable.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/swing/TaskListTable.java (revision 131)
@@ -135,6 +135,7 @@
135135 System.out.println("DataPane setPreferredSize: " + taskLineDataPane.getWidth() + "," + getTaskListTableModel().getRowCount() * 16);
136136 }
137137
138+ repaint();
138139
139140 if (app.getTaskListRootPane() != null) {
140141 app.getTaskListRootPane().getViewport().validate();
@@ -184,6 +185,7 @@
184185 project.getController().removeIndex(project.getIndexFromRow(row));
185186 deleted ++;
186187 }
188+ project.update();
187189 } finally {
188190 compound.end();
189191 }
@@ -205,6 +207,7 @@
205207 inserted ++;
206208 preSelected = s;
207209 }
210+ project.update();
208211 } finally {
209212 compound.end();
210213 }
@@ -345,16 +348,23 @@
345348 Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
346349 String data = (String)clip.getData(DataFlavor.stringFlavor);
347350
348- int[] selectedRows = getSelectedRows();
349- int baseRow = (selectedRows.length > 0 ? selectedRows[0] : 0);
350- String[] lines = data.split("\n");
351- for (int l=0; l<lines.length; l++) {
352- String line = lines[l];
353- String[] fragments = line.split("\t");
354- project.getController().insertTaskAtIndex(new Task(), project.getIndexFromRow(baseRow + l));
355- for (int f=0; f<fragments.length; f++) {
356- setValueAt(fragments[f], baseRow + l, f);
351+ CompoundEdit compound = new CompoundEdit();
352+ project.getUndoManager().addEdit(compound);
353+ try {
354+ int[] selectedRows = getSelectedRows();
355+ int baseRow = (selectedRows.length > 0 ? selectedRows[0] : 0);
356+ String[] lines = data.split("\n");
357+ for (int l=0; l<lines.length; l++) {
358+ String line = lines[l];
359+ String[] fragments = line.split("\t");
360+ project.getController().insertTaskAtIndex(new Task(), project.getIndexFromRow(baseRow + l));
361+ for (int f=0; f<fragments.length; f++) {
362+ setValueAt(fragments[f], baseRow + l, f);
363+ }
357364 }
365+ project.update();
366+ } finally {
367+ compound.end();
358368 }
359369 }
360370
@@ -541,6 +551,7 @@
541551 for (int row: rows) {
542552 project.getController().levelUpTask(project.getTaskAtRow(row));
543553 }
554+ project.update();
544555 } finally {
545556 compound.end();
546557 tableModel.fireTableChanged();
@@ -561,6 +572,7 @@
561572 for (int row: rows) {
562573 project.getController().levelDownTask(project.getTaskAtRow(row));
563574 }
575+ project.update();
564576 } finally {
565577 compound.end();
566578 tableModel.fireTableChanged();
--- trunk/src/jp/sourceforge/freegantt/swing/TaskLineDataPane.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/swing/TaskLineDataPane.java (revision 131)
@@ -577,6 +577,7 @@
577577 project.update();
578578 } finally {
579579 compound.end();
580+ project.getTaskTableModel().fireTableChanged();
580581 }
581582
582583 dragOperation = OPERATION_NONE;
@@ -845,6 +846,7 @@
845846 project.getController().removeSrcRestrictions(task);
846847 repaintProject();
847848 }
849+ project.update();
848850 } finally {
849851 compound.end();
850852 }
--- trunk/src/jp/sourceforge/freegantt/swing/TaskLineHeaderPane.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/swing/TaskLineHeaderPane.java (revision 131)
@@ -17,6 +17,7 @@
1717 import javax.swing.JPanel;
1818 import javax.swing.JPopupMenu;
1919 import javax.swing.JScrollBar;
20+import javax.swing.undo.CompoundEdit;
2021
2122 import jp.sourceforge.freegantt.locale.Resource;
2223 import jp.sourceforge.freegantt.util.CalendarUtil;
@@ -180,7 +181,14 @@
180181 item.addActionListener(new ActionListener(){
181182 @Override
182183 public void actionPerformed(ActionEvent e) {
183- app.getProject().getController().addAdditionalHoliday(calendar);
184+ CompoundEdit compound = new CompoundEdit();
185+ app.getProject().getUndoManager().addEdit(compound);
186+ try {
187+ app.getProject().getController().addAdditionalHoliday(calendar);
188+ app.getProject().update();
189+ } finally {
190+ compound.end();
191+ }
184192 }
185193 });
186194 menu.add(item);
@@ -189,7 +197,14 @@
189197 item.addActionListener(new ActionListener(){
190198 @Override
191199 public void actionPerformed(ActionEvent e) {
192- app.getProject().getController().removeAdditionalHoliday(calendar);
200+ CompoundEdit compound = new CompoundEdit();
201+ app.getProject().getUndoManager().addEdit(compound);
202+ try {
203+ app.getProject().getController().removeAdditionalHoliday(calendar);
204+ app.getProject().update();
205+ } finally {
206+ compound.end();
207+ }
193208 }
194209 });
195210 menu.add(item);
--- trunk/src/jp/sourceforge/freegantt/swing/ApplicationMenu.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/swing/ApplicationMenu.java (revision 131)
@@ -320,6 +320,7 @@
320320 public void actionPerformed(ActionEvent e) {
321321 if (app.getProject().getUndoManager().canUndo()) {
322322 app.getProject().getUndoManager().undo();
323+ app.getProject().getTaskTableModel().fireTableChanged();
323324 }
324325 }
325326 }
@@ -331,6 +332,7 @@
331332 public void actionPerformed(ActionEvent e) {
332333 if (app.getProject().getUndoManager().canRedo()) {
333334 app.getProject().getUndoManager().redo();
335+ app.getProject().getTaskTableModel().fireTableChanged();
334336 }
335337 }
336338 }
--- trunk/src/jp/sourceforge/freegantt/data/model/HolidayTableModel.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/model/HolidayTableModel.java (revision 131)
@@ -8,6 +8,7 @@
88 import javax.swing.event.TableModelEvent;
99 import javax.swing.event.TableModelListener;
1010 import javax.swing.table.TableModel;
11+import javax.swing.undo.CompoundEdit;
1112
1213 import jp.sourceforge.freegantt.data.Project;
1314 import jp.sourceforge.freegantt.locale.Resource;
@@ -68,10 +69,17 @@
6869 Calendar newCalendar = CalendarUtil.parseDate((String)aValue, Resource.getLocale());
6970 if (newCalendar == null) return;
7071
71- if (rowIndex == project.getAdditionalHolidays().size()) {
72- project.getController().addAdditionalHoliday(newCalendar, project.getAdditionalHolidays().size());
73- } else {
74- project.getController().setAdditionalHoliday(newCalendar, rowIndex);
72+ CompoundEdit compound = new CompoundEdit();
73+ project.getUndoManager().addEdit(compound);
74+ try {
75+ if (rowIndex == project.getAdditionalHolidays().size()) {
76+ project.getController().addAdditionalHoliday(newCalendar, project.getAdditionalHolidays().size());
77+ } else {
78+ project.getController().setAdditionalHoliday(newCalendar, rowIndex);
79+ }
80+ project.update();
81+ } finally {
82+ compound.end();
7583 }
7684 }
7785
--- trunk/src/jp/sourceforge/freegantt/data/controller/ProjectController.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/controller/ProjectController.java (revision 131)
@@ -30,9 +30,11 @@
3030 import jp.sourceforge.freegantt.data.undo.UpdatePrintCellSizeEdit;
3131 import jp.sourceforge.freegantt.data.undo.UpdateProjectNameEdit;
3232 import jp.sourceforge.freegantt.data.undo.UpdateProjectSummaryEdit;
33+import jp.sourceforge.freegantt.data.undo.UpdateTaskCriticalPathEdit;
3334 import jp.sourceforge.freegantt.data.undo.UpdateTaskEdit;
3435 import jp.sourceforge.freegantt.data.undo.UpdateTaskGroupEdit;
3536 import jp.sourceforge.freegantt.data.undo.UpdateTaskTableWidthEdit;
37+import jp.sourceforge.freegantt.data.undo.UpdateTaskVisibleEdit;
3638 import jp.sourceforge.freegantt.data.undo.UpdateViewTaskTableColumnsEdit;
3739 import jp.sourceforge.freegantt.util.CalendarUtil;
3840
@@ -75,7 +77,6 @@
7577 removeDestRestrictions(targetTask);
7678 compound.addEdit(new RemoveTaskEdit(project, index));
7779 if (targetTask != null) project.getTasks().remove(targetTask);
78- project.update();
7980 } finally {
8081 compound.end();
8182 project.getTaskTableModel().fireTableChanged();
@@ -95,7 +96,6 @@
9596
9697 getUndoManager().addEdit(new InsertTaskEdit(project, newTask, index));
9798 project.getTasks().add(index, newTask);
98- project.update();
9999 } finally {
100100 compound.end();
101101 project.getTaskTableModel().fireTableChanged();
@@ -132,7 +132,6 @@
132132 project.getTasks().set(index, newTask);
133133 } finally {
134134 compound.end();
135- project.getTaskTableModel().fireTableChanged();
136135 }
137136 }
138137
@@ -174,7 +173,6 @@
174173 project.getIndexByTask(src),
175174 project.getIndexByTask(dst)));
176175 src.addRestriction(dst);
177- project.update();
178176 project.getTaskTableModel().fireTableChanged();
179177 } finally {
180178 compound.end();
@@ -196,10 +194,9 @@
196194 project.getIndexByTask(src),
197195 project.getIndexByTask(dst)));
198196 src.removeRestriction(dst);
199- project.update();
200- project.getTaskTableModel().fireTableChanged();
201197 } finally {
202198 compound.end();
199+ project.getTaskTableModel().fireTableChanged();
203200 }
204201 }
205202
@@ -220,7 +217,6 @@
220217 project.getIndexByTask(task)));
221218 src.getRestrictions().remove(task);
222219 }
223- project.update();
224220 } finally {
225221 compound.end();
226222 }
@@ -242,7 +238,6 @@
242238 project.getIndexByTask(dst)));
243239 }
244240 task.getRestrictions().clear();
245- project.update();
246241 } finally {
247242 compound.end();
248243 }
@@ -264,8 +259,6 @@
264259 newTask.setLevel(task.getLevel() + 1);
265260
266261 setTaskAtIndex(newTask, index);
267-
268- project.update();
269262 } finally {
270263 compound.end();
271264 }
@@ -288,8 +281,6 @@
288281 newTask.setLevel(task.getLevel() - 1);
289282
290283 setTaskAtIndex(newTask, index);
291-
292- project.update();
293284 } finally {
294285 compound.end();
295286 }
@@ -329,7 +320,6 @@
329320 } else {
330321 project.getFixedHolidays().remove(new Integer(week));
331322 }
332- project.update();
333323 } finally {
334324 compound.end();
335325 project.getTaskTableModel().fireTableChanged();
@@ -350,7 +340,6 @@
350340
351341 compound.addEdit(new CreateAdditionalHolidayEdit(project, calendar, index));
352342 project.getAdditionalHolidays().add(index, calendar);
353- project.update();
354343 } finally {
355344 compound.end();
356345 project.getTaskTableModel().fireTableChanged();
@@ -375,7 +364,6 @@
375364
376365 compound.addEdit(new RemoveAdditionalHolidayEdit(project, index));
377366 project.getAdditionalHolidays().remove(index);
378- project.update();
379367 } finally {
380368 compound.end();
381369 project.getTaskTableModel().fireTableChanged();
@@ -406,7 +394,6 @@
406394
407395 compound.addEdit(new UpdateAdditionalHolidayEdit(project, calendar, index));
408396 project.getAdditionalHolidays().get(index).setTime(calendar.getTime());
409- project.update();
410397 } finally {
411398 compound.end();
412399 project.getTaskTableModel().fireTableChanged();
@@ -638,4 +625,38 @@
638625 compound.end();
639626 }
640627 }
628+
629+ public void setTaskCriticalPath(boolean criticalPath, int index) {
630+ Task task = project.getTaskAtIndex(index);
631+ if (task == null) return;
632+ if (task.isCriticalPath() == criticalPath) return;
633+
634+ CompoundEdit compound = new CompoundEdit();
635+ getUndoManager().addEdit(compound);
636+ try {
637+ setModified(true);
638+
639+ compound.addEdit(new UpdateTaskCriticalPathEdit(project, criticalPath, index));
640+ task.setCriticalPath(criticalPath);
641+ } finally {
642+ compound.end();
643+ }
644+ }
645+
646+ public void setTaskVisible(boolean visible, int index) {
647+ Task task = project.getTaskAtIndex(index);
648+ if (task == null) return;
649+ if (task.isVisible() == visible) return;
650+
651+ CompoundEdit compound = new CompoundEdit();
652+ getUndoManager().addEdit(compound);
653+ try {
654+ setModified(true);
655+
656+ compound.addEdit(new UpdateTaskVisibleEdit(project, visible, index));
657+ task.setVisible(visible);
658+ } finally {
659+ compound.end();
660+ }
661+ }
641662 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/CreateRestrictionEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/CreateRestrictionEdit.java (revision 131)
@@ -23,6 +23,7 @@
2323
2424 @Override
2525 public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
2627 super.undo();
2728 Task srcTask = project.getTaskAtRow(srcIndex);
2829 Task dstTask = project.getTaskAtRow(dstIndex);
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdatePrintCellSizeEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdatePrintCellSizeEdit.java (revision 131)
@@ -24,9 +24,9 @@
2424
2525 @Override
2626 public void undo() throws CannotUndoException {
27+ System.out.println("Undo " + getClass().toString());
2728 super.undo();
2829 project.getController().setPrintCellSize(oldPrintCellSize);
29- project.getTaskTableModel().fireTableChanged();
3030 }
3131
3232 @Override
@@ -33,7 +33,6 @@
3333 public void redo() throws CannotRedoException {
3434 super.redo();
3535 project.getController().setPrintCellSize(newPrintCellSize);
36- project.getTaskTableModel().fireTableChanged();
3736 }
3837
3938 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/CreateMemberEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/CreateMemberEdit.java (revision 131)
@@ -22,6 +22,7 @@
2222
2323 @Override
2424 public void undo() throws CannotUndoException {
25+ System.out.println("Undo " + getClass().toString());
2526 super.undo();
2627 project.getController().removeMember(index);
2728 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/RemoveRestrictioinEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/RemoveRestrictioinEdit.java (revision 131)
@@ -23,12 +23,11 @@
2323
2424 @Override
2525 public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
2627 super.undo();
2728 Task srcTask = project.getTaskAtIndex(srcIndex);
2829 Task dstTask = project.getTaskAtIndex(dstIndex);
2930 srcTask.getRestrictions().add(dstTask);
30- project.update();
31- project.getTaskTableModel().fireTableChanged();
3231 }
3332
3433 @Override
@@ -37,8 +36,6 @@
3736 Task srcTask = project.getTaskAtRow(srcIndex);
3837 Task dstTask = project.getTaskAtRow(dstIndex);
3938 srcTask.getRestrictions().remove(dstTask);
40- project.update();
41- project.getTaskTableModel().fireTableChanged();
4239 }
4340
4441 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskCriticalPathEdit.java (nonexistent)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskCriticalPathEdit.java (revision 131)
@@ -0,0 +1,42 @@
1+package jp.sourceforge.freegantt.data.undo;
2+
3+import javax.swing.undo.AbstractUndoableEdit;
4+import javax.swing.undo.CannotRedoException;
5+import javax.swing.undo.CannotUndoException;
6+
7+import jp.sourceforge.freegantt.data.Project;
8+
9+public class UpdateTaskCriticalPathEdit extends AbstractUndoableEdit {
10+ private static final long serialVersionUID = 5320839625323953628L;
11+
12+ Project project;
13+ boolean oldCriticalPath;
14+ boolean newCriticalPath;
15+ int index;
16+
17+ public UpdateTaskCriticalPathEdit(Project project, boolean newCriticalPath, int index) {
18+ this.project = project;
19+ this.oldCriticalPath = project.getTaskAtIndex(index).isCriticalPath();
20+ this.newCriticalPath = newCriticalPath;
21+ this.index = index;
22+ }
23+
24+ @Override
25+ public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
27+ super.undo();
28+ project.getController().setTaskCriticalPath(oldCriticalPath, index);
29+ }
30+
31+ @Override
32+ public void redo() throws CannotRedoException {
33+ super.redo();
34+ project.getController().setTaskCriticalPath(newCriticalPath, index);
35+ }
36+
37+ @Override
38+ public void die() {
39+ super.die();
40+ project = null;
41+ }
42+}
--- trunk/src/jp/sourceforge/freegantt/data/undo/RemoveAdditionalHolidayEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/RemoveAdditionalHolidayEdit.java (revision 131)
@@ -23,6 +23,7 @@
2323
2424 @Override
2525 public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
2627 super.undo();
2728 project.getController().addAdditionalHoliday(oldCalendar, index);
2829 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskEdit.java (revision 131)
@@ -17,8 +17,8 @@
1717
1818 int index;
1919 Task oldTask;
20+ Task newTask;
2021 List<Integer> oldRestrictionIndexes;
21- Task newTask;
2222 List<Integer> newRestrictionIndexes;
2323
2424 public UpdateTaskEdit(Project project, Task newTask, int index) {
@@ -27,41 +27,23 @@
2727 this.index = index;
2828 this.oldTask = project.getTaskAtIndex(index).clone();
2929 this.newTask = newTask.clone();
30- oldRestrictionIndexes = collectRestrictionIndexes(oldTask);
31- newRestrictionIndexes = collectRestrictionIndexes(newTask);
30+ oldRestrictionIndexes = project.collectRestrictionIndexes(oldTask);
31+ newRestrictionIndexes = project.collectRestrictionIndexes(newTask);
3232 }
33-
34- protected List<Integer> collectRestrictionIndexes(Task targetTask) {
35- List<Integer> list = new ArrayList<Integer>();
36- if (targetTask == null) return list;
37- for (Task task: targetTask.getRestrictions()) {
38- int index = project.getIndexByTask(task);
39- if (index >= 0) list.add(index);
40- }
41- return list;
42- }
43-
44- protected List<Task> collectTasksAtIndexes(List<Integer> indexes) {
45- List<Task> tasks = new ArrayList<Task>();
46- for (int index: indexes) {
47- Task task = project.getTaskAtIndex(index);
48- if (task != null) tasks.add(task);
49- }
50- return tasks;
51- }
5233
5334 @Override
5435 public void undo() throws CannotUndoException {
36+ System.out.println("Undo " + getClass().toString());
5537 super.undo();
56- oldTask.setRestrictions(collectTasksAtIndexes(oldRestrictionIndexes));
5738 project.getController().setTaskAtIndex(oldTask, index);
39+ oldTask.setRestrictions(project.collectTasksAtIndexes(oldRestrictionIndexes));
5840 }
5941
6042 @Override
6143 public void redo() throws CannotRedoException {
6244 super.redo();
63- newTask.setRestrictions(collectTasksAtIndexes(newRestrictionIndexes));
6445 project.getController().setTaskAtIndex(newTask, index);
46+ newTask.setRestrictions(project.collectTasksAtIndexes(newRestrictionIndexes));
6547 }
6648
6749 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/CreateAdditionalHolidayEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/CreateAdditionalHolidayEdit.java (revision 131)
@@ -23,6 +23,7 @@
2323
2424 @Override
2525 public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
2627 super.undo();
2728 project.getController().removeAdditionalHoliday(index);
2829 }
@@ -29,6 +30,7 @@
2930
3031 @Override
3132 public void redo() throws CannotRedoException {
33+ System.out.println("Redo " + getClass().toString());
3234 super.redo();
3335 project.getController().addAdditionalHoliday(newCalendar, index);
3436 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateViewTaskTableColumnsEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateViewTaskTableColumnsEdit.java (revision 131)
@@ -31,6 +31,7 @@
3131
3232 @Override
3333 public void undo() throws CannotUndoException {
34+ System.out.println("Undo " + getClass().toString());
3435 super.undo();
3536 project.getController().setViewTaskTableColumns(project, newColumns, oldColumns);
3637 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateProjectNameEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateProjectNameEdit.java (revision 131)
@@ -21,6 +21,7 @@
2121
2222 @Override
2323 public void undo() throws CannotUndoException {
24+ System.out.println("Undo " + getClass().toString());
2425 super.undo();
2526 project.getController().setName(oldText);
2627 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateMemberEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateMemberEdit.java (revision 131)
@@ -34,6 +34,7 @@
3434
3535 @Override
3636 public void undo() throws CannotUndoException {
37+ System.out.println("Undo " + getClass().toString());
3738 super.undo();
3839 project.getController().setMember(oldMember, index);
3940 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateFixedHolidayEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateFixedHolidayEdit.java (revision 131)
@@ -21,6 +21,7 @@
2121
2222 @Override
2323 public void undo() throws CannotUndoException {
24+ System.out.println("Undo " + getClass().toString());
2425 super.undo();
2526 project.getController().setFixedHoliday(week, !value);
2627 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskTableWidthEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskTableWidthEdit.java (revision 131)
@@ -21,6 +21,7 @@
2121
2222 @Override
2323 public void undo() throws CannotUndoException {
24+ System.out.println("Undo " + getClass().toString());
2425 super.undo();
2526 project.getController().setTaskTableWidth(project, newTaskTableWidth, oldTaskTableWidth);
2627 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateCellSizeEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateCellSizeEdit.java (revision 131)
@@ -23,6 +23,7 @@
2323
2424 @Override
2525 public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
2627 super.undo();
2728 project.getController().setCellSize(oldCellSize);
2829 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/RemoveTaskEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/RemoveTaskEdit.java (revision 131)
@@ -1,5 +1,7 @@
11 package jp.sourceforge.freegantt.data.undo;
22
3+import java.util.List;
4+
35 import javax.swing.undo.AbstractUndoableEdit;
46 import javax.swing.undo.CannotRedoException;
57 import javax.swing.undo.CannotUndoException;
@@ -13,6 +15,7 @@
1315 Project project;
1416 int index;
1517 Task oldTask;
18+ List<Integer> oldRestrictionIndexes;
1619
1720 public RemoveTaskEdit(Project project, int index) {
1821 this.project = project;
@@ -19,14 +22,15 @@
1922
2023 this.index = index;
2124 this.oldTask = project.getTaskAtIndex(index);
25+ oldRestrictionIndexes = project.collectRestrictionIndexes(oldTask);
2226 }
2327
2428 @Override
2529 public void undo() throws CannotUndoException {
30+ System.out.println("Undo " + getClass().toString());
2631 super.undo();
2732 project.getController().insertTaskAtIndex(oldTask, index);
28- project.update();
29- project.getTaskTableModel().fireTableChanged();
33+ oldTask.setRestrictions(project.collectTasksAtIndexes(oldRestrictionIndexes));
3034 }
3135
3236 @Override
@@ -33,8 +37,6 @@
3337 public void redo() throws CannotRedoException {
3438 super.redo();
3539 project.getController().removeIndex(index);
36- project.update();
37- project.getTaskTableModel().fireTableChanged();
3840 }
3941
4042 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateCalendarModeEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateCalendarModeEdit.java (revision 131)
@@ -21,6 +21,7 @@
2121
2222 @Override
2323 public void undo() throws CannotUndoException {
24+ System.out.println("Undo " + getClass().toString());
2425 super.undo();
2526 project.getController().setCalendarMode(oldMode);
2627 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskGroupEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskGroupEdit.java (revision 131)
@@ -23,6 +23,7 @@
2323
2424 @Override
2525 public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
2627 super.undo();
2728 project.getController().setTaskGroup(oldGroup, index);
2829 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateModifiedEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateModifiedEdit.java (revision 131)
@@ -21,6 +21,7 @@
2121
2222 @Override
2323 public void undo() throws CannotUndoException {
24+ System.out.println("Undo " + getClass().toString());
2425 super.undo();
2526 project.getController().setModified(oldFlag);
2627 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskVisibleEdit.java (nonexistent)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateTaskVisibleEdit.java (revision 131)
@@ -0,0 +1,42 @@
1+package jp.sourceforge.freegantt.data.undo;
2+
3+import javax.swing.undo.AbstractUndoableEdit;
4+import javax.swing.undo.CannotRedoException;
5+import javax.swing.undo.CannotUndoException;
6+
7+import jp.sourceforge.freegantt.data.Project;
8+
9+public class UpdateTaskVisibleEdit extends AbstractUndoableEdit {
10+ private static final long serialVersionUID = 2296955178955062184L;
11+
12+ Project project;
13+ boolean oldVisible;
14+ boolean newVisible;
15+ int index;
16+
17+ public UpdateTaskVisibleEdit(Project project, boolean newVisible, int index) {
18+ this.project = project;
19+ this.oldVisible = project.getTaskAtIndex(index).isVisible();
20+ this.newVisible = newVisible;
21+ this.index = index;
22+ }
23+
24+ @Override
25+ public void undo() throws CannotUndoException {
26+ System.out.println("Undo " + getClass().toString());
27+ super.undo();
28+ project.getController().setTaskVisible(oldVisible, index);
29+ }
30+
31+ @Override
32+ public void redo() throws CannotRedoException {
33+ super.redo();
34+ project.getController().setTaskVisible(newVisible, index);
35+ }
36+
37+ @Override
38+ public void die() {
39+ super.die();
40+ project = null;
41+ }
42+}
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateAdditionalHolidayEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateAdditionalHolidayEdit.java (revision 131)
@@ -25,6 +25,7 @@
2525
2626 @Override
2727 public void undo() throws CannotUndoException {
28+ System.out.println("Undo " + getClass().toString());
2829 super.undo();
2930 project.getController().setAdditionalHoliday(oldCalendar, index);
3031 }
--- trunk/src/jp/sourceforge/freegantt/data/undo/RemoveMemberEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/RemoveMemberEdit.java (revision 131)
@@ -31,6 +31,7 @@
3131
3232 @Override
3333 public void undo() throws CannotUndoException {
34+ System.out.println("Undo " + getClass().toString());
3435 super.undo();
3536 project.getController().addMember(oldMember, index);
3637 for (Integer index: srcTasks) {
@@ -37,7 +38,6 @@
3738 Task task = project.getTasks().get(index);
3839 task.setMember(oldMember);
3940 }
40- project.getTaskTableModel().fireTableChanged();
4141 }
4242
4343 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/CreateTaskEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/CreateTaskEdit.java (revision 131)
@@ -21,10 +21,9 @@
2121
2222 @Override
2323 public void undo() throws CannotUndoException {
24+ System.out.println("Undo " + getClass().toString());
2425 super.undo();
2526 project.getTasks().remove(project.getTasks().size() - 1);
26- project.update();
27- project.getTaskTableModel().fireTableChanged();
2827 }
2928
3029 @Override
@@ -31,8 +30,6 @@
3130 public void redo() throws CannotRedoException {
3231 super.redo();
3332 project.getTasks().add(newTask);
34- project.update();
35- project.getTaskTableModel().fireTableChanged();
3633 }
3734
3835 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/InsertTaskEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/InsertTaskEdit.java (revision 131)
@@ -1,5 +1,7 @@
11 package jp.sourceforge.freegantt.data.undo;
22
3+import java.util.List;
4+
35 import javax.swing.undo.AbstractUndoableEdit;
46 import javax.swing.undo.CannotRedoException;
57 import javax.swing.undo.CannotUndoException;
@@ -13,6 +15,7 @@
1315 Project project;
1416 int index;
1517 Task newTask;
18+ List<Integer> newRestrictionIndexes;
1619
1720 public InsertTaskEdit(Project project, Task newTask, int index) {
1821 this.project = project;
@@ -19,14 +22,14 @@
1922
2023 this.index = index;
2124 this.newTask = newTask.clone();
25+ newRestrictionIndexes = project.collectRestrictionIndexes(newTask);
2226 }
2327
2428 @Override
2529 public void undo() throws CannotUndoException {
30+ System.out.println("Undo " + getClass().toString());
2631 super.undo();
2732 project.getController().removeIndex(index);
28- project.update();
29- project.getTaskTableModel().fireTableChanged();
3033 }
3134
3235 @Override
@@ -33,8 +36,7 @@
3336 public void redo() throws CannotRedoException {
3437 super.redo();
3538 project.getController().insertTaskAtIndex(newTask, index);
36- project.update();
37- project.getTaskTableModel().fireTableChanged();
39+ newTask.setRestrictions(project.collectTasksAtIndexes(newRestrictionIndexes));
3840 }
3941
4042 @Override
--- trunk/src/jp/sourceforge/freegantt/data/undo/UpdateProjectSummaryEdit.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/undo/UpdateProjectSummaryEdit.java (revision 131)
@@ -21,6 +21,7 @@
2121
2222 @Override
2323 public void undo() throws CannotUndoException {
24+ System.out.println("Undo " + getClass().toString());
2425 super.undo();
2526 project.getController().setSummary(oldText);
2627 }
--- trunk/src/jp/sourceforge/freegantt/data/Project.java (revision 130)
+++ trunk/src/jp/sourceforge/freegantt/data/Project.java (revision 131)
@@ -261,6 +261,25 @@
261261
262262 return null;
263263 }
264+
265+ public List<Integer> collectRestrictionIndexes(Task targetTask) {
266+ List<Integer> list = new ArrayList<Integer>();
267+ if (targetTask == null) return list;
268+ for (Task task: targetTask.getRestrictions()) {
269+ int index = getIndexByTask(task);
270+ if (index >= 0) list.add(index);
271+ }
272+ return list;
273+ }
274+
275+ public List<Task> collectTasksAtIndexes(List<Integer> indexes) {
276+ List<Task> tasks = new ArrayList<Task>();
277+ for (int index: indexes) {
278+ Task task = getTaskAtIndex(index);
279+ if (task != null) tasks.add(task);
280+ }
281+ return tasks;
282+ }
264283
265284 public void update() {
266285
@@ -558,16 +577,17 @@
558577 * クリティカルパスを再計算し、フラグを立てる
559578 */
560579 public void updateCliticalPath() {
561- System.out.println("Project updateCliticalPath: ");
580+ List<Task> criticalTasks = new ArrayList<Task>();
581+ List<Task> endTasks = getEndTasks();
582+ criticalTasks.addAll(endTasks);
583+ for (Task endTask: endTasks) {
584+ criticalTasks.addAll( traceCliticalTask(endTask) );
585+ }
562586
563587 for (Task task: tasks) {
564- task.setCriticalPath(false);
588+ getController().setTaskCriticalPath(criticalTasks.contains(task), getIndexByTask(task));
589+ task.setCriticalPath(criticalTasks.contains(task));
565590 }
566-
567- List<Task> endTasks = getEndTasks();
568- for (Task endTask: endTasks) {
569- traceCliticalTask(endTask);
570- }
571591 }
572592
573593 /**
@@ -599,9 +619,9 @@
599619 * リンクされたタスクをたどってクリティカルパスフラグを立てる
600620 * @param endTask
601621 */
602- protected void traceCliticalTask(Task endTask) {
603- System.out.println("Project traceCliticalPath: " + endTask.getName());
604- endTask.setCriticalPath(true);
622+ protected List<Task> traceCliticalTask(Task endTask) {
623+ List<Task> criticalTasks = new ArrayList<Task>();
624+ criticalTasks.add(endTask);
605625
606626 List<Task> restrictionTasks = new ArrayList<Task>();
607627 for (Task task: tasks) {
@@ -617,8 +637,10 @@
617637 }
618638
619639 for (Task task: restrictionTasks) {
620- traceCliticalTask(task);
640+ criticalTasks.addAll( traceCliticalTask(task) );
621641 }
642+
643+ return criticalTasks;
622644 }
623645
624646 /**
@@ -666,12 +688,12 @@
666688 Task parent = getParentTask(targetTask);
667689 while (parent != null) {
668690 if (!parent.isOpened()) {
669- targetTask.setVisible(false);
691+ getController().setTaskVisible(false, getIndexByTask(targetTask));
670692 return;
671693 }
672694 parent = getParentTask(parent);
673695 }
674- targetTask.setVisible(true);
696+ getController().setTaskVisible(true, getIndexByTask(targetTask));
675697 }
676698
677699 public Member findFirstMemberByName(String memberName) {
Afficher sur ancien navigateur de dépôt.