airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1181994 - in /incubator/airavata/trunk/modules: commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/ xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/
Date Tue, 11 Oct 2011 18:02:45 GMT
Author: lahiru
Date: Tue Oct 11 18:02:44 2011
New Revision: 1181994

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

Modified:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionAdvancedOptionDialog.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

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=1181994&r1=1181993&r2=1181994&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 18:02:44 2011
@@ -277,6 +277,9 @@ public class JCRRegistry implements Axis
             session.save();
 
             result = node.getIdentifier();
+            
+    		//TODO save the wsdl for this service as well
+
         } catch (Exception e) {
             System.out.println(e);
             e.printStackTrace();

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionAdvancedOptionDialog.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionAdvancedOptionDialog.java?rev=1181994&r1=1181993&r2=1181994&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionAdvancedOptionDialog.java
(original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/ApplicationDescriptionAdvancedOptionDialog.java
Tue Oct 11 18:02:44 2011
@@ -2,41 +2,59 @@ package org.apache.airavata.xbaya.appwra
 
 import java.awt.BorderLayout;
 import java.awt.FlowLayout;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
 
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
 import javax.swing.GroupLayout;
 import javax.swing.GroupLayout.Alignment;
+import javax.swing.JButton;
+import javax.swing.JDialog;
 import javax.swing.JLabel;
-import javax.swing.JComboBox;
-import javax.swing.JTextField;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
 import javax.swing.JSeparator;
-import org.apache.airavata.xbaya.gui.XBayaLinkButton;
-import javax.swing.SwingConstants;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import java.awt.Font;
 import javax.swing.JTable;
-import javax.swing.table.DefaultTableModel;
+import javax.swing.JTextField;
+import javax.swing.LayoutStyle.ComponentPlacement;
 import javax.swing.ListSelectionModel;
-import javax.swing.JScrollPane;
+import javax.swing.SwingConstants;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.DefaultTableModel;
 
-public class ApplicationDescriptionAdvancedOptionDialog extends JDialog {
-	private JTextField textField;
-	private JTextField textField_1;
-	private JTextField textField_2;
-	private JTextField textField_3;
-	private JTextField textField_4;
-	private JTextField textField_5;
-	private JTable table;
+import org.apache.airavata.commons.gfac.type.DataType;
+import org.apache.airavata.commons.gfac.type.Parameter;
+import org.apache.airavata.commons.gfac.type.app.ShellApplicationDeployment;
+import org.apache.airavata.xbaya.XBayaEngine;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
 
+public class ApplicationDescriptionAdvancedOptionDialog extends JDialog {
+	private static final long serialVersionUID = 3920479739097405014L;
+	private JTextField txtInputDir;
+	private JTextField txtWorkingDir;
+	private JTextField txtOutputDir;
+	private JTextField txtSTDIN;
+	private JTextField txtSTDOUT;
+	private JTextField txtSTDERR;
+	private JTable tblEnv;
+	private XBayaEngine engine;
+	private ShellApplicationDeployment shellApplicationDescription;
+	private DefaultTableModel defaultTableModel;
+	private JButton btnDeleteVariable;
+	
 	/**
 	 * Launch the application.
 	 */
 	public static void main(String[] args) {
 		try {
-			ApplicationDescriptionAdvancedOptionDialog dialog = new ApplicationDescriptionAdvancedOptionDialog();
+			ApplicationDescriptionAdvancedOptionDialog dialog = new ApplicationDescriptionAdvancedOptionDialog(null,null);
 			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 			dialog.setVisible(true);
 		} catch (Exception e) {
@@ -47,23 +65,60 @@ public class ApplicationDescriptionAdvan
 	/**
 	 * Create the dialog.
 	 */
-	public ApplicationDescriptionAdvancedOptionDialog() {
+	public ApplicationDescriptionAdvancedOptionDialog(XBayaEngine engine, ShellApplicationDeployment
descriptor) {
+		addWindowListener(new WindowAdapter() {
+			@Override
+			public void windowOpened(WindowEvent arg0) {
+				loadApplicationDescriptionAdvancedOptions();
+			}
+		});
+		setEngine(engine);
+		setShellApplicationDescription(descriptor);
+		initGUI();
+	}
+	public void open(){
+		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+		setVisible(true);
+	}
+	
+	protected ApplicationDescriptionAdvancedOptionDialog getDialog(){
+		return this;
+	}
+	
+	public void close() {
+		getDialog().setVisible(false);
+	}
+	
+	private void initGUI() {
 		setTitle("Application Description Advance Options");
+		setModal(true);
 		setBounds(100, 100, 601, 284);
+		setLocationRelativeTo(null);
 		getContentPane().setLayout(new BorderLayout());
 		{
 			JPanel buttonPane = new JPanel();
 			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
 			getContentPane().add(buttonPane, BorderLayout.SOUTH);
 			{
-				JButton okButton = new JButton("OK");
+				JButton okButton = new JButton("Update");
 				okButton.setActionCommand("OK");
+				okButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						saveApplicationDescriptionAdvancedOptions();
+						close();
+					}
+				});
 				buttonPane.add(okButton);
 				getRootPane().setDefaultButton(okButton);
 			}
 			{
 				JButton cancelButton = new JButton("Cancel");
 				cancelButton.setActionCommand("Cancel");
+				cancelButton.addActionListener(new ActionListener() {
+					public void actionPerformed(ActionEvent e) {
+						close();
+					}
+				});
 				buttonPane.add(cancelButton);
 			}
 		}
@@ -72,15 +127,15 @@ public class ApplicationDescriptionAdvan
 			getContentPane().add(panel, BorderLayout.CENTER);
 			JLabel lblWorkingDirectory = new JLabel("Working Directory");
 			JLabel lblInputDirectory = new JLabel("Input directory");
-			textField = new JTextField();
-			textField.setColumns(10);
-			textField_1 = new JTextField();
-			textField_1.setColumns(10);
+			txtInputDir = new JTextField();
+			txtInputDir.setColumns(10);
+			txtWorkingDir = new JTextField();
+			txtWorkingDir.setColumns(10);
 			JLabel lblLocations = new JLabel("Locations");
 			lblLocations.setFont(new Font("Tahoma", Font.BOLD, 11));
 			
-			textField_2 = new JTextField();
-			textField_2.setColumns(10);
+			txtOutputDir = new JTextField();
+			txtOutputDir.setColumns(10);
 			
 			JLabel lblOutputDirectory = new JLabel("Output directory");
 			
@@ -92,20 +147,20 @@ public class ApplicationDescriptionAdvan
 			JLabel lblStdin = new JLabel("STDIN");
 			lblStdin.setHorizontalAlignment(SwingConstants.TRAILING);
 			
-			textField_3 = new JTextField();
-			textField_3.setColumns(10);
+			txtSTDIN = new JTextField();
+			txtSTDIN.setColumns(10);
 			
 			JLabel lblStdout = new JLabel("STDOUT");
 			lblStdout.setHorizontalAlignment(SwingConstants.TRAILING);
 			
-			textField_4 = new JTextField();
-			textField_4.setColumns(10);
+			txtSTDOUT = new JTextField();
+			txtSTDOUT.setColumns(10);
 			
 			JLabel lblStderr = new JLabel("STDERR");
 			lblStderr.setHorizontalAlignment(SwingConstants.TRAILING);
 			
-			textField_5 = new JTextField();
-			textField_5.setColumns(10);
+			txtSTDERR = new JTextField();
+			txtSTDERR.setColumns(10);
 			
 			JSeparator separator_1 = new JSeparator();
 			separator_1.setOrientation(SwingConstants.VERTICAL);
@@ -114,6 +169,14 @@ public class ApplicationDescriptionAdvan
 			lblEnvironmentalVariables.setFont(new Font("Tahoma", Font.BOLD, 11));
 			
 			JScrollPane scrollPane = new JScrollPane();
+			
+			btnDeleteVariable = new JButton("Delete variable");
+			btnDeleteVariable.addActionListener(new ActionListener() {
+				public void actionPerformed(ActionEvent e) {
+					deleteSelectedRows();
+				}
+			});
+			btnDeleteVariable.setEnabled(false);
 			GroupLayout gl_panel = new GroupLayout(panel);
 			gl_panel.setHorizontalGroup(
 				gl_panel.createParallelGroup(Alignment.LEADING)
@@ -131,15 +194,15 @@ public class ApplicationDescriptionAdvan
 									.addGroup(gl_panel.createSequentialGroup()
 										.addComponent(lblStderr, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
 										.addGap(18)
-										.addComponent(textField_5, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE))
+										.addComponent(txtSTDERR, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE))
 									.addGroup(gl_panel.createSequentialGroup()
 										.addComponent(lblStdout, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
 										.addGap(18)
-										.addComponent(textField_4, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE))
+										.addComponent(txtSTDOUT, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE))
 									.addGroup(gl_panel.createSequentialGroup()
 										.addComponent(lblStdin, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE)
 										.addGap(18)
-										.addComponent(textField_3, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)))
+										.addComponent(txtSTDIN, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)))
 								.addPreferredGap(ComponentPlacement.UNRELATED))
 							.addComponent(separator, GroupLayout.PREFERRED_SIZE, 293, GroupLayout.PREFERRED_SIZE)
 							.addGroup(gl_panel.createSequentialGroup()
@@ -154,18 +217,20 @@ public class ApplicationDescriptionAdvan
 										.addComponent(lblOutputDirectory)
 										.addGap(18)))
 								.addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
-									.addComponent(textField_2)
-									.addComponent(textField)
-									.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, 179, GroupLayout.PREFERRED_SIZE))))
+									.addComponent(txtOutputDir)
+									.addComponent(txtInputDir)
+									.addComponent(txtWorkingDir, GroupLayout.PREFERRED_SIZE, 179, GroupLayout.PREFERRED_SIZE))))
 						.addGap(2)
 						.addComponent(separator_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
 						.addPreferredGap(ComponentPlacement.UNRELATED)
-						.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
-							.addComponent(lblEnvironmentalVariables)
-							.addGroup(gl_panel.createSequentialGroup()
-								.addGap(10)
-								.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE)))
-						.addGap(411))
+						.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
+							.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
+								.addComponent(lblEnvironmentalVariables)
+								.addGroup(gl_panel.createSequentialGroup()
+									.addGap(10)
+									.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE)))
+							.addComponent(btnDeleteVariable))
+						.addContainerGap())
 			);
 			gl_panel.setVerticalGroup(
 				gl_panel.createParallelGroup(Alignment.LEADING)
@@ -177,14 +242,14 @@ public class ApplicationDescriptionAdvan
 								.addPreferredGap(ComponentPlacement.RELATED)
 								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
 									.addComponent(lblWorkingDirectory)
-									.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
+									.addComponent(txtWorkingDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
 								.addPreferredGap(ComponentPlacement.RELATED)
 								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
 									.addComponent(lblInputDirectory)
-									.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+									.addComponent(txtInputDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
 								.addPreferredGap(ComponentPlacement.RELATED)
 								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
-									.addComponent(textField_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
+									.addComponent(txtOutputDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
 									.addComponent(lblOutputDirectory))
 								.addPreferredGap(ComponentPlacement.RELATED)
 								.addComponent(separator, GroupLayout.PREFERRED_SIZE, 2, GroupLayout.PREFERRED_SIZE)
@@ -193,29 +258,35 @@ public class ApplicationDescriptionAdvan
 								.addGap(3)
 								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
 									.addComponent(lblStdin)
-									.addComponent(textField_3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
+									.addComponent(txtSTDIN, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 								.addGap(9)
 								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
 									.addComponent(lblStdout)
-									.addComponent(textField_4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
+									.addComponent(txtSTDOUT, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
 								.addGap(9)
 								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
 									.addComponent(lblStderr)
-									.addComponent(textField_5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)))
+									.addComponent(txtSTDERR, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
 							.addGroup(gl_panel.createSequentialGroup()
 								.addComponent(lblEnvironmentalVariables)
 								.addPreferredGap(ComponentPlacement.RELATED)
-								.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 179, GroupLayout.PREFERRED_SIZE)))
-						.addContainerGap(29, Short.MAX_VALUE))
+								.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 153, GroupLayout.PREFERRED_SIZE)
+								.addPreferredGap(ComponentPlacement.RELATED)
+								.addComponent(btnDeleteVariable)))
+						.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
 			);
 			
