Browse Source

Major changes

More GUI!
master
Sogomn 9 years ago
parent
commit
64d6299018
  1. 0
      Ratty/res/gui_menu_icons.png
  2. BIN
      Ratty/res/gui_notification_icons.png
  3. 0
      Ratty/res/gui_tree_icons.png
  4. 6
      Ratty/res/language/lang.properties
  5. 6
      Ratty/res/language/lang_de.properties
  6. 6
      Ratty/res/language/lang_en.properties
  7. 62
      Ratty/src/de/sogomn/rat/GUISettings.java
  8. 2
      Ratty/src/de/sogomn/rat/Ratty.java
  9. 2
      Ratty/src/de/sogomn/rat/server/gui/FileTree.java
  10. 19
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  11. 22
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

0
Ratty/res/menu_icons.png → Ratty/res/gui_menu_icons.png

Before

Width: 64  |  Height: 48  |  Size: 740 B

After

Width: 64  |  Height: 48  |  Size: 740 B

BIN
Ratty/res/gui_notification_icons.png

After

Width: 32  |  Height: 32  |  Size: 402 B

0
Ratty/res/menu_icons_tree.png → Ratty/res/gui_tree_icons.png

Before

Width: 48  |  Height: 32  |  Size: 522 B

After

Width: 48  |  Height: 32  |  Size: 522 B

6
Ratty/res/language/lang.properties

@ -4,6 +4,10 @@ debug.client=Client
server.port_question=Which port should the server be bind to?
server.port_error=Invalid port.
server.free_warning=The client won't be available until the device restarts.\r\n\
Continue?
server.free_yes=Yes
server.free_no=Cancel
builder.address_question=Which address should the client connect to?
builder.port_question=Which port?
@ -42,7 +46,7 @@ POPUP <CLIENT> <STRING>: Shows a popup on the client's device\r\n\
WEBSITE <CLIENT> <STRING>: Opens a website on the client's device\r\n\
\r\n\
<CLIENT>: Either a number (the index) or an IP address\r\n\
<STRING>: A string
<STRING>: A string surrounded by quotation marks
cmd.start=Ratty command line tool\r\n\
Type 'HELP' to get a list of commands
cmd.invalid=Invalid command or parameters

6
Ratty/res/language/lang_de.properties

@ -4,6 +4,10 @@ debug.client=Client
server.port_question=An welchen Port soll der Server gebunden werden?
server.port_error=Ungültiger Port.
server.free_warning=Der Client wird bis zum Neustart des Gerätes nicht erreichbar sein.\r\n\
Fortfahren?
server.free_yes=Ja
server.free_no=Abbrechen
builder.address_question=Mit welcher Adresse soll sich der Client verbinden?
builder.port_question=Welcher Port?
@ -42,7 +46,7 @@ POPUP <CLIENT> <STRING>:
WEBSITE <CLIENT> <STRING>: Öffnet eine Webseite beim Client\r\n\
\r\n\
<CLIENT>: Entweder eine Nummer (der Index) oder eine IP-Adresse\r\n\
<STRING>: Eine Zeichenkette
<STRING>: Eine Zeichenkette in Anführungszeichen
cmd.start=Ratty Kommandozeilen-Tool\r\n\
Gib 'HELP' für eine Listen von Befehlen ein
cmd.invalid=Ungültiger Befehl oder Parameter

6
Ratty/res/language/lang_en.properties

@ -4,6 +4,10 @@ debug.client=Client
server.port_question=Which port should the server be bind to?
server.port_error=Invalid port.
server.free_warning=The client won't be available until the device restarts.\r\n\
Continue?
server.free_yes=Yes
server.free_no=Cancel
builder.address_question=Which address should the client connect to?
builder.port_question=Which port?
@ -42,7 +46,7 @@ POPUP <CLIENT> <STRING>: Shows a popup on the client's device\r\n\
WEBSITE <CLIENT> <STRING>: Opens a website on the client's device\r\n\
\r\n\
<CLIENT>: Either a number (the index) or an IP address\r\n\
<STRING>: A string
<STRING>: A string surrounded by quotation marks
cmd.start=Ratty command line tool\r\n\
Type 'HELP' to get a list of commands
cmd.invalid=Invalid command or parameters

62
Ratty/src/de/sogomn/rat/GUISettings.java

