Add Registration functionality and tidy up
[WeStealzYourDataz.git] / src / uk / ac / ntu / n0521366 / wsyd / client / Login.java
index db417c1..27779e1 100644 (file)
@@ -1,7 +1,25 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * The MIT License
+ *
+ * Copyright 2015 Eddie Berrisford-Lynch <dev@fun2be.me>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
  */
 package uk.ac.ntu.n0521366.wsyd.client;
 
@@ -18,8 +36,13 @@ public class Login extends javax.swing.JDialog {
     public Login(java.awt.Frame parent, boolean modal) {
         super(parent, modal);
         initComponents();
+        this.getRootPane().setDefaultButton(gButtonLogin);
+             
+    }
+    public void setUserName(String newName) {
+        if (newName != null)
+        gFieldName.setText(newName);
     }
-
     /**
      * This method is called from within the constructor to initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is always
@@ -152,10 +175,14 @@ public class Login extends javax.swing.JDialog {
         // TODO add your handling code here:
     }//GEN-LAST:event_gFieldPasswordActionPerformed
 
+    /**
+     * Send the Username Password pair to the server to be validated.
+     * 
+     * @param evt 
+     */
     private void gButtonLoginMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gButtonLoginMouseClicked
         // TODO add your handling code here:
-        if (((ClientGUI)this.getOwner()).validateLogin(gFieldName.getText(), new String(gFieldPassword.getPassword()))); //this.dispose();
-        else gFieldName.setText("Invalid Login...");
+        ((ClientGUI)this.getOwner()).validateLogin(gFieldName.getText(), new String(gFieldPassword.getPassword()));
     }//GEN-LAST:event_gButtonLoginMouseClicked
 
     private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
@@ -169,7 +196,7 @@ public class Login extends javax.swing.JDialog {
 
     private void gButtonRegisterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gButtonRegisterMouseClicked
         // TODO add your handling code here:
-        ((ClientGUI)this.getOwner()).regiProfileDialog();
+        ((ClientGUI)this.getOwner()).registrationProfileDialog();
     }//GEN-LAST:event_gButtonRegisterMouseClicked
 
     /**