-			table = new JTable();
-			table.setFillsViewportHeight(true);
-			scrollPane.setViewportView(table);
-			table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-			table.setCellSelectionEnabled(true);
-			table.setColumnSelectionAllowed(true);
-			table.setModel(new DefaultTableModel(
+			tblEnv = new JTable();
+			tblEnv.addKeyListener(new KeyAdapter() {
+				@Override
+				public void keyReleased(KeyEvent arg0) {
+					addNewRowIfLastIsNotEmpty();
+				}
+			});
+			tblEnv.setFillsViewportHeight(true);
+			scrollPane.setViewportView(tblEnv);
+			tblEnv.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+			defaultTableModel = new DefaultTableModel(
 				new Object[][] {
 					{null, null},
 				},
@@ -229,12 +300,158 @@ public class ApplicationDescriptionAdvan
 				public Class getColumnClass(int columnIndex) {
 					return columnTypes[columnIndex];
 				}
-			});
-			table.getColumnModel().getColumn(0).setPreferredWidth(67);
-			table.getColumnModel().getColumn(1).setPreferredWidth(158);
+			};
+			tblEnv.setModel(defaultTableModel);
+			tblEnv.getColumnModel().getColumn(0).setPreferredWidth(67);
+			tblEnv.getColumnModel().getColumn(1).setPreferredWidth(158);
+			ListSelectionModel selectionModel = tblEnv.getSelectionModel();
+			selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
+			selectionModel.addListSelectionListener(new ListSelectionListener() {
+		      public void valueChanged(ListSelectionEvent e) {
+		    	  btnDeleteVariable.setEnabled(tblEnv.getSelectedRows().length>0);
+		      }
+
+		    });
 			gl_panel.setAutoCreateGaps(true);
 			gl_panel.setAutoCreateContainerGaps(true);
 			panel.setLayout(gl_panel);
 		}
 	}
