airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1199371 - in /incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya: graph/gui/ graph/impl/ gui/ menues/xbaya/ wf/ wf/gui/
Date Tue, 08 Nov 2011 18:07:17 GMT
Author: lahiru
Date: Tue Nov  8 18:07:16 2011
New Revision: 1199371

URL: http://svn.apache.org/viewvc?rev=1199371&view=rev
Log:
https://issues.apache.org/jira/browse/AIRAVATA-195

Modified:
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvasEvent.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/GraphImpl.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/XBayaMenuItem.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/gui/WorkflowPropertyWindow.java

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java
Tue Nov  8 18:07:16 2011
@@ -43,6 +43,7 @@ import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseMotionListener;
 import java.awt.image.BufferedImage;
+import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -61,6 +62,7 @@ import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
 
 import org.apache.airavata.common.utils.SwingUtil;
+import org.apache.airavata.common.utils.XMLUtil;
 import org.apache.airavata.xbaya.XBayaEngine;
 import org.apache.airavata.xbaya.XBayaException;
 import org.apache.airavata.xbaya.XBayaExecutionState;
@@ -87,6 +89,8 @@ import org.apache.airavata.xbaya.gui.Err
 import org.apache.airavata.xbaya.wf.Workflow;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.XmlElement;
+
 
 /**
  * A canvas to display a graph (workflow).
@@ -134,6 +138,8 @@ public class GraphCanvas {
 
     private PortAddable dynamicNodeWithFreePort;
 
+    private File workflowFile;
+    
     /*
      * For multiple selection
      */
@@ -147,6 +153,8 @@ public class GraphCanvas {
 
     private JMenuItem labelNodesItem;
 
+    private XmlElement originalWorkflowElement;
+    
     /**
      * Creates a GraphPanel.
      * 
@@ -164,9 +172,26 @@ public class GraphCanvas {
         this.workflow = new Workflow();
         this.graph = this.workflow.getGraph();
 
+        graph.setName(generateNewWorkflowName());
         initGUI();
     }
 
+	private String generateNewWorkflowName() {
+		String baseName="Workflow";
+        List<GraphCanvas> graphCanvases = this.engine.getGUI().getGraphCanvases();
+        List<String> existingNames=new ArrayList<String>();
+        for (GraphCanvas graphCanvas : graphCanvases) {
+        	existingNames.add(graphCanvas.getWorkflow().getName());
+		}
+        int i=1;
+        String newName=baseName+i;
+        while(existingNames.contains(newName)){
+        	i++;
+        	newName=baseName+i;
+        }
+		return newName;
+	}
+
     /**
      * @return The panel.
      */
@@ -212,6 +237,7 @@ public class GraphCanvas {
         notifyListeners(new GraphCanvasEvent(GraphCanvasEvent.GraphCanvasEventType.GRAPH_LOADED,
this, this.workflow));
         updateSize();
         this.panel.repaint();
+        updateOriginalWorkflowElement();
     }
 
     /**
@@ -1103,6 +1129,7 @@ public class GraphCanvas {
             @Override
             public void mouseReleased(MouseEvent event) {
                 GraphCanvas.this.mouseReleased(event);
+                notifyListeners(new GraphCanvasEvent(GraphCanvasEvent.GraphCanvasEventType.WORKFLOW_CHANGED,
GraphCanvas.this, GraphCanvas.this.workflow));
             }
         });
 
@@ -1358,4 +1385,33 @@ public class GraphCanvas {
         }
 
     }
+
+	public File getWorkflowFile() {
+		return workflowFile;
+	}
+
+	public void setWorkflowFile(File workflowFile) {
+		this.workflowFile = workflowFile;
+	}
+	
+	public boolean isWorkflowChanged(){
+		try {
+			if (originalWorkflowElement==null){
+				updateOriginalWorkflowElement();
+			}
+			return !XMLUtil.isEqual(originalWorkflowElement, getWorkflow().toXML());
+		} catch (Exception e) {
+			e.printStackTrace();
+			return true;
+		}
+	}
+	
+	public void workflowSaved(){
+		updateOriginalWorkflowElement();
+        notifyListeners(new GraphCanvasEvent(GraphCanvasEvent.GraphCanvasEventType.WORKFLOW_CHANGED,
this, this.workflow));
+	}
+
+	private void updateOriginalWorkflowElement() {
+		originalWorkflowElement = getWorkflow().toXML();
+	}
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvasEvent.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvasEvent.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvasEvent.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvasEvent.java
Tue Nov  8 18:07:16 2011
@@ -48,7 +48,12 @@ public class GraphCanvasEvent {
         /**
          * An output port is selected.
          */
-        OUTPUT_PORT_SELECTED
+        OUTPUT_PORT_SELECTED,
+        
+        /**
+         * Event when the workflow was changed
+         */
+        WORKFLOW_CHANGED
     }
 
     private GraphCanvasEventType type;

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/GraphImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/GraphImpl.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/GraphImpl.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/GraphImpl.java
Tue Nov  8 18:07:16 2011
@@ -111,8 +111,8 @@ public abstract class GraphImpl implemen
             // No other choice but to prompt
             // the user to pick an id
             final XBayaEngine engine = XBayaEngine.getInstance();
