Permalink
Browse files

WTF

  • Loading branch information...
Kyrre Kyrre
Kyrre authored and Kyrre committed Oct 10, 2012
1 parent 5ed1169 commit c2ed6c741ce4a550f4addba2d8a7931321f1d251
Showing with 44 additions and 59 deletions.
  1. +34 −1 src/client/Client.java
  2. +0 −12 src/client/Constants.java
  3. +1 −2 src/client/DbDownload.java
  4. +0 −37 src/gui/GUI.java
  5. +5 −4 src/gui/Hub.java
  6. +4 −3 src/gui/Login.java
View
@@ -1,6 +1,39 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
package client;
+import gui.Hub;
+import gui.Login;
+import javax.swing.SwingUtilities;
+
+/**
+ *
+ * @author Kyrre
+ */
public class Client {
-
+
+ public static Login login = new Login();
+ public static Hub hub = new Hub();
+ public static SocketClient sockCli;
+
+ public static void main(String[] args) {
+
+ sockCli = new SocketClient("localhost", 6667);
+ sockCli.run();
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ login.setVisible(true);
+
+ }
+ });
+
+ //sockCli.close();
+
+ }
}
+
View
@@ -1,12 +0,0 @@
-
-package client;
-
-/**
- *
- * @author Kyrre
- */
-public class Constants {
-
- public static final String SUPER_USERNAME = "scott";
- public static final String SUPER_PASSWORD = "tiger";
-}
@@ -1,6 +1,5 @@
package client;
-import gui.GUI;
import helpclasses.CommEnum;
import helpclasses.CommMessage;
import helpclasses.Owner;
@@ -11,6 +10,6 @@
public static void loadFarms(){
ArrayList<Owner> metadata = new ArrayList<Owner>();
metadata.add(ServerData.owner);
- GUI.sockCli.sendMessage(new CommMessage<Owner>(CommEnum.GETFARMS, metadata));
+ Client.sockCli.sendMessage(new CommMessage<Owner>(CommEnum.GETFARMS, metadata));
}
}
View
@@ -1,37 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package gui;
-
-import javax.swing.SwingUtilities;
-import client.SocketClient;
-
-/**
- *
- * @author Kyrre
- */
-public class GUI {
-
- static Login login = new Login();
- static Hub hub = new Hub();
- public static SocketClient sockCli;
-
- public static void main(String[] args) {
-
- sockCli = new SocketClient("localhost", 6667);
- sockCli.run();
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- login.setVisible(true);
-
- }
- });
-
- //sockCli.close();
-
- }
-}
-
View
@@ -6,6 +6,7 @@
import java.util.ArrayList;
+import client.Client;
import client.DbDownload;
import client.ServerData;
import helpclasses.CommEnum;
@@ -393,7 +394,7 @@ private void addFarmAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
addFarmName.setText(null);
ArrayList<Farm> metadata = new ArrayList<Farm>();
metadata.add(new Farm(-1, farmName, ServerData.owner.getOwnerId()));
- GUI.sockCli.sendMessage(new CommMessage<Farm>(CommEnum.ADDFARM,metadata));
+ Client.sockCli.sendMessage(new CommMessage<Farm>(CommEnum.ADDFARM,metadata));
DbDownload.loadFarms();
initRemoveFarm();
}else{
@@ -407,7 +408,7 @@ private void removeFarmAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN
System.out.print(farmToRemove);
ArrayList<Farm> metadata = new ArrayList<Farm>();
metadata.add(ServerData.getFarmByNameAndRemove(farmToRemove));
- GUI.sockCli.sendMessage(new CommMessage<Farm>(CommEnum.REMOVEFARM, metadata));
+ Client.sockCli.sendMessage(new CommMessage<Farm>(CommEnum.REMOVEFARM, metadata));
initRemoveFarm();
}//GEN-LAST:event_removeFarmAddActionPerformed
@@ -418,15 +419,15 @@ private void addSheepAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
addSheepName.setText(null);
ArrayList<Sheep> sheep = new ArrayList<Sheep>();
sheep.add(new Sheep(-1, name, birthYear, ServerData.getFarmByName(farmName).getFarmId(), ServerData.owner.getOwnerId()));
- GUI.sockCli.sendMessage(new CommMessage<Sheep>(CommEnum.ADDSHEEP, sheep));
+ Client.sockCli.sendMessage(new CommMessage<Sheep>(CommEnum.ADDSHEEP, sheep));
}//GEN-LAST:event_addSheepAddActionPerformed
private void removeSheepRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeSheepRemoveActionPerformed
int id = Integer.parseInt(removeSheepID.getText());
removeSheepID.setText(null);
ArrayList<Sheep> sheep = new ArrayList<Sheep>();
sheep.add(new Sheep(id, "", -1, -1, -1));
- GUI.sockCli.sendMessage(new CommMessage<Sheep>(CommEnum.REMOVESHEEP, sheep));
+ Client.sockCli.sendMessage(new CommMessage<Sheep>(CommEnum.REMOVESHEEP, sheep));
}//GEN-LAST:event_removeSheepRemoveActionPerformed
View
@@ -15,6 +15,7 @@
import javax.swing.JOptionPane;
+import client.Client;
import client.DbDownload;
import client.ServerData;
@@ -123,8 +124,8 @@ private void loginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
if(isUsernameAndPassword(username, password)){
this.setVisible(false);
DbDownload.loadFarms();
- GUI.hub.setVisible(true);
- GUI.hub.initComp();
+ Client.hub.setVisible(true);
+ Client.hub.initComp();
System.out.println(ServerData.owner);
System.out.println(ServerData.farms.get(0).getName());
System.out.println(ServerData.farms.get(1).getName());
@@ -165,7 +166,7 @@ private boolean isUsernameAndPassword(String username, String password) {
ArrayList<String> al = new ArrayList<String>();
al.add(username);
al.add(password);
- GUI.sockCli.sendMessage(new CommMessage<String>(CommEnum.LOGIN, al));
+ Client.sockCli.sendMessage(new CommMessage<String>(CommEnum.LOGIN, al));
return client.ServerData.isLoggedIn;
}
}

0 comments on commit c2ed6c7

Please sign in to comment.