+	
+	private void deleteSelectedRows() {
+		//TODO confirm deletion of selected rows
+		int selectedRow = tblEnv.getSelectedRow();
+		while(selectedRow>=0){
+			defaultTableModel.removeRow(selectedRow);
+			selectedRow = tblEnv.getSelectedRow();
+		}
+		addNewRowIfLastIsNotEmpty();
+	}
+	
+	public ShellApplicationDeployment getShellApplicationDescription() {
+		return shellApplicationDescription;
+	}
+
+	public void setShellApplicationDescription(
+			ShellApplicationDeployment shellApplicationDescription) {
+		this.shellApplicationDescription = shellApplicationDescription;
+	}
+
+	public XBayaEngine getEngine() {
+		return engine;
+	}
+
+	private void addNewRowIfLastIsNotEmpty() {
+		Object varName=null;
+		if (defaultTableModel.getRowCount()>0) {
+			varName = defaultTableModel.getValueAt(
+					defaultTableModel.getRowCount() - 1, 0);
+		}
+		if (defaultTableModel.getRowCount()==0 || (varName!=null && !varName.equals(""))){
+			defaultTableModel.addRow(new Object[]{null,null});
+		}
+	}
+	
+	public void setEngine(XBayaEngine engine) {
+		this.engine = engine;
+	}
+	
+	private void saveApplicationDescriptionAdvancedOptions() {
+		getShellApplicationDescription().setWorkingDir(txtWorkingDir.getText());
+		getShellApplicationDescription().setInputDir(txtInputDir.getText());
+		getShellApplicationDescription().setOutputDir(txtOutputDir.getText());
+		getShellApplicationDescription().setStdIn(txtSTDIN.getText());
+		getShellApplicationDescription().setStdOut(txtSTDOUT.getText());
+		getShellApplicationDescription().setStdErr(txtSTDERR.getText());
+		
+		getShellApplicationDescription().setEnv(new HashMap<String, String>());
+		for(int i=0;i<defaultTableModel.getRowCount();i++){
+			String varName = (String)defaultTableModel.getValueAt(i, 0);
+			if (varName!=null && !varName.equals("")) {
+				String varValue = (String) defaultTableModel.getValueAt(i, 1);
+				getShellApplicationDescription().getEnv()
+						.put(varName, varValue);
+			}
+		}
+	}
+	
+	private void loadApplicationDescriptionAdvancedOptions() {
+		txtWorkingDir.setText(getShellApplicationDescription().getWorkingDir());
+		txtInputDir.setText(getShellApplicationDescription().getInputDir());
+		txtOutputDir.setText(getShellApplicationDescription().getOutputDir());
+		txtSTDIN.setText(getShellApplicationDescription().getStdIn());
+		txtSTDOUT.setText(getShellApplicationDescription().getStdOut());
+		txtSTDERR.setText(getShellApplicationDescription().getStdErr());
+		
+		Map<String, String> env = getShellApplicationDescription().getEnv();
+		while(defaultTableModel.getRowCount()>0){
+			defaultTableModel.removeRow(0);
+		}
+		if (env!=null) {
+			for (String varName : env.keySet()) {
+				defaultTableModel.addRow(new String[] { varName,
+						env.get(varName) });
+			}
+		}
+		addNewRowIfLastIsNotEmpty();
+	}
+	
+	private String getNotNullValue(String value){
+		return value==null?"":value;
+	}
+//	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!!!");
+//		}
+//		
+//		List<ApplicationDeploymentDescription> deploymentDescriptions=null;
+//		try {
+//			deploymentDescriptions = getJCRComponentRegistry().getRegistry().searchDeploymentDescription(getServiceName(),
getHostName(), Pattern.quote(getApplicationName()));
+//		} catch (PathNotFoundException e) {
+//			//what we want
+//		} catch (Exception e){
+//			throw e;
+//		}
+//		if (deploymentDescriptions.size()>0){
+//			throw new Exception("Application descriptor with the given name already exists!!!");
+//		}
+//		
+//		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");
+//		}
+//
+//	}
+	
 }

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=1181994&r1=1181993&r2=1181994&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 18:02:44 2011
@@ -6,10 +6,6 @@ import java.awt.FlowLayout;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.util.List;
@@ -35,8 +31,10 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.xbaya.XBayaEngine;
 import org.apache.airavata.xbaya.component.registry.JCRComponentRegistry;
 import org.apache.airavata.xbaya.gui.XBayaLinkButton;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
 
