airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1181802 [1/2] - in /incubator/airavata/trunk/modules: commons/registry-api/src/main/java/org/apache/airavata/registry/api/ commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ commons/registry-api/src/main/java/or...
Date Tue, 11 Oct 2011 14:18:51 GMT
Author: lahiru
Date: Tue Oct 11 14:18:50 2011
New Revision: 1181802

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

Added:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java
Modified:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/file/gui/FileMenu.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/wf/gui/WorkflowMenu.java

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java Tue Oct 11 14:18:50 2011
@@ -24,9 +24,14 @@ package org.apache.airavata.registry.api
 import java.util.List;
 import java.util.Map;
 
+import javax.jcr.PathNotFoundException;
+
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.registry.api.exception.DeploymentDescriptionRetrieveException;
+import org.apache.airavata.registry.api.exception.HostDescriptionRetrieveException;
+import org.apache.airavata.registry.api.exception.ServiceDescriptionRetrieveException;
 
 import javax.jcr.Node;
 import javax.xml.namespace.QName;
@@ -45,8 +50,10 @@ public interface Registry {
 	 * 
 	 * @param serviceName
 	 * @return a service description or null if a description is not found
+	 * @throws PathNotFoundException 
+	 * @throws ServiceDescriptionRetrieveException 
 	 */
-	public ServiceDescription getServiceDescription(String serviceName);
+	public ServiceDescription getServiceDescription(String serviceName) throws ServiceDescriptionRetrieveException, PathNotFoundException;
 	
 	/**
 	 * Retrieve a deployment description for a service from the specific host
@@ -54,8 +61,10 @@ public interface Registry {
 	 * @param serviceName
 	 * @param hostName
 	 * @return a deployment description or null if a description is not found
+	 * @throws PathNotFoundException 
+	 * @throws DeploymentDescriptionRetrieveException 
 	 */
-	public ApplicationDeploymentDescription getDeploymentDescription(String serviceName, String hostName);
+	public ApplicationDeploymentDescription getDeploymentDescription(String serviceName, String hostName) throws DeploymentDescriptionRetrieveException, PathNotFoundException;
 	
 	/**
 	 * Retrieve a host description
@@ -63,7 +72,7 @@ public interface Registry {
 	 * @param name
 	 * @return a host description or null if a description is not found
 	 */
-	public HostDescription getHostDescription(String name);
+	public HostDescription getHostDescription(String name) throws HostDescriptionRetrieveException, PathNotFoundException;
 	
 	/**
 	 * Save a host description with the specific name.
@@ -107,16 +116,20 @@ public interface Registry {
 	 * 
 	 * @param name
 	 * @return the host descriptions with matched name
+	 * @throws HostDescriptionRetrieveException 
+	 * @throws PathNotFoundException 
 	 */
-	public List<HostDescription> searchHostDescription(String name);
+	public List<HostDescription> searchHostDescription(String name) throws HostDescriptionRetrieveException, PathNotFoundException;
 	
 	/**
 	 * Search service description with name
 	 * 
 	 * @param name
 	 * @return the service descriptions with matched name
+	 * @throws PathNotFoundException 
+	 * @throws ServiceDescriptionRetrieveException 
 	 */
-	public List<ServiceDescription> searchServiceDescription(String name);
+	public List<ServiceDescription> searchServiceDescription(String name) throws ServiceDescriptionRetrieveException, PathNotFoundException;
 	
 	/**
 	 * Search deployment description from a service and/or a hostname
@@ -124,8 +137,10 @@ public interface Registry {
 	 * @param serviceName 
 	 * @param hostName
 	 * @return the deployment descriptions with matched names
+	 * @throws PathNotFoundException 
+	 * @throws DeploymentDescriptionRetrieveException 
 	 */
-	public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName);
+	public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName) throws DeploymentDescriptionRetrieveException, PathNotFoundException;
 
     /**
      * This method can be used to save the gfacURL in to registry

Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java?rev=1181802&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/DeploymentDescriptionRetrieveException.java Tue Oct 11 14:18:50 2011
@@ -0,0 +1,14 @@
+package org.apache.airavata.registry.api.exception;
+
+public class DeploymentDescriptionRetrieveException extends Exception {
+	private final static String ERROR_MESSAGE="Error occured while attempting to retrieve existing deployment descriptions";
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2849422320139467602L;
+	
+	public DeploymentDescriptionRetrieveException(Exception e) {
+		super(ERROR_MESSAGE,e);
+	}
+
+}

Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java?rev=1181802&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/HostDescriptionRetrieveException.java Tue Oct 11 14:18:50 2011
@@ -0,0 +1,14 @@
+package org.apache.airavata.registry.api.exception;
+
+public class HostDescriptionRetrieveException extends Exception {
+	private final static String ERROR_MESSAGE="Error occured while attempting to retrieve existing hosts";
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2849422320139467602L;
+	
+	public HostDescriptionRetrieveException(Exception e) {
+		super(ERROR_MESSAGE,e);
+	}
+
+}

Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java?rev=1181802&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/exception/ServiceDescriptionRetrieveException.java Tue Oct 11 14:18:50 2011
@@ -0,0 +1,14 @@
+package org.apache.airavata.registry.api.exception;
+
+public class ServiceDescriptionRetrieveException extends Exception {
+	private final static String ERROR_MESSAGE="Error occured while attempting to retrieve existing service descriptions";
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2849422320139467602L;
+	
+	public ServiceDescriptionRetrieveException(Exception e) {
+		super(ERROR_MESSAGE,e);
+	}
+
+}

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java Tue Oct 11 14:18:50 2011
@@ -38,6 +38,7 @@ import javax.jcr.RepositoryFactory;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
 import javax.xml.namespace.QName;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
@@ -47,6 +48,9 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.commons.gfac.type.util.SchemaUtil;
 import org.apache.airavata.registry.api.Axis2Registry;
 import org.apache.airavata.registry.api.DataRegistry;
+import org.apache.airavata.registry.api.exception.DeploymentDescriptionRetrieveException;
+import org.apache.airavata.registry.api.exception.HostDescriptionRetrieveException;
+import org.apache.airavata.registry.api.exception.ServiceDescriptionRetrieveException;
 import org.apache.airavata.registry.api.user.UserManager;
 import org.apache.airavata.registry.api.user.UserManagerFactory;
 import org.slf4j.Logger;
@@ -168,7 +172,7 @@ public class JCRRegistry implements Axis
 		return result;
 	}
 
-	public ServiceDescription getServiceDescription(String serviceName) {
+	public ServiceDescription getServiceDescription(String serviceName) throws ServiceDescriptionRetrieveException, PathNotFoundException{
 		Session session = null;
 		ServiceDescription result = null;
 		try {
@@ -191,7 +195,7 @@ public class JCRRegistry implements Axis
 	}
 
 	public ApplicationDeploymentDescription getDeploymentDescription(
-			String serviceName, String host) {
+			String serviceName, String host) throws DeploymentDescriptionRetrieveException, PathNotFoundException {
 		Session session = null;
 		ApplicationDeploymentDescription result = null;
 		try {
@@ -218,20 +222,20 @@ public class JCRRegistry implements Axis
 		return result;
 	}
 
-	public HostDescription getHostDescription(String name) {
+	public HostDescription getHostDescription(String name) throws HostDescriptionRetrieveException, PathNotFoundException {
 		Session session = null;
 		HostDescription result = null;
 		try {
 			session = getSession();
 			Node hostNode = getHostNode(session);
 			Node node = hostNode.getNode(name);
-			Property prop = node.getProperty(XML_PROPERTY_NAME);
-			result = (HostDescription) SchemaUtil
-					.parseFromXML(prop.getString());
-		} catch (Exception e) {
-			System.out.println(e);
-			e.printStackTrace();
-			// TODO propagate
+			if (node!=null) {
+				result = getHostDescriptor(node);
+			}
+		}catch(PathNotFoundException e){
+			throw e;
+		}catch (Exception e) {
+			throw new HostDescriptionRetrieveException(e);
 		} finally {
 			if (session != null && session.isLive()) {
 				session.logout();
@@ -240,6 +244,16 @@ public class JCRRegistry implements Axis
 		return result;
 	}
 
+	private HostDescription getHostDescriptor(Node node)
+			throws PathNotFoundException, RepositoryException,
+			ValueFormatException {
+		HostDescription result;
+		Property prop = node.getProperty(XML_PROPERTY_NAME);
+		result = (HostDescription) SchemaUtil
+				.parseFromXML(prop.getString());
+		return result;
+	}
+
 	public String saveHostDescription(String name, HostDescription host) {
 		Session session = null;
 		String result = null;
@@ -355,12 +369,7 @@ public class JCRRegistry implements Axis
 		return false;
 	}
 
-	public List<HostDescription> searchHostDescription(String name) {
-		// TODO implementation
-		return null;
-	}
-
-	public List<ServiceDescription> searchServiceDescription(String name) {
+	public List<ServiceDescription> searchServiceDescription(String name) throws ServiceDescriptionRetrieveException, PathNotFoundException{
 	    Session session = null;
         ArrayList<ServiceDescription> result = new ArrayList<ServiceDescription>();
         try {
@@ -383,6 +392,36 @@ public class JCRRegistry implements Axis
         }	   
 		return result;
 	}
+	
+	public List<HostDescription> searchHostDescription(String nameRegEx) throws HostDescriptionRetrieveException, PathNotFoundException {
+	    Session session = null;
+        List<HostDescription> result = new ArrayList<HostDescription>();
+        try {
+            session = getSession();
+            Node node = getHostNode(session);
+            NodeIterator nodes = node.getNodes();
+            for (; nodes.hasNext();) {
+                Node host = nodes.nextNode();
+                if (host!=null && host.getName().matches(nameRegEx)){
+                    HostDescription hostDescriptor = getHostDescriptor(host);
+                	result.add(hostDescriptor);
+                }
+            }
+		}catch(PathNotFoundException e){
+			System.out.println(e);
+			e.printStackTrace();
+			throw e;
+        } catch (Exception e) {
+            System.out.println(e);
+            e.printStackTrace();
+            throw new HostDescriptionRetrieveException(e);
+        } finally {
+            if (session != null && session.isLive()) {
+                session.logout();
+            }
+        }	   
+		return result;
+	}
 
 	public List<ApplicationDeploymentDescription> searchDeploymentDescription(
 			String serviceName, String hostName) {

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java Tue Oct 11 14:18:50 2011
@@ -25,7 +25,11 @@ import java.net.UnknownHostException;
 import java.util.Iterator;
 import java.util.List;
 
+import javax.jcr.PathNotFoundException;
+
 import org.apache.airavata.registry.api.Registry;
+import org.apache.airavata.registry.api.exception.DeploymentDescriptionRetrieveException;
+import org.apache.airavata.registry.api.exception.ServiceDescriptionRetrieveException;
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
@@ -54,7 +58,16 @@ public class SchedulerImpl implements Sc
         /*
          * Load Service
          */
