summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/gui/tabs/execution
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/gui/tabs/execution')
-rw-r--r--src/main/java/com/c2kernel/gui/tabs/execution/ActivityItem.java7
-rw-r--r--src/main/java/com/c2kernel/gui/tabs/execution/ActivityViewer.java92
-rw-r--r--src/main/java/com/c2kernel/gui/tabs/execution/RequestButton.java18
3 files changed, 71 insertions, 46 deletions
diff --git a/src/main/java/com/c2kernel/gui/tabs/execution/ActivityItem.java b/src/main/java/com/c2kernel/gui/tabs/execution/ActivityItem.java
index 6a8f2f7..bacdd52 100644
--- a/src/main/java/com/c2kernel/gui/tabs/execution/ActivityItem.java
+++ b/src/main/java/com/c2kernel/gui/tabs/execution/ActivityItem.java
@@ -2,11 +2,11 @@ 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 stateName;
public String name;
ArrayList<Job> jobs = new ArrayList<Job>();
@@ -18,7 +18,8 @@ public class ActivityItem {
public ActivityItem(Job thisJob) {
stepPath = thisJob.getStepPath();
- state = thisJob.getCurrentState();
+ state = thisJob.getTransition().getOriginStateId();
+ stateName = thisJob.getOriginStateName();
name = thisJob.getStepName();
jobs.add(thisJob);
}
@@ -37,7 +38,7 @@ public class ActivityItem {
@Override
public String toString() {
- return name+(state>-1?" ("+States.getStateName(state)+")":"");
+ return name+(state>-1?" ("+stateName+")":"");
}
@Override
diff --git a/src/main/java/com/c2kernel/gui/tabs/execution/ActivityViewer.java b/src/main/java/com/c2kernel/gui/tabs/execution/ActivityViewer.java
index 7723e16..a265bc1 100644
--- a/src/main/java/com/c2kernel/gui/tabs/execution/ActivityViewer.java
+++ b/src/main/java/com/c2kernel/gui/tabs/execution/ActivityViewer.java
@@ -19,6 +19,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
+import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.agent.Job;
import com.c2kernel.entity.proxy.ItemProxy;
@@ -29,6 +30,7 @@ import com.c2kernel.gui.tabs.outcome.InvalidOutcomeException;
import com.c2kernel.gui.tabs.outcome.InvalidSchemaException;
import com.c2kernel.gui.tabs.outcome.OutcomeException;
import com.c2kernel.gui.tabs.outcome.OutcomeHandler;
+import com.c2kernel.persistency.outcome.Schema;
import com.c2kernel.utils.FileStringUtility;
import com.c2kernel.utils.Language;
import com.c2kernel.utils.LocalObjectLoader;
@@ -171,29 +173,42 @@ public class ActivityViewer extends JPanel implements Runnable {
outcomeButtons.add(Box.createHorizontalStrut(5));
newButton.setEnabled(false);
- if (thisJob.requiresOutcome() && outcomePanel == null) {
- try {
- outcomePanel = getOutcomeHandler(thisJob);
- outcomeView = outcomePanel.getPanel();
- newButton.setEnabled(true);
- } catch (ObjectNotFoundException ex) {
- outcomeView.add(new JLabel(Language.translate("Schema not found:")+" "+thisJob.getSchemaType()+" v"+thisJob.getSchemaVersion()));
- } catch (Exception ex) {
- outcomeView.add(new JLabel(Language.translate("ERROR loading outcome editor: ")
- +ex.getClass().getName()+" ("+ex.getMessage()+")"));
- Logger.error(ex);
- }
- }
- else if (thisJob.isError()) {
- try {
- errorPanel = getOutcomeHandler(thisJob);
- errorView.add(errorPanel.getPanel());
- newButton.setEnabled(true);
- } catch (Exception ex) {
- errorView.add(new JLabel(Language.translate("ERROR loading error editor: ")
+ if (thisJob.hasOutcome()) {
+
+ String schemaName;
+ int schemaVersion;
+ try {
+ schemaName = thisJob.getSchemaName();
+ schemaVersion = thisJob.getSchemaVersion();
+ } catch (Exception e) {
+ newButton.setToolTipText("Could not load schema for this job.");
+ continue;
+ }
+
+ if(!schemaName.equals("Errors") && outcomePanel == null) {
+ try {
+ outcomePanel = getOutcomeHandler(thisJob);
+ outcomeView = outcomePanel.getPanel();
+ newButton.setEnabled(true);
+ } catch (ObjectNotFoundException ex) {
+ outcomeView.add(new JLabel(Language.translate("Schema not found:")+" "+schemaName+" v"+schemaVersion));
+ } catch (Exception ex) {
+ outcomeView.add(new JLabel(Language.translate("ERROR loading outcome editor: ")
+ex.getClass().getName()+" ("+ex.getMessage()+")"));
-
- }
+ Logger.error(ex);
+ }
+ }
+ if (schemaName.equals("Errors")) {
+ try {
+ errorPanel = getOutcomeHandler(thisJob);
+ errorView.add(errorPanel.getPanel());
+ newButton.setEnabled(true);
+ } catch (Exception ex) {
+ errorView.add(new JLabel(Language.translate("ERROR loading error editor: ")
+ +ex.getClass().getName()+" ("+ex.getMessage()+")"));
+
+ }
+ }
}
else
newButton.setEnabled(true);
@@ -212,11 +227,11 @@ public class ActivityViewer extends JPanel implements Runnable {
}
- public OutcomeHandler getOutcomeHandler(Job thisJob) throws ObjectNotFoundException, InvalidSchemaException, InvalidOutcomeException {
+ public OutcomeHandler getOutcomeHandler(Job thisJob) throws ObjectNotFoundException, InvalidSchemaException, InvalidOutcomeException, InvalidDataException {
String schema;
OutcomeHandler thisForm;
- schema = LocalObjectLoader.getSchema(thisJob.getSchemaType(), thisJob.getSchemaVersion()).schema;
- thisForm = EntityTabPane.getOutcomeHandler(thisJob.getSchemaType(), thisJob.getSchemaVersion());
+ schema = LocalObjectLoader.getSchema(thisJob.getSchemaName(), thisJob.getSchemaVersion()).schema;
+ thisForm = EntityTabPane.getOutcomeHandler(thisJob.getSchemaName(), thisJob.getSchemaVersion());
thisForm.setReadOnly(false);
thisForm.setDescription(schema);
String outcomeString = thisJob.getOutcomeString();
@@ -280,21 +295,21 @@ public class ActivityViewer extends JPanel implements Runnable {
public void execute(Job thisJob) {
try {
- if (thisJob.requiresOutcome() && thisJob.getSchemaType().length() > 0)
- thisJob.setOutcome(outcomePanel.getOutcome());
- else if (thisJob.isError()) {
- //JOptionPane errorDialog = new JOptionPane();
- Box errorBox = Box.createVerticalBox();
- errorBox.add(new JLabel("Please give details of the error:"));
- errorBox.add(errorView);
- int result = JOptionPane.showConfirmDialog(this, errorBox, "Send Error", JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
- if (result != JOptionPane.OK_OPTION)
- return;
- thisJob.setOutcome(errorPanel.getOutcome());
- }
+ if (thisJob.hasOutcome())
+ if (!thisJob.getSchemaName().equals("Errors"))
+ thisJob.setOutcome(outcomePanel.getOutcome());
+ else {
+ Box errorBox = Box.createVerticalBox();
+ errorBox.add(new JLabel("Please give details of the error:"));
+ errorBox.add(errorView);
+ int result = JOptionPane.showConfirmDialog(this, errorBox, "Send Error", JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
+ if (result != JOptionPane.OK_OPTION)
+ return;
+ thisJob.setOutcome(errorPanel.getOutcome());
+ }
executingJob = thisJob;
new Thread(this).start();
- } catch (OutcomeException ex) {
+ } catch (Exception ex) {
MainFrame.exceptionDialog(ex);
}
@@ -313,6 +328,7 @@ public class ActivityViewer extends JPanel implements Runnable {
} catch (Exception e) {
Logger.error(e);
MainFrame.progress.stopBouncing(Language.translate("Error during execution"));
+ status.setText(Language.translate("Error during execution: "+e.getClass().getSimpleName()));
MainFrame.exceptionDialog(e);
}
enableAllButtons(true);
diff --git a/src/main/java/com/c2kernel/gui/tabs/execution/RequestButton.java b/src/main/java/com/c2kernel/gui/tabs/execution/RequestButton.java
index 96123ff..440bb58 100644
--- a/src/main/java/com/c2kernel/gui/tabs/execution/RequestButton.java
+++ b/src/main/java/com/c2kernel/gui/tabs/execution/RequestButton.java
@@ -6,7 +6,8 @@ import java.awt.event.ActionListener;
import javax.swing.JButton;
import com.c2kernel.entity.agent.Job;
-import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
+import com.c2kernel.gui.MainFrame;
+import com.c2kernel.utils.Logger;
/**
* Each job gets a RequestButton
*/
@@ -20,10 +21,17 @@ import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
super();
this.myJob = myJob;
this.parent = parent;
- String label = Transitions.getTransitionName(myJob.getPossibleTransition());
- label = Character.toUpperCase(label.charAt(0))+label.substring(1);
- if (myJob.requiresOutcome()) setBackground(Color.white);
- if (myJob.isError()) setBackground(Color.pink);
+ String label = myJob.getTransition().getName();
+ if (myJob.hasOutcome()) {
+ setBackground(Color.white);
+ try {
+ if (myJob.getSchemaName().equals("Errors")) setBackground(Color.pink);
+ } catch (Exception e) {
+ Logger.error(e);
+ MainFrame.exceptionDialog(e);
+ setEnabled(false);
+ }
+ }
super.setText(label);
addActionListener(this);
}