-public class ApplicationDescriptionDialog extends JDialog {
+public class ApplicationDescriptionDialog extends JDialog implements ActionListener{
 	/**
 	 * 
 	 */
@@ -116,6 +114,7 @@ public class ApplicationDescriptionDialo
 		setTitle("New Deployment Description");
 		setBounds(100, 100, 455, 349);
 		setModal(true);
+		setLocationRelativeTo(null);
 		getContentPane().setLayout(new BorderLayout());
 		{
 			JPanel buttonPane = new JPanel();
@@ -166,7 +165,7 @@ public class ApplicationDescriptionDialo
 			txtAppName = new JTextField();
 			txtAppName.addKeyListener(new KeyAdapter() {
 				@Override
-				public void keyReleased(KeyEvent e) {
+				public void keyReleased(KeyEvent arg0) {
 					setApplicationName(txtAppName.getText());
 				}
 			});
@@ -182,6 +181,16 @@ public class ApplicationDescriptionDialo
 			});
 			txtTempDir.setColumns(10);
 			JButton btnAdvance = new JButton("Advanced options...");
+			btnAdvance.addActionListener(new ActionListener() {
+				public void actionPerformed(ActionEvent e) {
+					try {
+						ApplicationDescriptionAdvancedOptionDialog serviceDescriptionDialog = new ApplicationDescriptionAdvancedOptionDialog(getEngine(),getShellApplicationDescription());
+	                	serviceDescriptionDialog.open();
+	                } catch (Exception e1) {
+	                    getEngine().getErrorWindow().error(e1);
+	                }
+				}
+			});
 			
 			JSeparator separator = new JSeparator();
 			
@@ -204,32 +213,10 @@ public class ApplicationDescriptionDialo
 			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();
-				}
-			});
-			
+			cmbServiceName.addActionListener(this);
+
 			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();
