summaryrefslogtreecommitdiff
path: root/sources/simulator/VSSimulationPanel.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-17 20:36:00 +0000
committerPaul Buetow <paul@buetow.org>2008-05-17 20:36:00 +0000
commitdbb780b7295c0df60269ee6f3c85c3056d6262b8 (patch)
treed8f084283d6b5b86482e7edb3d7fc786de737ceb /sources/simulator/VSSimulationPanel.java
parenta622ebff377f37d14535f91e484335e2ad215acb (diff)
VSEvent interface has now has the init method.
Diffstat (limited to 'sources/simulator/VSSimulationPanel.java')
-rw-r--r--sources/simulator/VSSimulationPanel.java52
1 files changed, 50 insertions, 2 deletions
diff --git a/sources/simulator/VSSimulationPanel.java b/sources/simulator/VSSimulationPanel.java
index 7fd0c23..e750b0a 100644
--- a/sources/simulator/VSSimulationPanel.java
+++ b/sources/simulator/VSSimulationPanel.java
@@ -9,6 +9,7 @@ import javax.swing.*;
import core.*;
import core.time.*;
import events.*;
+import events.implementations.*;
import prefs.*;
import prefs.editors.*;
import utils.*;
@@ -603,8 +604,55 @@ public class VSSimulationPanel extends JPanel implements Runnable, MouseMotionLi
}
public void mouseClicked(MouseEvent e) {
- VSProcess process = getProcessAtYPos(e.getY());
- editProcess(process);
+ final VSProcess process = getProcessAtYPos(e.getY());
+
+ if (process == null)
+ return;
+
+ if (SwingUtilities.isRightMouseButton(e)) {
+ ActionListener actionListener = new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ String actionCommand = ae.getActionCommand();
+ if (actionCommand.equals(prefs.getString("lang.edit"))) {
+ editProcess(process);
+
+ } else if (actionCommand.equals(prefs.getString("lang.crash"))) {
+ VSProcessEvent event = new ProcessCrashEvent();
+ event.init(process);
+ taskManager.addTask(new VSTask(process.getTime(), process, event));
+
+ } else if (actionCommand.equals(prefs.getString("lang.recover"))) {
+ VSProcessEvent event = new ProcessRecoverEvent();
+ event.init(process);
+ taskManager.addTask(new VSTask(process.getTime(), process, event));
+ }
+ }
+ };
+
+ JPopupMenu popup = new JPopupMenu();
+ JMenuItem item = new JMenuItem(prefs.getString("lang.edit"));
+ item.addActionListener(actionListener);
+ popup.add(item);
+
+ item = new JMenuItem(prefs.getString("lang.crash"));
+ if (process.isCrashed() || isPaused || time == 0)
+ item.setEnabled(false);
+ else
+ item.addActionListener(actionListener);
+ popup.add(item);
+
+ item = new JMenuItem(prefs.getString("lang.recover"));
+ if (!process.isCrashed() || isPaused || time == 0)
+ item.setEnabled(false);
+ else
+ item.addActionListener(actionListener);
+ popup.add(item);
+
+ popup.show(e.getComponent(), e.getX(), e.getY());
+
+ } else {
+ editProcess(process);
+ }
}
public void editProcess(int processNum) {