-        ServiceDescription serviceDesc = registryService.getServiceDescription(context.getServiceName());
+        ServiceDescription serviceDesc = null;
+		try {
+			serviceDesc = registryService.getServiceDescription(context.getServiceName());
+		} catch (PathNotFoundException e2) {
+			// TODO Auto-generated catch block
+			e2.printStackTrace();
+		} catch (ServiceDescriptionRetrieveException e2) {
+			// TODO Auto-generated catch block
+			e2.printStackTrace();
+		}
 
         if (serviceDesc == null)
             throw new SchedulerException("Service Desciption for " + context.getServiceName()
@@ -72,8 +85,17 @@ public class SchedulerImpl implements Sc
         /*
          * Load app
          */
-        ApplicationDeploymentDescription app = registryService.getDeploymentDescription(context.getServiceName(),
-                host.getName());
+        ApplicationDeploymentDescription app=null;
+		try {
+			app = registryService.getDeploymentDescription(context.getServiceName(),
+			        host.getName());
+		} catch (PathNotFoundException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		} catch (DeploymentDescriptionRetrieveException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
 
         if (app == null)
             throw new SchedulerException("App Desciption for " + context.getServiceName()

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionDialog.java Tue Oct 11 14:18:50 2011
@@ -3,31 +3,65 @@ package org.apache.airavata.xbaya.appwra
 import java.awt.BorderLayout;
 import java.awt.FlowLayout;
 
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
+import javax.jcr.PathNotFoundException;
 import javax.swing.GroupLayout;
 import javax.swing.GroupLayout.Alignment;
-import javax.swing.JLabel;
+import javax.swing.JButton;
 import javax.swing.JComboBox;
-import javax.swing.JTextField;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
 import javax.swing.JSeparator;
+import javax.swing.JTextField;
+import javax.swing.LayoutStyle.ComponentPlacement;
+
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.commons.gfac.type.app.ShellApplicationDeployment;
+import org.apache.airavata.registry.api.exception.ServiceDescriptionRetrieveException;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.component.registry.JCRComponentRegistry;
+
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.Color;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
 import org.apache.airavata.xbaya.gui.XBayaLinkButton;
 import javax.swing.SwingConstants;
-import javax.swing.LayoutStyle.ComponentPlacement;
+import java.awt.Font;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.List;
 
 public class ApplicationDescriptionDialog extends JDialog {
-	private JTextField textField;
-	private JTextField textField_1;
-	private JTextField textField_2;
-
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2745085755585610025L;
+	private JTextField txtExecPath;
+	private JTextField txtAppName;
+	private JTextField txtTempDir;
+	
+	private XBayaEngine engine;
+	private ShellApplicationDeployment shellApplicationDescription;
+	private JLabel lblError;
+	private boolean applcationDescCreated=false;
+	private JButton okButton;
+	
+	private String serviceName;
+	private String hostName;
+	private JComboBox cmbServiceName;
+	private JComboBox cmbHostName;
+	
 	/**
 	 * Launch the application.
 	 */
 	public static void main(String[] args) {
 		try {
-			ApplicationDescriptionDialog dialog = new ApplicationDescriptionDialog();
+			ApplicationDescriptionDialog dialog = new ApplicationDescriptionDialog(null);
 			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 			dialog.setVisible(true);
 		} catch (Exception e) {
@@ -38,22 +72,69 @@ public class ApplicationDescriptionDialo
 	/**
 	 * Create the dialog.
 	 */
-	public ApplicationDescriptionDialog() {
-		setTitle("New Application Description");
-		setBounds(100, 100, 441, 240);
+	public ApplicationDescriptionDialog(XBayaEngine engine) {
+		addWindowListener(new WindowAdapter() {
+			@Override
+			public void windowOpened(WindowEvent arg0) {
+				String baseName="Application";
+				int i=1;
+				String defaultName=baseName+i;
+				try {
+					while(getJCRComponentRegistry().getHostDescription(defaultName)!=null){
+						defaultName=baseName+(++i);
+					}
+				} catch (Exception e) {
+				}
+				txtAppName.setText(defaultName);
+				setApplicationName(txtAppName.getText());
+			}
+		});
+		setEngine(engine);
+		iniGUI();
+	}
+	
+	public void open(){
+		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+		setVisible(true);
+	}
+	
+	protected ApplicationDescriptionDialog getDialog(){
+		return this;
+	}
+	private void iniGUI() {
+		setTitle("New Deployment Description");
+		setBounds(100, 100, 455, 349);
+		setModal(true);
 		getContentPane().setLayout(new BorderLayout());
 		{
 			JPanel buttonPane = new JPanel();
 			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
 			getContentPane().add(buttonPane, BorderLayout.SOUTH);
+			
+			lblError = new JLabel("");
+			lblError.setForeground(Color.RED);
+			buttonPane.add(lblError);
 			{
-				JButton okButton = new JButton("Save");
+				okButton = new JButton("Save");
+				okButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						saveApplicationDescription();
+						close();
+					}
+				});
+				okButton.setEnabled(false);
 				okButton.setActionCommand("OK");
 				buttonPane.add(okButton);
 				getRootPane().setDefaultButton(okButton);
 			}
 			{
 				JButton cancelButton = new JButton("Cancel");
+				cancelButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						setApplicationDescCreated(false);
+						close();
+					}
+				});
 				cancelButton.setActionCommand("Cancel");
 				buttonPane.add(cancelButton);
 			}
@@ -61,89 +142,358 @@ public class ApplicationDescriptionDialo
 		{
 			JPanel panel = new JPanel();
 			getContentPane().add(panel, BorderLayout.CENTER);
-			JLabel label = new JLabel("Registry");
-			JComboBox comboBox = new JComboBox();
 			JLabel lblApplicationName = new JLabel("Application name");
 			JLabel lblExecutablePatyh = new JLabel("Executable path");
-			textField = new JTextField();
-			textField.setColumns(10);
-			textField_1 = new JTextField();
-			textField_1.setColumns(10);
-			JSeparator separator = new JSeparator();
+			txtExecPath = new JTextField();
+			txtExecPath.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent e) {
+					setExecutablePath(txtExecPath.getText());
+				}
+			});
+			txtExecPath.setColumns(10);
+			txtAppName = new JTextField();
+			txtAppName.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent e) {
+					setApplicationName(txtAppName.getText());
+				}
+			});
+			txtAppName.setColumns(10);
 			JSeparator separator_1 = new JSeparator();
 			JLabel lblTemporaryDirectory = new JLabel("Temporary directory");
-			textField_2 = new JTextField();
-			textField_2.setColumns(10);
+			txtTempDir = new JTextField();
+			txtTempDir.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent e) {
+					setTempDir(txtTempDir.getText());
+				}
+			});
+			txtTempDir.setColumns(10);
 			JButton btnAdvance = new JButton("Advanced options...");