-				}
-			});
+			cmbHostName.addActionListener(this);
 			
 			JLabel label_1 = new JLabel("Host");
 			
@@ -368,7 +355,11 @@ public class ApplicationDescriptionDialo
 		try {
 			List<HostDescription> hostDescriptions = getJCRComponentRegistry().searchHostDescription(".*");
 			for (HostDescription hostDescription : hostDescriptions) {
-				cmbHostName.addItem(hostDescription.getId());
+				if (hostDescription.getId()==null){
+					cmbHostName.addItem(hostDescription.getAddress());
+				}else{
+					cmbHostName.addItem(hostDescription.getId());
+				}
 			}
 		} catch (Exception e) {
 			setError(e.getLocalizedMessage());
@@ -463,6 +454,18 @@ public class ApplicationDescriptionDialo
 			throw new Exception("Name of the application cannot be empty!!!");
 		}
 		
+		List<ApplicationDeploymentDescription> deploymentDescriptions=null;
+		try {
+			deploymentDescriptions = getJCRComponentRegistry().getRegistry().searchDeploymentDescription(getServiceName(),
getHostName(), Pattern.quote(getApplicationName()));
+		} catch (PathNotFoundException e) {
+			//what we want
+		} catch (Exception e){
+			throw e;
+		}
+		if (deploymentDescriptions.size()>0){
+			throw new Exception("Application descriptor with the given name already exists!!!");
+		}
+		
 		if (getExecutablePath()==null || getExecutablePath().trim().equals("")){
 			throw new Exception("Executable path cannot be empty!!!");
 		}
