Navigation Menu

Skip to content

Commit

Permalink
WTF
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrre authored and Kyrre committed Oct 10, 2012
1 parent 5ed1169 commit c2ed6c7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 59 deletions.
35 changes: 34 additions & 1 deletion src/client/Client.java
@@ -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();

}
}

12 changes: 0 additions & 12 deletions src/client/Constants.java

This file was deleted.

3 changes: 1 addition & 2 deletions src/client/DbDownload.java
@@ -1,6 +1,5 @@
package client;

import gui.GUI;
import helpclasses.CommEnum;
import helpclasses.CommMessage;
import helpclasses.Owner;
Expand All @@ -11,6 +10,6 @@ public class DbDownload {
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));
}
}
37 changes: 0 additions & 37 deletions src/gui/GUI.java

This file was deleted.

9 changes: 5 additions & 4 deletions src/gui/Hub.java
Expand Up @@ -6,6 +6,7 @@

import java.util.ArrayList;

import client.Client;
import client.DbDownload;
import client.ServerData;
import helpclasses.CommEnum;
Expand Down Expand Up @@ -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{
Expand All @@ -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

Expand All @@ -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

Expand Down
7 changes: 4 additions & 3 deletions src/gui/Login.java
Expand Up @@ -15,6 +15,7 @@

import javax.swing.JOptionPane;

import client.Client;
import client.DbDownload;
import client.ServerData;

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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.