+			
+			JSeparator separator = new JSeparator();
+			
+			XBayaLinkButton blnkbtnCreateNewService = new XBayaLinkButton("New button");
+			blnkbtnCreateNewService.addActionListener(new ActionListener() {
+				public void actionPerformed(ActionEvent arg0) {
+					try {
+	                	ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(getEngine());
+	                	serviceDescriptionDialog.open();
+	                	if (serviceDescriptionDialog.isServiceCreated()){
+	                		loadServiceDescriptions();
+	                		cmbServiceName.setSelectedItem(serviceDescriptionDialog.getServiceName());
+	                	}
+	                } catch (Exception e1) {
+	                    getEngine().getErrorWindow().error(e1);
+	                }
+				}
+			});
+			blnkbtnCreateNewService.setText("Create new service...");
+			blnkbtnCreateNewService.setHorizontalAlignment(SwingConstants.TRAILING);
+			
+			cmbServiceName = new JComboBox();
+			cmbServiceName.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent arg0) {
+					updateServiceName();
+				}
+			});
+			cmbServiceName.addMouseListener(new MouseAdapter() {
+				@Override
+				public void mouseReleased(MouseEvent e) {
+					updateServiceName();
+				}
+			});
+			
+			cmbHostName = new JComboBox();
+			cmbHostName.addMouseListener(new MouseAdapter() {
+				@Override
+				public void mouseReleased(MouseEvent e) {
+					updateHostName();
+				}
+			});
+			cmbHostName.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent e) {
+					updateHostName();
+				}
+			});
+			
+			JLabel label_1 = new JLabel("Host");
+			
+			XBayaLinkButton bayaLinkButton_1 = new XBayaLinkButton("New button");
+			bayaLinkButton_1.addActionListener(new ActionListener() {
+				public void actionPerformed(ActionEvent e) {
+					try {
+						HostDescriptionDialog hostDescriptionDialog = new HostDescriptionDialog(getEngine());
+	                	hostDescriptionDialog.open();
+	                	if (hostDescriptionDialog.isHostCreated()){
+	                		loadHostDescriptions();
+	                		cmbHostName.setSelectedItem(hostDescriptionDialog.getHostLocation());
+	                	}
+	                } catch (Exception e1) {
+	                    getEngine().getErrorWindow().error(e1);
+	                }
+				}
+			});
+			bayaLinkButton_1.setText("Create new host...");
+			bayaLinkButton_1.setHorizontalAlignment(SwingConstants.TRAILING);
+			
+			JLabel lblService = new JLabel("Service");
+			
+			JLabel lblBindThisDeployment = new JLabel("Bind this deployment description to:");
+			lblBindThisDeployment.setFont(new Font("Tahoma", Font.BOLD, 11));
 			GroupLayout gl_panel = new GroupLayout(panel);
 			gl_panel.setHorizontalGroup(
 				gl_panel.createParallelGroup(Alignment.TRAILING)
 					.addGroup(gl_panel.createSequentialGroup()
-						.addGap(22)
-						.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
-							.addGroup(gl_panel.createSequentialGroup()
-								.addComponent(label, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
-								.addPreferredGap(ComponentPlacement.UNRELATED)
-								.addComponent(comboBox, 0, 341, Short.MAX_VALUE)
-								.addGap(15))
-							.addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
-								.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
-									.addComponent(lblApplicationName)
-									.addComponent(lblExecutablePatyh))
-								.addGap(18)
-								.addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
-									.addComponent(textField)
-									.addComponent(textField_1, GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE))
-								.addGap(19)))
-						.addGap(18))
-					.addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
-						.addContainerGap()
-						.addComponent(separator, GroupLayout.PREFERRED_SIZE, 425, GroupLayout.PREFERRED_SIZE)
-						.addContainerGap(36, Short.MAX_VALUE))
-					.addGroup(gl_panel.createSequentialGroup()
 						.addContainerGap()
 						.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
-							.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, 425, GroupLayout.PREFERRED_SIZE)
-							.addGroup(gl_panel.createSequentialGroup()
-								.addGap(10)
-								.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
-									.addComponent(btnAdvance)
+							.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
+								.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
 									.addGroup(gl_panel.createSequentialGroup()
-										.addComponent(lblTemporaryDirectory)
-										.addPreferredGap(ComponentPlacement.RELATED)
-										.addComponent(textField_2, GroupLayout.PREFERRED_SIZE, 305, GroupLayout.PREFERRED_SIZE)))))
-						.addGap(36))
+										.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
+											.addGroup(gl_panel.createSequentialGroup()
+												.addGap(12)
+												.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
+													.addComponent(lblApplicationName)
+													.addComponent(lblExecutablePatyh))
+												.addGap(18)
+												.addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
+													.addComponent(txtExecPath)
+													.addComponent(txtAppName, GroupLayout.PREFERRED_SIZE, 309, GroupLayout.PREFERRED_SIZE)))
+											.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, 425, GroupLayout.PREFERRED_SIZE)
+											.addComponent(separator, GroupLayout.PREFERRED_SIZE, 425, GroupLayout.PREFERRED_SIZE)
+											.addGroup(gl_panel.createSequentialGroup()
+												.addGap(10)
+												.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
+													.addComponent(btnAdvance)
+													.addGroup(gl_panel.createSequentialGroup()
+														.addComponent(lblTemporaryDirectory)
+														.addPreferredGap(ComponentPlacement.RELATED)
+														.addComponent(txtTempDir, GroupLayout.PREFERRED_SIZE, 305, GroupLayout.PREFERRED_SIZE))))
+											.addGroup(gl_panel.createSequentialGroup()
+												.addGap(20)
+												.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
+													.addComponent(lblService)
+													.addComponent(label_1, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE))
+												.addPreferredGap(ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
+												.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
+													.addComponent(cmbServiceName, GroupLayout.PREFERRED_SIZE, 313, GroupLayout.PREFERRED_SIZE)
+													.addComponent(cmbHostName, GroupLayout.PREFERRED_SIZE, 313, GroupLayout.PREFERRED_SIZE))
+												.addGap(10)))
+										.addContainerGap(12, Short.MAX_VALUE))
+									.addGroup(gl_panel.createSequentialGroup()
+										.addComponent(lblBindThisDeployment)
+										.addContainerGap(234, Short.MAX_VALUE)))
+								.addComponent(blnkbtnCreateNewService, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 156, GroupLayout.PREFERRED_SIZE))
+							.addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup()
+								.addComponent(bayaLinkButton_1, GroupLayout.PREFERRED_SIZE, 156, GroupLayout.PREFERRED_SIZE)
+								.addGap(2))))
 			);
 			gl_panel.setVerticalGroup(
 				gl_panel.createParallelGroup(Alignment.LEADING)
 					.addGroup(gl_panel.createSequentialGroup()
+						.addContainerGap()
 						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
-							.addComponent(label)
-							.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-						.addPreferredGap(ComponentPlacement.RELATED)
-						.addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-						.addGap(8)
-						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
-							.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+							.addComponent(txtAppName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 							.addComponent(lblApplicationName))
 						.addPreferredGap(ComponentPlacement.RELATED)
 						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
-							.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+							.addComponent(txtExecPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 							.addComponent(lblExecutablePatyh))
 						.addPreferredGap(ComponentPlacement.UNRELATED)
 						.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 						.addPreferredGap(ComponentPlacement.UNRELATED)
 						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
 							.addComponent(lblTemporaryDirectory)
-							.addComponent(textField_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+							.addComponent(txtTempDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 						.addPreferredGap(ComponentPlacement.RELATED)
 						.addComponent(btnAdvance)
-						.addGap(109))
+						.addPreferredGap(ComponentPlacement.UNRELATED)
+						.addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+						.addPreferredGap(ComponentPlacement.UNRELATED)
+						.addComponent(lblBindThisDeployment)
+						.addPreferredGap(ComponentPlacement.RELATED)
+						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
+							.addComponent(cmbServiceName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+							.addComponent(lblService))
+						.addGap(2)
+						.addComponent(blnkbtnCreateNewService, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
+						.addPreferredGap(ComponentPlacement.RELATED)
+						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
+							.addComponent(cmbHostName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+							.addComponent(label_1))
+						.addPreferredGap(ComponentPlacement.RELATED)
+						.addComponent(bayaLinkButton_1, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
+						.addContainerGap(44, Short.MAX_VALUE))
 			);
 			gl_panel.setAutoCreateGaps(true);
 			gl_panel.setAutoCreateContainerGaps(true);
 			panel.setLayout(gl_panel);
+			loadServiceDescriptions();
+			loadHostDescriptions();
+		}
+	}
+
+	private void loadServiceDescriptions(){
+		cmbServiceName.removeAll();
+		setServiceName(null);
+		try {
+			List<ServiceDescription> serviceDescriptions = getJCRComponentRegistry().searchServiceDescription("");
+			for (ServiceDescription serviceDescription : serviceDescriptions) {
+				cmbServiceName.addItem(serviceDescription.getName());
+			}
+		} catch (Exception e) {
+			setError(e.getLocalizedMessage());
+		}
+	}
+	
+	private void loadHostDescriptions(){
+		cmbHostName.removeAll();
+		setHostName(null);
+		try {
+			List<HostDescription> hostDescriptions = getJCRComponentRegistry().searchHostDescription(".*");
+			for (HostDescription hostDescription : hostDescriptions) {
+				cmbHostName.addItem(hostDescription.getName());
+			}
+		} catch (Exception e) {
+			setError(e.getLocalizedMessage());
 		}
 	}
+	
+	public XBayaEngine getEngine() {
+		return engine;
+	}
+
+	public void setEngine(XBayaEngine engine) {
+		this.engine = engine;
+	}
 
+	public ShellApplicationDeployment getShellApplicationDescription() {
+		if (shellApplicationDescription==null){
+			shellApplicationDescription=new ShellApplicationDeployment();
+		}
+		return shellApplicationDescription;
+	}
+
+	public String getApplicationName() {
+		return getShellApplicationDescription().getName();
+	}
+
+	public void setApplicationName(String applicationName) {
+		getShellApplicationDescription().setName(applicationName);
+		updateDialogStatus();
+	}
+
+	public String getExecutablePath() {
+		return getShellApplicationDescription().getExecutable();
+	}
+
+	public void setExecutablePath(String executablePath) {
+		getShellApplicationDescription().setExecutable(executablePath);
+		updateDialogStatus();
+	}
+
+	public String getTempDir() {
+		return getShellApplicationDescription().getTmpDir();
+	}
+
+	public void setTempDir(String tempDir) {
+		getShellApplicationDescription().setTmpDir(tempDir);
+		updateDialogStatus();
+	}
+	
+	public void close() {
+		getDialog().setVisible(false);
+	}
+	
+	public void saveApplicationDescription() {
+		getJCRComponentRegistry().saveDeploymentDescription(getServiceName(), getHostName(), getShellApplicationDescription());
+		setApplicationDescCreated(true);
+	}
+	
+	public boolean isApplicationDescCreated() {
+		return applcationDescCreated;
+	}
+
+	public void setApplicationDescCreated(boolean applicationDescCreated) {
+		this.applcationDescCreated = applicationDescCreated;
+	}
+
+	private JCRComponentRegistry getJCRComponentRegistry() {
+		return getEngine().getConfiguration().getJcrComponentRegistry();
+	}
+	
+	private void setError(String errorMessage){
+		if (errorMessage==null || errorMessage.trim().equals("")){
+			lblError.setText("");
+		}else{
+			lblError.setText(errorMessage.trim());
+		}
+	}
+	
+	private void updateDialogStatus(){
+		String message=null;
+		try {
+			validateDialog();
+		} catch (Exception e) {
+			message=e.getLocalizedMessage();
+		}
+		okButton.setEnabled(message==null);
+		setError(message);
+	}
+	
+	private void validateDialog() throws Exception{
+		if (getApplicationName()==null || getApplicationName().trim().equals("")){
+			throw new Exception("Name of the application cannot be empty!!!");
+		}
+		
+		if (getExecutablePath()==null || getExecutablePath().trim().equals("")){
+			throw new Exception("Executable path cannot be empty!!!");
+		}
+		
+		if (getTempDir()==null || getTempDir().trim().equals("")){
+			throw new Exception("Temporary directory location cannot be empty!!!");
+		}
+		
+		if (getServiceName()==null || getServiceName().trim().equals("")){
+			throw new Exception("Please select/create service to bind to this deployment description");
+		}
+	
+		if (getHostName()==null || getHostName().trim().equals("")){
+			throw new Exception("Please select/create host to bind to this deployment description");
+		}
+	}
+
+	public String getServiceName() {
+		return serviceName;
+	}
+
+	public void setServiceName(String serviceName) {
+		this.serviceName = serviceName;
+		updateDialogStatus();
+	}
+
+	public String getHostName() {
+		return hostName;
+	}
+
+	public void setHostName(String hostName) {
+		this.hostName = hostName;
+		updateDialogStatus();
+	}
+
+	private void updateServiceName() {
+		if (cmbServiceName.getSelectedItem()!=null){
+			setServiceName(cmbServiceName.getSelectedItem().toString());
+		}
+	}
+	
+	private void updateHostName() {
+		if (cmbHostName.getSelectedItem()!=null){
+			setHostName(cmbHostName.getSelectedItem().toString());
+		}
+	}
 }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java Tue Oct 11 14:18:50 2011