-            JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Provide a relatively
unique workflow name",
-                    "Workflow Name", JOptionPane.OK_OPTION);
+//            JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Provide a relatively
unique workflow name",
+//                    "Workflow Name", JOptionPane.OK_OPTION);
             engine.getWorkflowPropertyWindow().show();
             this.id = this.name;
             // If its still null

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaGUI.java
Tue Nov  8 18:07:16 2011
@@ -215,6 +215,10 @@ public class XBayaGUI implements EventLi
         return this.toolbar;
     }
 
+    public GraphCanvas newGraphCanvas(boolean focus) {
+    	return newGraphCanvas(focus, false);
+    }
+    
     /**
      * Creates a new graph tab.
      * 
@@ -224,10 +228,10 @@ public class XBayaGUI implements EventLi
      * 
      * @return The graph canvas created
      */
-    public GraphCanvas newGraphCanvas(boolean focus) {
+    public GraphCanvas newGraphCanvas(boolean focus, boolean withID) {
         GraphCanvas newGraphCanvas = new GraphCanvas(this.engine);
         this.graphCanvases.add(newGraphCanvas);
-        this.graphTabbedPane.addTab("Workflow", newGraphCanvas.getSwingComponent());
+        this.graphTabbedPane.addTab(newGraphCanvas.getWorkflow().getName(), newGraphCanvas.getSwingComponent());
         if (focus) {
             setFocus(newGraphCanvas);
         }
@@ -247,21 +251,37 @@ public class XBayaGUI implements EventLi
                             String name = workflow.getName();
 
                             // Change the name of the tab.
-                            int index = XBayaGUI.this.graphTabbedPane.indexOfComponent(graphCanvas.getSwingComponent());
-                            XBayaGUI.this.graphTabbedPane.setTitleAt(index, workflow.getName());
+                            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());
                 }
             }
+            private void updateTabTitle(
+					final GraphCanvas graphCanvas,
+					final Workflow workflow) {
+				int index = XBayaGUI.this.graphTabbedPane.indexOfComponent(graphCanvas.getSwingComponent());
+                String newTitle = workflow.getName();
+                if (graphCanvas.isWorkflowChanged()){
+                	newTitle="*"+newTitle;
+                }
+				XBayaGUI.this.graphTabbedPane.setTitleAt(index, newTitle);
+			}
         });
+        if (withID){
+        	newGraphCanvas.getWorkflow().getGraph().getID();
+        }
         return newGraphCanvas;
     }
 
