summaryrefslogtreecommitdiff
path: root/sources/simulator/VSSimulator.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-06-14 00:39:52 +0000
committerPaul Buetow <paul@buetow.org>2008-06-14 00:39:52 +0000
commitdb6b97e9ef3c5f0c081dd1aaa0921239c274f962 (patch)
tree1f8544839a41df95848341934c4d97ca1f863268 /sources/simulator/VSSimulator.java
parent44e54849fdcc4a582e3bee4c48524686060b6607 (diff)
fixed: JComboBox if PID changed @ Table Editor -> remove if onMouseOver
Diffstat (limited to 'sources/simulator/VSSimulator.java')
-rw-r--r--sources/simulator/VSSimulator.java54
1 files changed, 51 insertions, 3 deletions
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index a996ee6..7259bfc 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -143,6 +143,12 @@ public class VSSimulator extends JPanel implements VSSerializable {
/** The task manager local model. */
private VSTaskManagerTableModel taskManagerLocalModel;
+ /** The task manager global editor. */
+ private VSTaskManagerCellEditor taskManagerGlobalEditor;
+
+ /** The task manager local editor. */
+ private VSTaskManagerCellEditor taskManagerLocalEditor;
+
/** The simulator has started. */
private boolean hasStarted = false;
@@ -195,6 +201,9 @@ public class VSSimulator extends JPanel implements VSSerializable {
/** The table. */
private JTable table;
+ /** The editor. */
+ private VSTaskManagerCellEditor editor;
+
/**
* Instantiates a new VSTaskManagerTableModel object
*
@@ -222,6 +231,15 @@ public class VSSimulator extends JPanel implements VSSerializable {
}
/**
+ * Sets the editor.
+ *
+ * @param editor the editor
+ */
+ public void setEditor(VSTaskManagerCellEditor editor) {
+ this.editor = editor;
+ }
+
+ /**
* Sets new values.
*
* @param process the process
@@ -328,6 +346,22 @@ public class VSSimulator extends JPanel implements VSSerializable {
}
/**
+ * Checks if a specific row exists
+ *
+ * @param row the row
+ * @return True, if the row exists. False, if not
+ */
+ public boolean rowExists(int row) {
+ if (row < 0)
+ return false;
+
+ if (tasks.size() <= row)
+ return false;
+
+ return true;
+ }
+
+ /**
* Gets the task at a specified row.
*
* @param row the row
@@ -450,6 +484,14 @@ public class VSSimulator extends JPanel implements VSSerializable {
*/
public VSTaskManagerCellEditor(VSTaskManagerTableModel model) {
this.model = model;
+ model.setEditor(this);
+ }
+
+ /**
+ * Stops editing
+ */
+ public void stopEditing() {
+ fireEditingStopped();
}
/**
@@ -506,7 +548,7 @@ public class VSSimulator extends JPanel implements VSSerializable {
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int index = comboBox.getSelectedIndex() - 1;
- if (index >= 0) {
+ if (model.rowExists(index)) {
VSTask task = model.removeTaskAtRow(row);
VSProcess process =
simulatorCanvas.getProcess(index);
@@ -918,10 +960,13 @@ public class VSSimulator extends JPanel implements VSSerializable {
VSTaskManagerCellEditor cellEditor =
new VSTaskManagerCellEditor(model);
- if (localTasks)
+ if (localTasks) {
taskManagerLocalModel = model;
- else
+ taskManagerLocalEditor = cellEditor;
+ } else {
taskManagerGlobalModel = model;
+ taskManagerGlobalEditor = cellEditor;
+ }
JTable table = new JTable(model);
table.setDefaultEditor(Object.class, cellEditor);
@@ -1239,6 +1284,9 @@ public class VSSimulator extends JPanel implements VSSerializable {
VSProcess process = getSelectedProcess();
boolean allProcesses = process == null;
+ taskManagerLocalEditor.stopEditing();
+ taskManagerGlobalEditor.stopEditing();
+
taskManagerLocalModel.set(process,
VSTaskManagerTableModel.LOCAL,
allProcesses);