summaryrefslogtreecommitdiff
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
parent19c666a62379a94e22acc96b9ed81660fcb1e53f (diff)
new package has been documented.
-rw-r--r--sources/core/VSTask.java2
-rw-r--r--sources/simulator/2DOCUMENT0
-rw-r--r--sources/simulator/VSLogging.java48
-rw-r--r--sources/simulator/VSMain.java24
-rw-r--r--sources/simulator/VSMenuItemStates.java8
-rw-r--r--sources/simulator/VSSimulator.java724
-rw-r--r--sources/simulator/VSSimulatorCanvas.java652
-rw-r--r--sources/simulator/VSSimulatorFrame.java247
8 files changed, 870 insertions, 835 deletions
diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java
index 1e3958d..6f39021 100644
--- a/sources/core/VSTask.java
+++ b/sources/core/VSTask.java
@@ -212,11 +212,9 @@ public class VSTask implements Comparable {
event.init(process);
if (messageLine != null) {
- System.out.println("FO");
if (!event.onStart())
process.getSimulatorCanvas().removeMessageLine(messageLine);
} else {
- System.out.println("BA");
event.onStart();
}
}
diff --git a/sources/simulator/2DOCUMENT b/sources/simulator/2DOCUMENT
deleted file mode 100644
index e69de29..0000000
--- a/sources/simulator/2DOCUMENT
+++ /dev/null
diff --git a/sources/simulator/VSLogging.java b/sources/simulator/VSLogging.java
index b89751c..b7ce221 100644
--- a/sources/simulator/VSLogging.java
+++ b/sources/simulator/VSLogging.java
@@ -10,11 +10,14 @@ import javax.swing.*;
import utils.*;
-// TODO: Auto-generated Javadoc
/**
- * The Class VSLogging.
+ * The Class VSLogging. An object of this class is responsible for the logging
+ * of text messages into the simulator's logging window.
+ *
+ * @author Paul C. Buetow
*/
public class VSLogging {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/** The logging area. */
@@ -23,7 +26,9 @@ public class VSLogging {
/** The filter text. */
private String filterText;
- /** The pause lines. */
+ /** The pause lines. Used for cacheing the logging if the logging is
+ * deactivated for a while
+ */
private ArrayList<StringBuffer> pauseLines;
/** The logging lines. */
@@ -32,17 +37,17 @@ public class VSLogging {
/** The simulation canvas. */
private VSSimulatorCanvas simulationCanvas;
- /** The is filtered. */
+ /** The logging messages are filtered. */
private boolean isFiltered;
- /** The is paused. */
+ /** The logging is paused. */
private boolean isPaused;
/** The filter pattern. */
private Pattern filterPattern;
/**
- * Instantiates a new lang.process.removelogging.
+ * Instantiates a new VSLogging object.
*/
public VSLogging() {
loggingArea = new JTextArea(0, 0);
@@ -57,7 +62,7 @@ public class VSLogging {
/**
* Sets the simulation canvas.
*
- * @param simulationCanvas the new simulation canvas
+ * @param simulationCanvas the simulation canvas
*/
public void setSimulationCanvas(VSSimulatorCanvas simulationCanvas) {
this.simulationCanvas = simulationCanvas;
@@ -73,7 +78,7 @@ public class VSLogging {
}
/**
- * Logg.
+ * Loggs a message using the global time.
*
* @param message the message
*/
@@ -85,7 +90,7 @@ public class VSLogging {
}
/**
- * Logg.
+ * Loggs a message using the specified time.
*
* @param message the message
* @param time the time
@@ -103,9 +108,9 @@ public class VSLogging {
}
/**
- * Checks if is paused.
+ * Sets if the logging is paused.
*
- * @param isPaused the is paused
+ * @param isPaused true, if the logging is paused
*/
public synchronized void isPaused(boolean isPaused) {
this.isPaused = isPaused;
@@ -119,26 +124,29 @@ public class VSLogging {
}
/**
- * Logg filtered.
+ * If the logging is filtered, it's using the pattern matching.
*
- * @param buffer the buffer
+ * @param buffer the logging buffer to filter
*/
private void loggFiltered(StringBuffer buffer) {
loggingLines.add(buffer);
if (!isFiltered) {
loggingArea.append(buffer.toString()+"\n");
- loggingArea.setCaretPosition(loggingArea.getDocument().getLength());
+ loggingArea.setCaretPosition(
+ loggingArea.getDocument().getLength());
- } else if (filterPattern != null && filterPattern.matcher(buffer).find()) {
+ } else if (filterPattern != null &&
+ filterPattern.matcher(buffer).find()) {
loggingArea.append(buffer.toString()+"\n");
- loggingArea.setCaretPosition(loggingArea.getDocument().getLength());
+ loggingArea.setCaretPosition(
+ loggingArea.getDocument().getLength());
}
}
/**
- * Checks if is filtered.
+ * Checks if the logging is filtered.
*
- * @param isFiltered the is filtered
+ * @param isFiltered true, if the logging is filtered
*/
public synchronized void isFiltered(boolean isFiltered) {
this.isFiltered = isFiltered;
@@ -160,7 +168,7 @@ public class VSLogging {
}
/**
- * Clear.
+ * Clears the logging.
*/
public synchronized void clear() {
loggingLines.clear();
@@ -169,7 +177,7 @@ public class VSLogging {
}
/**
- * Filter.
+ * Filters the logging.
*/
private void filter() {
try {
diff --git a/sources/simulator/VSMain.java b/sources/simulator/VSMain.java
index f8a6df8..b8aa84a 100644
--- a/sources/simulator/VSMain.java
+++ b/sources/simulator/VSMain.java
@@ -11,15 +11,18 @@ import events.*;
import prefs.*;
import prefs.editors.*;
-// TODO: Auto-generated Javadoc
/**
- * The Class VSMain.
+ * The Class VSMain. This class contains the static main method. The simulator
+ * starts here!
+ *
+ * @author Paul C. Buetow
*/
public class VSMain {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/**
- * Instantiates a new lang.process.removemain.
+ * Instantiates a new VSMain object.
*
* @param prefs the prefs
*/
@@ -28,24 +31,27 @@ public class VSMain {
}
/**
- * Instantiates a new lang.process.removemain.
+ * Instantiates a new VSMain object
*
* @param prefs the prefs
- * @param relativeTo the relative to
+ * @param relativeTo the component to open the window relative to
*/
public VSMain(VSPrefs prefs, Component relativeTo) {
init(prefs, relativeTo);
}
/**
- * Inits the.
+ * Inits the VSMain object.
*
* @param prefs the prefs
- * @param relativeTo the relative to
+ * @param relativeTo the component to open the window relative to
*/
private void init(VSPrefs prefs, Component relativeTo) {
- VSSimulatorFrame simulatorFrame = new VSSimulatorFrame(prefs, relativeTo);
- new VSEditorFrame(prefs, relativeTo, new VSSimulatorEditor(prefs, simulatorFrame));
+ VSSimulatorFrame simulatorFrame =
+ new VSSimulatorFrame(prefs, relativeTo);
+
+ new VSEditorFrame(prefs, relativeTo,
+ new VSSimulatorEditor(prefs, simulatorFrame));
}
/**
diff --git a/sources/simulator/VSMenuItemStates.java b/sources/simulator/VSMenuItemStates.java
index ba901de..b751b29 100644
--- a/sources/simulator/VSMenuItemStates.java
+++ b/sources/simulator/VSMenuItemStates.java
@@ -7,8 +7,11 @@ package simulator;
/**
* The Class VSMenuItemStates. Used by the VSSimulation to update the
* "simulation" bar of the VSSimulationFrame.
+ *
+ * @author Paul C. Buetow
*/
public class VSMenuItemStates {
+ /** The serial version uid */
private static final long serialVersionUID = 1L;
/** The pause state. */
@@ -24,14 +27,15 @@ public class VSMenuItemStates {
private volatile boolean start;
/**
- * Instantiates a new lang.process.removemenu item states.
+ * Instantiates a new VSMenuItemStates object.
*
* @param pause the pause state
* @param replay the replay state
* @param reset the reset state
* @param start the start state
*/
- public VSMenuItemStates(boolean pause, boolean replay, boolean reset, boolean start) {
+ public VSMenuItemStates(boolean pause, boolean replay, boolean reset,
+ boolean start) {
this.pause = pause;
this.replay = replay;
this.reset = reset;
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) {