diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-18 20:20:53 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-18 20:20:53 +0000 |
| commit | ace76b508e2f6c1bc420112306ebee52f478de13 (patch) | |
| tree | afaba5e0bbaf5a8e063e168ae478eae7f8056407 /sources | |
| parent | 5d50dcd635b9f17eb89688650860730b8e3e859f (diff) | |
Process Crash and Process Recover Events work with the new Task maanger.
Diffstat (limited to 'sources')
| -rw-r--r-- | sources/core/VSTask.java | 7 | ||||
| -rw-r--r-- | sources/core/VSTaskManager.java | 16 | ||||
| -rw-r--r-- | sources/events/VSEvent.java | 3 | ||||
| -rw-r--r-- | sources/simulator/VSSimulation.java | 42 | ||||
| -rw-r--r-- | sources/simulator/VSSimulationPanel.java | 8 |
5 files changed, 63 insertions, 13 deletions
diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java index eef2642..503d57e 100644 --- a/sources/core/VSTask.java +++ b/sources/core/VSTask.java @@ -47,6 +47,13 @@ public class VSTask implements Comparable { return false; } + public boolean equals(VSTask task) { + return event.equals(task.getEvent()) + && taskTime == task.getTaskTime() + && isGlobalTimed == task.isGlobalTimed() + && isProgrammed == task.isProgrammed; + } + public boolean isProcess(VSProcess process) { return this.process.equals(process); } diff --git a/sources/core/VSTaskManager.java b/sources/core/VSTaskManager.java index 04cff9d..6683e71 100644 --- a/sources/core/VSTaskManager.java +++ b/sources/core/VSTaskManager.java @@ -197,11 +197,17 @@ public class VSTaskManager { insert(task); } - public synchronized void removeTask(VSTask task) { - if (task.isGlobalTimed()) - globalTasks.remove(task); - else - tasks.remove(task); + public synchronized boolean removeTask(VSTask task) { + if (fullfilledProgrammedTasks.remove(task)) + return true; + + else if (task.isGlobalTimed() && globalTasks.remove(task)) + return true; + + else if (!task.isGlobalTimed() && tasks.remove(task)) + return true; + + return false; } public synchronized LinkedList<VSTask> getProtocolTasks(VSProtocol protocol) { diff --git a/sources/events/VSEvent.java b/sources/events/VSEvent.java index 1ce8570..130d1f5 100644 --- a/sources/events/VSEvent.java +++ b/sources/events/VSEvent.java @@ -12,7 +12,7 @@ abstract public class VSEvent extends VSPrefs { this.process = process; this.prefs = process.getPrefs(); - onInit(); + onInit(); } protected final void setClassname(String eventClassname) { @@ -31,7 +31,6 @@ abstract public class VSEvent extends VSPrefs { } public final String getShortname() { - System.out.println("getShortname " + eventClassname); return VSRegisteredEvents.getShortname(eventClassname); } diff --git a/sources/simulator/VSSimulation.java b/sources/simulator/VSSimulation.java index 2cffea8..bfe310e 100644 --- a/sources/simulator/VSSimulation.java +++ b/sources/simulator/VSSimulation.java @@ -381,7 +381,7 @@ public class VSSimulation extends VSFrame implements ActionListener { public VSTask createTask(VSProcess process, long time, boolean localTimedTask) { VSEvent event = VSRegisteredEvents.createEventInstanceByClassname(eventClassname, process); - event.init(process); + event.init(process); if (isProtocolActivation || isProtocolDeactivation) { ProtocolEvent protocolEvent = (ProtocolEvent) event; @@ -394,7 +394,7 @@ public class VSSimulation extends VSFrame implements ActionListener { } } - private class VSTaskManagerTableModel extends AbstractTableModel { + private class VSTaskManagerTableModel extends AbstractTableModel implements MouseListener { public static final boolean LOCAL = true; public static final boolean GLOBAL = false; private VSPriorityQueue<VSTask> tasks; @@ -452,6 +452,42 @@ public class VSSimulation extends VSFrame implements ActionListener { tasks.add(task); fireTableDataChanged(); } + + private void removeRow(int row) { + VSTask task = tasks.get(row); + tasks.remove(task); + taskManager.removeTask(task); + fireTableDataChanged(); + } + + public void mouseClicked(MouseEvent me) { + JTable source = (JTable) me.getSource(); + final int row = source.rowAtPoint(me.getPoint()); + final int col = source.columnAtPoint(me.getPoint()); + + if (SwingUtilities.isRightMouseButton(me)) { + ActionListener actionListener = new ActionListener() { + public void actionPerformed(ActionEvent ae) { + String actionCommand = ae.getActionCommand(); + if (actionCommand.equals(prefs.getString("lang.remove"))) { + removeRow(row); + } + } + }; + + JPopupMenu popup = new JPopupMenu(); + JMenuItem item = new JMenuItem(prefs.getString("lang.remove")); + item.addActionListener(actionListener); + popup.add(item); + + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + + public void mouseEntered(MouseEvent me) { } + public void mouseExited(MouseEvent me) { } + public void mousePressed(MouseEvent me) { } + public void mouseReleased(MouseEvent me) { } } private JTable createTaskTable(boolean localTasks) { @@ -464,6 +500,8 @@ public class VSSimulation extends VSFrame implements ActionListener { taskManagerGlobalModel = model; JTable table = new JTable(model); + table.addMouseListener(model); + TableColumn col = table.getColumnModel().getColumn(0); col.setMaxWidth(75); col.setResizable(false); diff --git a/sources/simulator/VSSimulationPanel.java b/sources/simulator/VSSimulationPanel.java index b1836c1..e9ade8c 100644 --- a/sources/simulator/VSSimulationPanel.java +++ b/sources/simulator/VSSimulationPanel.java @@ -622,13 +622,13 @@ public class VSSimulationPanel extends JPanel implements Runnable, MouseMotionLi } } - public void mouseClicked(MouseEvent e) { - final VSProcess process = getProcessAtYPos(e.getY()); + public void mouseClicked(MouseEvent me) { + final VSProcess process = getProcessAtYPos(me.getY()); if (process == null) return; - if (SwingUtilities.isRightMouseButton(e)) { + if (SwingUtilities.isRightMouseButton(me)) { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { String actionCommand = ae.getActionCommand(); @@ -667,7 +667,7 @@ public class VSSimulationPanel extends JPanel implements Runnable, MouseMotionLi item.addActionListener(actionListener); popup.add(item); - popup.show(e.getComponent(), e.getX(), e.getY()); + popup.show(me.getComponent(), me.getX(), me.getY()); } else { editProcess(process); |
