diff options
| author | Paul Buetow <paul@buetow.org> | 2008-06-13 19:19:12 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-06-13 19:19:12 +0000 |
| commit | 86d37c2c10b9a0abbf1f4256333f13914c3c740b (patch) | |
| tree | 7049ef48ab696eedd306ca3321cc346f67dbfc35 | |
| parent | a9141ec1869f57d918473213628775c0f87d84fe (diff) | |
copy events works
| -rw-r--r-- | ROADMAP | 8 | ||||
| -rw-r--r-- | sources/core/VSTask.java | 12 | ||||
| -rw-r--r-- | sources/prefs/VSDefaultPrefs.java | 3 | ||||
| -rw-r--r-- | sources/simulator/VSSimulator.java | 29 |
4 files changed, 46 insertions, 6 deletions
@@ -1,7 +1,7 @@ +If Copy group of events and events changable -> make copy constructor of changed +event! Must do: Warn if a file does not exists while trying to open! - Overwrite some default values of VSPrefs while deserializing - lang.* Reliable Multicast Helper: Print warning if not activated protocol while doing a protocol request @@ -9,13 +9,11 @@ Must do: Change PID Change time Copy event - Delete group of events - Copy group of events Paint area right click: Add local event Add global event (in expert mode) - Splash screen Evtl.: + Splash screen Kapseln: Protokolle sollen nur fuer sie bestimtme methoden aufrufen koennen Periodische Tasks anlegen koennen "Himmelobjekt"? diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java index 1a5718c..daa85eb 100644 --- a/sources/core/VSTask.java +++ b/sources/core/VSTask.java @@ -96,6 +96,18 @@ public class VSTask implements Comparable, VSSerializable { } /** + * Instantiates a new task, it's a copy constructor. + * + * @param task the task to copy + */ + public VSTask(VSTask task) { + init(task.getTaskTime(), + task.getProcess(), + task.getEvent(), + !task.isGlobalTimed()); + } + + /** * Instantiates a new task during a deserialization. * * @param serialize the serialize object diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java index 312e375..e746731 100644 --- a/sources/prefs/VSDefaultPrefs.java +++ b/sources/prefs/VSDefaultPrefs.java @@ -98,7 +98,7 @@ public class VSDefaultPrefs extends VSPrefs { initString("lang.message.recv", "Nachricht erhalten"); initString("lang.message.sent", "Nachricht versendet"); initString("lang.mode.expert", "Expertenmodus"); - initString("lang.name", "VS-Simulator v0.3-devel-II"); + initString("lang.name", "VS-Simulator v0.3-dev-II Lucky Luke"); initString("lang.ok", "OK"); initString("lang.open", "Öffnen"); initString("lang.pause", "Pausieren"); @@ -136,6 +136,7 @@ public class VSDefaultPrefs extends VSPrefs { initString("lang.protocols", "Protokolle"); initString("lang.quit", "Beenden"); initString("lang.recovered", "Wiederbelebt"); + initString("lang.copy", "Kopieren"); initString("lang.remove", "Entfernen"); initString("lang.replay", "Wiederholen"); //initString("lang.requests", "Anfragen"); diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java index ac7588a..ea552f6 100644 --- a/sources/simulator/VSSimulator.java +++ b/sources/simulator/VSSimulator.java @@ -323,6 +323,26 @@ public class VSSimulator extends JPanel implements VSSerializable { fireTableDataChanged(); } + /** + * Copies the tasks at a specified rows. + * + * @param rows the rows + */ + private void copyTasksAtRows(int rows[]) { + ArrayList<VSTask> copiedTasks = new ArrayList<VSTask>(); + + for (int row : rows) + /* Use the copy constructor */ + copiedTasks.add(new VSTask(tasks.get(row))); + + for (VSTask task : copiedTasks) { + taskManager.addTask(task, VSTaskManager.PROGRAMMED); + addTask(task); + } + + fireTableDataChanged(); + } + /* (non-Javadoc) * @see java.awt.event.MouseListener#mouseClicked( * java.awt.event.MouseEvent) @@ -337,9 +357,14 @@ public class VSSimulator extends JPanel implements VSSerializable { public void actionPerformed(ActionEvent ae) { String command = ae.getActionCommand(); int rows[] = source.getSelectedRows(); + if (command.equals(prefs.getString("lang.remove"))) { for (int i = rows.length - 1; i >= 0; --i) removeTaskAtRow(rows[i]); + + } else if (command.equals( + prefs.getString("lang.copy"))) { + copyTasksAtRows(rows); } } }; @@ -349,6 +374,10 @@ public class VSSimulator extends JPanel implements VSSerializable { item.addActionListener(actionListener); popup.add(item); + item = new JMenuItem(prefs.getString("lang.copy")); + item.addActionListener(actionListener); + popup.add(item); + popup.show(me.getComponent(), me.getX(), me.getY()); } } |
