< prev index next >

## src/com/sun/javatest/agent/AgentPanel.java

Print this page

     673
     674
     675         }
     676
     677         public void actionPerformed(ActionEvent e) {
     678             ackError(); // hmm, not the most obvious name, but it will work
     679         }
     680     }
     681
     682     //-------------------------------------------------------------------
     683
     684     private class HistoryList extends List implements ItemListener {
     685         HistoryList() {
     686             super(5, false);
     687             super.addItemListener(this);
     688         }
     689
     690         public synchronized void addTask(TaskState task) {
     691             if (tasks.size() >= maxTasks) {
     692                 for (int i = 0; i < tasks.size(); i++) {
     693                     String s = (String) getItem(i);
     694                     // skip over active tasks that will be updated later
     695                     if (s.startsWith("CONN") || s.startsWith("EXEC"))
     696                         continue;
     697
     698                     tasks.removeElementAt(i);
     699                     super.remove(i);
     700                 }
     701             }
     702
     703             tasks.addElement(task);
     704             super.add("CONN " + task.connection.getName());
     705         }
     706
     707         public synchronized TaskState getTask(Connection c) {
     708             for (int i = 0; i < tasks.size(); i++) {
     709                 TaskState ts = (TaskState)(tasks.elementAt(i));
     710                 if (ts.connection == c)
     711                     return ts;
     712             }
     713             throw new Error("AgentPanel.HistoryList.getTask: can't find socket");
     714         }
     715
     716         public synchronized TaskState getSelectedTask() {
     717             return (TaskState)(tasks.elementAt(super.getSelectedIndex()));
     718         }
     719
     720         public synchronized void removeAll() {
     721             tasks.setSize(0);
     722             if (getItemCount() > 0)
     723                 // calling List.removeAll on empty list generates motif
     724                 // warning message
     725                 super.removeAll();
     726         }
     727
     728         public synchronized void removeTask(TaskState task) {
     729             int index = tasks.indexOf(task);
     730             tasks.removeElementAt(index);
     731             super.remove(index);
     732         }
     733
     734         public synchronized void setMaxTasks(int n) {
     735             maxTasks = n;
     736         }
     737
     741
     742         public void itemStateChanged(ItemEvent e) {
     743             Object src = e.getItemSelectable();
     744             if (src == this) {
     745                 switch (e.getStateChange()) {
     746                 case ItemEvent.SELECTED:
     747                     showTask(getSelectedTask());
     748                     break;
     749                 case Event.LIST_DESELECT:
     750                     showTask(null);
     751                     break;
     752                 }
     753             }
     754         }
     755
     756         private String getKey(String state, String detail) {
     757             return (state + " " + detail);
     758         }
     759
     760         private int maxTasks = 10;
     761         private Vector tasks = new Vector();
     762     }
     763
     764
     765     //-------------------------------------------------------------------
     766
     767     private class ParamPanel extends Panel  implements ItemListener {
     768         ParamPanel(ModeOptions[] modeOptions) {
     769             setLayout(new GridBagLayout());
     770
     771             GridBagConstraints lc = new GridBagConstraints();
     772             lc.anchor = GridBagConstraints.EAST;
     773
     774             GridBagConstraints fc = new GridBagConstraints();
     775             fc.fill = GridBagConstraints.HORIZONTAL;
     776             fc.gridwidth = GridBagConstraints.REMAINDER;
     777             fc.weightx = 1;
     778             fc.weighty = 0;
     779
     780
     781             // First row: mode choice, and the mode options deck
     956                 return;
     957             tasks.removeElementAt(index);
     958             activeField.setText(String.valueOf(tasks.size()));
     959             if (!completedNormally)
     960                 exceptionsField.setText(String.valueOf(++exceptionsCount));
     961             if (task.status != null) {
     962                 int t = task.status.getType();
     963                 statusFields[t].setText(String.valueOf(++statusCounts[t]));
     964             }
     965         }
     966
     967         private TextField addField(String name, GridBagConstraints lc, GridBagConstraints fc) {
     968             add(new Label(name), lc);
     969             TextField f = new TextField("0", 10);
     970             f.setEditable(false);
     971             add(f, fc);
     972             return f;
     973         }
     974
     975
     976         private Vector tasks = new Vector();
     977
     978         private int[] statusCounts = new int[Status.NUM_STATES];
     979         private int exceptionsCount;
     980
     981         private TextField activeField;
     982         private TextField[] statusFields = new TextField[Status.NUM_STATES];
     983         private TextField exceptionsField;
     984     }
     985
     986     //-------------------------------------------------------------------
     987
     988     private class TaskPanel extends Panel {
     989         TaskPanel() {
     990             setLayout(new GridBagLayout());
     991
     992             GridBagConstraints lc = new GridBagConstraints();
     993             lc.anchor = GridBagConstraints.EAST;
     994             GridBagConstraints fc = new GridBagConstraints();
     995             fc.weightx = 1;
     996             fc.fill = GridBagConstraints.HORIZONTAL;
     673
     674
     675         }
     676
     677         public void actionPerformed(ActionEvent e) {
     678             ackError(); // hmm, not the most obvious name, but it will work
     679         }
     680     }
     681
     682     //-------------------------------------------------------------------
     683
     684     private class HistoryList extends List implements ItemListener {
     685         HistoryList() {
     686             super(5, false);
     687             super.addItemListener(this);
     688         }
     689
     690         public synchronized void addTask(TaskState task) {
     691             if (tasks.size() >= maxTasks) {
     692                 for (int i = 0; i < tasks.size(); i++) {
     693                     String s = getItem(i);
     694                     // skip over active tasks that will be updated later
     695                     if (s.startsWith("CONN") || s.startsWith("EXEC"))
     696                         continue;
     697
     698                     tasks.removeElementAt(i);
     699                     super.remove(i);
     700                 }
     701             }
     702
     703             tasks.addElement(task);
     704             super.add("CONN " + task.connection.getName());
     705         }
     706
     707         public synchronized TaskState getTask(Connection c) {
     708             for (int i = 0; i < tasks.size(); i++) {
     709                 TaskState ts = tasks.elementAt(i);
     710                 if (ts.connection == c)
     711                     return ts;
     712             }
     713             throw new Error("AgentPanel.HistoryList.getTask: can't find socket");
     714         }
     715
     716         public synchronized TaskState getSelectedTask() {
     717             return tasks.elementAt(super.getSelectedIndex());
     718         }
     719
     720         public synchronized void removeAll() {
     721             tasks.setSize(0);
     722             if (getItemCount() > 0)
     723                 // calling List.removeAll on empty list generates motif
     724                 // warning message
     725                 super.removeAll();
     726         }
     727
     728         public synchronized void removeTask(TaskState task) {
     729             int index = tasks.indexOf(task);
     730             tasks.removeElementAt(index);
     731             super.remove(index);
     732         }
     733
     734         public synchronized void setMaxTasks(int n) {
     735             maxTasks = n;
     736         }
     737
     741
     742         public void itemStateChanged(ItemEvent e) {
     743             Object src = e.getItemSelectable();
     744             if (src == this) {
     745                 switch (e.getStateChange()) {
     746                 case ItemEvent.SELECTED:
     747                     showTask(getSelectedTask());
     748                     break;
     749                 case Event.LIST_DESELECT:
     750                     showTask(null);
     751                     break;
     752                 }
     753             }
     754         }
     755
     756         private String getKey(String state, String detail) {
     757             return (state + " " + detail);
     758         }
     759
     760         private int maxTasks = 10;
     761         private Vector<TaskState> tasks = new Vector<>();
     762     }
     763
     764
     765     //-------------------------------------------------------------------
     766
     767     private class ParamPanel extends Panel  implements ItemListener {
     768         ParamPanel(ModeOptions[] modeOptions) {
     769             setLayout(new GridBagLayout());
     770
     771             GridBagConstraints lc = new GridBagConstraints();
     772             lc.anchor = GridBagConstraints.EAST;
     773
     774             GridBagConstraints fc = new GridBagConstraints();
     775             fc.fill = GridBagConstraints.HORIZONTAL;
     776             fc.gridwidth = GridBagConstraints.REMAINDER;
     777             fc.weightx = 1;
     778             fc.weighty = 0;
     779
     780
     781             // First row: mode choice, and the mode options deck
     956                 return;
     957             tasks.removeElementAt(index);
     958             activeField.setText(String.valueOf(tasks.size()));
     959             if (!completedNormally)
     960                 exceptionsField.setText(String.valueOf(++exceptionsCount));
     961             if (task.status != null) {
     962                 int t = task.status.getType();
     963                 statusFields[t].setText(String.valueOf(++statusCounts[t]));
     964             }
     965         }
     966
     967         private TextField addField(String name, GridBagConstraints lc, GridBagConstraints fc) {
     968             add(new Label(name), lc);
     969             TextField f = new TextField("0", 10);
     970             f.setEditable(false);
     971             add(f, fc);
     972             return f;
     973         }
     974
     975
     976         private Vector<TaskState> tasks = new Vector<>();
     977
     978         private int[] statusCounts = new int[Status.NUM_STATES];
     979         private int exceptionsCount;
     980
     981         private TextField activeField;
     982         private TextField[] statusFields = new TextField[Status.NUM_STATES];
     983         private TextField exceptionsField;
     984     }
     985
     986     //-------------------------------------------------------------------
     987
     988     private class TaskPanel extends Panel {
     989         TaskPanel() {
     990             setLayout(new GridBagLayout());
     991
     992             GridBagConstraints lc = new GridBagConstraints();
     993             lc.anchor = GridBagConstraints.EAST;
     994             GridBagConstraints fc = new GridBagConstraints();
     995             fc.weightx = 1;
     996             fc.fill = GridBagConstraints.HORIZONTAL;

< prev index next >