@@ -1,56 +1,124 @@
 package org.apache.airavata.xbaya.appwrapper;
 
 import java.awt.BorderLayout;
+import java.awt.Color;
 import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
 
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
+import javax.jcr.PathNotFoundException;
 import javax.swing.GroupLayout;
 import javax.swing.GroupLayout.Alignment;
-import javax.swing.JLabel;
+import javax.swing.JButton;
 import javax.swing.JComboBox;
-import javax.swing.JTextField;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
 import javax.swing.JSeparator;
+import javax.swing.JTextField;
 import javax.swing.LayoutStyle.ComponentPlacement;
 
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.registry.api.exception.HostDescriptionRetrieveException;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.component.registry.JCRComponentRegistry;
+
 public class HostDescriptionDialog extends JDialog {
-	private JTextField textField;
-	private JTextField textField_1;
 
+	private static final long serialVersionUID = 1423293834766468324L;
+	private JTextField txtHostLocation;
+	private JTextField txtHostName;
+	private XBayaEngine engine;
+	private HostDescription hostDescription;
+	
+	private String hostName;
+	private JButton okButton;
+	private boolean hostCreated=false;
+	private JLabel lblError;
+	
 	/**
 	 * Launch the application.
 	 */
 	public static void main(String[] args) {
 		try {
-			HostDescriptionDialog dialog = new HostDescriptionDialog();
-			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
-			dialog.setVisible(true);
+			HostDescriptionDialog dialog = new HostDescriptionDialog(null);
+			dialog.open();
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 	}
-
+	
+	public void open(){
+		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+		setVisible(true);
+	}
+	
+	protected HostDescriptionDialog getDialog(){
+		return this;
+	}
 	/**
 	 * Create the dialog.
 	 */
-	public HostDescriptionDialog() {
+	public HostDescriptionDialog(XBayaEngine engine) {
+		addWindowListener(new WindowAdapter() {
+			@Override
+			public void windowOpened(WindowEvent arg0) {
+				String baseName="Host";
+				int i=1;
+				String defaultName=baseName+i;
+				try {
+					while(getJCRComponentRegistry().getHostDescription(defaultName)!=null){
+						defaultName=baseName+(++i);
+					}
+				} catch (HostDescriptionRetrieveException e) {
+				} catch (PathNotFoundException e) {
+				}
+				txtHostName.setText(defaultName);
+				setHostName(txtHostName.getText());
+			}
+		});
+		setEngine(engine);
+		initGUI();
+	}
+
+	private void initGUI() {
 		setTitle("New Host Description");
-		setBounds(100, 100, 446, 167);
+		setBounds(100, 100, 448, 129);
+		setModal(true);
 		getContentPane().setLayout(new BorderLayout());
 		{
 			JPanel buttonPane = new JPanel();
 			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
 			getContentPane().add(buttonPane, BorderLayout.SOUTH);
 			{
-				JButton okButton = new JButton("Save");
+				okButton = new JButton("Save");
+				okButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						saveHostDescription();
+						close();
+					}
+				});
+				
+				lblError = new JLabel("");
+				lblError.setForeground(Color.RED);
+				buttonPane.add(lblError);
+				okButton.setEnabled(false);
 				okButton.setActionCommand("OK");
 				buttonPane.add(okButton);
 				getRootPane().setDefaultButton(okButton);
 			}
 			{
 				JButton cancelButton = new JButton("Cancel");
+				cancelButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						setHostCreated(false);
+						close();
+					}
+				});
 				cancelButton.setActionCommand("Cancel");
 				buttonPane.add(cancelButton);
 			}
@@ -59,16 +127,29 @@ public class HostDescriptionDialog exten
 			JPanel panel = new JPanel();
 			getContentPane().add(panel, BorderLayout.CENTER);
 			JLabel label = new JLabel("Registry");
+			label.setVisible(false);
 			JComboBox comboBox = new JComboBox();
+			comboBox.setVisible(false);
 			JLabel lblHostName = new JLabel("Host name");
-			lblHostName.setEnabled(false);
 			JLabel lblHostLocationip = new JLabel("Host location/ip");
-			textField = new JTextField();
-			textField.setColumns(10);
-			textField_1 = new JTextField();
-			textField_1.setEnabled(false);
-			textField_1.setColumns(10);
+			txtHostLocation = new JTextField();
+			txtHostLocation.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent e) {
+					setHostLocation(txtHostLocation.getText());
+				}
+			});
+			txtHostLocation.setColumns(10);
+			txtHostName = new JTextField();
+			txtHostName.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent e) {
+					setHostName(txtHostName.getText());
+				}
+			});
+			txtHostName.setColumns(10);
 			JSeparator separator = new JSeparator();
+			separator.setVisible(false);
 			GroupLayout gl_panel = new GroupLayout(panel);
 			gl_panel.setHorizontalGroup(
 				gl_panel.createParallelGroup(Alignment.TRAILING)
@@ -86,8 +167,8 @@ public class HostDescriptionDialog exten
 									.addComponent(lblHostLocationip))
 								.addGap(18)
 								.addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