@@ -478,18 +481,7 @@ public class ApplicationDescriptionDialo
 		if (getHostName()==null || getHostName().trim().equals("")){
 			throw new Exception("Please select/create host to bind to this deployment description");
 		}
-		
-		List<ApplicationDeploymentDescription> deploymentDescriptions=null;
-		try {
-			deploymentDescriptions = getJCRComponentRegistry().getRegistry().searchDeploymentDescription(getServiceName(),
getHostName(), Pattern.quote(getApplicationName()));
-		} catch (PathNotFoundException e) {
-			//what we want
-		} catch (Exception e){
-			throw e;
-		}
-		if (deploymentDescriptions.size()>0){
-			throw new Exception("Application descriptor with the given name already exists!!!");
-		}
+
 	}
 
 	public String getServiceName() {
@@ -521,4 +513,23 @@ public class ApplicationDescriptionDialo
 			setHostName(cmbHostName.getSelectedItem().toString());
 		}
 	}
+
+	@Override
+	public void actionPerformed(ActionEvent e) {
+		if (e.getSource()==cmbServiceName){
+			updateServiceName();
+		}
+		if (e.getSource()==cmbHostName){
+			updateHostName();
+		}
+		if (e.getSource()==txtAppName){
+			setApplicationName(txtAppName.getText());
+		}
+		if(e.getSource()==txtExecPath){
+			setExecutablePath(txtExecPath.getText());
+		}
+		if(e.getSource()==txtTempDir){
+			setTempDir(txtTempDir.getText());
+		}
+	}
 }

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=1181994&r1=1181993&r2=1181994&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 18:02:44 2011
@@ -36,7 +36,6 @@ public class HostDescriptionDialog exten
 	private XBayaEngine engine;
 	private HostDescription hostDescription;
 	
-	private String hostName;
 	private JButton okButton;
 	private boolean hostCreated=false;
 	private JLabel lblError;
@@ -79,7 +78,7 @@ public class HostDescriptionDialog exten
 				} catch (PathNotFoundException e) {
 				}
 				txtHostName.setText(defaultName);
-				setHostName(txtHostName.getText());
+				setHostId(txtHostName.getText());
 			}
 		});
 		setEngine(engine);
