airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject airavata git commit: Fixed - Opening new workflow issues
Date Wed, 26 Nov 2014 00:19:28 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 4a79ee6ce -> b30577739


Fixed - Opening new workflow issues


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/b3057773
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/b3057773
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/b3057773

Branch: refs/heads/master
Commit: b305777397b0b75fa78ef8c5ba712528d5afbbad
Parents: 4a79ee6
Author: shamrath <shameerainfo@gmail.com>
Authored: Tue Nov 25 18:20:26 2014 -0500
Committer: shamrath <shameerainfo@gmail.com>
Committed: Tue Nov 25 18:20:26 2014 -0500

----------------------------------------------------------------------
 .../org/apache/airavata/xbaya/ui/XBayaGUI.java  | 164 ++++++++++---------
 .../workflow/WorkflowPropertyWindow.java        |  91 +++-------
 .../airavata/xbaya/ui/graph/GraphCanvas.java    |  14 +-
 3 files changed, 121 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/b3057773/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
index ac55462..1e44243 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/XBayaGUI.java
@@ -52,6 +52,7 @@ import org.apache.airavata.common.utils.SwingUtil;
 import org.apache.airavata.workflow.model.component.Component;
 import org.apache.airavata.workflow.model.exceptions.WorkflowException;
 import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
+import org.apache.airavata.workflow.model.graph.Graph;
 import org.apache.airavata.workflow.model.graph.Node;
 import org.apache.airavata.workflow.model.graph.Port;
 import org.apache.airavata.workflow.model.wf.Workflow;