@@ -302,7 +322,7 @@ public class XBayaGUI implements EventLi
     public void closeGraphCanvas() {
         removeGraphCanvasFromIndex(this.graphTabbedPane.getSelectedIndex());
     	//I dont know why but aparently you have to have atleast one tab present
-    	newGraphCanvas(true);
+//    	newGraphCanvas(true);
     }
 
     public void closeAllGraphCanvas(){
@@ -310,7 +330,7 @@ public class XBayaGUI implements EventLi
     		removeGraphCanvasFromIndex(0);
     	}
     	//I dont know why but aparently you have to have atleast one tab present
-    	newGraphCanvas(true);
+//    	newGraphCanvas(true);
     }
     
 	private void removeGraphCanvasFromIndex(int index) {
@@ -408,7 +428,7 @@ public class XBayaGUI implements EventLi
         initPane();
 
         // Create an empty graph canvas.
-        newGraphCanvas(true);
+//        newGraphCanvas(true);
 
         this.frame.setVisible(true);
     }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/WorkflowFiler.java
Tue Nov  8 18:07:16 2011
@@ -23,6 +23,7 @@ package org.apache.airavata.xbaya.menues
 
 import java.io.File;
 import java.io.IOException;
+import java.util.List;
 
 import javax.swing.JFileChooser;
 import javax.swing.filechooser.FileFilter;
@@ -33,6 +34,7 @@ import org.apache.airavata.xbaya.XBayaEn
 import org.apache.airavata.xbaya.component.ComponentException;
 import org.apache.airavata.xbaya.file.XBayaPathConstants;
 import org.apache.airavata.xbaya.graph.GraphException;
+import org.apache.airavata.xbaya.graph.gui.GraphCanvas;
 import org.apache.airavata.xbaya.graph.ws.WSGraph;
 import org.apache.airavata.xbaya.graph.ws.WSGraphFactory;
 import org.apache.airavata.xbaya.gui.ErrorMessages;