-									.addComponent(textField)
-									.addComponent(textField_1, GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE))
+									.addComponent(txtHostLocation)
+									.addComponent(txtHostName, GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE))
 								.addGap(19)))
 						.addGap(18))
 					.addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
@@ -106,11 +187,11 @@ public class HostDescriptionDialog exten
 						.addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 						.addGap(8)
 						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
-							.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+							.addComponent(txtHostName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 							.addComponent(lblHostName))
 						.addPreferredGap(ComponentPlacement.RELATED)
 						.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
-							.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+							.addComponent(txtHostLocation, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 							.addComponent(lblHostLocationip))
 						.addGap(176))
 			);
@@ -120,4 +201,97 @@ public class HostDescriptionDialog exten
 		}
 	}
 
+	public XBayaEngine getEngine() {
+		return engine;
+	}
+
+	public void setEngine(XBayaEngine engine) {
+		this.engine = engine;
+	}
+
+	public String getHostName() {
+		return hostName;
+	}
+
+	public void setHostName(String hostName) {
+		this.hostName = hostName;
+		updateDialogStatus();
+	}
+
+	public String getHostLocation() {
+		return getHostDescription().getName();
+	}
+
+	public void setHostLocation(String hostLocation) {
+		getHostDescription().setName(hostLocation);
+		updateDialogStatus();
+	}
+
+	private void validateDialog() throws Exception{
+		if (getHostName()==null || getHostName().trim().equals("")){
+			throw new Exception("Name of the host cannot be empty!!!");
+		}
+		
+		HostDescription hostDescription2=null;
+		try {
+			hostDescription2 = getJCRComponentRegistry().getHostDescription(getHostName());
+		} catch (PathNotFoundException e) {
+			//what we want
+		} catch (Exception e){
+			throw e;
+		}
+		if (hostDescription2!=null){
+			throw new Exception("Host descriptor with the given name already exists!!!");
+		}
+		
+		if (getHostLocation()==null || getHostLocation().trim().equals("")){
+			throw new Exception("Host location/ip cannot be empty!!!");
+		}
+	}
+	private void updateDialogStatus(){
+		String message=null;
+		try {
+			validateDialog();
+		} catch (Exception e) {
+			message=e.getLocalizedMessage();
+		}
+		okButton.setEnabled(message==null);
+		setError(message);
+	}
+
+	public void close() {
+		getDialog().setVisible(false);
+	}
+
+	public boolean isHostCreated() {
+		return hostCreated;
+	}
+
+	public void setHostCreated(boolean hostCreated) {
+		this.hostCreated = hostCreated;
+	}
+
+	public HostDescription getHostDescription() {
+		if (hostDescription==null){
+			hostDescription=new HostDescription();
+		}
+		return hostDescription;
+	}
+
+	public void saveHostDescription() {
+		getJCRComponentRegistry().saveHostDescription(getHostName(), getHostDescription());
+		setHostCreated(true);
+	}
+
+	private JCRComponentRegistry getJCRComponentRegistry() {
+		return getEngine().getConfiguration().getJcrComponentRegistry();
+	}
+	
+	private void setError(String errorMessage){
+		if (errorMessage==null || errorMessage.trim().equals("")){
+			lblError.setText("");
+		}else{
+			lblError.setText(errorMessage.trim());
+		}
+	}
 }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/RegisterApplicationsMenu.java Tue Oct 11 14:18:50 2011
