You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by he...@apache.org on 2011/12/18 23:37:06 UTC

svn commit: r1220559 - /incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java

Author: heshan
Date: Sun Dec 18 22:37:06 2011
New Revision: 1220559

URL: http://svn.apache.org/viewvc?rev=1220559&view=rev
Log:
Fix for the issue AIRAVATA-234

Modified:
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/appwrapper/HostDescriptionDialog.java

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=1220559&r1=1220558&r2=1220559&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 Sun Dec 18 22:37:06 2011
@@ -21,17 +21,6 @@
 
 package org.apache.airavata.xbaya.appwrapper;
 
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.regex.Pattern;
-
-import javax.swing.AbstractAction;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-
 import org.apache.airavata.common.utils.SwingUtil;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.registry.api.Registry;
@@ -44,6 +33,14 @@ import org.apache.airavata.xbaya.gui.XBa
 import org.apache.airavata.xbaya.gui.XBayaLabel;
 import org.apache.airavata.xbaya.gui.XBayaTextField;
 
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.util.regex.Pattern;
+
 public class HostDescriptionDialog extends JDialog {
 
     private XBayaEngine engine;
@@ -72,6 +69,12 @@ public class HostDescriptionDialog exten
 
 	private XBayaLabel gridFTPLabel;
 
+    private JLabel lblError;
+
+    private String hostId;
+
+    JButton okButton = new JButton("OK");
+
     /**
      * @param engine XBaya workflow engine
      */
@@ -93,7 +96,7 @@ public class HostDescriptionDialog exten
     }
 
     private void ok() {
-        String hostId = this.hostIdTextField.getText();
+        hostId = this.hostIdTextField.getText();
         String hostAddress = this.hostAddressTextField.getText();
         String globusGateKeeperEPR = this.globusGateKeeperTextField.getText();
         String gridFTP = this.GridFTPTextField.getText();
@@ -125,6 +128,10 @@ public class HostDescriptionDialog exten
         }
     }
 
+    private String getServiceName() {
+        return this.hostId;
+    }
+
     private void setGridFTPEPR(String epr) {
         ((GlobusHostType)hostDescription.getType()).addGridFTPEndPoint(epr);
     }
@@ -157,6 +164,17 @@ public class HostDescriptionDialog exten
 				updateGlobusHostTypeAndControls();
 			}
         });
+        hostIdTextField.getSwingComponent().addKeyListener(new KeyAdapter() {
+            @Override
+            public void keyPressed(KeyEvent e) {
+                try {
+                    validateDialog();
+                } catch (Exception e1) {
+                    setError(e1.getMessage());
+                }
+                setError(null);
+            }
+        });
         GridPanel infoPanel1 = new GridPanel();
         infoPanel1.add(hostIdLabel);
         infoPanel1.add(this.hostIdTextField);
@@ -179,7 +197,6 @@ public class HostDescriptionDialog exten
         infoPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
         SwingUtil.layoutToGrid(infoPanel.getSwingComponent(), 3, 1, SwingUtil.WEIGHT_NONE, 0);
 
-        JButton okButton = new JButton("OK");
         okButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 ok();
@@ -194,8 +211,13 @@ public class HostDescriptionDialog exten
         });
 
         GridPanel buttonPanel = new GridPanel();
+        lblError = new JLabel("xcf");
+        lblError.setForeground(Color.RED);
+        buttonPanel.add(lblError);
+
         buttonPanel.add(okButton);
         buttonPanel.add(cancelButton);
+        buttonPanel.layout(1,3,SwingUtil.WEIGHT_NONE,0);
         buttonPanel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
         this.dialog = new XBayaDialog(this.engine, "New Host Description", infoPanel, buttonPanel);
         this.dialog.setDefaultButton(okButton);
@@ -248,13 +270,18 @@ public class HostDescriptionDialog exten
         } catch (Exception e) {
             message = e.getLocalizedMessage();
         }
-        //okButton.setEnabled(message == null);
-        //setError(message);
+        okButton.setEnabled(message == null);
+        setError(message);
     }
 
-/*    public void close() {
-        getDialog().setVisible(false);
-    }*/
+    private void setError(String errorMessage) {
+        if (errorMessage == null || errorMessage.trim().equals("")) {
+            lblError.setText("");
+        } else {
+            lblError.setText(errorMessage.trim());
+        }
+
+    }
 
     public boolean isHostCreated() {
         return hostCreated;
@@ -277,14 +304,6 @@ public class HostDescriptionDialog exten
         setHostCreated(true);
     }
 
-/*    private void setError(String errorMessage) {
-        if (errorMessage == null || errorMessage.trim().equals("")) {
-            lblError.setText("");
-        } else {
-            lblError.setText(errorMessage.trim());
-        }
-    }*/
-
     public Registry getRegistry() {
         return registry;
     }