@ -1,21 +1,39 @@
package de.sogomn.rat;
import java.awt.Color;
import java.awt.Font;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.Painter;
import javax.swing.UIDefaults;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.ColorUIResource;
import de.sogomn.engine.fx.SpriteSheet;
import de.sogomn.engine.util.ImageUtils;
/*
* WHEEE! Hardcoding!
*/
final class GUISettings {
private static final Color BACKGROUND = new Color(255, 245, 245);
private static final Color BACKGROUND = new Color(250, 250, 255);
private static final Color BASE = new Color(245, 205, 175);
private static final Color BRIGHTER = new Color(255, 220, 190);
private static final Color DARKER = new Color(225, 185, 155);
private static final Color ALTERNATIVE = new Color(245, 235, 215);
private static final Color SELECTION = new Color(225, 215, 195);
private static final EmptyBorder TABLE_CELL_BORDER = new EmptyBorder(2, 5, 2, 5);
private static final Color BASE = new Color(240, 160, 100);
private static final Color BRIGHTER = new Color(250, 170, 110);
private static final Color DARKER = new Color(230, 150, 90);
private static final Font FONT = new Font("Trebuchet MS", Font.PLAIN, 12);
private static final Color ALTERNATIVE = new Color(255, 240, 220);
private static final Color ALTERNATIVE_DARKER = new Color(245, 230, 210);
private static final Color SELECTION = new Color(205, 170, 160);
private static final BufferedImage[] ICONS = new SpriteSheet("/gui_notification_icons.png", 16, 16).getSprites();
private static final ImageIcon ERROR_ICON = new ImageIcon(ImageUtils.scaleImage(ICONS[0], 2));
private static final ImageIcon INFORMATION_ICON = new ImageIcon(ImageUtils.scaleImage(ICONS[1], 2));
private static final ImageIcon QUESTION_ICON = new ImageIcon(ImageUtils.scaleImage(ICONS[2], 2));
private static final ImageIcon WARNING_ICON = new ImageIcon(ImageUtils.scaleImage(ICONS[3], 2));
private static final Painter<?> BASE_PAINTER = (g, object, width, height) -> {
g.setColor(BASE);
@ -66,9 +84,12 @@ final class GUISettings {
defaults.put("ToggleButton[Pressed+Selected].backgroundPainter", DARKER_PAINTER);
defaults.put("ToggleButton[Focused+Pressed+Selected].backgroundPainter", DARKER_PAINTER);
defaults.put("Table.background", new ColorUIResource(ALTERNATIVE));
defaults.put("Table:\"Table.cellRenderer\".background", ALTERNATIVE);
defaults.put("Table.alternateRowColor", ALTERNATIVE_DARKER);
defaults.put("Table.alternateRowColor", ALTERNATIVE);
defaults.put("Table[Enabled+Selected].textBackground", SELECTION);
defaults.put("Table[Enabled+Selected].textForeground", Color.BLACK);
defaults.put("Table.focusCellHighlightBorder", TABLE_CELL_BORDER);
defaults.put("TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter", BASE_PAINTER);
defaults.put("TableHeader:\"TableHeader.renderer\"[MouseOver].backgroundPainter", BASE_PAINTER);
defaults.put("TableHeader:\"TableHeader.renderer\"[Enabled+Sorted].backgroundPainter", BASE_PAINTER);
@ -78,10 +99,31 @@ final class GUISettings {
defaults.put("ScrollBar:ScrollBarTrack[Enabled].backgroundPainter", DARKER_PAINTER);
defaults.put("ScrollBar:ScrollBarThumb[Enabled].backgroundPainter", BASE_PAINTER);
defaults.put("ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter", BRIGHTER_PAINTER);
defaults.put("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", BRIGHTER_PAINTER);
defaults.put("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", BASE_PAINTER);
defaults.put("ScrollBar:\"ScrollBar.button\"[Enabled].foregroundPainter", BASE_PAINTER);
defaults.put("ScrollBar:\"ScrollBar.button\"[MouseOver].foregroundPainter", BRIGHTER_PAINTER);
defaults.put("ScrollBar:\"ScrollBar.button\"[Pressed].foregroundPainter", BRIGHTER_PAINTER);
defaults.put("ScrollBar:\"ScrollBar.button\"[Pressed].foregroundPainter", BASE_PAINTER);
defaults.put("Button.font", FONT);
defaults.put("Table.font", FONT);
defaults.put("Label.font", FONT);
defaults.put("TableHeader.font", FONT);
defaults.put("FileChooser.font", FONT);
defaults.put("TextField.font", FONT);
defaults.put("FormattedTextField.font", FONT);
defaults.put("PopupMenu.font", FONT);
defaults.put("Menu.font", FONT);
defaults.put("MenuItem.font", FONT);
defaults.put("Panel.font", FONT);
defaults.put("Tree.font", FONT);
defaults.put("ToggleButton.font", FONT);
defaults.put("List.font", FONT);
defaults.put("OptionPane.font", FONT);
defaults.put("OptionPane.errorIcon", ERROR_ICON);
defaults.put("OptionPane.informationIcon", INFORMATION_ICON);
defaults.put("OptionPane.questionIcon", QUESTION_ICON);
defaults.put("OptionPane.warningIcon", WARNING_ICON);
}
}

2
Ratty/src/de/sogomn/rat/Ratty.java

@ -183,7 +183,7 @@ public final class Ratty {
if (port != -1) {
startServer(port, true);
} else {
JOptionPane.showMessageDialog(null, PORT_ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, PORT_ERROR_MESSAGE, null, JOptionPane.ERROR_MESSAGE);
}
}
}

2
Ratty/src/de/sogomn/rat/server/gui/FileTree.java

@ -38,7 +38,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
private static final String ROOT_NAME = "";
private static final Dimension DEFAULT_SIZE = new Dimension(500, 500);
private static final BufferedImage[] MENU_ICONS = new SpriteSheet(ImageUtils.scaleImage(ImageUtils.loadImage("/menu_icons_tree.png"), 2), 16 * 2, 16 * 2).getSprites();
private static final BufferedImage[] MENU_ICONS = new SpriteSheet(ImageUtils.scaleImage(ImageUtils.loadImage("/gui_tree_icons.png"), 2), 16 * 2, 16 * 2).getSprites();
public static final String REQUEST = LANGUAGE.getString("action.request_files");
public static final String DOWNLOAD = LANGUAGE.getString("action.download");

19
Ratty/src/de/sogomn/rat/server/gui/RattyGui.java

@ -25,6 +25,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
@ -51,11 +52,11 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
private static final Dimension SIZE = new Dimension(800, 600);
private static final BufferedImage GUI_ICON_SMALL = ImageUtils.loadImage("/gui_icon.png");
private static final BufferedImage GUI_ICON_MEDIUM = ImageUtils.scaleImage(ImageUtils.loadImage("/gui_icon.png"), 64, 64);
private static final BufferedImage GUI_ICON_LARGE = ImageUtils.scaleImage(ImageUtils.loadImage("/gui_icon.png"), 128, 128);
private static final BufferedImage GUI_ICON_HUGE = ImageUtils.scaleImage(ImageUtils.loadImage("/gui_icon.png"), 128, 128);
private static final BufferedImage GUI_ICON_MEDIUM = ImageUtils.scaleImage(GUI_ICON_SMALL, 64, 64);
private static final BufferedImage GUI_ICON_LARGE = ImageUtils.scaleImage(GUI_ICON_SMALL, 128, 128);
private static final BufferedImage GUI_ICON_HUGE = ImageUtils.scaleImage(GUI_ICON_SMALL, 256, 256);
private static final List<BufferedImage> GUI_ICONS = Arrays.asList(GUI_ICON_SMALL, GUI_ICON_MEDIUM, GUI_ICON_LARGE, GUI_ICON_HUGE);
private static final BufferedImage[] MENU_ICONS = new SpriteSheet(ImageUtils.scaleImage(ImageUtils.loadImage("/menu_icons.png"), 2), 16 * 2, 16 * 2).getSprites();
private static final BufferedImage[] MENU_ICONS = new SpriteSheet(ImageUtils.scaleImage(ImageUtils.loadImage("/gui_menu_icons.png"), 2), 16 * 2, 16 * 2).getSprites();
public static final String POPUP = LANGUAGE.getString("action.popup");
public static final String SCREENSHOT = LANGUAGE.getString("action.screenshot");
@ -122,6 +123,8 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
table.setComponentPopupMenu(menu);
table.addMouseListener(mouseAdapter);
table.setModel(tableModel);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setShowHorizontalLines(true);
container.add(scrollPane, BorderLayout.CENTER);
container.add(menuBar, BorderLayout.SOUTH);
@ -164,8 +167,14 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
tableModel.removeServerClient(client);
}
public int showWarning(final String message, final String... options) {
final int input = JOptionPane.showOptionDialog(frame, message, null, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null);
return input;
}
public void showMessage(final String message) {
final JOptionPane pane = new JOptionPane(message);
final JOptionPane pane = new JOptionPane(message, JOptionPane.INFORMATION_MESSAGE);
final JDialog dialog = pane.createDialog(frame, null);
dialog.setModal(false);

22
Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

@ -1,10 +1,14 @@
package de.sogomn.rat.server.gui;
import static de.sogomn.rat.Ratty.LANGUAGE;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.HashMap;
import java.util.Set;
import javax.swing.JOptionPane;
import de.sogomn.engine.fx.Sound;
import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.builder.StubBuilder;
@ -38,6 +42,10 @@ public final class RattyGuiController extends AbstractRattyController implements
private HashMap<ActiveConnection, ServerClient> clients;
private static final String FREE_WARNING = LANGUAGE.getString("server.free_warning");
private static final String FREE_OPTION_YES = LANGUAGE.getString("server.free_yes");
private static final String FREE_OPTION_NO = LANGUAGE.getString("server.free_no");
public RattyGuiController() {
gui = new RattyGui();
clients = new HashMap<ActiveConnection, ServerClient>();
@ -154,6 +162,18 @@ public final class RattyGuiController extends AbstractRattyController implements
return null;
}
private FreePacket createFreePacket() {
final int input = gui.showWarning(FREE_WARNING, FREE_OPTION_YES, FREE_OPTION_NO);
if (input == JOptionPane.YES_OPTION) {
final FreePacket packet = new FreePacket();
return packet;
}
return null;
}
private void toggleDesktopStream(final ServerClient client) {
final boolean streamingDesktop = client.isStreamingDesktop();
@ -203,7 +223,7 @@ public final class RattyGuiController extends AbstractRattyController implements
IPacket packet = null;
if (command == RattyGui.FREE) {
packet = new FreePacket();
packet = createFreePacket();
} else if (command == RattyGui.POPUP) {
packet = createPopupPacket();
} else if (command == RattyGui.CLIPBOARD) {

Loading…
Cancel
Save