@@ -125,23 +125,9 @@ public class RegisterApplicationsMenu {
 
             @Override
             public void actionPerformed(ActionEvent e) {
-                if (this.window == null) {
-                    RegisterApplicationsMenu.this.myProxyChecker = new MyProxyChecker(
-                            RegisterApplicationsMenu.this.engine);
-                    boolean loaded = RegisterApplicationsMenu.this.myProxyChecker.loadIfNecessary();
-                    if (loaded) {
-                        // intended to be blank
-                    } else {
-                        return; // error
-                    }
-
-                    this.window = ServiceDescriptionRegistrationWindow.getInstance();
-                }
-                if (!this.window.isEngineSet()) {
-                    this.window.setXBayaEngine(RegisterApplicationsMenu.this.engine);
-                }
                 try {
-                    this.window.show();
+                	ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(RegisterApplicationsMenu.this.engine);
+                	serviceDescriptionDialog.open();
                 } catch (Exception e1) {
                     RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
                 }
@@ -158,26 +144,12 @@ public class RegisterApplicationsMenu {
 
             @Override
             public void actionPerformed(ActionEvent e) {
-                if (this.window == null) {
-                    RegisterApplicationsMenu.this.myProxyChecker = new MyProxyChecker(
-                            RegisterApplicationsMenu.this.engine);
-                    boolean loaded = RegisterApplicationsMenu.this.myProxyChecker.loadIfNecessary();
-                    if (loaded) {
-                        // intended to be blank
-                    } else {
-                        return; // error
-                    }
-
-                    this.window = ApplicationDescriptionRegistrationWindow.getInstance();
-                }
-                if (!this.window.isEngineSet()) {
-                    this.window.setXBayaEngine(RegisterApplicationsMenu.this.engine);
-                }
-                try {
-                    this.window.show();
-                } catch (Exception e1) {
-                    RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
-                }
+            	 try {
+            		 ApplicationDescriptionDialog applicationDescriptionDialog = new ApplicationDescriptionDialog(RegisterApplicationsMenu.this.engine);
+            		 applicationDescriptionDialog.open();
+                 } catch (Exception e1) {
+                     RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
+                 }
             }
         });
 
@@ -191,23 +163,9 @@ public class RegisterApplicationsMenu {
 
             @Override
             public void actionPerformed(ActionEvent e) {
-                if (this.window == null) {
-                    RegisterApplicationsMenu.this.myProxyChecker = new MyProxyChecker(
-                            RegisterApplicationsMenu.this.engine);
-                    boolean loaded = RegisterApplicationsMenu.this.myProxyChecker.loadIfNecessary();
-                    if (loaded) {
-                        // intended to be blank
-                    } else {
-                        return; // error
-                    }
-
-                    this.window = HostDescriptionRegistrationWindow.getInstance();
-                }
-                if (!this.window.isEngineSet()) {
-                    this.window.setXBayaEngine(RegisterApplicationsMenu.this.engine);
-                }
                 try {
-                    this.window.show();
+                	HostDescriptionDialog hostDescriptionDialog = new HostDescriptionDialog(RegisterApplicationsMenu.this.engine);
+                	hostDescriptionDialog.open();
                 } catch (Exception e1) {
                     RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
                 }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ServiceDescriptionDialog.java Tue Oct 11 14:18:50 2011
@@ -1,9 +1,17 @@
 package org.apache.airavata.xbaya.appwrapper;
 
 import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
 
+import javax.jcr.PathNotFoundException;
+import javax.swing.DefaultCellEditor;
 import javax.swing.GroupLayout;
 import javax.swing.GroupLayout.Alignment;
 import javax.swing.JButton;
@@ -11,27 +19,52 @@ import javax.swing.JComboBox;
 import javax.swing.JDialog;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
+import javax.swing.JScrollPane;
 import javax.swing.JSeparator;
+import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.SwingConstants;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableModel;
 
-import org.apache.airavata.xbaya.gui.XBayaLinkButton;
+import org.apache.airavata.commons.gfac.type.DataType;
+import org.apache.airavata.commons.gfac.type.Parameter;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.component.registry.JCRComponentRegistry;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.List;
 
 public class ServiceDescriptionDialog extends JDialog {
 
+	private static final long serialVersionUID = 2705760838264284423L;
 	private final JPanel contentPanel = new JPanel();
-	private JLabel lblRegistry;
 	private JLabel lblServiceName;
-	private JTextField textField;
-	private JTextField textField_1;
-
+	private JTextField txtServiceName;
+	private JTable tblParameters;
+	private boolean serviceCreated=false;
+	private JLabel lblError;
+	private XBayaEngine engine;
+	private ServiceDescription serviceDescription;
+	private JButton okButton;
+	private JButton btnDeleteParameter;
+	private DefaultTableModel defaultTableModel;
+	
 	/**
 	 * Launch the application.
 	 */
 	public static void main(String[] args) {
 		try {
-			ServiceDescriptionDialog dialog = new ServiceDescriptionDialog();
+			ServiceDescriptionDialog dialog = new ServiceDescriptionDialog(null);
 			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 			dialog.setVisible(true);
 		} catch (Exception e) {
@@ -42,9 +75,42 @@ public class ServiceDescriptionDialog ex
 	/**
 	 * Create the dialog.
 	 */
-	public ServiceDescriptionDialog() {
+	public ServiceDescriptionDialog(XBayaEngine engine) {
+		addWindowListener(new WindowAdapter() {
+			@Override
+			public void windowOpened(WindowEvent arg0) {
+				String baseName="Service";
+				int i=1;
+				String defaultName=baseName+i;
+				try {
+					while(getJCRComponentRegistry().getServiceDescription(defaultName)!=null){
+						defaultName=baseName+(++i);
+					}
+				} catch (Exception e) {
+				}
+				txtServiceName.setText(defaultName);
+				setServiceName(txtServiceName.getText());
+			}
+		});		
+		setEngine(engine);
+		initGUI();
+		
+		
+	}
+	
+	public void open(){
+		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+		setVisible(true);
+	}
+	
+	protected ServiceDescriptionDialog getDialog(){
+		return this;
+	}
+	
+	private void initGUI() {
 		setTitle("New Service Description");
-		setBounds(100, 100, 457, 354);
+		setBounds(100, 100, 463, 369);
+		setModal(true);
 		BorderLayout borderLayout = new BorderLayout();
 		borderLayout.setVgap(5);
 		borderLayout.setHgap(5);
@@ -54,147 +120,121 @@ public class ServiceDescriptionDialog ex
 		{
 			lblServiceName = new JLabel("Service name");
 		}
-		{
-			lblRegistry = new JLabel("Registry");
-		}
-		
-		JComboBox comboBox = new JComboBox();
-		
-		JSeparator lblSeperator = new JSeparator();
-		
-		textField = new JTextField();
-		textField.setColumns(10);
-		
-		JLabel lblNewLabel = new JLabel("Method name");
 		
-		textField_1 = new JTextField();
-		textField_1.setColumns(10);
-		
-		JButton btnConfigureInputs = new JButton("Configure Inputs...");
-		
-		JButton btnConfigureOutputs = new JButton("Configure Outputs...");
+		txtServiceName = new JTextField();
+		txtServiceName.addKeyListener(new KeyAdapter() {
+			@Override
+			public void keyReleased(KeyEvent e) {
+				setServiceName(txtServiceName.getText());
+			}
+		});
+		txtServiceName.setColumns(10);
 		
 		JSeparator separator = new JSeparator();
 		
-		JLabel lblApplicationName = new JLabel("Application");
-		
-		JComboBox comboBox_1 = new JComboBox();
-		
-		XBayaLinkButton btnNewButton = new XBayaLinkButton("New button");
-		btnNewButton.setHorizontalAlignment(SwingConstants.TRAILING);
-		btnNewButton.setText("Create new application...");
-		
-		JSeparator separator_1 = new JSeparator();
-		
-		JLabel lblHost = new JLabel("Host");
+		JLabel lblInputParameters = new JLabel("Service Parameters");
+		lblInputParameters.setFont(new Font("Tahoma", Font.BOLD, 11));
 		
-		JComboBox comboBox_2 = new JComboBox();
+		JScrollPane scrollPane = new JScrollPane();
 		
-		XBayaLinkButton blnkbtnCreateNewHost = new XBayaLinkButton("New button");
-		blnkbtnCreateNewHost.setText("Create new host...");
-		blnkbtnCreateNewHost.setHorizontalAlignment(SwingConstants.TRAILING);
+		btnDeleteParameter = new JButton("Delete parameter");
+		btnDeleteParameter.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent arg0) {
+				deleteSelectedRows();
+			}
+		});
+		btnDeleteParameter.setEnabled(false);
 		GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
 		gl_contentPanel.setHorizontalGroup(
-			gl_contentPanel.createParallelGroup(Alignment.TRAILING)
-				.addGroup(gl_contentPanel.createSequentialGroup()
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
-						.addGroup(gl_contentPanel.createSequentialGroup()
-							.addGap(22)
-							.addComponent(lblRegistry, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
-							.addPreferredGap(ComponentPlacement.UNRELATED)
-							.addComponent(comboBox, 0, 317, Short.MAX_VALUE)
-							.addGap(15))
-						.addGroup(gl_contentPanel.createSequentialGroup()
-							.addGap(19)
-							.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
-								.addGroup(gl_contentPanel.createSequentialGroup()
-									.addComponent(btnConfigureInputs)
-									.addPreferredGap(ComponentPlacement.RELATED)
-									.addComponent(btnConfigureOutputs))
-								.addGroup(gl_contentPanel.createSequentialGroup()
-									.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
-										.addGroup(gl_contentPanel.createSequentialGroup()
-											.addComponent(lblServiceName)
-											.addGap(18))
-										.addGroup(gl_contentPanel.createSequentialGroup()
-											.addComponent(lblNewLabel)
-											.addGap(17)))
-									.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING, false)
-										.addComponent(textField_1)
-										.addComponent(textField, GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE))))
-							.addGap(19)))
-					.addGap(18))
-				.addGroup(gl_contentPanel.createSequentialGroup()
-					.addContainerGap(12, Short.MAX_VALUE)
-					.addComponent(lblSeperator, GroupLayout.PREFERRED_SIZE, 425, GroupLayout.PREFERRED_SIZE)
-					.addContainerGap())
-				.addGroup(gl_contentPanel.createSequentialGroup()
-					.addContainerGap(12, Short.MAX_VALUE)
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
-						.addGroup(gl_contentPanel.createSequentialGroup()
-							.addGap(10)
-							.addComponent(lblApplicationName)
-							.addGap(26)
-							.addComponent(comboBox_1, GroupLayout.PREFERRED_SIZE, 311, GroupLayout.PREFERRED_SIZE))
-						.addComponent(separator, GroupLayout.PREFERRED_SIZE, 425, GroupLayout.PREFERRED_SIZE))
-					.addContainerGap())
-				.addGroup(gl_contentPanel.createSequentialGroup()
-					.addContainerGap(269, Short.MAX_VALUE)
-					.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-					.addGap(24))
+			gl_contentPanel.createParallelGroup(Alignment.LEADING)
 				.addGroup(gl_contentPanel.createSequentialGroup()
-					.addContainerGap(14, Short.MAX_VALUE)
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
-						.addGroup(gl_contentPanel.createSequentialGroup()
-							.addGap(10)
-							.addComponent(lblHost)
-							.addGap(56)
-							.addComponent(comboBox_2, GroupLayout.PREFERRED_SIZE, 310, GroupLayout.PREFERRED_SIZE))
-						.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, 425, GroupLayout.PREFERRED_SIZE))
+					.addGap(177)
+					.addComponent(lblInputParameters)
+					.addContainerGap(313, Short.MAX_VALUE))
+				.addGroup(Alignment.TRAILING, gl_contentPanel.createSequentialGroup()
+					.addContainerGap(171, Short.MAX_VALUE)
+					.addComponent(lblServiceName)
+					.addGap(18)
+					.addComponent(txtServiceName, GroupLayout.PREFERRED_SIZE, 309, GroupLayout.PREFERRED_SIZE)
+					.addGap(30))
+				.addGroup(Alignment.TRAILING, gl_contentPanel.createSequentialGroup()
+					.addGap(181)
+					.addComponent(separator)
 					.addContainerGap())
-				.addGroup(gl_contentPanel.createSequentialGroup()
-					.addContainerGap(271, Short.MAX_VALUE)
-					.addComponent(blnkbtnCreateNewHost, GroupLayout.PREFERRED_SIZE, 156, GroupLayout.PREFERRED_SIZE)
-					.addGap(22))
+				.addGroup(Alignment.TRAILING, gl_contentPanel.createSequentialGroup()
+					.addContainerGap(195, Short.MAX_VALUE)
+					.addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING)
+						.addComponent(btnDeleteParameter)
+						.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 380, GroupLayout.PREFERRED_SIZE))
+					.addGap(27))
 		);
 		gl_contentPanel.setVerticalGroup(
 			gl_contentPanel.createParallelGroup(Alignment.LEADING)
 				.addGroup(gl_contentPanel.createSequentialGroup()
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)
-						.addComponent(lblRegistry)
-						.addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-					.addPreferredGap(ComponentPlacement.RELATED)
-					.addComponent(lblSeperator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-					.addGap(8)
+					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 					.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)
 						.addComponent(lblServiceName)
-						.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-					.addPreferredGap(ComponentPlacement.RELATED)
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)
-						.addComponent(lblNewLabel)
-						.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-					.addPreferredGap(ComponentPlacement.UNRELATED)
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)
-						.addComponent(btnConfigureOutputs)
-						.addComponent(btnConfigureInputs))
+						.addComponent(txtServiceName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 					.addPreferredGap(ComponentPlacement.UNRELATED)
 					.addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 					.addPreferredGap(ComponentPlacement.UNRELATED)
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)
-						.addComponent(comboBox_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-						.addComponent(lblApplicationName))
-					.addGap(1)
-					.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-					.addPreferredGap(ComponentPlacement.UNRELATED)
-					.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-					.addPreferredGap(ComponentPlacement.UNRELATED)
-					.addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE)
-						.addComponent(lblHost)
-						.addComponent(comboBox_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+					.addComponent(lblInputParameters)
 					.addPreferredGap(ComponentPlacement.RELATED)
-					.addComponent(blnkbtnCreateNewHost, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
-					.addGap(13))
+					.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 182, GroupLayout.PREFERRED_SIZE)
+					.addPreferredGap(ComponentPlacement.RELATED)
+					.addComponent(btnDeleteParameter)
+					.addGap(74))
+		);
+		
+		tblParameters = new JTable();
+		tblParameters.addKeyListener(new KeyAdapter() {
+			@Override
+			public void keyReleased(KeyEvent arg0) {
+				int selectedRow = tblParameters.getSelectedRow();
+				Object parameterIOType = defaultTableModel.getValueAt(selectedRow, 0);
+				Object parameterDataType = defaultTableModel.getValueAt(selectedRow, 2);
+				if (parameterIOType==null || parameterIOType.equals("")){
+					defaultTableModel.setValueAt(getIOStringList()[0],selectedRow, 0);
+				}
+				if (parameterDataType==null || parameterDataType.equals("")){
+					defaultTableModel.setValueAt(getDataTypes()[0],selectedRow, 2);
+				}
+				addNewRowIfLastIsNotEmpty();
+			}
+		});
+		tblParameters.setFillsViewportHeight(true);
+		defaultTableModel = new DefaultTableModel(
+			new Object[][] {
+				{null, null, null, null},
+			},
+			new String[] {
+				"I/O", "Parameter Name", "Type", "Description"
+			}
 		);
