Implemented login error messages
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@500 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
ace7175f1a
commit
4df5c0e665
13 changed files with 330 additions and 121 deletions
|
@ -12,6 +12,7 @@ import jrummikub.util.IEvent2;
|
|||
import jrummikub.util.MockEvent;
|
||||
import jrummikub.util.MockEvent1;
|
||||
import jrummikub.util.MockEvent2;
|
||||
import jrummikub.view.LoginError;
|
||||
|
||||
/** */
|
||||
public class MockConnectionControl implements IConnectionControl {
|
||||
|
@ -20,7 +21,7 @@ public class MockConnectionControl implements IConnectionControl {
|
|||
/** */
|
||||
public MockEvent connectedEvent = new MockEvent();
|
||||
/** */
|
||||
public MockEvent connectionFailedEvent = new MockEvent();
|
||||
public MockEvent1<LoginError> connectionFailedEvent = new MockEvent1<LoginError>();
|
||||
/** */
|
||||
public MockEvent1<GameData> gameOfferEvent = new MockEvent1<GameData>();
|
||||
/** */
|
||||
|
@ -66,7 +67,7 @@ public class MockConnectionControl implements IConnectionControl {
|
|||
@Override
|
||||
public void connect() {
|
||||
if (failOnConnect) {
|
||||
connectionFailedEvent.emit();
|
||||
connectionFailedEvent.emit(LoginError.UNKNOWN_ERROR);
|
||||
} else {
|
||||
connected = true;
|
||||
connectedEvent.emit();
|
||||
|
@ -84,7 +85,7 @@ public class MockConnectionControl implements IConnectionControl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IEvent getConnectionFailedEvent() {
|
||||
public IEvent1<LoginError> getConnectionFailedEvent() {
|
||||
return connectionFailedEvent;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,6 +224,12 @@ public class MockView implements IView {
|
|||
return gameListPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConnectPanel getConnectPanel() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInitialMeldError(int points) {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -295,4 +301,10 @@ public class MockView implements IView {
|
|||
public void load() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showConnectPanel(boolean show) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ public class ApplicationControl {
|
|||
public void handle() {
|
||||
view.getQuitWarningPanel().setMode(QuitMode.QUIT_GAME);
|
||||
view.showQuitWarningPanel(true);
|
||||
tempConnection = view.getQuitWarningPanel().getQuitEvent().add(new IListener() {
|
||||
tempConnection = view.getQuitWarningPanel().getQuitEvent()
|
||||
.add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
abortControls();
|
||||
|
@ -97,16 +98,22 @@ public class ApplicationControl {
|
|||
}
|
||||
});
|
||||
|
||||
addLoginControlListeners();
|
||||
view.getNetworkGameEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
abortControls();
|
||||
|
||||
createLoginControl();
|
||||
}
|
||||
});
|
||||
|
||||
saveControl.getLoadEvent().add(
|
||||
new IListener3<GameSettings, GameState, IRoundState>() {
|
||||
@Override
|
||||
public void handle(GameSettings settings,
|
||||
GameState gameState, IRoundState roundState) {
|
||||
public void handle(GameSettings settings, GameState gameState,
|
||||
IRoundState roundState) {
|
||||
abortControls();
|
||||
gameControl = new GameControl(settings, saveControl,
|
||||
view);
|
||||
gameControl = new GameControl(settings, saveControl, view);
|
||||
addGameControlListeners(gameControl);
|
||||
gameControl.continueGame(gameState, roundState);
|
||||
}
|
||||
|
@ -119,12 +126,7 @@ public class ApplicationControl {
|
|||
});
|
||||
}
|
||||
|
||||
private void addLoginControlListeners() {
|
||||
view.getNetworkGameEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
abortControls();
|
||||
|
||||
private void createLoginControl() {
|
||||
loginControl = new LoginControl(view);
|
||||
loginControl.getLoginEvent().add(new IListener1<LoginData>() {
|
||||
@Override
|
||||
|
@ -140,8 +142,6 @@ public class ApplicationControl {
|
|||
});
|
||||
loginControl.startLogin();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void abortControls() {
|
||||
if (settingsControl != null) {
|
||||
|
@ -215,6 +215,14 @@ public class ApplicationControl {
|
|||
}
|
||||
});
|
||||
|
||||
networkControl.getBackToLoginEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
networkControl = null;
|
||||
createLoginControl();
|
||||
}
|
||||
});
|
||||
|
||||
networkControl.startNetwork();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,12 @@ public class LoginControl {
|
|||
@Override
|
||||
public void handle(LoginData loginData) {
|
||||
abort();
|
||||
// TODO connectPanel anzeigen
|
||||
loginEvent.emit(loginData);
|
||||
}
|
||||
}));
|
||||
|
||||
connections.add(view.getLoginPanel().getCancelEvent()
|
||||
.add(new IListener() {
|
||||
connections.add(view.getLoginPanel().getCancelEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
abort();
|
||||
|
|
|
@ -16,6 +16,7 @@ import jrummikub.util.IEvent;
|
|||
import jrummikub.util.IEvent1;
|
||||
import jrummikub.util.IEvent2;
|
||||
import jrummikub.util.LoginData;
|
||||
import jrummikub.view.LoginError;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
|
@ -46,7 +47,7 @@ public class ConnectionControl implements IConnectionControl {
|
|||
private volatile MultiUserChat muc;
|
||||
|
||||
private Event connectedEvent = new Event();
|
||||
private Event connectionFailedEvent = new Event();
|
||||
private Event1<LoginError> connectionFailedEvent = new Event1<LoginError>();
|
||||
|
||||
private Event1<GameData> gameOfferEvent = new Event1<GameData>();
|
||||
private Event1<UUID> gameWithdrawalEvent = new Event1<UUID>();
|
||||
|
@ -91,7 +92,7 @@ public class ConnectionControl implements IConnectionControl {
|
|||
@Override
|
||||
public void disconnect() {
|
||||
connectedEvent = new Event();
|
||||
connectionFailedEvent = new Event();
|
||||
connectionFailedEvent = new Event1<LoginError>();
|
||||
run(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -111,7 +112,7 @@ public class ConnectionControl implements IConnectionControl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IEvent getConnectionFailedEvent() {
|
||||
public IEvent1<LoginError> getConnectionFailedEvent() {
|
||||
return connectionFailedEvent;
|
||||
}
|
||||
|
||||
|
@ -252,8 +253,7 @@ public class ConnectionControl implements IConnectionControl {
|
|||
protected void addData(DefaultPacketExtension extension) {
|
||||
extension.setValue("messageType", "change_color");
|
||||
extension.setValue("uuid", uuid.toString());
|
||||
extension.setValue("color",
|
||||
Base64.encodeObject(color, Base64.GZIP));
|
||||
extension.setValue("color", Base64.encodeObject(color, Base64.GZIP));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -316,8 +316,8 @@ public class ConnectionControl implements IConnectionControl {
|
|||
protected void addData(DefaultPacketExtension extension) {
|
||||
extension.setValue("messageType", "game_offer");
|
||||
extension.setValue("uuid", data.getGameID().toString());
|
||||
extension.setValue("gameSettings", Base64.encodeObject(
|
||||
data.getGameSettings(), Base64.GZIP));
|
||||
extension.setValue("gameSettings",
|
||||
Base64.encodeObject(data.getGameSettings(), Base64.GZIP));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -340,6 +340,15 @@ public class ConnectionControl implements IConnectionControl {
|
|||
});
|
||||
}
|
||||
|
||||
private static <T> void emitLater(final Event1<T> event, final T arg) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
event.emit(arg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Message createMessage(PacketExtension extension) {
|
||||
Message message = muc.createMessage();
|
||||
message.addExtension(extension);
|
||||
|
@ -355,8 +364,8 @@ public class ConnectionControl implements IConnectionControl {
|
|||
.getExtension(ELEMENT_NAME, NAMESPACE);
|
||||
|
||||
if (((Message) packet).getType() == Message.Type.error) {
|
||||
System.err.println("Received error message from '"
|
||||
+ packet.getFrom() + "'");
|
||||
System.err.println("Received error message from '" + packet.getFrom()
|
||||
+ "'");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -372,14 +381,13 @@ public class ConnectionControl implements IConnectionControl {
|
|||
String sender, String messageType) {
|
||||
if (messageType.equals("game_offer")) {
|
||||
UUID uuid = UUID.fromString(extension.getValue("uuid"));
|
||||
GameSettings settings = (GameSettings) Base64
|
||||
.decodeToObject(extension.getValue("gameSettings"));
|
||||
GameSettings settings = (GameSettings) Base64.decodeToObject(extension
|
||||
.getValue("gameSettings"));
|
||||
|
||||
GameData gameData = new GameData(uuid, settings, sender);
|
||||
gameOfferEvent.emit(gameData);
|
||||
} else if (messageType.equals("game_withdrawal")) {
|
||||
gameWithdrawalEvent
|
||||
.emit(UUID.fromString(extension.getValue("uuid")));
|
||||
gameWithdrawalEvent.emit(UUID.fromString(extension.getValue("uuid")));
|
||||
} else if (messageType.equals("game_request")) {
|
||||
if (offeredGame != null) {
|
||||
sendGameOffer();
|
||||
|
@ -447,10 +455,26 @@ public class ConnectionControl implements IConnectionControl {
|
|||
connection.disconnect();
|
||||
connection = null;
|
||||
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
XMPPError xmppError = e.getXMPPError();
|
||||
|
||||
emitLater(connectionFailedEvent);
|
||||
if (xmppError != null) {
|
||||
int code = xmppError.getCode();
|
||||
if (code == 504) {
|
||||
emitLater(connectionFailedEvent, LoginError.UNKNOWN_HOST);
|
||||
return;
|
||||
} else if (code == 404) {
|
||||
emitLater(connectionFailedEvent, LoginError.UNKNOWN_CHANNEL);
|
||||
return;
|
||||
} else if (code == 503) {
|
||||
emitLater(connectionFailedEvent, LoginError.RESOURCE_CONFLICT);
|
||||
return;
|
||||
} else if (code == 401 || code == 402 || code == 407) {
|
||||
emitLater(connectionFailedEvent, LoginError.AUTHENTICATION_FAILED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
emitLater(connectionFailedEvent, LoginError.UNKNOWN_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -471,8 +495,7 @@ public class ConnectionControl implements IConnectionControl {
|
|||
break; // Join was successful, break the loop
|
||||
} catch (XMPPException e) {
|
||||
XMPPError error = e.getXMPPError();
|
||||
if (error.getType() == Type.CANCEL
|
||||
&& error.getCode() == 409) {
|
||||
if (error.getType() == Type.CANCEL && error.getCode() == 409) {
|
||||
// There was a conflict, try again with another
|
||||
// nickname
|
||||
nickname += "_";
|
||||
|
|
|
@ -9,6 +9,7 @@ import jrummikub.util.GameData;
|
|||
import jrummikub.util.IEvent;
|
||||
import jrummikub.util.IEvent1;
|
||||
import jrummikub.util.IEvent2;
|
||||
import jrummikub.view.LoginError;
|
||||
|
||||
interface IConnectionControl {
|
||||
|
||||
|
@ -20,7 +21,7 @@ interface IConnectionControl {
|
|||
|
||||
public IEvent getConnectedEvent();
|
||||
|
||||
public IEvent getConnectionFailedEvent();
|
||||
public IEvent1<LoginError> getConnectionFailedEvent();
|
||||
|
||||
public IEvent1<GameData> getGameOfferEvent();
|
||||
|
||||
|
@ -65,5 +66,4 @@ interface IConnectionControl {
|
|||
public void endTurn(ITable table);
|
||||
|
||||
public void startTurn(IRoundState state);
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ import jrummikub.util.IListener;
|
|||
import jrummikub.util.IListener1;
|
||||
import jrummikub.util.LoginData;
|
||||
import jrummikub.view.IView;
|
||||
import jrummikub.view.LoginError;
|
||||
|
||||
/**
|
||||
* Class dealing with network connection, offering and choice of network games
|
||||
|
@ -24,6 +25,7 @@ public class NetworkControl {
|
|||
private IView view;
|
||||
private List<Connection> connections = new ArrayList<Connection>();
|
||||
private Event stopNetworkEvent = new Event();
|
||||
private Event backToLoginEvent = new Event();
|
||||
|
||||
private NetworkSettingsControl settingsControl;
|
||||
private GameOfferControl gameOfferControl;
|
||||
|
@ -133,22 +135,29 @@ public class NetworkControl {
|
|||
|
||||
private void addConnectionSetupListeners(final LoginData loginData,
|
||||
final IView view) {
|
||||
connections.add(connectionControl.getConnectedEvent().add(
|
||||
new IListener() {
|
||||
connections.add(connectionControl.getConnectedEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
view.getGameListPanel().setChannelName(
|
||||
loginData.getChannelName());
|
||||
view.getGameListPanel().setChannelName(loginData.getChannelName());
|
||||
view.showGameListPanel(true);
|
||||
}
|
||||
}));
|
||||
|
||||
connections.add(connectionControl.getConnectionFailedEvent().add(
|
||||
new IListener() {
|
||||
new IListener1<LoginError>() {
|
||||
@Override
|
||||
public void handle(LoginError error) {
|
||||
view.getConnectPanel().setMode(error);
|
||||
view.showConnectPanel(true);
|
||||
}
|
||||
}));
|
||||
|
||||
connections.add(view.getConnectPanel().getCancelEvent()
|
||||
.add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
abort();
|
||||
backToLoginEvent.emit();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -181,9 +190,11 @@ public class NetworkControl {
|
|||
}
|
||||
|
||||
/**
|
||||
* Starts a new network connection with the sepcified data
|
||||
* Starts a new network connection with the specified data
|
||||
*/
|
||||
public void startNetwork() {
|
||||
view.showConnectPanel(true);
|
||||
view.getConnectPanel().setMode(null);
|
||||
connectionControl.connect();
|
||||
}
|
||||
|
||||
|
@ -195,6 +206,7 @@ public class NetworkControl {
|
|||
c.remove();
|
||||
}
|
||||
view.showGameListPanel(false);
|
||||
view.showConnectPanel(false);
|
||||
|
||||
if (settingsControl != null) {
|
||||
settingsControl.abort();
|
||||
|
@ -218,6 +230,10 @@ public class NetworkControl {
|
|||
return stopNetworkEvent;
|
||||
}
|
||||
|
||||
public IEvent getBackToLoginEvent() {
|
||||
return backToLoginEvent;
|
||||
}
|
||||
|
||||
private void createSettingsControl() {
|
||||
if (settingsControl != null) {
|
||||
return;
|
||||
|
@ -247,8 +263,7 @@ public class NetworkControl {
|
|||
if (gameOfferControl != null) {
|
||||
return;
|
||||
}
|
||||
gameOfferControl = new GameOfferControl(connectionControl, settings,
|
||||
view);
|
||||
gameOfferControl = new GameOfferControl(connectionControl, settings, view);
|
||||
gameOfferControl.getBackEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
|
|
11
src/jrummikub/view/IConnectPanel.java
Normal file
11
src/jrummikub/view/IConnectPanel.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package jrummikub.view;
|
||||
|
||||
import jrummikub.util.IEvent;
|
||||
|
||||
public interface IConnectPanel {
|
||||
|
||||
public void setMode(LoginError error);
|
||||
|
||||
public IEvent getCancelEvent();
|
||||
|
||||
}
|
|
@ -126,8 +126,8 @@ public interface IView {
|
|||
public void setCurrentPlayerColor(Color color);
|
||||
|
||||
/**
|
||||
* Is used for the PlayerPanel to display if a player has laid out along
|
||||
* with the name
|
||||
* Is used for the PlayerPanel to display if a player has laid out along with
|
||||
* the name
|
||||
*
|
||||
* @param hasLaidOut
|
||||
* specifies if the current player has laid out or not
|
||||
|
@ -150,8 +150,8 @@ public interface IView {
|
|||
public void setBottomPanel(BottomPanelType type);
|
||||
|
||||
/**
|
||||
* The menu new game event is emitted when the user selects the new game
|
||||
* menu entry
|
||||
* The menu new game event is emitted when the user selects the new game menu
|
||||
* entry
|
||||
*
|
||||
* @return the event
|
||||
*/
|
||||
|
@ -322,4 +322,8 @@ public interface IView {
|
|||
public IEvent1<File> getLoadFileEvent();
|
||||
|
||||
public void load();
|
||||
|
||||
public void showConnectPanel(boolean show);
|
||||
|
||||
public IConnectPanel getConnectPanel();
|
||||
}
|
||||
|
|
18
src/jrummikub/view/LoginError.java
Normal file
18
src/jrummikub/view/LoginError.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package jrummikub.view;
|
||||
|
||||
public enum LoginError {
|
||||
/** */
|
||||
UNKNOWN_ERROR,
|
||||
/** */
|
||||
TIMEOUT,
|
||||
/** */
|
||||
CONNECTION_REFUSED,
|
||||
/** */
|
||||
AUTHENTICATION_FAILED,
|
||||
/** */
|
||||
RESOURCE_CONFLICT,
|
||||
/** */
|
||||
UNKNOWN_HOST,
|
||||
/** */
|
||||
UNKNOWN_CHANNEL
|
||||
}
|
109
src/jrummikub/view/impl/ConnectPanel.java
Normal file
109
src/jrummikub/view/impl/ConnectPanel.java
Normal file
|
@ -0,0 +1,109 @@
|
|||
package jrummikub.view.impl;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import jrummikub.util.Event;
|
||||
import jrummikub.util.IEvent;
|
||||
import jrummikub.view.IConnectPanel;
|
||||
import jrummikub.view.LoginError;
|
||||
|
||||
public class ConnectPanel extends JPanel implements IConnectPanel {
|
||||
private JLabel messageLabel;
|
||||
private JProgressBar foobar;
|
||||
private JButton cancelButton;
|
||||
|
||||
private Event cancelEvent = new Event();
|
||||
|
||||
public ConnectPanel() {
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
c.weightx = 1;
|
||||
c.weighty = 1;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
c.anchor = GridBagConstraints.CENTER;
|
||||
|
||||
messageLabel = new JLabel();
|
||||
messageLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
add(messageLabel, c);
|
||||
|
||||
c.gridy = 1;
|
||||
c.insets = new Insets(5, 5, 5, 5);
|
||||
|
||||
foobar = new JProgressBar();
|
||||
foobar.setIndeterminate(true);
|
||||
add(foobar, c);
|
||||
|
||||
c.gridy = 2;
|
||||
|
||||
cancelButton = new JButton();
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
cancelEvent.emit();
|
||||
}
|
||||
});
|
||||
add(cancelButton, c);
|
||||
|
||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
||||
10, 10, 10, 10)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMode(LoginError error) {
|
||||
if (error == null) {
|
||||
foobar.setVisible(true);
|
||||
messageLabel.setText("Verbindung wird hergestellt");
|
||||
cancelButton.setText("Abbrechen");
|
||||
} else {
|
||||
foobar.setVisible(false);
|
||||
String text = "";
|
||||
switch (error) {
|
||||
case UNKNOWN_ERROR:
|
||||
text = "Ein unbekannter Fehler ist aufgetreten";
|
||||
break;
|
||||
case AUTHENTICATION_FAILED:
|
||||
text = "Die Authentifizierung ist fehlgeschlagen";
|
||||
break;
|
||||
case CONNECTION_REFUSED:
|
||||
text = "Die Verbindung wurde abgelehnt";
|
||||
break;
|
||||
case RESOURCE_CONFLICT:
|
||||
text = "Es gibt bereits einen solchen Spieler";
|
||||
break;
|
||||
case TIMEOUT:
|
||||
text = "Der Server reagiert nicht";
|
||||
break;
|
||||
case UNKNOWN_CHANNEL:
|
||||
text = "Der Channel konnte nicht gefunden werden";
|
||||
break;
|
||||
case UNKNOWN_HOST:
|
||||
text = "Der Server konnte nicht gefunden werden";
|
||||
break;
|
||||
}
|
||||
messageLabel.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent getCancelEvent() {
|
||||
return cancelEvent;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,6 @@ import jrummikub.util.IEvent;
|
|||
import jrummikub.view.IQuitWarningPanel;
|
||||
|
||||
public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
||||
private JPanel buttonPanel;
|
||||
private JButton cancelButton;
|
||||
private JButton quitButton;
|
||||
private QuitMode quitMode;
|
||||
|
@ -51,8 +50,8 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
|||
c.gridx = 1;
|
||||
add(quitButton, c);
|
||||
|
||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
|
||||
new EmptyBorder(10, 10, 10, 10)));
|
||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
||||
10, 10, 10, 10)));
|
||||
}
|
||||
|
||||
private JButton createButton(String title, final Event event) {
|
||||
|
@ -71,8 +70,7 @@ public class QuitWarningPanel extends JPanel implements IQuitWarningPanel {
|
|||
this.quitMode = mode;
|
||||
switch (quitMode) {
|
||||
case QUIT_PROCESS:
|
||||
messageLabel
|
||||
.setText("Beim Beenden geht das aktuelle Spiel verloren");
|
||||
messageLabel.setText("Beim Beenden geht das aktuelle Spiel verloren");
|
||||
break;
|
||||
case QUIT_GAME:
|
||||
messageLabel.setText("Der aktuelle Spielstand geht verloren");
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
|
@ -36,6 +37,7 @@ import jrummikub.util.IEvent;
|
|||
import jrummikub.util.IEvent1;
|
||||
import jrummikub.util.IListener;
|
||||
import jrummikub.util.Pair;
|
||||
import jrummikub.view.IConnectPanel;
|
||||
import jrummikub.view.IGameListPanel;
|
||||
import jrummikub.view.IHandPanel;
|
||||
import jrummikub.view.ILoginPanel;
|
||||
|
@ -73,7 +75,7 @@ public class View extends JFrame implements IView {
|
|||
private GameListPanel gameListPanel;
|
||||
private SidePanel sidePanel;
|
||||
private QuitWarningPanel quitWarningPanel;
|
||||
|
||||
private ConnectPanel connectPanel;
|
||||
private BottomPanelType bottomPanelType;
|
||||
|
||||
private JFileChooser chooser;
|
||||
|
@ -131,6 +133,11 @@ public class View extends JFrame implements IView {
|
|||
return quitWarningPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConnectPanel getConnectPanel() {
|
||||
return connectPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGameListPanel getGameListPanel() {
|
||||
return gameListPanel;
|
||||
|
@ -312,19 +319,21 @@ public class View extends JFrame implements IView {
|
|||
|
||||
loginPanel = new LoginPanel();
|
||||
loginPanel.setVisible(false);
|
||||
|
||||
layeredPane.setLayer(loginPanel, JLayeredPane.POPUP_LAYER);
|
||||
layeredPane.add(loginPanel);
|
||||
|
||||
gameListPanel = new GameListPanel();
|
||||
gameListPanel.setVisible(false);
|
||||
|
||||
layeredPane.setLayer(gameListPanel, JLayeredPane.POPUP_LAYER);
|
||||
layeredPane.add(gameListPanel);
|
||||
|
||||
connectPanel = new ConnectPanel();
|
||||
connectPanel.setVisible(false);
|
||||
layeredPane.setLayer(connectPanel, JLayeredPane.POPUP_LAYER);
|
||||
layeredPane.add(connectPanel);
|
||||
|
||||
quitWarningPanel = new QuitWarningPanel();
|
||||
quitWarningPanel.setVisible(false);
|
||||
|
||||
layeredPane.setLayer(quitWarningPanel, JLayeredPane.POPUP_LAYER);
|
||||
layeredPane.add(quitWarningPanel);
|
||||
|
||||
|
@ -386,10 +395,6 @@ public class View extends JFrame implements IView {
|
|||
winPanel.setVisible(false);
|
||||
mainLayer.add(winPanel);
|
||||
|
||||
quitWarningPanel = new QuitWarningPanel();
|
||||
quitWarningPanel.setVisible(false);
|
||||
mainLayer.add(quitWarningPanel);
|
||||
|
||||
sidePanel = new SidePanel();
|
||||
sidePanel.setVisible(false);
|
||||
mainLayer.add(sidePanel);
|
||||
|
@ -440,6 +445,7 @@ public class View extends JFrame implements IView {
|
|||
rescaleSubpanel(loginPanel, 1 / 3.0, 1 / 3.0, 200, 200);
|
||||
rescaleSubpanel(gameListPanel, 1 / 2.0, 1 / 2.0, 475, 300);
|
||||
rescaleSubpanel(quitWarningPanel, 1 / 2.0, 1 / 6.0, 400, 150);
|
||||
rescaleSubpanel(connectPanel, 1 / 2.0, 1 / 6.0, 400, 150);
|
||||
}
|
||||
|
||||
private void rescaleSubpanel(JPanel sub, double widthFactor,
|
||||
|
@ -504,6 +510,11 @@ public class View extends JFrame implements IView {
|
|||
quitWarningPanel.setVisible(show);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showConnectPanel(boolean show) {
|
||||
connectPanel.setVisible(show);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentPlayerName(String playerName) {
|
||||
playerPanel.setCurrentPlayerName(playerName);
|
||||
|
@ -600,7 +611,6 @@ public class View extends JFrame implements IView {
|
|||
@Override
|
||||
public void setBottomPanel(BottomPanelType type) {
|
||||
bottomPanelType = type;
|
||||
|
||||
doSetBottomPanel(type);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue