diff --git a/bin/application/Controller$1.class b/bin/application/Controller$1.class deleted file mode 100644 index 9443f57368164992a75c52bf12b88f549fcef31f..0000000000000000000000000000000000000000 Binary files a/bin/application/Controller$1.class and /dev/null differ diff --git a/bin/application/Controller.class b/bin/application/Controller.class deleted file mode 100644 index abdd41f6c449844cf366c2927e5ce7fed4ffb582..0000000000000000000000000000000000000000 Binary files a/bin/application/Controller.class and /dev/null differ diff --git a/bin/application/Main.class b/bin/application/Main.class deleted file mode 100644 index b5b3eedf81bec76ca1d9917dcdd2460e72266410..0000000000000000000000000000000000000000 Binary files a/bin/application/Main.class and /dev/null differ diff --git a/bin/commandLine/CommandLine.class b/bin/commandLine/CommandLine.class new file mode 100644 index 0000000000000000000000000000000000000000..9c81c321ce78cc0accd66fcc29f07531d8bf0ca9 Binary files /dev/null and b/bin/commandLine/CommandLine.class differ diff --git a/bin/commandLine/CommandLineController$1.class b/bin/commandLine/CommandLineController$1.class new file mode 100644 index 0000000000000000000000000000000000000000..880eccbdc686b23d4d6337cda0c8fa6005ac990d Binary files /dev/null and b/bin/commandLine/CommandLineController$1.class differ diff --git a/bin/commandLine/CommandLineController.class b/bin/commandLine/CommandLineController.class new file mode 100644 index 0000000000000000000000000000000000000000..599d4ef1c027c4c82ded9c8f7daf005973c1b040 Binary files /dev/null and b/bin/commandLine/CommandLineController.class differ diff --git a/src/application/MainGUI.fxml b/bin/commandLine/CommandLineGUI.fxml similarity index 93% rename from src/application/MainGUI.fxml rename to bin/commandLine/CommandLineGUI.fxml index 3d7ae6ee6f84fb892d25f56871229044c017d5b6..ea27a9460dc9cd9d4163ea5886e9a09372715958 100644 --- a/src/application/MainGUI.fxml +++ b/bin/commandLine/CommandLineGUI.fxml @@ -6,7 +6,7 @@ <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.VBox?> -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller"> +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="commandLine.CommandLineController"> <children> <VBox layoutX="14.0" layoutY="14.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0"> <children> diff --git a/src/application/_de.properties b/bin/commandLine/_de.properties similarity index 81% rename from src/application/_de.properties rename to bin/commandLine/_de.properties index 34e77aea180208a74b51be584f2ecee45d9e1e28..c7814cf01dd0527d7ee1a118c1d02621a4a11f4c 100644 --- a/src/application/_de.properties +++ b/bin/commandLine/_de.properties @@ -1,12 +1,13 @@ app.name=CommandLine version.code=1 version.name=1.0.0 -version.date=22.07.16 +version.date=26.07.16 help.list=list - lists all possible commands help.help=help - shows help for given command\nSYNTAX: help [COMMAND] help.clear=clear - clears the history +error.general=An error occurred. error.unknown.command=Unknown command. Use \"list\" for a list of possible commands. error.invalid.arguments=Invalid arguments. Use \"help commandname\" for help. -error.no.help=Unknown command as parameter. Can't display help. Use \"list\" for a list of possible commands \ No newline at end of file +error.no.help=Unknown command as parameter. Can't display help. Use \"list\" for a list of possible commands. \ No newline at end of file diff --git a/bin/commands/Command.class b/bin/commands/Command.class index 40fddff4115933d253769c294cf92c52705ce2d1..b067f6d875a4100c0db43c42a623b8a050e419a2 100644 Binary files a/bin/commands/Command.class and b/bin/commands/Command.class differ diff --git a/bin/commands/CommandBundle.class b/bin/commands/CommandBundle.class new file mode 100644 index 0000000000000000000000000000000000000000..cbeee66dd17083562222e69d6ffb1a2ea74dd485 Binary files /dev/null and b/bin/commands/CommandBundle.class differ diff --git a/bin/commands/CommandClear.class b/bin/commands/CommandClear.class index 71d46c5942d1e34952a7e6785b6a07bab70240e5..2cb70e91aff99f6a297a04b0f413288e9cca2d05 100644 Binary files a/bin/commands/CommandClear.class and b/bin/commands/CommandClear.class differ diff --git a/bin/commands/CommandHelp.class b/bin/commands/CommandHelp.class index 0ab23cd743bcbf327044dc67dc0c65fd44037e11..0c7dc7069c808f58fe85cef1fb778102f5b41da1 100644 Binary files a/bin/commands/CommandHelp.class and b/bin/commands/CommandHelp.class differ diff --git a/bin/commands/CommandList$1.class b/bin/commands/CommandList$1.class index e3b2858a80d5ef11794f98dfb5e40c266a2e2159..1b8c80a8389195f474106bd200e123c29b063f40 100644 Binary files a/bin/commands/CommandList$1.class and b/bin/commands/CommandList$1.class differ diff --git a/bin/commands/CommandList.class b/bin/commands/CommandList.class index 0b0782e573ce2e8ead6b801933d467ba4ef11a9d..ab08f9baa6cc4cb97742718b23d7aed2708c6af9 100644 Binary files a/bin/commands/CommandList.class and b/bin/commands/CommandList.class differ diff --git a/bin/commands/HistoryEntry.class b/bin/commands/HistoryEntry.class index 555ac2bee0604b0272bb28b80dbf6e2bbba727d7..273d82bffe3ac7a4e47f974a862e35b85b9ae2a5 100644 Binary files a/bin/commands/HistoryEntry.class and b/bin/commands/HistoryEntry.class differ diff --git a/bin/commands/PossibleCommands.class b/bin/commands/PossibleCommands.class index 3757d2e80d89e17e3c8bc2acd1889e00262fb30d..f89f06a53eb69b4c55cd2523a41972728870249d 100644 Binary files a/bin/commands/PossibleCommands.class and b/bin/commands/PossibleCommands.class differ diff --git a/bin/test/Main$1.class b/bin/test/Main$1.class new file mode 100644 index 0000000000000000000000000000000000000000..3524c51fd0d955d6f06fad56fb746d3ec7a2f3c1 Binary files /dev/null and b/bin/test/Main$1.class differ diff --git a/bin/test/Main$2.class b/bin/test/Main$2.class new file mode 100644 index 0000000000000000000000000000000000000000..3aab3c6a6671eb2faa5cea2791db11dc46128ba0 Binary files /dev/null and b/bin/test/Main$2.class differ diff --git a/bin/test/Main.class b/bin/test/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..27f2a876e6fcb195df6a10bc48a37326ad9f09b7 Binary files /dev/null and b/bin/test/Main.class differ diff --git a/src/application/Main.java b/src/application/Main.java deleted file mode 100644 index 4adcc79a8b4f3241289ee48c889d6793220461f6..0000000000000000000000000000000000000000 --- a/src/application/Main.java +++ /dev/null @@ -1,43 +0,0 @@ -package application; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; - -public class Main extends Application -{ - @Override - public void start(Stage stage) - { - try - { - FXMLLoader loader = new FXMLLoader(getClass().getResource("MainGUI.fxml")); - Parent root = (Parent)loader.load(); - - Scene scene = new Scene(root, 600, 600); - - stage.setResizable(true); - stage.setTitle("CommandLine"); - stage.setScene(scene); - stage.setResizable(true); - stage.setMinHeight(250); - stage.setMinWidth(400); - - Controller controller = (Controller)loader.getController(); - controller.setStage(stage); - controller.init(); - stage.show(); - } - catch(Exception e) - { - e.printStackTrace(); - } - } - - public static void main(String[] args) - { - launch(args); - } -} \ No newline at end of file diff --git a/src/commandLine/CommandLine.java b/src/commandLine/CommandLine.java new file mode 100644 index 0000000000000000000000000000000000000000..16d1f8f388cbf237b5ba24bd38301135e5365f3c --- /dev/null +++ b/src/commandLine/CommandLine.java @@ -0,0 +1,133 @@ +package commandLine; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.ResourceBundle; + +import commands.CommandBundle; +import commands.HistoryEntry; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.stage.Modality; +import javafx.stage.Stage; + +/** + * CommandLine object, initialization and configuration for a new CommandLine stage + * @author deadlocker8 + * + */ +public class CommandLine +{ + private Stage owner; + private Stage newStage; + private Image icon; + private ResourceBundle languageBundle; + public ArrayList<HistoryEntry> globalHistory = new ArrayList<>(); + public int lastShownCommand = 1; + public ArrayList<HistoryEntry> history = new ArrayList<>(); + private final String promptText = ">>>"; + private CommandBundle bundle; + + public CommandLine(Stage owner, Image icon, ResourceBundle languageBundle, CommandBundle commandBundle) + { + this.owner = owner; + this.icon = icon; + this.languageBundle = languageBundle; + this.bundle = commandBundle; + } + + public Stage getOwner() + { + return owner; + } + + public Stage getStage() + { + return newStage; + } + + public Image getIcon() + { + return icon; + } + + public int getLastShwonCommand() + { + return lastShownCommand; + } + + public String getPromptText() + { + return promptText; + } + + public ResourceBundle getLanguageBundle() + { + return languageBundle; + } + + public CommandBundle getBundle() + { + return bundle; + } + + public void showCommandLine(String title, double width, double height, double minWidth, double minHeight, double positionX, double positionY, boolean dark) throws IOException + { + if(newStage != null) + { + if(newStage.isShowing()) + { + return; + } + } + + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/commandLine/CommandLineGUI.fxml")); + + Parent root = (Parent)fxmlLoader.load(); + newStage = new Stage(); + newStage.setScene(new Scene(root, width, height)); + newStage.setResizable(true); + newStage.setTitle(title); + newStage.initOwner(owner); + + newStage.setMinWidth(minWidth); + newStage.setMinHeight(minHeight); + if(positionX != -1) + { + newStage.setX(positionX); + } + if(positionY != -1) + { + newStage.setY(positionY); + } + + if(dark) + { + root.setStyle("-fx-base: rgb(50, 50, 50); -fx-background: rgb(50, 50, 50); -fx-control-inner-background: rgb(10, 10, 10);"); + } + + if(icon != null) + { + newStage.getIcons().add(icon); + } + + CommandLineController newController = fxmlLoader.getController(); + newController.init(this); + + newStage.initModality(Modality.NONE); + newStage.show(); + } + + public void closeCommandLine() + { + if(newStage != null) + { + if(newStage.isShowing()) + { + newStage.close(); + } + } + } +} \ No newline at end of file diff --git a/src/application/Controller.java b/src/commandLine/CommandLineController.java similarity index 61% rename from src/application/Controller.java rename to src/commandLine/CommandLineController.java index 3066586ea2a3498d97725fcb6f2459cac1204ca2..d4b4fc5b03df9de28e8ea1c16077409ea4a8472f 100644 --- a/src/application/Controller.java +++ b/src/commandLine/CommandLineController.java @@ -1,41 +1,37 @@ -package application; +package commandLine; import java.util.ArrayList; -import java.util.Locale; -import java.util.ResourceBundle; -import commands.PossibleCommands; import commands.Command; import commands.HistoryEntry; import commands.HistoryType; +import commands.PossibleCommands; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; -import javafx.stage.Stage; -public class Controller +/** + * Controller for the CommandLine stage + * @author deadlocker8 + * + */ +public class CommandLineController { @FXML private TextArea textareaHistory; @FXML private TextField textfieldInput; - public Stage stage; - private final ResourceBundle bundle = ResourceBundle.getBundle("application/", Locale.GERMANY); - - private ArrayList<HistoryEntry> globalHistory = new ArrayList<>(); - private int lastShwonCommand = 1; - private ArrayList<HistoryEntry> history = new ArrayList<>(); - private final String promptText = ">>>"; - - public void setStage(Stage stage) - { - this.stage = stage; - } + private CommandLine commandLine; - public void init() + public void init(CommandLine commandLine) { + this.commandLine = commandLine; + + commandLine.getBundle().setController(this); + commandLine.getBundle().setLanguageBundle(commandLine.getLanguageBundle()); + textareaHistory.setEditable(false); textareaHistory.setWrapText(true); @@ -59,8 +55,8 @@ public class Controller clearConsole(); } } - }); - + }); + printPrompt(); } @@ -72,7 +68,7 @@ public class Controller public void print(String message) { - history.add(new HistoryEntry(HistoryType.MESSAGE, message)); + commandLine.history.add(new HistoryEntry(HistoryType.MESSAGE, message)); setConsoleText(); printPrompt(); } @@ -84,7 +80,7 @@ public class Controller public void clearHistory() { - history = new ArrayList<>(); + commandLine.history = new ArrayList<>(); } public void clearConsole() @@ -99,16 +95,16 @@ public class Controller StringBuilder sb = new StringBuilder(); boolean printedLastEntry = false; - for(int i = 0; i < history.size(); i++) + for(int i = 0; i < commandLine.history.size(); i++) { - HistoryEntry currentEntry = history.get(i); + HistoryEntry currentEntry = commandLine.history.get(i); if(currentEntry.getType().equals(HistoryType.COMMAND)) { if(printedLastEntry) { sb.append("\n"); } - sb.append(promptText); + sb.append(commandLine.getPromptText()); sb.append(" "); sb.append(currentEntry.getText()); printedLastEntry = true; @@ -124,8 +120,8 @@ public class Controller } } - textareaHistory.setText(sb.toString()); - textareaHistory.positionCaret(sb.toString().length()); + textareaHistory.setText(sb.toString()); + textareaHistory.positionCaret(sb.toString().length()); } private boolean executeCommand(String[] command) @@ -133,8 +129,8 @@ public class Controller for(Command cmd : PossibleCommands.possibleCommands) { if(cmd.getKeyword().equals(command[0])) - { - cmd.execute(command, this); + { + cmd.execute(command, commandLine.getBundle()); return true; } } @@ -151,14 +147,14 @@ public class Controller return; } - globalHistory.add(new HistoryEntry(HistoryType.COMMAND, input)); - history.add(new HistoryEntry(HistoryType.COMMAND, input)); - lastShwonCommand = -1; + commandLine.globalHistory.add(new HistoryEntry(HistoryType.COMMAND, input)); + commandLine.history.add(new HistoryEntry(HistoryType.COMMAND, input)); + commandLine.lastShownCommand = -1; String[] command = input.split(" "); if(!executeCommand(command)) { - print(bundle.getString("error.unknown.command")); + print(commandLine.getLanguageBundle().getString("error.unknown.command")); } else { @@ -168,17 +164,17 @@ public class Controller private void showLastCommand() { - if(globalHistory.size() > 0) + if(commandLine.globalHistory.size() > 0) { - if(lastShwonCommand <= 0) + if(commandLine.lastShownCommand <= 0) { - textfieldInput.setText(globalHistory.get(globalHistory.size()-1).getText()); - lastShwonCommand = globalHistory.size()-1; + textfieldInput.setText(commandLine.globalHistory.get(commandLine.globalHistory.size()-1).getText()); + commandLine.lastShownCommand = commandLine.globalHistory.size()-1; } else { - textfieldInput.setText(globalHistory.get(lastShwonCommand - 1).getText()); - lastShwonCommand--; + textfieldInput.setText(commandLine.globalHistory.get(commandLine.lastShownCommand - 1).getText()); + commandLine.lastShownCommand--; } } } diff --git a/bin/application/MainGUI.fxml b/src/commandLine/CommandLineGUI.fxml similarity index 93% rename from bin/application/MainGUI.fxml rename to src/commandLine/CommandLineGUI.fxml index 3d7ae6ee6f84fb892d25f56871229044c017d5b6..ea27a9460dc9cd9d4163ea5886e9a09372715958 100644 --- a/bin/application/MainGUI.fxml +++ b/src/commandLine/CommandLineGUI.fxml @@ -6,7 +6,7 @@ <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.VBox?> -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller"> +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="commandLine.CommandLineController"> <children> <VBox layoutX="14.0" layoutY="14.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0"> <children> diff --git a/bin/application/_de.properties b/src/commandLine/_de.properties similarity index 75% rename from bin/application/_de.properties rename to src/commandLine/_de.properties index 1ea1c0a41f36ff433bffe51a8f687effe0f4d5fe..c7814cf01dd0527d7ee1a118c1d02621a4a11f4c 100644 --- a/bin/application/_de.properties +++ b/src/commandLine/_de.properties @@ -1,12 +1,13 @@ app.name=CommandLine -version.code=0 -version.name=0.0.1 -version.date=22.07.16 +version.code=1 +version.name=1.0.0 +version.date=26.07.16 help.list=list - lists all possible commands help.help=help - shows help for given command\nSYNTAX: help [COMMAND] help.clear=clear - clears the history +error.general=An error occurred. error.unknown.command=Unknown command. Use \"list\" for a list of possible commands. error.invalid.arguments=Invalid arguments. Use \"help commandname\" for help. -error.no.help=Unknown command as parameter. Can't display help. Use \"list\" for a list of possible commands \ No newline at end of file +error.no.help=Unknown command as parameter. Can't display help. Use \"list\" for a list of possible commands. \ No newline at end of file diff --git a/src/commands/Command.java b/src/commands/Command.java index 2f9d39e3a667b86f8ddef64f1ede4061a5fae9b9..68974cc971183283c7fd93de51565f8adbaf268d 100644 --- a/src/commands/Command.java +++ b/src/commands/Command.java @@ -1,16 +1,15 @@ package commands; -import java.util.Locale; -import java.util.ResourceBundle; - -import application.Controller; - +/** + * abstract class Command + * @author deadlocker8 + * + */ public abstract class Command { public String keyword; public int numberOfParams; - public String helptText; - public final ResourceBundle bundle = ResourceBundle.getBundle("application/", Locale.GERMANY); + public String helptText; public String getKeyword() { @@ -39,5 +38,5 @@ public abstract class Command } } - public abstract void execute(String[] command, Controller controller); + public abstract void execute(String[] command, CommandBundle bundle); } \ No newline at end of file diff --git a/src/commands/CommandBundle.java b/src/commands/CommandBundle.java new file mode 100644 index 0000000000000000000000000000000000000000..16c8c5ca081136d64fdbc7bf4aed22dbef4785ef --- /dev/null +++ b/src/commands/CommandBundle.java @@ -0,0 +1,42 @@ +package commands; + +import java.util.ResourceBundle; + +import commandLine.CommandLineController; + +/** + * holds important objects that are needed by the commands + * --> fill in your variables (with getters and setters) here + * @author deadlocker8 + * + */ +public class CommandBundle +{ + private CommandLineController controller; + private ResourceBundle languageBundle; + + public CommandBundle() + { + + } + + public CommandLineController getController() + { + return controller; + } + + public ResourceBundle getLanguageBundle() + { + return languageBundle; + } + + public void setController(CommandLineController controller) + { + this.controller = controller; + } + + public void setLanguageBundle(ResourceBundle languageBundle) + { + this.languageBundle = languageBundle; + } +} \ No newline at end of file diff --git a/src/commands/CommandClear.java b/src/commands/CommandClear.java index 1facf0b5cf8f18799430b2ff7dd0632fa9f4c8db..853b054548512e99e1d011af910558309b03cbe4 100644 --- a/src/commands/CommandClear.java +++ b/src/commands/CommandClear.java @@ -1,7 +1,10 @@ package commands; -import application.Controller; - +/** + * Clears the history log and console + * @author deadlocker8 + * + */ public class CommandClear extends Command { public CommandClear() @@ -12,17 +15,17 @@ public class CommandClear extends Command } @Override - public void execute(String[] command, Controller controller) + public void execute(String[] command, CommandBundle bundle) { if(!isValid(command)) { - controller.print(bundle.getString("error.invalid.arguments")); + bundle.getController().print(bundle.getLanguageBundle().getString("error.invalid.arguments")); return; } - controller.clearHistory(); - controller.clearHistoryLog(); - controller.clearConsole(); - controller.printPrompt(); + bundle.getController().clearHistory(); + bundle.getController().clearHistoryLog(); + bundle.getController().clearConsole(); + bundle.getController().printPrompt(); } } \ No newline at end of file diff --git a/src/commands/CommandHelp.java b/src/commands/CommandHelp.java index 36fb39a1675c3f5bc6d2caa7ca0cf4f169e8feb3..c8d25ddf6b22a19533b749f4f5ddcc1062bc3d6b 100644 --- a/src/commands/CommandHelp.java +++ b/src/commands/CommandHelp.java @@ -1,7 +1,12 @@ package commands; -import application.Controller; +import java.util.MissingResourceException; +/** + * prints help for given command + * @author deadlocker8 + * + */ public class CommandHelp extends Command { public CommandHelp() @@ -13,23 +18,30 @@ public class CommandHelp extends Command } @Override - public void execute(String[] command, Controller controller) + public void execute(String[] command, CommandBundle bundle) { if(!isValid(command)) { - controller.print(bundle.getString("error.invalid.arguments")); + bundle.getController().print(bundle.getLanguageBundle().getString("error.invalid.arguments")); return; - } + } for(Command cmd : PossibleCommands.possibleCommands) { if(cmd.getKeyword().equals(command[1])) - { - controller.print(bundle.getString("help." + command[1])); + { + try + { + bundle.getController().print(bundle.getLanguageBundle().getString("help." + command[1])); + } + catch(MissingResourceException e) + { + bundle.getController().print(bundle.getLanguageBundle().getString("error.general")); + } return; } } - controller.print(bundle.getString("error.no.help")); + bundle.getController().print(bundle.getLanguageBundle().getString("error.no.help")); } } diff --git a/src/commands/CommandList.java b/src/commands/CommandList.java index 2deaa747424f52e04451121b34bae0926c2bc5c0..5435bb6e529b85f77da0fe6fd48d60b7a2deae07 100644 --- a/src/commands/CommandList.java +++ b/src/commands/CommandList.java @@ -3,8 +3,11 @@ package commands; import java.util.ArrayList; import java.util.Comparator; -import application.Controller; - +/** + * Lists all available commands + * @author deadlocker8 + * + */ public class CommandList extends Command { public CommandList() @@ -16,14 +19,15 @@ public class CommandList extends Command } @Override - public void execute(String[] command, Controller controller) + public void execute(String[] command, CommandBundle bundle) { if(!isValid(command)) { - controller.print(bundle.getString("error.invalid.arguments")); + bundle.getController().print(bundle.getLanguageBundle().getString("error.invalid.arguments")); return; } + //sort possible commands alphabetically ArrayList<Command> commands = PossibleCommands.possibleCommands; commands.sort(new Comparator<Command>() { @@ -34,6 +38,7 @@ public class CommandList extends Command } }); + //loop through all possible commands and print keyword StringBuilder sb = new StringBuilder(); sb.append("All possible commands:\n"); for(int i = 0; i < commands.size(); i++) @@ -45,6 +50,6 @@ public class CommandList extends Command } } - controller.print(sb.toString()); + bundle.getController().print(sb.toString()); } } \ No newline at end of file diff --git a/src/commands/HistoryEntry.java b/src/commands/HistoryEntry.java index ffaf0a91ea12c03be0448de8fe4656d76a163013..460aa8e5ad3f062e03c6a6a61b46480f9c06ae76 100644 --- a/src/commands/HistoryEntry.java +++ b/src/commands/HistoryEntry.java @@ -1,5 +1,10 @@ package commands; +/** + * Entry in the history log + * @author deadlocker8 + * + */ public class HistoryEntry { private HistoryType type; diff --git a/src/commands/HistoryType.java b/src/commands/HistoryType.java index 169f897674b8489d8ed2962ff916d1a8ec1016ff..218d868ca65aefb03c83e03b9596a14494ade787 100644 --- a/src/commands/HistoryType.java +++ b/src/commands/HistoryType.java @@ -3,4 +3,4 @@ package commands; public enum HistoryType { COMMAND, MESSAGE -} +} \ No newline at end of file diff --git a/src/commands/PossibleCommands.java b/src/commands/PossibleCommands.java index 8de7de25154eda1fba9b6f892f01e0689734453d..bdf8a51fec10af772e05ad612db9a51c244c9260 100644 --- a/src/commands/PossibleCommands.java +++ b/src/commands/PossibleCommands.java @@ -3,12 +3,16 @@ package commands; import java.util.ArrayList; import java.util.Arrays; +/** + * contains all possible allowed commands + * @author deadlocker8 + * + */ public class PossibleCommands -{ - +{ public static final ArrayList<Command> possibleCommands = new ArrayList<>(Arrays.asList( new CommandList(), new CommandHelp(), - new CommandClear() + new CommandClear() )); } \ No newline at end of file diff --git a/src/test/Main.java b/src/test/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..82ee1e1506f26c8643b98d8b596158dbef60a61a --- /dev/null +++ b/src/test/Main.java @@ -0,0 +1,82 @@ +package test; + +import java.io.IOException; +import java.util.Locale; +import java.util.ResourceBundle; + +import commandLine.CommandLine; +import commands.CommandBundle; +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.HBox; +import javafx.stage.Stage; + +public class Main extends Application +{ + @Override + public void start(Stage stage) + { + try + { + AnchorPane mainPane = new AnchorPane(); + Scene scene = new Scene(mainPane, 600, 600); + + stage.setTitle("Test"); + stage.setScene(scene); + stage.setResizable(true); + + CommandBundle cb = new CommandBundle(); + + CommandLine cmd = new CommandLine(stage, null, ResourceBundle.getBundle("commandLine/", Locale.GERMANY), cb); + + HBox hbox = new HBox(); + + Button button = new Button("Open"); + button.setOnAction(new EventHandler<ActionEvent>() + { + @Override + public void handle(ActionEvent event) + { + try + { + cmd.showCommandLine("CommandLine", 400, 250, 400, 200, -1, -1, false); + } + catch(IOException e) + { + //ERRORHANDLING + e.printStackTrace(); + } + } + }); + hbox.getChildren().add(button); + + Button button2 = new Button("Close"); + button2.setOnAction(new EventHandler<ActionEvent>() + { + @Override + public void handle(ActionEvent event) + { + cmd.closeCommandLine(); + } + }); + hbox.getChildren().add(button2); + + mainPane.getChildren().add(hbox); + + stage.show(); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public static void main(String[] args) + { + launch(args); + } +} \ No newline at end of file