+		tblParameters.setModel(defaultTableModel);
+		TableColumn ioColumn = tblParameters.getColumnModel().getColumn(0);
+		String[] ioStringList = getIOStringList();
+		ioColumn.setCellEditor(new StringArrayComboBoxEditor(ioStringList));
+//		ioColumn.setCellRenderer(new StringArrayComboBoxRenderer(ioStringList));
+		
+		TableColumn datatypeColumn = tblParameters.getColumnModel().getColumn(2);
+		DataType[] dataTypeStringList = getDataTypes();
+		datatypeColumn.setCellEditor(new StringArrayComboBoxEditor(dataTypeStringList));
+//		datatypeColumn.setCellRenderer(new StringArrayComboBoxRenderer(dataTypeStringList));
+		
+		tblParameters.getColumnModel().getColumn(1).setPreferredWidth(190);
+		scrollPane.setViewportView(tblParameters);
+		
+		ListSelectionModel selectionModel = tblParameters.getSelectionModel();
+		selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
+		selectionModel.addListSelectionListener(new ListSelectionListener() {
+	      public void valueChanged(ListSelectionEvent e) {
+	    	  btnDeleteParameter.setEnabled(tblParameters.getSelectedRows().length>0);
+	      }
+
+	    });
+	    
 		gl_contentPanel.setAutoCreateContainerGaps(true);
 		gl_contentPanel.setAutoCreateGaps(true);
 		contentPanel.setLayout(gl_contentPanel);
@@ -207,6 +247,14 @@ public class ServiceDescriptionDialog ex
 			gbl_buttonPane.columnWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
 			gbl_buttonPane.rowWeights = new double[]{0.0, Double.MIN_VALUE};
 			buttonPane.setLayout(gbl_buttonPane);
+			
+			lblError = new JLabel("");
+			lblError.setForeground(Color.RED);
+			GridBagConstraints gbc_lblError = new GridBagConstraints();
+			gbc_lblError.insets = new Insets(0, 0, 0, 5);
+			gbc_lblError.gridx = 0;
+			gbc_lblError.gridy = 0;
+			buttonPane.add(lblError, gbc_lblError);
 			JPanel panel = new JPanel();
 			GridBagConstraints gbc_panel = new GridBagConstraints();
 			gbc_panel.anchor = GridBagConstraints.NORTHWEST;
@@ -214,18 +262,186 @@ public class ServiceDescriptionDialog ex
 			gbc_panel.gridy = 0;
 			buttonPane.add(panel, gbc_panel);
 			{
-				JButton okButton = new JButton("Save");
+				okButton = new JButton("Save");
+				okButton.setEnabled(false);
+				okButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						saveServiceDescription();
+						close();
+					}
+				});
 				panel.add(okButton);
 				okButton.setActionCommand("OK");
 				getRootPane().setDefaultButton(okButton);
 			}
 			{
 				JButton cancelButton = new JButton("Cancel");
+				cancelButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						setServiceCreated(false);
+						close();
+					}
+				});
 				panel.add(cancelButton);
 				cancelButton.setActionCommand("Cancel");
 			}
 		}
+	}
+
+	private String[] getIOStringList() {
+		String[] ioStringList = new String[]{"Input","Output"};
+		return ioStringList;
+	}
+
+	private DataType[] getDataTypes() {
+		return DataType.values();
+	}
+
+	public boolean isServiceCreated() {
+		return serviceCreated;
+	}
+
+	public void setServiceCreated(boolean serviceCreated) {
+		this.serviceCreated = serviceCreated;
+	}
+
+	public ServiceDescription getServiceDescription() {
+		if (serviceDescription==null){
+			serviceDescription=new ServiceDescription();
+		}
+		return serviceDescription;
+	}
+
+	public XBayaEngine getEngine() {
+		return engine;
+	}
+
+	public void setEngine(XBayaEngine engine) {
+		this.engine = engine;
+	}
+
+	public String getServiceName() {
+		return getServiceDescription().getName();
+	}
+
+	public void setServiceName(String serviceName) {
+		getServiceDescription().setName(serviceName);
+		updateDialogStatus();
+	}
+	
+	private void validateDialog() throws Exception{
+		if (getServiceName()==null || getServiceName().trim().equals("")){
+			throw new Exception("Name of the service cannot be empty!!!");
+		}
 		
+		ServiceDescription serviceDescription2=null;
+		try {
+			serviceDescription2 = getJCRComponentRegistry().getServiceDescription(getServiceName());
+		} catch (PathNotFoundException e) {
+			//what we want
+		} catch (Exception e){
+			throw e;
+		}
+		if (serviceDescription2!=null){
+			throw new Exception("Service descriptor with the given name already exists!!!");
+		}
+
 		
 	}
+	private void updateDialogStatus(){
+		String message=null;
+		try {
+			validateDialog();
+		} catch (Exception e) {
+			message=e.getLocalizedMessage();
+		}
+		okButton.setEnabled(message==null);
+		setError(message);
+	}
+
+	public void close() {
+		getDialog().setVisible(false);
+	}
+
+	public void saveServiceDescription() {
+		getServiceDescription().setInputParameters(new ArrayList<Parameter>());
+		getServiceDescription().setOutputParameters(new ArrayList<Parameter>());
+		for(int i=0;i<defaultTableModel.getRowCount();i++){
+			Parameter parameter = new Parameter();
+			String parameterName = (String)defaultTableModel.getValueAt(i, 1);
+			DataType parameterDataType = (DataType)defaultTableModel.getValueAt(i, 2);
+			String parameterDescription = (String)defaultTableModel.getValueAt(i, 3);
+			parameter.setName(parameterName);
+			parameter.setDescription(parameterDescription);
+			parameter.setType(parameterDataType);
+			if (getIOStringList()[0].equals(defaultTableModel.getValueAt(i, 0))){
+				getServiceDescription().getInputParameters().add(parameter);
+			}else{
+				getServiceDescription().getOutputParameters().add(parameter);
+			}
+		}
+		
+		getJCRComponentRegistry().saveServiceDescription(getServiceName(), getServiceDescription());
+		setServiceCreated(true);
+	}
+
+	private JCRComponentRegistry getJCRComponentRegistry() {
+		return getEngine().getConfiguration().getJcrComponentRegistry();
+	}
+	
+	private void setError(String errorMessage){
+		if (errorMessage==null || errorMessage.trim().equals("")){
+			lblError.setText("");
+		}else{
+			lblError.setText(errorMessage.trim());
+		}
+	}
+	
+	private void deleteSelectedRows() {
+		//TODO confirm deletion of selected rows
+		int selectedRow = tblParameters.getSelectedRow();
+		while(selectedRow>=0){
+			defaultTableModel.removeRow(selectedRow);
+			selectedRow = tblParameters.getSelectedRow();
+		}
+		addNewRowIfLastIsNotEmpty();
+	}
+
+	private void addNewRowIfLastIsNotEmpty() {
+		Object parameterName = defaultTableModel.getValueAt(defaultTableModel.getRowCount()-1, 1);
+		if (parameterName!=null && !parameterName.equals("")){
+			defaultTableModel.addRow(new Object[]{null,null,null,null});
+		}
+	}
+
+	private class StringArrayComboBoxRenderer extends JComboBox implements TableCellRenderer {
+		private static final long serialVersionUID = 8634257755770934231L;
+
+		public StringArrayComboBoxRenderer(String[] items) {
+	        super(items);
+	    }
+
+	    public Component getTableCellRendererComponent(JTable table, Object value,
+	            boolean isSelected, boolean hasFocus, int row, int column) {
+	        if (isSelected) {
+	            setForeground(table.getSelectionForeground());
+	            super.setBackground(table.getSelectionBackground());
+	        } else {
+	            setForeground(table.getForeground());
+	            setBackground(table.getBackground());
+	        }
+
+	        // Select the current value
+	        setSelectedItem(value);
+	        return this;
+	    }
+	}
+
+	private class StringArrayComboBoxEditor extends DefaultCellEditor {
+		private static final long serialVersionUID = -304464739219209395L;
+
+		public StringArrayComboBoxEditor(Object[] items) {
+	        super(new JComboBox(items));
+	    }
+	}
 }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/registry/JCRComponentRegistry.java Tue Oct 11 14:18:50 2011