@@ -90,18 +92,6 @@ public class WorkflowFiler {
      */
     public void openWorkflow() {
         Workflow workflow = null;
-        workflow = getWorkflow();
-        if (null != workflow) {
-            this.engine.setWorkflow(workflow);
-        }
-    }
-
-    /**
-     * @param workflow
-     * @return
-     */
-    public Workflow getWorkflow() {
-        Workflow workflow = null;
         int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
 
         if (returnVal == JFileChooser.APPROVE_OPTION) {
@@ -118,7 +108,8 @@ public class WorkflowFiler {
                     XmlElement workflowElement = XMLUtil.loadXML(file);
                     workflow = new Workflow(workflowElement);
                 }
-
+                this.engine.setWorkflow(workflow);
+                engine.getGUI().getGraphCanvas().setWorkflowFile(file);
             } catch (IOException e) {
                 this.engine.getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
             } catch (GraphException e) {
@@ -131,22 +122,44 @@ public class WorkflowFiler {
                 this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
             }
         }
-        return workflow;
+        
     }
 
     /**
      * Saves a current workflow to the local file.
      */
     public void saveWorkflow() {
-        //TODO should chk if this is already in saved. if so save to the same file else save
as... 
-    	saveAsWorkflow();
+		saveWorkflow(engine.getGUI().getGraphCanvas());
     }
+
+    public void saveAsWorkflow() {
+		GraphCanvas graphCanvas = engine.getGUI().getGraphCanvas();
+		File saveAsWorkflowFile = saveAsWorkflow(graphCanvas);
+		if (saveAsWorkflowFile!=null){
+        	graphCanvas.setWorkflowFile(saveAsWorkflowFile);
+		}
+    }
+    
+	private void saveWorkflow(GraphCanvas graphCanvas) {
+		if (graphCanvas.getWorkflowFile()==null){
+        	File saveAsWorkflowFile = saveAsWorkflow(graphCanvas);
+        	graphCanvas.setWorkflowFile(saveAsWorkflowFile);
+        }else{
+        	saveWorkflow(graphCanvas.getWorkflow(), graphCanvas.getWorkflowFile());
+        }
+		if (graphCanvas.getWorkflowFile()!=null){
+			graphCanvas.workflowSaved();
+		}
+	}
     
     public void saveAllWorkflows(){
-    	//TODO
+    	List<GraphCanvas> graphCanvases = engine.getGUI().getGraphCanvases();
+    	for (GraphCanvas graphCanvas : graphCanvases) {
+    		saveWorkflow(graphCanvas);
+		}
     }
 
-	public void saveAsWorkflow() {
+	public File saveAsWorkflow(GraphCanvas graphCanvas) {
 		int returnVal = this.graphFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
         if (returnVal == JFileChooser.APPROVE_OPTION) {
             File file = this.graphFileChooser.getSelectedFile();
@@ -157,18 +170,22 @@ public class WorkflowFiler {
             if (!path.endsWith(XBayaConstants.WORKFLOW_FILE_SUFFIX)) {
                 file = new File(path + XBayaConstants.WORKFLOW_FILE_SUFFIX);
             }
-
-            Workflow workflow = this.engine.getWorkflow();
-            try {
-                XMLUtil.saveXML(workflow.toXML(), file);
-            } catch (IOException e) {
-                this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
-            } catch (RuntimeException e) {
-                this.engine.getErrorWindow().error(ErrorMessages.GRAPH_SAVE_ERROR, e);
-            } catch (Error e) {
-                this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
-            }
+            saveWorkflow(graphCanvas.getWorkflow(),file);
+            return file;
         }
+        return null;
+	}
+
+	private void saveWorkflow(Workflow workflow, File file) {
+		try {
+		    XMLUtil.saveXML(workflow.toXML(), file);
+		} catch (IOException e) {
+		    this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
+		} catch (RuntimeException e) {
+		    this.engine.getErrorWindow().error(ErrorMessages.GRAPH_SAVE_ERROR, e);
+		} catch (Error e) {
+		    this.engine.getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
+		}
 	}
 
     /**

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/XBayaMenuItem.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/XBayaMenuItem.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/XBayaMenuItem.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/menues/xbaya/XBayaMenuItem.java
Tue Nov  8 18:07:16 2011
@@ -28,6 +28,8 @@ import javax.swing.AbstractAction;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.KeyStroke;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
 
 import org.apache.airavata.xbaya.XBayaEngine;
 import org.apache.airavata.xbaya.XBayaException;
@@ -37,6 +39,7 @@ import org.apache.airavata.xbaya.appwrap
 import org.apache.airavata.xbaya.component.gui.ComponentMenu;
 import org.apache.airavata.xbaya.component.gui.URLRegistryWindow;
 import org.apache.airavata.xbaya.experiment.gui.RegistryLoaderWindow;
+import org.apache.airavata.xbaya.graph.gui.GraphCanvas;
 import org.apache.airavata.xbaya.ode.ODEDeploymentDescriptor;
 import org.apache.airavata.xbaya.registry.RegistryAccesser;
 import org.apache.airavata.xbaya.util.XBayaUtil;
@@ -208,6 +211,21 @@ public class XBayaMenuItem {
         xbayaMenuItem.addSeparator();
         
         xbayaMenuItem.add(exitItem);
+        
+        xbayaMenuItem.addMenuListener(new MenuListener() {
+			
+			@Override
+			public void menuSelected(MenuEvent e) {
+				GraphCanvas graphCanvas = engine.getGUI().getGraphCanvas();
+				saveAsWorkflowItem.setEnabled(graphCanvas!=null && graphCanvas.getWorkflowFile()!=null);
+				saveWorkflowItem.setEnabled(graphCanvas!=null && (graphCanvas.getWorkflowFile()==null
|| graphCanvas.isWorkflowChanged()));
+				saveAllWorkflowItem.setEnabled(engine.getGUI().getGraphCanvases().size()>0);
+			}
+			@Override
+			public void menuDeselected(MenuEvent e) {}
+			@Override
+			public void menuCanceled(MenuEvent e) {}
+		});
     }
 
     /**
@@ -228,7 +246,7 @@ public class XBayaMenuItem {
     }
     
     private JMenuItem createURLRegistryItem() {
-        JMenuItem item = new JMenuItem("WSDL from URL");
+        JMenuItem item = new JMenuItem("WSDL from URL...");
         item.setMnemonic(KeyEvent.VK_U);
         item.addActionListener(new AbstractAction() {
             private URLRegistryWindow window;
@@ -323,7 +341,7 @@ public class XBayaMenuItem {
         menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
         menuItem.addActionListener(new AbstractAction() {
             public void actionPerformed(ActionEvent e) {
-                engine.getGUI().newGraphCanvas(true);
+                engine.getGUI().newGraphCanvas(true, true);
             }
         });
         return menuItem;
@@ -369,6 +387,7 @@ public class XBayaMenuItem {
     private void createOpenWorkflowMenuItem() {
         this.openWorkflowItem = new JMenuItem("Open...");
         this.openWorkflowItem.setMnemonic(KeyEvent.VK_O);
+        openWorkflowItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
         this.openWorkflowItem.addActionListener(new AbstractAction() {
             public void actionPerformed(ActionEvent event) {
                 XBayaMenuItem.this.graphFiler.openWorkflow();

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/Workflow.java
Tue Nov  8 18:07:16 2011
@@ -553,6 +553,10 @@ public class Workflow {
         return XMLUtil.xmlElementToString(toXML());
     }
 
+    public void setGraphID(String id){
+    	getGraph().setID(id);
+    }
+    
     /**
      * Returns the XmlElement of the workflow.
      * 

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/gui/WorkflowPropertyWindow.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/gui/WorkflowPropertyWindow.java?rev=1199371&r1=1199370&r2=1199371&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/gui/WorkflowPropertyWindow.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/gui/WorkflowPropertyWindow.java
Tue Nov  8 18:07:16 2011
@@ -23,6 +23,7 @@ package org.apache.airavata.xbaya.wf.gui
 
 import java.awt.event.ActionEvent;
 import java.net.URI;
+import java.util.List;
 
 import javax.swing.AbstractAction;
 import javax.swing.JButton;
@@ -62,6 +63,7 @@ public class WorkflowPropertyWindow {
 
     private XBayaTextArea metadataTextArea;
 
+    
     /**
      * @param engine
      */
@@ -115,9 +117,22 @@ public class WorkflowPropertyWindow {
         this.dialog.hide();
     }
 
+    private boolean isWorkflowNameAlreadyPresent(String name){
+    	List<GraphCanvas> graphCanvases = engine.getGUI().getGraphCanvases();
+    	for (GraphCanvas graphCanvas : graphCanvases) {
+    		if (graphCanvas!=engine.getGUI().getGraphCanvas()){
+				String existingName = graphCanvas.getWorkflow().getGraph().getName();
+				if (name.equals(existingName)){
+					return true;
+				}
+    		}
+		}
+    	return false;
+    }
+    
     private void setToWorkflow() {
         String name = this.nameTextField.getText();
-        if (name != null && name.equals(StringUtil.convertToJavaIdentifier(name)))
{
+        if (name != null && name.equals(StringUtil.convertToJavaIdentifier(name))
&& (!isWorkflowNameAlreadyPresent(name))) {
             String description = this.descriptionTextArea.getText();
             String metadataText = this.metadataTextArea.getText();
 
@@ -141,7 +156,7 @@ public class WorkflowPropertyWindow {
         } else {
             this.nameTextField.setText(StringUtil.convertToJavaIdentifier(name));
             JOptionPane.showMessageDialog(this.engine.getGUI().getFrame(),
-                    "Invalid Name. Please consider the Name suggsted", "Invalid Name", JOptionPane.OK_OPTION);
+                    "Invalid Name or a Workflow under the same name already exists. Please
consider the Name suggsted", "Invalid Name", JOptionPane.OK_OPTION);
         }
     }
 



Mime
View raw message