From b9402204384bb5cfc25e6038d2f976f9f0c16fba Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 18 Nov 2013 09:53:33 +0100 Subject: 3.0-SNAPSHOT IssueID #28 --- .../gui/tabs/execution/ActivityViewer.java | 92 +++++++++++++--------- 1 file changed, 54 insertions(+), 38 deletions(-) (limited to 'src/main/java/com/c2kernel/gui/tabs/execution/ActivityViewer.java') 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); -- cgit v1.2.3