summaryrefslogtreecommitdiff
path: root/sources/simulator/VSSimulator.java
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-30 00:52:51 +0000
committerPaul Buetow <paul@buetow.org>2008-05-30 00:52:51 +0000
commitb82536ec35d01fd1195a11733203be7c1c008ad6 (patch)
tree55b69f0d6d2a1ba2dcedd57a2cac7d92ea784393 /sources/simulator/VSSimulator.java
parent19c666a62379a94e22acc96b9ed81660fcb1e53f (diff)
new package has been documented.
Diffstat (limited to 'sources/simulator/VSSimulator.java')
-rw-r--r--sources/simulator/VSSimulator.java724
1 files changed, 325 insertions, 399 deletions
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index 3497dd1..be368fd 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -19,10 +19,15 @@ import prefs.editors.*;
import utils.*;
/**
- * The Class VSSimulator.
+ * The Class VSSimulator. An object of this class represents a whole simulation.
+ * It may be, that several parallel simulations exist. They are independent
+ * fron each other.
+ *
+ * @author Paul C. Buetow
*/
public class VSSimulator extends JPanel {
- private static final long serialVersionUID = 1L;
+ /** the serial version uid */
+ private static final long serialversionuid = 1l;
/** The global text fields. */
private ArrayList<String> globalTextFields;
@@ -30,7 +35,7 @@ public class VSSimulator extends JPanel {
/** The local text fields. */
private ArrayList<String> localTextFields;
- /** The create tasks. */
+ /** The create tasks array list. */
private ArrayList<VSCreateTask> createTasks;
/** The filter active check box. */
@@ -117,12 +122,15 @@ public class VSSimulator extends JPanel {
/** The task manager local model. */
private VSTaskManagerTableModel taskManagerLocalModel;
- /** The has started. */
+ /** The simulation has started. */
private boolean hasStarted = false;
/** The last selected process num. */
private int lastSelectedProcessNum;
+ /** The last expert state. */
+ private boolean lastExpertState;
+
/** The simulation counter. */
private static int simulationCounter;
@@ -130,7 +138,222 @@ public class VSSimulator extends JPanel {
private static int simulationNum;
/**
- * Instantiates a new lang.process.removesimulator.
+ * The Class VSTaskManagerTableModel. An object of this class handles
+ * the task manager's JTable.
+ */
+ private class VSTaskManagerTableModel extends AbstractTableModel
+ implements MouseListener {
+ /** the serial version uid */
+ private static final long serialversionuid = 1l;
+
+ /** The Constant LOCAL. */
+ public static final boolean LOCAL = true;
+
+ /** The Constant GLOBAL. */
+ public static final boolean GLOBAL = false;
+
+ /** The Constant ALL_PROCESSES. */
+ public static final boolean ALL_PROCESSES = true;
+
+ /** The Constant ONE_PROCESS. */
+ public static final boolean ONE_PROCESS = false;
+
+ /** The all processes. */
+ public boolean allProcesses;
+
+ /** The tasks. */
+ private VSPriorityQueue<VSTask> tasks;
+
+ /** The column names. */
+ private String columnNames[];
+
+ /** The num columns. */
+ private int numColumns;
+
+ /** The table. */
+ private JTable table;
+
+ /**
+ * Instantiates a new VSTaskManagerTableModel object
+ *
+ * @param process the process
+ * @param localTask true, if this table manages the local task. false,
+ * if this table manages the global tasks.
+ */
+ public VSTaskManagerTableModel(VSProcess process, boolean localTask) {
+ set(process, localTask, ONE_PROCESS);
+ columnNames = new String[3];
+ columnNames[0]= prefs.getString("lang.time") + " (ms)";
+ columnNames[1] = prefs.getString("lang.process.id");
+ columnNames[2] = prefs.getString("lang.event");
+ numColumns = 3;
+ }
+
+ /**
+ * Sets the table.
+ *
+ * @param table the table
+ */
+ public void setTable(JTable table) {
+ this.table = table;
+ }
+
+ /**
+ * Sets new values.
+ *
+ * @param process the process
+ * @param localTasks true, if this table manages the local tasks. false
+ * if this table manages the global tasks.
+ * @param allProcesses true, if this table shows tasks of all processes.
+ * false, if this table only shows tasks of the specified process.
+ */
+ public void set(VSProcess process, boolean localTasks,
+ boolean allProcesses) {
+ this.allProcesses = allProcesses;
+
+ if (allProcesses) {
+ this.tasks = localTasks
+ ? taskManager.getLocalTasks()
+ : taskManager.getGlobalTasks();
+ } else {
+ this.tasks = localTasks
+ ? taskManager.getProcessLocalTasks(process)
+ : taskManager.getProcessGlobalTasks(process);
+ }
+
+ fireTableDataChanged();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.AbstractTableModel#getColumnName(int)
+ */
+ public String getColumnName(int col) {
+ return columnNames[col];
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ public int getRowCount() {
+ return tasks == null ? 0 : tasks.size();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ public int getColumnCount() {
+ return numColumns;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ public Object getValueAt(int row, int col) {
+ VSTask task = tasks.get(row);
+
+ switch (col) {
+ case 0:
+ return task.getTaskTime();
+ case 1:
+ return task.getProcess().getProcessID();
+ }
+
+ return task.getEvent().getShortname();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int)
+ */
+ public boolean isCellEditable(int row, int col) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.table.AbstractTableModel#setValueAt(
+ * java.lang.Object, int, int)
+ */
+ public void setValueAt(Object value, int row, int col) {
+ fireTableDataChanged();
+ }
+
+ /**
+ * Adds the task.
+ *
+ * @param task the task
+ */
+ public void addTask(VSTask task) {
+ tasks.add(task);
+ fireTableDataChanged();
+ }
+
+ /**
+ * Removes the task at a specified row.
+ *
+ * @param row the row
+ */
+ private void removeTaskAtRow(int row) {
+ VSTask task = tasks.get(row);
+ tasks.remove(task);
+ taskManager.removeTask(task);
+ fireTableDataChanged();
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseClicked(
+ * java.awt.event.MouseEvent)
+ */
+ 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 command = ae.getActionCommand();
+ if (command.equals(prefs.getString("lang.remove"))) {
+ removeTaskAtRow(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());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseEntered(
+ * java.awt.event.MouseEvent)
+ */
+ public void mouseEntered(MouseEvent me) { }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseExited(
+ * java.awt.event.MouseEvent)
+ */
+ public void mouseExited(MouseEvent me) { }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mousePressed(
+ * java.awt.event.MouseEvent)
+ */
+ public void mousePressed(MouseEvent me) { }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.MouseListener#mouseReleased(
+ * java.awt.event.MouseEvent)
+ */
+ public void mouseReleased(MouseEvent me) { }
+ }
+
+
+ /**
+ * Instantiates a new VSSimulator object.
*
* @param prefs the prefs
* @param simulatorFrame the simulator frame
@@ -171,7 +394,7 @@ public class VSSimulator extends JPanel {
}
/**
- * Fill content pane.
+ * Fills the content pane.
*/
private void fillContentPane() {
loggingArea = logging.getLoggingArea();
@@ -195,7 +418,7 @@ public class VSSimulator extends JPanel {
loggingPanel.setPreferredSize(new Dimension(200, 1));
splitPaneH.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
- splitPaneH.setLeftComponent(createProcessPane());
+ splitPaneH.setLeftComponent(createProcessPanel());
splitPaneH.setRightComponent(canvasPanel);
splitPaneH.setContinuousLayout(true);
splitPaneH.setOneTouchExpandable(true);
@@ -208,25 +431,24 @@ public class VSSimulator extends JPanel {
this.add(splitPaneV);
}
- /** The last expert state. */
- private boolean lastExpertState;
-
/**
* Creates the tools panel.
*
- * @return the j panel
+ * @return the panel
*/
private JPanel createToolsPanel() {
JPanel toolsPanel = new JPanel();
boolean expertMode = prefs.getBoolean("sim.mode.expert");
toolsPanel.setLayout(new BoxLayout(toolsPanel, BoxLayout.X_AXIS));
+ JCheckBox expertActiveCheckBox =
+ new JCheckBox(prefs.getString("lang.mode.expert"));
- JCheckBox expertActiveCheckBox = new JCheckBox(prefs.getString("lang.mode.expert"));
expertActiveCheckBox.setSelected(expertMode);
expertActiveCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
- AbstractButton abstractButton = (AbstractButton) ce.getSource();
+ AbstractButton abstractButton =
+ (AbstractButton) ce.getSource();
ButtonModel buttonModel = abstractButton.getModel();
boolean newState = buttonModel.isSelected();
if (lastExpertState != newState) {
@@ -239,11 +461,13 @@ public class VSSimulator extends JPanel {
toolsPanel.add(expertActiveCheckBox);
if (expertMode) {
- lamportActiveCheckBox = new JCheckBox(prefs.getString("lang.time.lamport"));
+ lamportActiveCheckBox = new JCheckBox(
+ prefs.getString("lang.time.lamport"));
lamportActiveCheckBox.setSelected(false);
lamportActiveCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
- AbstractButton abstractButton = (AbstractButton) ce.getSource();
+ AbstractButton abstractButton =
+ (AbstractButton) ce.getSource();
ButtonModel buttonModel = abstractButton.getModel();
simulationCanvas.showLamport(buttonModel.isSelected());
if (buttonModel.isSelected())
@@ -252,11 +476,13 @@ public class VSSimulator extends JPanel {
});
toolsPanel.add(lamportActiveCheckBox);
- vectorTimeActiveCheckBox = new JCheckBox(prefs.getString("lang.time.vector"));
+ vectorTimeActiveCheckBox = new JCheckBox(
+ prefs.getString("lang.time.vector"));
vectorTimeActiveCheckBox.setSelected(false);
vectorTimeActiveCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
- AbstractButton abstractButton = (AbstractButton) ce.getSource();
+ AbstractButton abstractButton =
+ (AbstractButton) ce.getSource();
ButtonModel buttonModel = abstractButton.getModel();
simulationCanvas.showVectorTime(buttonModel.isSelected());
if (buttonModel.isSelected())
@@ -265,11 +491,13 @@ public class VSSimulator extends JPanel {
});
toolsPanel.add(vectorTimeActiveCheckBox);
- JCheckBox antiAliasing = new JCheckBox(prefs.getString("lang.antialiasing"));
+ JCheckBox antiAliasing = new JCheckBox(
+ prefs.getString("lang.antialiasing"));
antiAliasing.setSelected(false);
antiAliasing.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
- AbstractButton abstractButton = (AbstractButton) ce.getSource();
+ AbstractButton abstractButton =
+ (AbstractButton) ce.getSource();
ButtonModel buttonModel = abstractButton.getModel();
simulationCanvas.isAntiAliased(buttonModel.isSelected());
}
@@ -277,11 +505,13 @@ public class VSSimulator extends JPanel {
toolsPanel.add(antiAliasing);
}
- JCheckBox loggingActiveCheckBox = new JCheckBox(prefs.getString("lang.logging.active"));
+ JCheckBox loggingActiveCheckBox = new JCheckBox(
+ prefs.getString("lang.logging.active"));
loggingActiveCheckBox.setSelected(true);
loggingActiveCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
- AbstractButton abstractButton = (AbstractButton) ce.getSource();
+ AbstractButton abstractButton =
+ (AbstractButton) ce.getSource();
ButtonModel buttonModel = abstractButton.getModel();
logging.isPaused(!buttonModel.isSelected());
}
@@ -289,11 +519,13 @@ public class VSSimulator extends JPanel {
toolsPanel.add(loggingActiveCheckBox);
if (expertMode) {
- filterActiveCheckBox = new JCheckBox(prefs.getString("lang.filter"));
+ filterActiveCheckBox = new JCheckBox(
+ prefs.getString("lang.filter"));
filterActiveCheckBox.setSelected(false);
filterActiveCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ce) {
- AbstractButton abstractButton = (AbstractButton) ce.getSource();
+ AbstractButton abstractButton =
+ (AbstractButton) ce.getSource();
ButtonModel buttonModel = abstractButton.getModel();
logging.isFiltered(buttonModel.isSelected());
if (buttonModel.isSelected())
@@ -303,26 +535,27 @@ public class VSSimulator extends JPanel {
toolsPanel.add(filterActiveCheckBox);
filterTextField = new JTextField();
- filterTextField.getDocument().addDocumentListener(new DocumentListener() {
+ filterTextField.getDocument().addDocumentListener(
+ new DocumentListener() {
public void insertUpdate(DocumentEvent de) {
logging.setFilterText(filterTextField.getText());
}
-
public void removeUpdate(DocumentEvent de) {
logging.setFilterText(filterTextField.getText());
}
-
public void changedUpdate(DocumentEvent de) {
logging.setFilterText(filterTextField.getText());
}
});
toolsPanel.add(filterTextField);
- JButton clearButton = new JButton(prefs.getString("lang.logging.clear"));
+ JButton clearButton = new JButton(
+ prefs.getString("lang.logging.clear"));
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
- String actionCommand = ae.getActionCommand();
- if (actionCommand.equals(prefs.getString("lang.logging.clear"))) {
+ String command = ae.getActionCommand();
+ if (command.equals(
+ prefs.getString("lang.logging.clear"))) {
logging.clear();
}
}
@@ -334,11 +567,11 @@ public class VSSimulator extends JPanel {
}
/**
- * Creates the process pane.
+ * Creates the process panel.
*
- * @return the j panel
+ * @return the panel
*/
- private JPanel createProcessPane() {
+ private JPanel createProcessPanel() {
JPanel editPanel = new JPanel(new GridBagLayout());
boolean expertMode = prefs.getBoolean("sim.mode.expert");
editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.Y_AXIS));
@@ -362,7 +595,8 @@ public class VSSimulator extends JPanel {
localPIDComboBox.addItem(prefs.getString("lang.all"));
globalPIDComboBox.addItem(prefs.getString("lang.all"));
- tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT);
+ tabbedPane = new JTabbedPane(JTabbedPane.TOP,
+ JTabbedPane.WRAP_TAB_LAYOUT);
localPanel = createTaskLabel(VSTaskManagerTableModel.LOCAL);
JPanel globalPanel = createTaskLabel(VSTaskManagerTableModel.GLOBAL);
@@ -380,8 +614,10 @@ public class VSSimulator extends JPanel {
processesComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
- localTextFields.set(lastSelectedProcessNum, localTextField.getText());
- globalTextFields.set(lastSelectedProcessNum, globalTextField.getText());
+ localTextFields.set(lastSelectedProcessNum,
+ localTextField.getText());
+ globalTextFields.set(lastSelectedProcessNum,
+ globalTextField.getText());
updateTaskManagerTable();
int processNum = getSelectedProcessNum();
@@ -405,8 +641,10 @@ public class VSSimulator extends JPanel {
if (processNum != simulationCanvas.getNumProcesses()) {
VSProcess process = getSelectedProcess();
- VSProcessEditor processEditor = new VSProcessEditor(prefs, process);
- tabbedPane.setComponentAt(1, processEditor.getContentPane());
+ VSProcessEditor processEditor =
+ new VSProcessEditor(prefs, process);
+ tabbedPane.setComponentAt(1,
+ processEditor.getContentPane());
}
}
});
@@ -424,7 +662,7 @@ public class VSSimulator extends JPanel {
*
* @param text the text
*
- * @return the j panel
+ * @return the panel
*/
private JPanel createLabelPanel(String text) {
JPanel panel = new JPanel();
@@ -437,9 +675,10 @@ public class VSSimulator extends JPanel {
/**
* Creates the task label.
*
- * @param localTasks the local tasks
+ * @param localTasks true, if the local task label has to get created.
+ * false, if the global task label has to get created.
*
- * @return the j panel
+ * @return the panel
*/
private JPanel createTaskLabel(boolean localTasks) {
JPanel panel = new JPanel(new GridBagLayout());
@@ -462,346 +701,17 @@ public class VSSimulator extends JPanel {
}
/**
- * The Class VSCreateTask.
- */
- private class VSCreateTask {
-
- /** The event classname. */
- private String eventClassname;
-
- /** The protocol classname. */
- private String protocolClassname;
-
- /** The shortname. */
- private String shortname;
-
- /* Those 3 values are for VSProtocolEvent events */
- /** The is protocol activation. */
- private boolean isProtocolActivation;
-
- /** The is protocol deactivation. */
- private boolean isProtocolDeactivation;
-
- /** The is client protocol. */
- private boolean isClientProtocol;
-
- /* Those values are for ProtocolClient onStart events */
- /** The is client request. */
- private boolean isRequest;
-
- /**
- * Instantiates a new lang.process.removecreate task.
- *
- * @param eventClassname the event classname
- */
- public VSCreateTask(String eventClassname) {
- this.eventClassname = eventClassname;
- }
-
- /**
- * Checks if is protocol activation.
- *
- * @param isProtocolActivation the is protocol activation
- */
- public void isProtocolActivation(boolean isProtocolActivation) {
- this.isProtocolActivation = isProtocolActivation;
-
- if (isProtocolActivation)
- isProtocolDeactivation(false);
- }
-
- /**
- * Checks if is protocol deactivation.
- *
- * @param isProtocolDeactivation the is protocol deactivation
- */
- public void isProtocolDeactivation(boolean isProtocolDeactivation) {
- this.isProtocolDeactivation = isProtocolDeactivation;
-
- if (isProtocolDeactivation)
- isProtocolActivation(false);
- }
-
- /**
- * Checks if is client protocol.
- *
- * @param isClientProtocol the is client protocol
- */
- public void isClientProtocol(boolean isClientProtocol) {
- this.isClientProtocol = isClientProtocol;
- }
-
- /**
- * Checks if is client request.
- *
- * @param isRequest the is client request
- */
- public void isRequest(boolean isRequest) {
- this.isRequest = isRequest;
- }
-
- /**
- * Sets the protocol classname.
- *
- * @param protocolClassname the new protocol classname
- */
- public void setProtocolClassname(String protocolClassname) {
- this.protocolClassname = protocolClassname;
- }
-
- /**
- * Sets the shortname.
- *
- * @param shortname the new shortname
- */
- public void setShortname(String shortname) {
- this.shortname = shortname;
- }
-
- /**
- * Creates the task.
- *
- * @param process the process
- * @param time the time
- * @param localTimedTask the local timed task
- *
- * @return the lang.process.removetask
- */
- public VSTask createTask(VSProcess process, long time, boolean localTimedTask) {
- VSAbstractEvent event = null;
-
- if (isRequest) {
- event = process.getProtocolObject(eventClassname);
-
- } else {
- event = VSRegisteredEvents.createEventInstanceByClassname(eventClassname, process);
- }
-
- event.init(process);
- if (shortname != null)
- event.setShortname(shortname);
-
- if (isProtocolActivation || isProtocolDeactivation) {
- VSProtocolEvent protocolEvent = (VSProtocolEvent) event;
- protocolEvent.setProtocolClassname(protocolClassname);
- protocolEvent.isProtocolActivation(isProtocolActivation);
- protocolEvent.isClientProtocol(isClientProtocol);
- }
-
- return new VSTask(time, process, event, localTimedTask);
- }
- }
-
- /**
- * The Class VSTaskManagerTableModel.
- */
- private class VSTaskManagerTableModel extends AbstractTableModel implements MouseListener {
-
- /** The Constant LOCAL. */
- public static final boolean LOCAL = true;
-
- /** The Constant GLOBAL. */
- public static final boolean GLOBAL = false;
-
- /** The Constant ALL_PROCESSES. */
- public static final boolean ALL_PROCESSES = true;
-
- /** The Constant ONE_PROCESS. */
- public static final boolean ONE_PROCESS = false;
-
- /** The all processes. */
- public boolean allProcesses;
-
- /** The tasks. */
- private VSPriorityQueue<VSTask> tasks;
-
- /** The column names. */
- private String columnNames[];
-
- /** The num columns. */
- private int numColumns;
-
- /** The table. */
- private JTable table;
-
- /**
- * Instantiates a new lang.process.removetask manager table model.
- *
- * @param process the process
- * @param localTask the local task
- */
- public VSTaskManagerTableModel(VSProcess process, boolean localTask) {
- set(process, localTask, ONE_PROCESS);
- columnNames = new String[3];
- columnNames[0]= prefs.getString("lang.time") + " (ms)";
- columnNames[1] = prefs.getString("lang.process.id");
- columnNames[2] = prefs.getString("lang.event");
- numColumns = 3;
- }
-
- /**
- * Sets the table.
- *
- * @param table the new table
- */
- public void setTable(JTable table) {
- this.table = table;
- }
-
- /**
- * Sets the.
- *
- * @param process the process
- * @param localTasks the local tasks
- * @param allProcesses the all processes
- */
- public void set(VSProcess process, boolean localTasks, boolean allProcesses) {
- this.allProcesses = allProcesses;
-
- if (allProcesses) {
- this.tasks = localTasks
- ? taskManager.getLocalTasks()
- : taskManager.getGlobalTasks();
- } else {
- this.tasks = localTasks
- ? taskManager.getProcessLocalTasks(process)
- : taskManager.getProcessGlobalTasks(process);
- }
-
- fireTableDataChanged();
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.AbstractTableModel#getColumnName(int)
- */
- public String getColumnName(int col) {
- return columnNames[col];
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#getRowCount()
- */
- public int getRowCount() {
- return tasks == null ? 0 : tasks.size();
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#getColumnCount()
- */
- public int getColumnCount() {
- return numColumns;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#getValueAt(int, int)
- */
- public Object getValueAt(int row, int col) {
- VSTask task = tasks.get(row);
-
- switch (col) {
- case 0:
- return task.getTaskTime();
- case 1:
- return task.getProcess().getProcessID();
- }
-
- return task.getEvent().getShortname();
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int)
- */
- public boolean isCellEditable(int row, int col) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, int, int)
- */
- public void setValueAt(Object value, int row, int col) {
- fireTableDataChanged();
- }
-
- /**
- * Adds the task.
- *
- * @param task the task
- */
- public void addTask(VSTask task) {
- tasks.add(task);
- fireTableDataChanged();
- }
-
- /**
- * Removes the task at row.
- *
- * @param row the row
- */
- private void removeTaskAtRow(int row) {
- VSTask task = tasks.get(row);
- tasks.remove(task);
- taskManager.removeTask(task);
- fireTableDataChanged();
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
- */
- 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"))) {
- removeTaskAtRow(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());
- }
- }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
- */
- public void mouseEntered(MouseEvent me) { }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
- */
- public void mouseExited(MouseEvent me) { }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
- */
- public void mousePressed(MouseEvent me) { }
-
- /* (non-Javadoc)
- * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
- */
- public void mouseReleased(MouseEvent me) { }
- }
-
- /**
* Creates the task table.
*
- * @param localTasks the local tasks
+ * @param localTasks true, if the local task label has to get created.
+ * false, if the global task label has to get created.
*
- * @return the j table
+ * @return the table
*/
private JTable createTaskTable(boolean localTasks) {
VSProcess process = getSelectedProcess();
- VSTaskManagerTableModel model = new VSTaskManagerTableModel(process, localTasks);
+ VSTaskManagerTableModel model =
+ new VSTaskManagerTableModel(process, localTasks);
if (localTasks)
taskManagerLocalModel = model;
@@ -831,9 +741,10 @@ public class VSSimulator extends JPanel {
* Inits the add panel.
*
* @param panel the panel
- * @param localTasks the local tasks
+ * @param localTasks true, if the local task label has to get created.
+ * false, if the global task label has to get created.
*
- * @return the j panel
+ * @return the panel
*/
private JPanel initAddPanel(JPanel panel, final boolean localTasks) {
JPanel addPanel = new JPanel();
@@ -863,7 +774,6 @@ public class VSSimulator extends JPanel {
JButton takeoverButton = new JButton(prefs.getString("lang.takeover"));
takeoverButton.addActionListener(new ActionListener() {
private boolean isRed;
-
public void actionPerformed(ActionEvent ae) {
String textValue = textField.getText();
Long longValue = null;
@@ -914,13 +824,16 @@ public class VSSimulator extends JPanel {
if (createTask == null)
return false;
- ArrayList<VSProcess> processes = getConcernedProcesses(localTasks);
+ ArrayList<VSProcess> processes =
+ getConcernedProcesses(localTasks);
for (VSProcess process : processes) {
- VSTask task = createTask.createTask(process, time, localTasks);
+ VSTask task = createTask.createTask(process, time,
+ localTasks);
taskManager.addTask(task, VSTaskManager.PROGRAMMED);
- if (selectedProcess == null || process.equals(selectedProcess)) {
+ if (selectedProcess == null ||
+ process.equals(selectedProcess)) {
if (localTasks)
taskManagerLocalModel.addTask(task);
else
@@ -937,15 +850,18 @@ public class VSSimulator extends JPanel {
boolean createTaskFlag = createTasks == null;
if (createTaskFlag) createTasks = new ArrayList<VSCreateTask>();
- Vector<String> eventClassnames = VSRegisteredEvents.getNonProtocolClassnames();
+ Vector<String> eventClassnames =
+ VSRegisteredEvents.getNonProtocolClassnames();
comboBox.setMaximumRowCount(20);
- comboBox.addItem("----- " + prefs.getString("lang.events.process") + " -----");
+ comboBox.addItem("----- " + prefs.getString("lang.events.process") +
+ " -----");
if (createTaskFlag)
createTasks.add(null);
for (String eventClassname : eventClassnames) {
- String eventShortname = VSRegisteredEvents.getShortnameByClassname(eventClassname);
+ String eventShortname =
+ VSRegisteredEvents.getShortnameByClassname(eventClassname);
comboBox.addItem(eventShortname);
if (createTaskFlag)
createTasks.add(new VSCreateTask(eventClassname));
@@ -963,14 +879,15 @@ public class VSSimulator extends JPanel {
eventClassnames = VSRegisteredEvents.getProtocolClassnames();
for (String eventClassname : eventClassnames) {
- String eventShortname_ = VSRegisteredEvents.getShortnameByClassname(eventClassname);
+ String eventShortname_ =
+ VSRegisteredEvents.getShortnameByClassname(eventClassname);
String eventShortname = null;
- comboBox.addItem("----- " + eventShortname_ + " " + protocol + " -----");
+ comboBox.addItem("----- " + eventShortname_ + " " +
+ protocol + " -----");
if (createTaskFlag)
createTasks.add(null);
-
if (VSRegisteredEvents.isOnServerStartProtocol(eventClassname))
eventShortname = eventShortname_ + " " + serverRequest;
else
@@ -987,7 +904,8 @@ public class VSSimulator extends JPanel {
eventShortname = eventShortname_ + " " + client + " " + activate;
comboBox.addItem(eventShortname);
if (createTaskFlag) {
- VSCreateTask createTask = new VSCreateTask(protocolEventClassname);
+ VSCreateTask createTask =
+ new VSCreateTask(protocolEventClassname);
createTask.isProtocolActivation(true);
createTask.isClientProtocol(true);
createTask.setProtocolClassname(eventClassname);
@@ -998,7 +916,8 @@ public class VSSimulator extends JPanel {
eventShortname = eventShortname_ + " " + client + " " + deactivate;
comboBox.addItem(eventShortname);
if (createTaskFlag) {
- VSCreateTask createTask = new VSCreateTask(protocolEventClassname);
+ VSCreateTask createTask =
+ new VSCreateTask(protocolEventClassname);
createTask.isProtocolDeactivation(true);
createTask.isClientProtocol(true);
createTask.setProtocolClassname(eventClassname);
@@ -1009,7 +928,8 @@ public class VSSimulator extends JPanel {
eventShortname = eventShortname_ + " " + server + " " + activate;
comboBox.addItem(eventShortname);
if (createTaskFlag) {
- VSCreateTask createTask = new VSCreateTask(protocolEventClassname);
+ VSCreateTask createTask =
+ new VSCreateTask(protocolEventClassname);
createTask.isProtocolActivation(true);
createTask.isClientProtocol(false);
createTask.setProtocolClassname(eventClassname);
@@ -1020,7 +940,8 @@ public class VSSimulator extends JPanel {
eventShortname = eventShortname_ + " " + server + " " + deactivate;
comboBox.addItem(eventShortname);
if (createTaskFlag) {
- VSCreateTask createTask = new VSCreateTask(protocolEventClassname);
+ VSCreateTask createTask =
+ new VSCreateTask(protocolEventClassname);
createTask.isProtocolDeactivation(true);
createTask.isClientProtocol(false);
createTask.setProtocolClassname(eventClassname);
@@ -1075,7 +996,8 @@ public class VSSimulator extends JPanel {
/**
* Gets the concerned processes.
*
- * @param localTasks the local tasks
+ * @param localTasks true, if this table manages the local tasks. false
+ * if this table manages the global tasks.
*
* @return the concerned processes
*/
@@ -1099,12 +1021,14 @@ public class VSSimulator extends JPanel {
public void updateTaskManagerTable() {
VSProcess process = getSelectedProcess();
boolean allProcesses = process == null;
- taskManagerLocalModel.set(process, VSTaskManagerTableModel.LOCAL, allProcesses);
- taskManagerGlobalModel.set(process, VSTaskManagerTableModel.GLOBAL, allProcesses);
+ taskManagerLocalModel.set(process,
+ VSTaskManagerTableModel.LOCAL, allProcesses);
+ taskManagerGlobalModel.set(process,
+ VSTaskManagerTableModel.GLOBAL, allProcesses);
}
/**
- * Finish.
+ * The simulation has finished.
*/
public void finish() {
menuItemStates.setStart(false);
@@ -1159,7 +1083,7 @@ public class VSSimulator extends JPanel {
}
/**
- * Removes the process at index.
+ * Removes the process at a specified index.
*
* @param index the index
*/
@@ -1180,7 +1104,7 @@ public class VSSimulator extends JPanel {
}
/**
- * Adds the process at index.
+ * Adds the process at a specified index.
*
* @param index the index
*/
@@ -1199,7 +1123,7 @@ public class VSSimulator extends JPanel {
}
/**
- * Fire expert mode changed.
+ * Fire expert mode changed. Tell, that the expert mode has changed.
*/
public void fireExpertModeChanged() {
boolean expertMode = prefs.getBoolean("sim.mode.expert");
@@ -1209,7 +1133,8 @@ public class VSSimulator extends JPanel {
if (expertMode) {
tabbedPane.remove(localPanel);
- tabbedPane.insertTab(prefs.getString("lang.events"), null, splitPane1, null, 0);
+ tabbedPane.insertTab(prefs.getString("lang.events"), null,
+ splitPane1, null, 0);
splitPane1.setTopComponent(localPanel);
//splitPane1.setDividerLocation((int) (getPaintSize()/2) - 20);
@@ -1218,7 +1143,8 @@ public class VSSimulator extends JPanel {
} else {
tabbedPane.remove(splitPane1);
- tabbedPane.insertTab(prefs.getString("lang.events"), null, localPanel, null, 0);
+ tabbedPane.insertTab(prefs.getString("lang.events"), null,
+ localPanel, null, 0);
/* addPanel */
localAddPanel.remove(2);