summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/gui/tabs/execution
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2012-05-30 08:37:45 +0200
committerAndrew Branson <andrew.branson@cern.ch>2012-05-30 08:37:45 +0200
commitb086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch)
tree8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /source/com/c2kernel/gui/tabs/execution
parent22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff)
Initial Maven Conversion
Diffstat (limited to 'source/com/c2kernel/gui/tabs/execution')
-rw-r--r--source/com/c2kernel/gui/tabs/execution/ActivityItem.java55
-rw-r--r--source/com/c2kernel/gui/tabs/execution/ActivityViewer.java296
-rw-r--r--source/com/c2kernel/gui/tabs/execution/DefaultExecutor.java35
-rw-r--r--source/com/c2kernel/gui/tabs/execution/Executor.java22
-rw-r--r--source/com/c2kernel/gui/tabs/execution/RequestButton.java34
5 files changed, 0 insertions, 442 deletions
diff --git a/source/com/c2kernel/gui/tabs/execution/ActivityItem.java b/source/com/c2kernel/gui/tabs/execution/ActivityItem.java
deleted file mode 100644
index 6a8f2f7..0000000
--- a/source/com/c2kernel/gui/tabs/execution/ActivityItem.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.c2kernel.gui.tabs.execution;
-import java.util.ArrayList;
-
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.lifecycle.instance.stateMachine.States;
-
-public class ActivityItem {
- public String stepPath;
- public int state;
- public String name;
- ArrayList<Job> jobs = new ArrayList<Job>();
-
- public ActivityItem() {
- stepPath = "";
- state = -1;
- name = "--";
- }
-
- public ActivityItem(Job thisJob) {
- stepPath = thisJob.getStepPath();
- state = thisJob.getCurrentState();
- name = thisJob.getStepName();
- jobs.add(thisJob);
- }
-
- public void addJob(Job newJob) {
- jobs.add(newJob);
- }
-
- public ArrayList<Job> getJobs() {
- return jobs;
- }
-
- public String getStepPath() {
- return stepPath;
- }
-
- @Override
- public String toString() {
- return name+(state>-1?" ("+States.getStateName(state)+")":"");
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof ActivityItem)
- return hashCode() == ((ActivityItem)other).hashCode();
- return false;
- }
-
- @Override
- public int hashCode() {
- return stepPath.hashCode();
- }
-
-}
diff --git a/source/com/c2kernel/gui/tabs/execution/ActivityViewer.java b/source/com/c2kernel/gui/tabs/execution/ActivityViewer.java
deleted file mode 100644
index 707f311..0000000
--- a/source/com/c2kernel/gui/tabs/execution/ActivityViewer.java
+++ /dev/null
@@ -1,296 +0,0 @@
-package com.c2kernel.gui.tabs.execution;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.util.ArrayList;
-
-import javax.swing.Box;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.entity.proxy.ItemProxy;
-import com.c2kernel.gui.MainFrame;
-import com.c2kernel.gui.tabs.EntityTabPane;
-import com.c2kernel.gui.tabs.ExecutionPane;
-import com.c2kernel.gui.tabs.outcome.OutcomeException;
-import com.c2kernel.gui.tabs.outcome.OutcomeHandler;
-import com.c2kernel.utils.FileStringUtility;
-import com.c2kernel.utils.Language;
-import com.c2kernel.utils.LocalObjectLoader;
-import com.c2kernel.utils.Logger;
-
-public class ActivityViewer extends JPanel implements Runnable {
-
- ItemProxy item;
- Box outcomeButtons = Box.createHorizontalBox();
- OutcomeHandler outcomePanel;
- JPanel outcomeView = new JPanel(new GridLayout(1,1));
- ActivityItem thisAct;
- ArrayList<RequestButton> requestButtons = new ArrayList<RequestButton>();
- JLabel noOutcome = new JLabel(Language.translate("No outcome data is required for this activity"));
- ExecutionPane parent;
- JLabel status;
- JComboBox executors;
- JButton saveButton = new JButton("Save");
- JButton loadButton = new JButton("Load");
- GridBagLayout gridbag = new GridBagLayout();
- Job executingJob = null;
- static JFileChooser chooser = new JFileChooser();
- static {
- chooser.addChoosableFileFilter(
- new javax.swing.filechooser.FileFilter() {
- @Override
- public String getDescription() {
- return "XML Files";
- }
- @Override
- public boolean accept(File f) {
- if (f.isDirectory() || (f.isFile() && f.getName().endsWith(".xml"))) {
- return true;
- }
- return false;
- }
- });
- }
-
- public ActivityViewer (ActivityItem newAct, ItemProxy item, ExecutionPane parent){
- thisAct = newAct;
- this.item = item;
- this.parent = parent;
- setLayout(gridbag);
-
- GridBagConstraints c = new GridBagConstraints();
- c.gridx=0; c.gridy=1; c.weightx=1.0; c.weighty=0.0;
- c.insets = new Insets(5,5,5,5);
- c.anchor = GridBagConstraints.NORTHWEST;
- c.fill = GridBagConstraints.HORIZONTAL;
-
-// activity title
- JLabel actTitle = new JLabel(Language.translate("Activity")+": "+newAct.name);
- actTitle.setFont(EntityTabPane.titleFont);
- gridbag.setConstraints(actTitle, c);
- add(actTitle);
-
- Job firstJob = (thisAct.getJobs().get(0));
-// desc
- String desc = firstJob.getDescription();
- if (desc != null && desc.length() > 0) {
- Box descBox = Box.createHorizontalBox();
-
- String chopDesc = null;
- if(desc.length() >= 40) chopDesc = desc.substring(0,40);
- else chopDesc = desc;
-
- descBox.add(new JLabel("Description: "+chopDesc));
- if (desc.length()>chopDesc.length()) {
- descBox.add(new JLabel(" ..."));
- descBox.add(Box.createHorizontalStrut(7));
- JButton descButton = new JButton("View");
- descButton.setMargin(new Insets(0,0,0,0));
- descButton.setActionCommand(desc);
- descButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JTextArea descArea = new JTextArea(e.getActionCommand());
- descArea.setLineWrap(true);
- descArea.setWrapStyleWord(true);
- JScrollPane descScroll = new JScrollPane(descArea);
- descScroll.setPreferredSize(new Dimension(400,150));
- JOptionPane.showMessageDialog(null, descScroll, "Activity Description", JOptionPane.PLAIN_MESSAGE);
- }
- });
- descBox.add(descButton);
- }
-
- c.gridy++;
- gridbag.setConstraints(descBox, c);
- add(descBox);
- }
-
-
-// agentid
- String roleName = firstJob.getAgentRole();
- if (roleName!= null && roleName.length()>0) {
- c.gridy++;
- JLabel role = new JLabel(Language.translate("Agent Role")+": "+roleName);
- gridbag.setConstraints(role, c);
- add(role);
- }
-
- c.gridy++;
- c.anchor = GridBagConstraints.EAST;
- gridbag.setConstraints(outcomeButtons, c);
- add(outcomeButtons);
-
- executors = MainFrame.getExecutionPlugins();
- if (executors.getItemCount() > 1) {
- c.gridx++;
- gridbag.setConstraints(executors, c);
- add(executors);
- c.gridx--;
- }
-
- c.gridy++;
-
- status = new JLabel(Language.translate("Waiting for request"));
- status.setFont(EntityTabPane.titleFont);
- gridbag.setConstraints(status, c);
- add(status);
-
- c.gridx++;
- Box fileBox = Box.createHorizontalBox();
- fileBox.add(saveButton); fileBox.add(Box.createHorizontalGlue()); fileBox.add(loadButton);
- gridbag.setConstraints(fileBox, c);
- add(fileBox);
- saveButton.setEnabled(false);
- loadButton.setEnabled(false);
- c.gridx--;
- c.gridwidth = 2;
- boolean outcomeEmpty = true;
- for (Object name2 : thisAct.getJobs()) {
- Job thisJob = (Job)name2;
- RequestButton newButton = new RequestButton(thisJob, this);
- requestButtons.add(newButton);
- outcomeButtons.add(newButton);
- outcomeButtons.add(Box.createHorizontalStrut(5));
-
- if (thisJob.isOutcomeUsed()) {
- String schema;
- if (outcomeEmpty) {
- try {
- schema = LocalObjectLoader.getSchema(thisJob.getSchemaType(), thisJob.getSchemaVersion()).schema;
- outcomePanel = EntityTabPane.getOutcomeHandler(thisJob.getSchemaType(), thisJob.getSchemaVersion());
- outcomePanel.setReadOnly(false);
- outcomePanel.setDescription(schema);
- String outcomeString = thisJob.getOutcomeString();
- if ( outcomeString!= null && outcomeString.length() > 0)
- outcomePanel.setOutcome(outcomeString);
- outcomeView = outcomePanel.getPanel();
- } catch (ObjectNotFoundException ex) {
- outcomeView.add(new JLabel(Language.translate("Schema not found:")+" "+thisJob.getSchemaType()+" v"+thisJob.getSchemaVersion()));
- outcomePanel = null;
- } catch (Exception ex) {
- outcomeView.add(new JLabel(Language.translate("ERROR loading outcome editor: ")
- +ex.getClass().getName()+" ("+ex.getMessage()+")"));
- Logger.error(ex);
- outcomePanel = null;
- }
- }
- outcomeEmpty = false;
- if (outcomePanel == null) newButton.setEnabled(false);
- else {
- saveButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String output;
- try {
- output = outcomePanel.getOutcome();
- int returnVal = chooser.showSaveDialog(null);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File targetFile = chooser.getSelectedFile();
- if (!(targetFile.getAbsolutePath().endsWith(".xml")))
- targetFile = new File(targetFile.getAbsolutePath()+".xml");
-
- Logger.msg(2, "ExecutionPane - Exporting outcome to file " + targetFile.getName());
- FileStringUtility.string2File(targetFile, output);
- }
- } catch (Exception ex) {
- Logger.error(ex);
- Logger.exceptionDialog(ex);
- }
- }
- });
- saveButton.setEnabled(true);
-
- loadButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- try {
- int returnVal = chooser.showOpenDialog(null);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File targetFile = chooser.getSelectedFile();
-
- Logger.msg(2, "ViewpointPane.actionPerformed() - Reading outcome from file " + targetFile.getName());
- String outcome = FileStringUtility.file2String(targetFile);
- outcomePanel.setOutcome(outcome);
- new Thread(outcomePanel).start();
- }
- } catch (Exception ex) {
- Logger.error(ex);
- Logger.exceptionDialog(ex);
- }
- }
- });
- loadButton.setEnabled(true);
- }
- }
- }
- if (outcomeEmpty)
- outcomeView.add(noOutcome);
- c.gridy++; c.weighty=1.0;
- c.anchor = GridBagConstraints.NORTHWEST;
- c.fill = GridBagConstraints.BOTH;
- gridbag.setConstraints(outcomeView, c);
- add(outcomeView);
-
- }
-
- public void init() {
- if (outcomePanel != null)
- new Thread(outcomePanel).start();
- }
-
- public void execute(Job thisJob) {
- try{
- if (thisJob.isOutcomeUsed() && thisJob.getSchemaType().length() > 0)
- thisJob.setOutcome(outcomePanel.getOutcome());
- executingJob = thisJob;
- new Thread(this).start();
- } catch (OutcomeException ex) {
- Logger.exceptionDialog(ex);
- }
-
- }
-
- /**
- * Submits the job to the database
- */
- @Override
- public void run() {
- Thread.currentThread().setName("Activity Execution");
- enableAllButtons(false);
- try {
- Executor selectedExecutor = (Executor)executors.getSelectedItem();
- selectedExecutor.execute(executingJob, status);
- } catch (Exception e) {
- Logger.error(e);
- status.setText(Language.translate("Error during execution"));
- Logger.exceptionDialog(e);
- }
- enableAllButtons(true);
- }
-
- private void enableAllButtons(boolean enabled) {
-
- for (RequestButton thisButton : requestButtons) {
- thisButton.setEnabled(enabled);
- }
- }
-
- public ActivityItem getActivity() {
- return thisAct;
- }
-}
diff --git a/source/com/c2kernel/gui/tabs/execution/DefaultExecutor.java b/source/com/c2kernel/gui/tabs/execution/DefaultExecutor.java
deleted file mode 100644
index 378cc2e..0000000
--- a/source/com/c2kernel/gui/tabs/execution/DefaultExecutor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.c2kernel.gui.tabs.execution;
-
-import javax.swing.JLabel;
-
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.gui.MainFrame;
-import com.c2kernel.utils.Language;
-
-/**************************************************************************
- *
- * $Revision: 1.2 $
- * $Date: 2003/11/04 14:31:30 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-public class DefaultExecutor implements Executor {
-
- public DefaultExecutor() {
- super();
- }
-
- @Override
- public void execute(Job job, JLabel status) throws Exception {
- status.setText(Language.translate("Requesting, please wait."));
- MainFrame.userAgent.execute(job);
- status.setText(Language.translate("Execution complete. Waiting for joblist update."));
- }
-
- @Override
- public String toString() {
- return "Normal";
- }
-}
diff --git a/source/com/c2kernel/gui/tabs/execution/Executor.java b/source/com/c2kernel/gui/tabs/execution/Executor.java
deleted file mode 100644
index 6fbde17..0000000
--- a/source/com/c2kernel/gui/tabs/execution/Executor.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.c2kernel.gui.tabs.execution;
-
-import javax.swing.JLabel;
-
-import com.c2kernel.entity.agent.Job;
-
-/**************************************************************************
- *
- * $Revision: 1.1 $
- * $Date: 2003/09/25 10:28:02 $
- *
- * Copyright (C) 2003 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-public interface Executor {
-
- @Override
- public String toString();
-
- public void execute(Job job, JLabel status) throws Exception;
-}
diff --git a/source/com/c2kernel/gui/tabs/execution/RequestButton.java b/source/com/c2kernel/gui/tabs/execution/RequestButton.java
deleted file mode 100644
index e1372a2..0000000
--- a/source/com/c2kernel/gui/tabs/execution/RequestButton.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.c2kernel.gui.tabs.execution;
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
-/**
- * Each job gets a RequestButton
- */
-
- public class RequestButton extends JButton implements ActionListener {
-
- Job myJob;
- ActivityViewer parent;
-
- public RequestButton(Job myJob, ActivityViewer parent) {
- super();
- this.myJob = myJob;
- this.parent = parent;
- String label = Transitions.getTransitionName(myJob.getPossibleTransition());
- label = Character.toUpperCase(label.charAt(0))+label.substring(1);
- if (myJob.isOutcomeUsed()) setBackground(Color.white);
- super.setText(label);
- addActionListener(this);
- }
-
- @Override
- public void actionPerformed(ActionEvent event) {
- parent.execute(myJob);
- }
- }