summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-06-02 01:43:11 +0000
committerPaul Buetow <paul@buetow.org>2008-06-02 01:43:11 +0000
commit16200e39c38ed76ddac954c7e005a22b6233c642 (patch)
treef4703e6359da7fbc3d5ca97e7427556777839b39 /sources
parent378c2674fc704b2a6bbf0e6a01b721a7aea7c2e2 (diff)
foo
Diffstat (limited to 'sources')
-rw-r--r--sources/core/VSProcess.java11
-rw-r--r--sources/prefs/editors/VSProcessEditor.java4
-rw-r--r--sources/simulator/VSSimulator.java4
-rw-r--r--sources/simulator/VSSimulatorCanvas.java47
4 files changed, 48 insertions, 18 deletions
diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java
index 1b88fc0..7c4ac41 100644
--- a/sources/core/VSProcess.java
+++ b/sources/core/VSProcess.java
@@ -280,7 +280,7 @@ public class VSProcess extends VSPrefs implements VSSerializable {
* Called from the VSProcessEditor, after finishing editing! This makes
* sure that the VSProcess object is using the up to date prefs!
*/
- public synchronized void updateFromVSPrefs() {
+ public synchronized void updateFromPrefs() {
setClockVariance(getFloat("process.clock.variance"));
setLocalTime(getLong("process.localtime"));
crashedColor = getColor("col.process.crashed");
@@ -1019,6 +1019,12 @@ public class VSProcess extends VSPrefs implements VSSerializable {
ObjectOutputStream objectOutputStream)
throws IOException {
super.serialize(serialize, objectOutputStream);
+
+ if (VSSerialize.DEBUG)
+ System.out.println("Serializing: VSProcess (num: " + processNum
+ + "; id: " + processID + ")");
+
+ objectOutputStream.writeObject(new Integer(processID));
objectOutputStream.writeObject(new Integer(protocolsToReset.size()));
for (VSAbstractProtocol protocol : protocolsToReset) {
objectOutputStream.writeObject(protocol.getClassname());
@@ -1035,10 +1041,13 @@ public class VSProcess extends VSPrefs implements VSSerializable {
ObjectInputStream objectInputStream)
throws IOException, ClassNotFoundException {
super.deserialize(serialize, objectInputStream);
+ updateFromPrefs();
if (VSSerialize.DEBUG)
System.out.println("Deserializing: VSProcess");
+ this.processID = ((Integer)
+ objectInputStream.readObject()).intValue();
int numProtocols = ((Integer)
objectInputStream.readObject()).intValue();
diff --git a/sources/prefs/editors/VSProcessEditor.java b/sources/prefs/editors/VSProcessEditor.java
index c36f17f..38d5c4e 100644
--- a/sources/prefs/editors/VSProcessEditor.java
+++ b/sources/prefs/editors/VSProcessEditor.java
@@ -103,11 +103,11 @@ public class VSProcessEditor extends VSAbstractBetterEditor {
if (actionCommand.equals(prefs.getString("lang.ok"))) {
savePrefs();
- process.updateFromVSPrefs();
+ process.updateFromPrefs();
} else if (actionCommand.equals(prefs.getString("lang.takeover"))) {
savePrefs();
- process.updateFromVSPrefs();
+ process.updateFromPrefs();
} else {
super.actionPerformed(e);
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index 4323190..b6cdb44 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -335,6 +335,7 @@ public class VSSimulator extends JPanel implements VSSerializable {
if (SwingUtilities.isRightMouseButton(me)) {
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
+ System.out.println("BAZ");
String command = ae.getActionCommand();
if (command.equals(prefs.getString("lang.remove"))) {
removeTaskAtRow(row);
@@ -596,6 +597,7 @@ public class VSSimulator extends JPanel implements VSSerializable {
prefs.getString("lang.logging.clear"));
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
+ System.out.println("BAY");
String command = ae.getActionCommand();
if (command.equals(
prefs.getString("lang.logging.clear"))) {
@@ -818,6 +820,7 @@ public class VSSimulator extends JPanel implements VSSerializable {
takeoverButton.addActionListener(new ActionListener() {
private boolean isRed;
public void actionPerformed(ActionEvent ae) {
+ System.out.println("BAR");
String textValue = textField.getText();
Long longValue = null;
@@ -1247,6 +1250,7 @@ public class VSSimulator extends JPanel implements VSSerializable {
serialize.setObject("logging", logging);
simulatorCanvas.deserialize(serialize, objectInputStream);
+ updateFromPrefs();
updateTaskManagerTable();
}
}
diff --git a/sources/simulator/VSSimulatorCanvas.java b/sources/simulator/VSSimulatorCanvas.java
index 1d12a06..752f726 100644
--- a/sources/simulator/VSSimulatorCanvas.java
+++ b/sources/simulator/VSSimulatorCanvas.java
@@ -673,6 +673,11 @@ public class VSSimulatorCanvas extends Canvas
* order to gain performance!
*/
private void recalcOnChange() {
+ synchronized (processes) {
+ if (processes.size() == 0)
+ return;
+ }
+
processlineColor = prefs.getColor("col.process.line");
processSecondlineColor = prefs.getColor("col.process.secondline");
processSeplineColor = prefs.getColor("col.process.sepline");
@@ -1484,16 +1489,15 @@ public class VSSimulatorCanvas extends Canvas
index = processes.indexOf(process);
processes.remove(index);
- for (VSProcess p : processes) {
+ for (VSProcess p : processes)
p.removedAProcessAtIndex(index);
- }
numProcesses = processes.size();
}
- taskManager.removeTasksOf(process);
- simulator.removedAProcessAtIndex(index);
- recalcOnChange();
+ taskManager.removeTasksOf(process);
+ simulator.removedAProcessAtIndex(index);
+ recalcOnChange();
ArrayList<VSMessageLine> removeThose =
new ArrayList<VSMessageLine>();
@@ -1530,8 +1534,10 @@ public class VSSimulatorCanvas extends Canvas
/**
* Adds a new process to the simulator.
+ *
+ * @return The process which has been added
*/
- private void addProcess() {
+ private VSProcess addProcess() {
synchronized (processes) {
numProcesses = processes.size() + 1;
VSProcess newProcess = createProcess(processes.size());
@@ -1543,6 +1549,8 @@ public class VSSimulatorCanvas extends Canvas
recalcOnChange();
simulator.addProcessAtIndex(processes.size()-1);
+
+ return newProcess;
}
}
@@ -1573,16 +1581,25 @@ public class VSSimulatorCanvas extends Canvas
if (VSSerialize.DEBUG)
System.out.println("Deserializing: VSSimulatorCanvas");
+ int num = ((Integer) objectInputStream.readObject()).intValue();
+ logging.clear();
+
+ ArrayList<VSProcess> newProcesses = new ArrayList<VSProcess>();
+ for (int i = 0; i < num; ++i) {
+ VSProcess process = createProcess(i);
+ process.deserialize(serialize, objectInputStream);
+ newProcesses.add(process);
+ }
+
synchronized (processes) {
- numProcesses = ((Integer)
- objectInputStream.readObject()).intValue();
-
- processes.clear();
- for (int i = 0; i < numProcesses; ++i) {
- VSProcess process = createProcess(i);
- process.deserialize(serialize, objectInputStream);
- processes.add(process);
- }
+ int diff = numProcesses - num;
+ if (diff > 0)
+ for (int i = num; i < numProcesses; ++i)
+ removeProcess(processes.get(num));
+
+ for (int i = 0; i < num; ++i) {
+
+ }
}
taskManager.deserialize(serialize, objectInputStream);