@@ -25,14 +25,20 @@ import java.net.URI;
 import java.util.HashMap;
 import java.util.List;
 
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.registry.api.Registry;
+import org.apache.airavata.registry.api.exception.DeploymentDescriptionRetrieveException;
+import org.apache.airavata.registry.api.exception.HostDescriptionRetrieveException;
+import org.apache.airavata.registry.api.exception.ServiceDescriptionRetrieveException;
 import org.apache.airavata.registry.api.impl.JCRRegistry;
 import org.apache.airavata.registry.api.user.UserManager;
 import org.apache.airavata.xbaya.component.gui.ComponentTreeNode;
 
-import javax.jcr.RepositoryException;
-
 public class JCRComponentRegistry extends ComponentRegistry {
 
     private static final String NAME = "JCR Components";
@@ -71,12 +77,20 @@ public class JCRComponentRegistry extend
     @Override
     public ComponentTreeNode getComponentTree() {
         ComponentTreeNode tree = new ComponentTreeNode(this);
-        List<ServiceDescription> services = this.registry.searchServiceDescription("");
-        for (ServiceDescription serviceDescription : services) {
-            String serviceName = serviceDescription.getName();
-            JCRComponentReference jcr = new JCRComponentReference(serviceName, registry.getWSDL(serviceName));
-            tree.add(new ComponentTreeNode(jcr));    
-        }
+        try {
+			List<ServiceDescription> services = this.registry.searchServiceDescription("");
+			for (ServiceDescription serviceDescription : services) {
+			    String serviceName = serviceDescription.getName();
+			    JCRComponentReference jcr = new JCRComponentReference(serviceName, registry.getWSDL(serviceName));
+			    tree.add(new ComponentTreeNode(jcr));    
+			}
+		} catch (PathNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (ServiceDescriptionRetrieveException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
         
         return tree;
     }
@@ -101,8 +115,41 @@ public class JCRComponentRegistry extend
 			ApplicationDeploymentDescription app){
     	return registry.saveDeploymentDescription(service, host, app);
     }
+    
+	public String saveHostDescription(String name, HostDescription host) {
+    	return registry.saveHostDescription(name, host);
+	}
+	
+	public List<HostDescription> searchHostDescription(String nameRegEx) throws HostDescriptionRetrieveException, PathNotFoundException {
+		return registry.searchHostDescription(nameRegEx);
+	}
+	
+	public HostDescription getHostDescription(String nameRegEx) throws HostDescriptionRetrieveException, PathNotFoundException {
+		return registry.getHostDescription(nameRegEx);
+	}
+	
+	public List<ApplicationDeploymentDescription> searchApplicationDescription(String serviceName, String host) throws HostDescriptionRetrieveException {
+		return registry.searchDeploymentDescription(serviceName, host);
+	}
+	
+	public ApplicationDeploymentDescription getApplicationDescription(String serviceName, String host) throws PathNotFoundException, DeploymentDescriptionRetrieveException {
+		return registry.getDeploymentDescription(serviceName, host);
+	}
+	
+	public String saveServiceDescription(String name, ServiceDescription service) {
+		return registry.saveServiceDescription(name, service);
+	}
+	
+	public ServiceDescription getServiceDescription(String serviceName) throws PathNotFoundException, ServiceDescriptionRetrieveException {
+		return registry.getServiceDescription(serviceName);
+	}
+
+	public List<ServiceDescription> searchServiceDescription(String serviceName) throws ServiceDescriptionRetrieveException, PathNotFoundException{
+		return registry.searchServiceDescription(serviceName);
+	}
+
+	public Registry getRegistry() {
+		return registry;
+	}
 
-    public JCRRegistry getRegistry() {
-        return registry;
-    }
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/file/gui/FileMenu.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/file/gui/FileMenu.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/file/gui/FileMenu.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/file/gui/FileMenu.java Tue Oct 11 14:18:50 2011
@@ -27,13 +27,20 @@ import java.awt.event.KeyEvent;
 import javax.swing.AbstractAction;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
+import javax.swing.KeyStroke;
 
 import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.XBayaException;
 import org.apache.airavata.xbaya.ode.ODEDeploymentDescriptor;
+import org.apache.airavata.xbaya.wf.gui.WorkflowMenu;
 import org.apache.airavata.xbaya.xregistry.XRegistryAccesser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FileMenu {
 
+	private static final Logger logger = LoggerFactory.getLogger(FileMenu.class);
+
     private JMenu fileMenu;
 
     private WorkflowFiler graphFiler;
@@ -64,6 +71,8 @@ public class FileMenu {
 
     private JMenuItem exportODEScriptsItem;
 
+    private JMenuItem exitItem;
+
     private XBayaEngine engine;
 
     /**
@@ -82,6 +91,8 @@ public class FileMenu {
         this.odeDeploymentDescription = new ODEDeploymentDescriptor();
         this.xregistryAccesser = new XRegistryAccesser(engine);
 
+        this.exitItem = createExitItem();
+
         createFileMenu();
     }
 
@@ -109,6 +120,8 @@ public class FileMenu {
         this.fileMenu.add(this.exportODEScriptsItem);
         this.fileMenu.addSeparator();
         this.fileMenu.add(this.saveImageItem);
+        this.fileMenu.addSeparator();
+        this.fileMenu.add(this.exitItem);
     }
 
     /**
@@ -149,7 +162,7 @@ public class FileMenu {
     }
 
     private void createExportJythonScriptItem() {
-        this.exportJythonItem = new JMenuItem("Export WS Jython Script");
+        this.exportJythonItem = new JMenuItem("Save as WS Jython Script");
         this.exportJythonItem.setMnemonic(KeyEvent.VK_J);
         this.exportJythonItem.addActionListener(new AbstractAction() {
             public void actionPerformed(ActionEvent e) {
@@ -159,7 +172,7 @@ public class FileMenu {
     }
 
     private void createExportBpelScriptItem() {
-        this.exportBpelItem = new JMenuItem("Export BPEL2 Script");
+        this.exportBpelItem = new JMenuItem("Save as BPEL2 Script");
         this.exportBpelItem.setMnemonic(KeyEvent.VK_B);
         this.exportBpelItem.addActionListener(new AbstractAction() {
             public void actionPerformed(ActionEvent e) {
@@ -189,7 +202,7 @@ public class FileMenu {
     // }
 
     private void createExportODEScriptsItem() {
-        this.exportODEScriptsItem = new JMenuItem("Export ODE Scripts");
+        this.exportODEScriptsItem = new JMenuItem("Save as ODE Scripts");
         this.exportODEScriptsItem.addActionListener(new AbstractAction() {
             public void actionPerformed(ActionEvent e) {
                 new ODEScriptFiler(FileMenu.this.engine).save();
@@ -198,4 +211,21 @@ public class FileMenu {
         });
     }
 
+    private JMenuItem createExitItem() {
+        JMenuItem menuItem = new JMenuItem("Exit");
+        menuItem.setMnemonic(KeyEvent.VK_X);
+        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
+        menuItem.addActionListener(new AbstractAction() {
+            public void actionPerformed(ActionEvent event) {
+                try {
+                    FileMenu.this.engine.dispose();
+                } catch (XBayaException e) {
+                    logger.error(e.getMessage(), e);
+                } finally {
+                	FileMenu.this.engine.getGUI().getFrame().dispose();
+                }
+            }
+        });
+        return menuItem;
+    }
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java?rev=1181802&r1=1181801&r2=1181802&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/gui/XBayaMenu.java Tue Oct 11 14:18:50 2011
@@ -77,8 +77,8 @@ public class XBayaMenu implements XBayaC
     public XBayaMenu(XBayaEngine engine) {
         this.engine = engine;
 
-        this.workflowMenu = new WorkflowMenu(this.engine);
         this.fileMenu = new FileMenu(this.engine);
+        this.workflowMenu = new WorkflowMenu(this.engine);
         this.experimentMenu = new ExperimentMenu(this.engine);
         this.gpelMenu = new GPELMenu(this.engine);
         this.pegasusMenu = new PegasusMenu(this.engine);
@@ -107,8 +107,8 @@ public class XBayaMenu implements XBayaC
 
         this.menuBar = new JMenuBar();
 
-        this.menuBar.add(this.workflowMenu.getMenu());
         this.menuBar.add(this.fileMenu.getMenu());
+        this.menuBar.add(this.workflowMenu.getMenu());
         this.menuBar.add(this.componentMenu.getMenu());
         this.menuBar.add(this.experimentMenu.getMenu());
         this.menuBar.add(this.gpelMenu.getMenu());



Mime
View raw message