80 lines
1.9 KiB
Java
80 lines
1.9 KiB
Java
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
|
*/
|
|
|
|
package ChatProgramm.controller.commands;
|
|
|
|
import ChatProgramm.model.Client;
|
|
import ChatProgramm.model.Server;
|
|
import ChatProgramm.util.OhmLogger;
|
|
import ChatProgramm.view.ChatView;
|
|
import java.io.IOException;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import javax.swing.JDialog;
|
|
import javax.swing.JRadioButton;
|
|
|
|
/**
|
|
*
|
|
* @author ahren
|
|
*/
|
|
public class CommandConnect implements CommandInterface
|
|
{
|
|
private JRadioButton rBtnServer;
|
|
private JRadioButton rBtnClient;
|
|
private JDialog dialogFenster;
|
|
private static Logger lg = OhmLogger.getLogger();
|
|
|
|
private CommandSend commandSend;
|
|
|
|
private ChatView view;
|
|
|
|
public CommandConnect(ChatView view, CommandInterface value)
|
|
{
|
|
rBtnServer = view.getBtnServer();
|
|
rBtnClient = view.getBtnClient();
|
|
dialogFenster = view.getjDialog1();
|
|
|
|
commandSend = (CommandSend) value;
|
|
|
|
this.view = view;
|
|
}
|
|
|
|
@Override
|
|
public void execute()
|
|
{
|
|
if(rBtnServer.isSelected()){
|
|
lg.info("Server ausgewählt");
|
|
try {
|
|
commandSend.transmitterInterface = new Server(view);
|
|
} catch (IOException ex) {
|
|
lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
|
|
}
|
|
}
|
|
|
|
if(rBtnClient.isSelected()){
|
|
lg.info("Client ausgewählt");
|
|
try {
|
|
commandSend.transmitterInterface = new Client(view);
|
|
} catch (IOException ex) {
|
|
lg.info("Die Verbindung zum Client ist Fehlgeschlagen");
|
|
|
|
}
|
|
}
|
|
|
|
dialogFenster.setVisible(false);
|
|
}
|
|
|
|
@Override
|
|
public boolean isUndoable()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public void undo()
|
|
{
|
|
}
|
|
}
|