@@ -90,6 +89,7 @@ public class HostDescriptionDialog exten
 		setTitle("New Host Description");
 		setBounds(100, 100, 448, 129);
 		setModal(true);
+		setLocationRelativeTo(null);
 		getContentPane().setLayout(new BorderLayout());
 		{
 			JPanel buttonPane = new JPanel();
@@ -131,8 +131,8 @@ public class HostDescriptionDialog exten
 			label.setVisible(false);
 			JComboBox comboBox = new JComboBox();
 			comboBox.setVisible(false);
-			JLabel lblHostName = new JLabel("Host name");
-			JLabel lblHostLocationip = new JLabel("Host location/ip");
+			JLabel lblHostName = new JLabel("Host id");
+			JLabel lblHostLocationip = new JLabel("Host address");
 			txtHostLocation = new JTextField();
 			txtHostLocation.addKeyListener(new KeyAdapter() {
 				@Override
@@ -145,7 +145,7 @@ public class HostDescriptionDialog exten
 			txtHostName.addKeyListener(new KeyAdapter() {
 				@Override
 				public void keyReleased(KeyEvent e) {
-					setHostName(txtHostName.getText());
+					setHostId(txtHostName.getText());
 				}
 			});
 			txtHostName.setColumns(10);
@@ -210,12 +210,12 @@ public class HostDescriptionDialog exten
 		this.engine = engine;
 	}
 
-	public String getHostName() {
-		return hostName;
+	public String getHostId() {
+		return getHostDescription().getId();
 	}
 
-	public void setHostName(String hostName) {
-		this.hostName = hostName;
+	public void setHostId(String hostId) {
+		getHostDescription().setId(hostId);
 		updateDialogStatus();
 	}
 
@@ -229,20 +229,20 @@ public class HostDescriptionDialog exten
 	}
 
 	private void validateDialog() throws Exception{
-		if (getHostName()==null || getHostName().trim().equals("")){
-			throw new Exception("Name of the host cannot be empty!!!");
+		if (getHostId()==null || getHostId().trim().equals("")){
+			throw new Exception("Id of the host cannot be empty!!!");
 		}
 		
 		HostDescription hostDescription2=null;
 		try {
-			hostDescription2 = getJCRComponentRegistry().getHostDescription(Pattern.quote(getHostName()));
+			hostDescription2 = getJCRComponentRegistry().getHostDescription(Pattern.quote(getHostId()));
 		} 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!!!");
+			throw new Exception("Host descriptor with the given id already exists!!!");
 		}
 		
 		if (getHostLocation()==null || getHostLocation().trim().equals("")){
@@ -280,7 +280,7 @@ public class HostDescriptionDialog exten
 	}
 
 	public void saveHostDescription() {
-		getJCRComponentRegistry().saveHostDescription(getHostName(), getHostDescription());
+		getJCRComponentRegistry().saveHostDescription(getHostId(), getHostDescription());
 		setHostCreated(true);
 	}
 

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=1181994&r1=1181993&r2=1181994&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 18:02:44 2011
@@ -29,6 +29,7 @@ import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 
 import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.component.gui.JCRRegistryWindow;
 import org.apache.airavata.xbaya.myproxy.gui.MyProxyChecker;
 
 public class RegisterApplicationsMenu {
@@ -68,23 +69,31 @@ public class RegisterApplicationsMenu {
 
     private void createRegsiterApplicationsMenu() {
 
+        createRegisterHostDesc();
         createRegisterServiceDesc();
         createRegisterApplicationDesc();
-        createRegisterHostDesc();
         createRegisterThroughFile();
         createSearchAndEdit();
 
         this.registerApplicationsMenu = new JMenu("Register Applications");
         this.registerApplicationsMenu.setMnemonic(KeyEvent.VK_P);
 
+        this.registerApplicationsMenu.add(this.registerHostDesc);
         this.registerApplicationsMenu.add(this.registerServiceDesc);
         this.registerApplicationsMenu.add(this.registerApplicationDesc);
-        this.registerApplicationsMenu.add(this.registerHostDesc);
         this.registerApplicationsMenu.add(this.registerThroughFile);
         this.registerApplicationsMenu.addSeparator();
         this.registerApplicationsMenu.add(this.searchAndEdit);
     }
 
+    private boolean acquireJCRRegistry(){
+    	if (engine.getConfiguration().getJcrComponentRegistry()==null){
+	    	JCRRegistryWindow window = new JCRRegistryWindow(this.engine);
+			window.show();
+    	}
+    	return engine.getConfiguration().getJcrComponentRegistry()!=null;
+    }
+    
     private void createRegisterThroughFile() {
         this.registerThroughFile = new JMenuItem("Register Description Through File");
 
@@ -125,12 +134,16 @@ public class RegisterApplicationsMenu {
 
             @Override
             public void actionPerformed(ActionEvent e) {
-                try {
-                	ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(RegisterApplicationsMenu.this.engine);
-                	serviceDescriptionDialog.open();
-                } catch (Exception e1) {
-                    RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
-                }
+                if (acquireJCRRegistry()) {
+					try {
+						ServiceDescriptionDialog serviceDescriptionDialog = new ServiceDescriptionDialog(
+								RegisterApplicationsMenu.this.engine);
+						serviceDescriptionDialog.open();
+					} catch (Exception e1) {
+						RegisterApplicationsMenu.this.engine.getErrorWindow()
+								.error(e1);
+					}
+				}
             }
         });
 
@@ -144,12 +157,16 @@ public class RegisterApplicationsMenu {
 
             @Override
             public void actionPerformed(ActionEvent e) {
-            	 try {
-            		 ApplicationDescriptionDialog applicationDescriptionDialog = new ApplicationDescriptionDialog(RegisterApplicationsMenu.this.engine);
-            		 applicationDescriptionDialog.open();
-                 } catch (Exception e1) {
-                     RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
-                 }
+            	 if (acquireJCRRegistry()) {
+					try {
+						ApplicationDescriptionDialog applicationDescriptionDialog = new ApplicationDescriptionDialog(
+								RegisterApplicationsMenu.this.engine);
+						applicationDescriptionDialog.open();
+					} catch (Exception e1) {
+						RegisterApplicationsMenu.this.engine.getErrorWindow()
+								.error(e1);
+					}
+				}
             }
         });
 
@@ -163,12 +180,16 @@ public class RegisterApplicationsMenu {
 
             @Override
             public void actionPerformed(ActionEvent e) {
-                try {
-                	HostDescriptionDialog hostDescriptionDialog = new HostDescriptionDialog(RegisterApplicationsMenu.this.engine);
-                	hostDescriptionDialog.open();
-                } catch (Exception e1) {
-                    RegisterApplicationsMenu.this.engine.getErrorWindow().error(e1);
-                }
+                if (acquireJCRRegistry()) {
+					try {
+						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=1181994&r1=1181993&r2=1181994&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 18:02:44 2011
@@ -2,13 +2,18 @@ package org.apache.airavata.xbaya.appwra
 
 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.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 java.util.ArrayList;
+import java.util.regex.Pattern;
 
 import javax.jcr.PathNotFoundException;
 import javax.swing.DefaultCellEditor;
@@ -28,22 +33,13 @@ 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.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;
-import java.util.regex.Pattern;
 
 public class ServiceDescriptionDialog extends JDialog {
 
@@ -112,6 +108,7 @@ public class ServiceDescriptionDialog ex
 		setTitle("New Service Description");
 		setBounds(100, 100, 463, 369);
 		setModal(true);
+		setLocationRelativeTo(null);
 		BorderLayout borderLayout = new BorderLayout();
 		borderLayout.setVgap(5);
 		borderLayout.setHgap(5);
@@ -216,12 +213,10 @@ public class ServiceDescriptionDialog ex
 		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);
@@ -383,6 +378,7 @@ public class ServiceDescriptionDialog ex
 		}
 		
 		getJCRComponentRegistry().saveServiceDescription(getServiceName(), getServiceDescription());
+		
 		setServiceCreated(true);
 	}
 
@@ -415,29 +411,6 @@ public class ServiceDescriptionDialog ex
 		}
 	}
 
-	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;
 



Mime
View raw message