From 254ee6f47eebfc00462c10756a92066e82cc1a96 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 21 Jun 2011 15:46:02 +0200 Subject: Initial commit --- .../gui/view/ElemActDefOutcomeHandler.java | 152 +++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100755 source/com/c2kernel/lifecycle/gui/view/ElemActDefOutcomeHandler.java (limited to 'source/com/c2kernel/lifecycle/gui/view/ElemActDefOutcomeHandler.java') diff --git a/source/com/c2kernel/lifecycle/gui/view/ElemActDefOutcomeHandler.java b/source/com/c2kernel/lifecycle/gui/view/ElemActDefOutcomeHandler.java new file mode 100755 index 0000000..a30491e --- /dev/null +++ b/source/com/c2kernel/lifecycle/gui/view/ElemActDefOutcomeHandler.java @@ -0,0 +1,152 @@ +package com.c2kernel.lifecycle.gui.view; + +import java.io.File; + +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import com.c2kernel.graph.model.GraphableVertex; +import com.c2kernel.graph.view.VertexPropertyPanel; +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.gui.tabs.outcome.OutcomeNotInitialisedException; +import com.c2kernel.lifecycle.ActivityDef; +import com.c2kernel.lifecycle.ActivitySlotDef; +import com.c2kernel.lifecycle.CompositeActivityDef; +import com.c2kernel.utils.CastorXMLUtility; +import com.c2kernel.utils.FileStringUtility; +import com.c2kernel.utils.LocalObjectLoader; +import com.c2kernel.utils.Logger; + +/************************************************************************** + * + * $Revision: 1.5 $ + * $Date: 2005/10/05 07:39:37 $ + * + * Copyright (C) 2003 CERN - European Organization for Nuclear Research + * All rights reserved. + **************************************************************************/ + +public class ElemActDefOutcomeHandler extends VertexPropertyPanel implements OutcomeHandler { + + ActivityDef act; + boolean unsaved; + public ElemActDefOutcomeHandler() { + super(); + createLayout(null); + } + + /** + * + */ + public void setOutcome(String outcome) throws InvalidOutcomeException { + try { + act = (ActivityDef)CastorXMLUtility.unmarshall(outcome); + setVertex(act); + } catch (Exception ex) { + Logger.error(ex); + throw new InvalidOutcomeException(); + } + } + + /** + * + */ + public void setDescription(String description) + throws InvalidSchemaException { + // ignore + } + + /** + * + */ + public void setReadOnly(boolean readOnly) { + setEditable(!readOnly); + + } + + /** + * + */ + public JPanel getPanel() throws OutcomeNotInitialisedException { + return this; + } + + /** + * + */ + public String getOutcome() throws OutcomeException { + try { + return CastorXMLUtility.marshall(act); + } catch (Exception ex) { + Logger.error(ex); + throw new OutcomeException(); + } + } + + /** + * + */ + public void run() { + validate(); + } + + public boolean isUnsaved() { + return unsaved; + } + + public void saved() { + unsaved = false; + } + + public void export(File targetFile) throws Exception { + exportAct(targetFile.getParentFile(), act); + } + + public static void exportAct(File dir, ActivityDef actDef) throws Exception { + FileStringUtility.string2File(new File(dir, actDef.getActName()+".xml"), CastorXMLUtility.marshall(actDef)); + // Export associated schema + exportSchema((String)actDef.getProperties().get("SchemaType"), (String)actDef.getProperties().get("SchemaVersion"), dir); + // Export associated script + exportScript((String)actDef.getProperties().get("ScriptName"), (String)actDef.getProperties().get("ScriptVersion"), dir); + + //Export child act if composite + if (actDef instanceof CompositeActivityDef) { + CompositeActivityDef compActDef = (CompositeActivityDef)actDef; + for (int i=0; i