Skip to content
Snippets Groups Projects
Commit d28b503c authored by Robert Goldmann's avatar Robert Goldmann
Browse files

made it usable in other projects, add some comments

parent ee2d2bb6
Branches
Tags
No related merge requests found
Showing
with 137 additions and 46 deletions
File deleted
File deleted
File added
No preview for this file type
File added
......@@ -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>
......
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
No preview for this file type
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
File added
File added
File added
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment