summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-06-13 23:51:24 +0000
committerPaul Buetow <paul@buetow.org>2008-06-13 23:51:24 +0000
commitc30c9c6e5d278671d7df7321953c72c49bc5df0e (patch)
tree018e41ae84fe5febcc8f2dad83c2318e98a61c70 /sources
parent053ecc68889e3b4ed1afd23ec12d6ff0aea593d4 (diff)
ok, works: change PIDs and TIMEs in the task manager.
Diffstat (limited to 'sources')
-rw-r--r--sources/core/VSTask.java26
-rw-r--r--sources/events/VSAbstractEvent.java25
-rw-r--r--sources/simulator/VSSimulator.java16
3 files changed, 55 insertions, 12 deletions
diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java
index bbc9cec..c06aad2 100644
--- a/sources/core/VSTask.java
+++ b/sources/core/VSTask.java
@@ -105,12 +105,11 @@ public class VSTask implements Comparable, VSSerializable {
VSAbstractEvent event = task.getEvent();
try {
- VSAbstractEvent copy = event.getCopy();
// Use the copy of the event object
- event = copy;
+ event = event.getCopy();
+
} catch (VSEventNotCopyableException e) {
// Use the original event object
- System.out.println(e);
}
init(task.getTaskTime(),
@@ -313,9 +312,24 @@ public class VSTask implements Comparable, VSSerializable {
* @param process the process
*/
public void setProcess(VSProcess process) {
- this.process = process;
- // TODO:: use the process' specific event object
- //this.event = null;
+ /* Only do it if the process differs */
+ if (!this.process.equals(process)) {
+ this.process = process;
+
+ try {
+ // Use the copy of the event object
+ event = event.getCopy(process);
+
+ } catch (VSEventNotCopyableException e) {
+ if (event instanceof VSAbstractProtocol) {
+ String eventShortname = event.getShortname();
+ event = process.getProtocolObject(event.getClassname());
+ event.setShortname(eventShortname);
+ } else {
+ System.out.println(e);
+ }
+ }
+ }
}
/**
diff --git a/sources/events/VSAbstractEvent.java b/sources/events/VSAbstractEvent.java
index 263f21f..7f0a4e8 100644
--- a/sources/events/VSAbstractEvent.java
+++ b/sources/events/VSAbstractEvent.java
@@ -55,24 +55,41 @@ abstract public class VSAbstractEvent extends VSPrefs {
private String eventClassname;
/**
- * Creates a copy of the event.
+ * Creates a copy of the event and using a new process.
*
+ * @param newProcess The new process
* @return The copy
*/
- final public VSAbstractEvent getCopy() throws VSEventNotCopyableException {
+ final public VSAbstractEvent getCopy(VSProcess theProcess)
+ throws VSEventNotCopyableException {
+
+ if (theProcess == null)
+ theProcess = process;
+
if (!(this instanceof VSCopyableEvent))
- throw new VSEventNotCopyableException(eventShortname);
+ throw new VSEventNotCopyableException(
+ eventShortname + " (" + eventClassname + ")");
VSAbstractEvent copy =
VSRegisteredEvents.createEventInstanceByClassname(
- eventClassname, process);
+ eventClassname, theProcess);
((VSCopyableEvent) this).initCopy(copy);
+ copy.setShortname(eventShortname);
return copy;
}
/**
+ * Creates a copy of the event.
+ *
+ * @return The copy
+ */
+ final public VSAbstractEvent getCopy() throws VSEventNotCopyableException {
+ return getCopy(null);
+ }
+
+ /**
* Inits the event.
*
* @param process the process
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index ece71b0..a996ee6 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -505,13 +505,15 @@ public class VSSimulator extends JPanel implements VSSerializable {
comboBox.setSelectedIndex(0);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
- System.out.println("DFSDF ");
int index = comboBox.getSelectedIndex() - 1;
if (index >= 0) {
- VSTask task = model.getTaskAtRow(row);
+ VSTask task = model.removeTaskAtRow(row);
VSProcess process =
simulatorCanvas.getProcess(index);
task.setProcess(process);
+ taskManager.addTask(task, VSTaskManager.PROGRAMMED);
+ if (allProcessesAreSelected())
+ model.addTask(task);
}
fireEditingStopped();
@@ -1189,6 +1191,16 @@ public class VSSimulator extends JPanel implements VSSerializable {
}
/**
+ * Checks if 'all processes' is selected
+ *
+ * @return True, if 'all processes' are selected, else false
+ */
+ private boolean allProcessesAreSelected() {
+ return processesComboBox.getSelectedIndex() + 1
+ == processesComboBox.getItemCount();
+ }
+
+ /**
* Gets the selected process.
*
* @return the selected process