@@ -256,55 +257,67 @@ public class XBayaGUI implements EventListener, XBayaExecutionModeListener
{
     public GraphCanvas newGraphCanvas(boolean focus) {
     	return newGraphCanvas(focus, false);
     }
-    
+
     /**
      * Creates a new graph tab.
-     * 
+     *
      * This method needs to be called by Swing event thread.
-     * 
+     *
      * @param focus
-     * 
+     *
      * @return The graph canvas created
      */
-    public GraphCanvas newGraphCanvas(boolean focus, boolean withID) {
-        GraphCanvas newGraphCanvas = new GraphCanvas(this.engine);
+    public GraphCanvas newGraphCanvas(boolean focus, boolean newFreshWorkflow) {
+        if (newFreshWorkflow) {
+            getWorkflowPropertyWindow().show();
+            return null;
+        } else {
+            GraphCanvas graphCanvas = getNewGraphCanvas(null, null);
+            if (focus) {
+                setFocus(graphCanvas);
+            }
+            return graphCanvas;
+        }
+    }
+
+    public GraphCanvas getNewGraphCanvas(String wfName, String wfDescription) {
+        GraphCanvas newGraphCanvas = new GraphCanvas(this.engine, wfName);
+        newGraphCanvas.setDescription(wfDescription);
         this.graphCanvases.add(newGraphCanvas);
         this.graphTabbedPane.addTab(newGraphCanvas.getWorkflow().getName(), newGraphCanvas.getSwingComponent());
-        final int index = graphTabbedPane.getTabCount()-1;
-		TabLabelButton tabLabelButton = new TabLabelButton(graphTabbedPane,"Close this workflow");
-		graphTabbedPane.setTabComponentAt(index, tabLabelButton); 
-		tabLabelButton.setCloseButtonListener(new ActionListener(){
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				removeGraphCanvasFromIndex(index);				
-			}
-		});
-        graphTabbedPane.addContainerListener(new ContainerListener(){
+        final int index = graphTabbedPane.getTabCount() - 1;
+        TabLabelButton tabLabelButton = new TabLabelButton(graphTabbedPane, "Close this workflow");
+        graphTabbedPane.setTabComponentAt(index, tabLabelButton);
+        tabLabelButton.setCloseButtonListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                removeGraphCanvasFromIndex(index);
+            }
+        });
+        graphTabbedPane.addContainerListener(new ContainerListener() {
 
-			@Override
-			public void componentAdded(ContainerEvent event) {
-			}
+            @Override
+            public void componentAdded(ContainerEvent event) {
+            }
+
+            @Override
+            public void componentRemoved(ContainerEvent event) {
+                List<GraphCanvas> graphCanvases = engine.getGUI().getGraphCanvases();
+                for (GraphCanvas graphCanvas : graphCanvases) {
+                    if (graphCanvas.getSwingComponent() == event.getComponent()) {
+                        if (graphCanvas.isWorkflowChanged()) {
+                            setFocus(graphCanvas);
+                            if (JOptionPane.showConfirmDialog(null, "The workflow '" + graphCanvas.getWorkflow().getName()
+ "' has been modified. Save changes?", "Save Workflow", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
{
+                                graphFiler.saveWorkflow(graphCanvas);
+                            }
+                        }
+                        break;
+                    }
+                }
+            }
 
-			@Override
-			public void componentRemoved(ContainerEvent event) {
-				List<GraphCanvas> graphCanvases = engine.getGUI().getGraphCanvases();
-				for (GraphCanvas graphCanvas : graphCanvases) {
-					if (graphCanvas.getSwingComponent()==event.getComponent()){
-						if (graphCanvas.isWorkflowChanged()){
-							setFocus(graphCanvas);
-							if (JOptionPane.showConfirmDialog(null, "The workflow '"+graphCanvas.getWorkflow().getName()+"'
has been modified. Save changes?", "Save Workflow", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
-								graphFiler.saveWorkflow(graphCanvas);
-							}
-						}
-						break;
-					}
-				}
-			}
-        	
         });
-        if (focus) {
-            setFocus(newGraphCanvas);
-        }
+
         newGraphCanvas.addGraphCanvasListener(this.componentViewer);
         newGraphCanvas.addGraphCanvasListener(this.portViewer);
         newGraphCanvas.addGraphCanvasListener(new GraphCanvasListener() {
@@ -314,55 +327,52 @@ public class XBayaGUI implements EventListener, XBayaExecutionModeListener
{
                 final GraphCanvas graphCanvas = event.getGraphCanvas();
                 final Workflow workflow = event.getWorkflow();
                 switch (type) {
-                case GRAPH_LOADED:
-                case NAME_CHANGED:
-                    SwingUtilities.invokeLater(new Runnable() {
-                        public void run() {
-                            String name = workflow.getName();
-
-                            // Change the name of the tab.
-                            updateTabTitle(graphCanvas, workflow);
-
-                            // Change the name of the frame.
-                            setFrameName(name);
+                    case GRAPH_LOADED:
+                    case NAME_CHANGED:
+                        SwingUtilities.invokeLater(new Runnable() {
+                            public void run() {
+                                String name = workflow.getName();
+
+                                // Change the name of the tab.
+                                updateTabTitle(graphCanvas, workflow);
+
+                                // Change the name of the frame.
+                                setFrameName(name);
+                            }
+                        });
+                        break;
+                    case NODE_SELECTED:
+                    case INPUT_PORT_SELECTED:
+                    case OUTPUT_PORT_SELECTED:
+                        // Do nothing
+                    case WORKFLOW_CHANGED:
+                        updateTabTitle(graphCanvas, graphCanvas.getWorkflow());
+                        setFrameName(workflow.getName());
+                        for (ChangeListener listener : tabChangeListeners) {
+                            try {
+                                listener.stateChanged(null);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
                         }
-
-						
-                    });
-                    break;
-                case NODE_SELECTED:
-                case INPUT_PORT_SELECTED:
-                case OUTPUT_PORT_SELECTED:
-                    // Do nothing
-                case WORKFLOW_CHANGED:
-                	updateTabTitle(graphCanvas,graphCanvas.getWorkflow());
-                	setFrameName(workflow.getName());
-                	for (ChangeListener listener:tabChangeListeners){
-                		try{
-                			listener.stateChanged(null);
-                		}catch(Exception e){
-                			e.printStackTrace();
-                		}
-                	}
                 }
             }
+
             private void updateTabTitle(
-					final GraphCanvas graphCanvas,
-					final Workflow workflow) {
-				int index = XBayaGUI.this.graphTabbedPane.indexOfComponent(graphCanvas.getSwingComponent());
+                    final GraphCanvas graphCanvas,
+                    final Workflow workflow) {
+                int index = XBayaGUI.this.graphTabbedPane.indexOfComponent(graphCanvas.getSwingComponent());
                 String newTitle = workflow.getName();
-                if (graphCanvas.isWorkflowChanged()){
-                	newTitle="*"+newTitle;
+                if (graphCanvas.isWorkflowChanged()) {
+                    newTitle = "*" + newTitle;
                 }
-				XBayaGUI.this.graphTabbedPane.setTitleAt(index, newTitle);
-			}
+                XBayaGUI.this.graphTabbedPane.setTitleAt(index, newTitle);
+            }
         });
-        if (withID){
-        	getWorkflowPropertyWindow().show();
-        }
         return newGraphCanvas;
     }
 
+
     /**
      * @param graphCanvas
      */

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3057773/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
index aad4141..d4bd884 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/workflow/WorkflowPropertyWindow.java
@@ -23,6 +23,7 @@ package org.apache.airavata.xbaya.ui.dialogs.workflow;
 
 import java.awt.event.ActionEvent;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.swing.AbstractAction;
@@ -80,38 +81,32 @@ public class WorkflowPropertyWindow {
      * Shows the dialog.
      */
     public void show() {
-        this.workflow = this.xbayaGUI.getWorkflow();
+//        this.workflow = this.xbayaGUI.getWorkflow();
 
-        String name = this.workflow.getName();
+//        String name = this.workflow.getName();
+        String name = generateNewWorkflowName();
         this.nameTextField.setText(name);
 
-        String description = this.workflow.getDescription();
+        String description = "Airavata workflow";
         this.descriptionTextArea.setText(description);
-
-        URI templateID = this.workflow.getUniqueWorkflowName();
-        if (templateID == null) {
-            this.templateIDField.setText("");
-        } else {
-            this.templateIDField.setText(templateID.toString());
+        this.dialog.show();
+    }
+    private String generateNewWorkflowName() {
+        String baseName="Workflow";
+        List<String> existingNames=new ArrayList<String>();
+        if (this.xbayaGUI != null) {
+            List<GraphCanvas> graphCanvases = this.xbayaGUI.getGraphCanvases();
+            for (GraphCanvas graphCanvas : graphCanvases) {
+                existingNames.add(graphCanvas.getWorkflow().getName());
+            }
         }
-
-        URI instanceID = this.workflow.getGPELInstanceID();
-        if (instanceID == null) {
-            this.instanceIDField.setText("");
-        } else {
-            this.instanceIDField.setText(instanceID.toString());
+        int i=1;
+        String newName=baseName+i;
+        while(existingNames.contains(newName)){
+            i++;
+            newName=baseName+i;
         }
-
-//        XmlElement metadata = this.workflow.getMetadata();
-//        String metadataText;
-//        if (metadata == null) {
-//            metadataText = WSConstants.EMPTY_APPINFO;
-//        } else {
-//            metadataText = XMLUtil.xmlElementToString(metadata);
-//        }
-//        this.metadataTextArea.setText(metadataText);
-
-        this.dialog.show();
+        return newName;
     }
 
     /**
@@ -138,29 +133,7 @@ public class WorkflowPropertyWindow {
         String name = this.nameTextField.getText();
         if (name != null && name.equals(StringUtil.convertToJavaIdentifier(name))
&& (!isWorkflowNameAlreadyPresent(name))) {
             String description = this.descriptionTextArea.getText();
-//            String metadataText = this.metadataTextArea.getText();
-
-//            XmlElement metadata;
-//            if (metadataText.length() == 0) {
-//                metadata = null;
-//            } else {
-//                try {
-////                    metadata = XMLUtil.stringToXmlElement(metadataText);
-//                    JsonObject metadataObject = new JsonObject();
-//                    JsonObject appInfoObject = new JsonObject();
-//                    appInfoObject.add("data", JSONUtil.stringToJSONObject(metadataText));
-//
-//                    metadata = XMLUtil.stringToXmlElement(metadataText);
-//                } catch (RuntimeException e) {
-//                    String warning = "The metadata is ill-formed.";
-//                    this.xbayaGUI.getErrorWindow().error(warning, e);
-//                    return;
-//                }
-//            }
-
-            GraphCanvas graphCanvas = this.xbayaGUI.getGraphCanvas();
-            graphCanvas.setNameAndDescription(name, description);
-//            graphCanvas.getWorkflow().setMetadata(metadata);
+            this.xbayaGUI.getNewGraphCanvas(name, description);
             hide();
         } else {
             this.nameTextField.setText(StringUtil.convertToJavaIdentifier(name));
@@ -172,33 +145,15 @@ public class WorkflowPropertyWindow {
     private void initGui() {
         this.nameTextField = new XBayaTextField();
         XBayaLabel nameLabel = new XBayaLabel("Name", this.nameTextField);
-
-        this.templateIDField = new XBayaTextField();
-        this.templateIDField.setEditable(false);
-        XBayaLabel templateIDLabel = new XBayaLabel("Template ID", this.templateIDField);
-
-        this.instanceIDField = new XBayaTextField();
-        this.instanceIDField.setEditable(false);
-        XBayaLabel instanceIDLabel = new XBayaLabel("Instance ID", this.instanceIDField);
-
         this.descriptionTextArea = new XBayaTextArea();
         XBayaLabel descriptionLabel = new XBayaLabel("Description", this.descriptionTextArea);
 
-//        this.metadataTextArea = new XBayaTextArea();
-//        XBayaLabel metadataLabel = new XBayaLabel("Metadata", this.metadataTextArea);
-
         GridPanel mainPanel = new GridPanel();
         mainPanel.add(nameLabel);
         mainPanel.add(this.nameTextField);
-        mainPanel.add(templateIDLabel);
-        mainPanel.add(this.templateIDField);
-        mainPanel.add(instanceIDLabel);
-        mainPanel.add(this.instanceIDField);
         mainPanel.add(descriptionLabel);
         mainPanel.add(this.descriptionTextArea);
-//        mainPanel.add(metadataLabel);
-//        mainPanel.add(this.metadataTextArea);
-        mainPanel.layout(new double[] { 0, 0, 0, 0.5}, new double[] { 0, 1 });
+        mainPanel.layout(new double[] { 0, 0.5}, new double[] { 0, 1 });
 
         this.okButton = new JButton("OK");
         this.okButton.addActionListener(new AbstractAction() {

http://git-wip-us.apache.org/repos/asf/airavata/blob/b3057773/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
index fa7b8eb..517e0f7 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/graph/GraphCanvas.java
@@ -163,17 +163,22 @@ public class GraphCanvas implements XBayaExecutionModeListener{
      *            The XBayaEngine
      */
     public GraphCanvas(XBayaEngine engine) {
+        this(engine, null);
+    }
 
+    public GraphCanvas(XBayaEngine engine, String workflowName) {
         this.engine = engine;
-
         this.listeners = new LinkedList<GraphCanvasListener>();
-
         // To avoid null check. Do not call newWorkflow() here because something
         // are not initialized yet at this point.
         this.workflow = new Workflow();
         this.graph = this.workflow.getGraph();
         engine.getConfiguration().registerExecutionModeChangeListener(this);
-        graph.setName(generateNewWorkflowName());
+        if (workflowName == null) {
+            graph.setName(generateNewWorkflowName());
+        } else {
+            graph.setName(workflowName);
+        }
         initGUI();
         executionModeChanged(engine.getConfiguration());
     }
@@ -263,6 +268,9 @@ public class GraphCanvas implements XBayaExecutionModeListener{
         notifyListeners(new GraphCanvasEvent(GraphCanvasEvent.GraphCanvasEventType.NAME_CHANGED,
this, this.workflow));
     }
 
+    public void setDescription(String description) {
+        this.workflow.setDescription(description);
+    }
     /**
      * Creates a new Node from a specified Component and adds it.
      * 


Mime
View raw message