diff --git a/Ratty/src/de/sogomn/rat/Ratty.java b/Ratty/src/de/sogomn/rat/Ratty.java index b2d8b57..223ddfc 100644 --- a/Ratty/src/de/sogomn/rat/Ratty.java +++ b/Ratty/src/de/sogomn/rat/Ratty.java @@ -1,11 +1,17 @@ package de.sogomn.rat; +import java.awt.Color; import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import javax.swing.JDialog; +import javax.swing.JFrame; import javax.swing.JOptionPane; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; import de.sogomn.engine.util.FileUtils; import de.sogomn.rat.server.ActiveServer; @@ -38,6 +44,23 @@ public final class Ratty { //... } + private static void setLookAndFeel() { + final NimbusLookAndFeel nimbus = new NimbusLookAndFeel(); + final UIDefaults defaults = nimbus.getDefaults(); + + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + + defaults.put("nimbusBase", Color.LIGHT_GRAY); + defaults.put("cotrol", Color.LIGHT_GRAY); + + try { + UIManager.setLookAndFeel(nimbus); + } catch (final Exception ex) { + ex.printStackTrace(); + } + } + private static void readConnectionData() throws ArrayIndexOutOfBoundsException, NumberFormatException { final String[] lines = FileUtils.readInternalLines(CONNECTION_DATA_FILE_NAME); final String addressString = lines[0].trim(); @@ -110,6 +133,7 @@ public final class Ratty { } public static void main(final String[] args) { + setLookAndFeel(); readConnectionData(); if (DEBUG) { @@ -131,11 +155,9 @@ public final class Ratty { } else { final int port = getPortInput(); - if (port == -1) { - return; + if (port != -1) { + startServer(port); } - - startServer(port); } } diff --git a/Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java b/Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java index 19c4def..6613648 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java +++ b/Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java @@ -34,8 +34,8 @@ public final class DisplayPanel extends AbstractListenerContainer { } public String getInput() { - final String input = JOptionPane.showInputDialog(frame); + final String input = JOptionPane.showInputDialog(frame, null); return input; } diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java index 08fb194..ee1eaa1 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java @@ -1,5 +1,6 @@ package de.sogomn.rat.server.gui; +import java.awt.image.BufferedImage; import java.util.ArrayList; import de.sogomn.rat.ActiveConnection; @@ -35,6 +36,12 @@ public final class RattyGuiController implements IServerObserver, IConnectionObs * ================================================== */ + private void showScreenshot(final ServerClient client, final ScreenshotPacket packet) { + final BufferedImage image = packet.getImage(); + + client.displayPanel.showImage(image); + } + private PopupPacket createPopupPacket() { final String input = gui.getInput(); @@ -72,14 +79,26 @@ public final class RattyGuiController implements IServerObserver, IConnectionObs } private boolean handlePacket(final ServerClient client, final IPacket packet) { - return false; + final Class clazz = packet.getClass(); + + boolean consumed = true; + + if (clazz == ScreenshotPacket.class) { + final ScreenshotPacket screenshot = (ScreenshotPacket)packet; + + showScreenshot(client, screenshot); + } else { + consumed = false; + } + + return consumed; } private void handleCommand(final ServerClient client, final String command) { //... } - private IPacket getPacket(final String command, final ServerClient client) { + private IPacket getPacket(final ServerClient client, final String command) { IPacket packet = null; if (command == RattyGui.FREE) { @@ -172,7 +191,7 @@ public final class RattyGuiController implements IServerObserver, IConnectionObs @Override public void userInput(final String command) { final ServerClient client = gui.getLastServerClientClicked(); - final IPacket packet = getPacket(command, client); + final IPacket packet = getPacket(client, command); handleCommand(client, command); diff --git a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java b/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java index 9b8f4c0..efb7b9e 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java +++ b/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java @@ -18,6 +18,11 @@ final class ServerClient { displayPanel = new DisplayPanel(); fileTree = new FileTree(); + + final String address = connection.getAddress(); + + displayPanel.setTitle(address); + fileTree.setTitle(address); } public void logIn(final String name, final String os, final String version) {