Updated version to 3.11 because of Java 11 requirements
Also introduced mod support -> Documentation tbd
This commit is contained in:
parent
c607426328
commit
93ece68815
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.cookiestudios</groupId>
|
||||
<artifactId>QuickLaunch</artifactId>
|
||||
<version>3.11</version>
|
||||
<name>INTQuick</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<junit.version>5.7.1</junit.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>11.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>11.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Default configuration for running with: mvn clean javafx:run -->
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<mainClass>main/main.Start
|
||||
</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -59,7 +59,7 @@ public class BasicGuiApp extends Application{
|
|||
public void start(Stage primaryStage) throws Exception {
|
||||
|
||||
mainStage = primaryStage;
|
||||
mainStage.setTitle("QuickLaunch "+Start.VERSION);
|
||||
mainStage.setTitle("QuickLaunch v"+Start.VERSION);
|
||||
mainStage.getIcons().add(new Image(BasicGuiApp.class.getResourceAsStream("/icon.png")));
|
||||
mainStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
|
||||
|
|
|
@ -3,31 +3,14 @@ package basics;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BasicMod {
|
||||
private String modname = "mod:mod";
|
||||
private double version = 0.0;
|
||||
public abstract class BasicMod {
|
||||
protected String modName = "mod:mod";
|
||||
protected double version = 0.0;
|
||||
public double getVersion() { return version; }
|
||||
public String getModName() { return modName; }
|
||||
|
||||
public void setModName(String name) {
|
||||
this.modname = name;
|
||||
}
|
||||
|
||||
public void setVersion(double version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getModname() {
|
||||
return this.modname;
|
||||
}
|
||||
|
||||
public double getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public void checkInput(String input) throws IOException {
|
||||
}
|
||||
public abstract int init();
|
||||
public abstract void checkInput(String input);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,11 +54,7 @@ public class MainGui extends AnchorPane{
|
|||
}
|
||||
|
||||
for (BasicMod bm : ModLoader.mods) {
|
||||
try {
|
||||
bm.checkInput(input);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
bm.checkInput(input);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,81 +53,6 @@ public class SettingGui extends AnchorPane {
|
|||
setting3Box.prefWidth(30);
|
||||
setting3Box.prefHeight(30);
|
||||
setting3Box.setSelected(SettingManager.isCheckUptdateOnBoot());
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
if (SettingManager.getOperatingSystem() == OperatingSystem.WINDOWS) {
|
||||
Text setting4 = new Text("QuickLaunch shortcut:");
|
||||
setting4.setFont(ResourceManager.getFontSmall());
|
||||
setting4.setLayoutX(10);
|
||||
setting4.setLayoutY(128);
|
||||
setting4.prefWidth(180);
|
||||
setting4.prefHeight(30);
|
||||
|
||||
final Button setting4button1 = new Button("key1");
|
||||
if (!(SettingManager.getKey1() == -1)) {
|
||||
setting4button1.setText(SettingManager.getKey1() + "");
|
||||
}
|
||||
setting4button1.setFont(ResourceManager.getFontSmall());
|
||||
setting4button1.setLayoutX(10);
|
||||
setting4button1.setLayoutY(145);
|
||||
setting4button1.prefWidth(40);
|
||||
setting4button1.prefHeight(24);
|
||||
setting4button1.setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
public void handle(ActionEvent event) {
|
||||
ShortcutKeyChecker skc = new ShortcutKeyChecker();
|
||||
GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener);
|
||||
GlobalScreen.addNativeKeyListener(skc);
|
||||
while (skc.lastKey == -1) {
|
||||
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
setting4button1.setText(skc.lastKey + "");
|
||||
SettingManager.setKey1(skc.lastKey);
|
||||
GlobalScreen.removeNativeKeyListener(skc);
|
||||
GlobalScreen.addNativeKeyListener(BasicGuiApp.listener);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
final Button setting4button2 = new Button("key2");
|
||||
if (!(SettingManager.getKey2() == -1)) {
|
||||
setting4button2.setText(SettingManager.getKey2() + "");
|
||||
}
|
||||
setting4button2.setFont(ResourceManager.getFontSmall());
|
||||
setting4button2.setLayoutX(95);
|
||||
setting4button2.setLayoutY(145);
|
||||
setting4button2.prefWidth(40);
|
||||
setting4button2.prefHeight(24);
|
||||
setting4button2.setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
public void handle(ActionEvent event) {
|
||||
ShortcutKeyChecker skc = new ShortcutKeyChecker();
|
||||
GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener);
|
||||
GlobalScreen.addNativeKeyListener(skc);
|
||||
while (skc.lastKey == -1) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
setting4button2.setText(skc.lastKey + "");
|
||||
SettingManager.setKey2(skc.lastKey);
|
||||
GlobalScreen.removeNativeKeyListener(skc);
|
||||
GlobalScreen.addNativeKeyListener(BasicGuiApp.listener);
|
||||
}
|
||||
});
|
||||
this.getChildren().add(setting4);
|
||||
this.getChildren().add(setting4button1);
|
||||
this.getChildren().add(setting4button2);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Button exit = new Button("Done");
|
||||
exit.setFont(ResourceManager.getFontSmall());
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import basics.BasicMod;
|
||||
|
@ -49,37 +51,19 @@ public class ModLoader {
|
|||
}
|
||||
while (nextMod != null) {
|
||||
try {
|
||||
mods.add((BasicMod)Class.forName(nextMod).getConstructors()[0].newInstance(new Object[0]));
|
||||
nextMod = this.bfr.readLine();
|
||||
continue;
|
||||
}
|
||||
catch (InstantiationException e) {
|
||||
System.out.println("Trying for "+nextMod+".jar");
|
||||
File modJar = new File(SettingManager.getJarDirectory()+File.separator+nextMod+".jar");
|
||||
System.out.println(modJar.exists() ? "Found "+nextMod : "Not found");
|
||||
ClassLoader cl = new URLClassLoader(new URL[] {modJar.toURL()}, Thread.currentThread().getContextClassLoader());
|
||||
mods.add((BasicMod)cl.loadClass("mod_"+nextMod.toLowerCase()+"."+nextMod).getConstructors()[0].newInstance(new Object[0]));
|
||||
nextMod = bfr.readLine();
|
||||
} catch (InstantiationException | IOException | SecurityException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
System.out.println("'" + nextMod + "'" + " is not installed");
|
||||
System.out.println("Did not work");
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("'" + nextMod + "'" + " is not installed");
|
||||
break;
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import manager.SettingManager;
|
|||
import manager.ResourceManager;
|
||||
|
||||
public class Start {
|
||||
public static final float VERSION = 3.1f;
|
||||
public static final float VERSION = 3.11f;
|
||||
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
|
|
|
@ -10,9 +10,9 @@ import guis.FileChooseWindow;
|
|||
public class Gui extends BasicMod {
|
||||
|
||||
FileChooseWindow fcw;
|
||||
public void init() {
|
||||
public int init() {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public void checkInput(String input) {
|
||||
|
|
|
@ -14,17 +14,17 @@ public class Calcmod extends BasicMod{
|
|||
String tmp;
|
||||
double output;
|
||||
double temp;
|
||||
public void init(){
|
||||
public int init(){
|
||||
values = new ArrayList<Double>();
|
||||
operators = new ArrayList<Character>();
|
||||
current = ' ';
|
||||
tmp = "";
|
||||
System.out.println("Calculator installed");
|
||||
this.setModName("Calculator");
|
||||
this.setVersion(0.81);
|
||||
|
||||
modName = "Calculator";
|
||||
version = 0.81;
|
||||
return 0;
|
||||
}
|
||||
public void checkInput(String input) throws IOException {
|
||||
public void checkInput(String input){
|
||||
if(!input.isEmpty()){
|
||||
if(input.charAt(0)=='$'){
|
||||
for(int i = 1;i < input.length();i++){
|
||||
|
|
|
@ -13,13 +13,14 @@ extends BasicMod {
|
|||
Scanner scn;
|
||||
|
||||
|
||||
public void init() {
|
||||
this.setModName("ipChat");
|
||||
public int init() {
|
||||
modName = "ipChat";
|
||||
this.scn = new Scanner(System.in);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkInput(String input) throws IOException {
|
||||
public void checkInput(String input) {
|
||||
if (input.equalsIgnoreCase("chat")) {
|
||||
System.out.println("Syntax: chat -c \"creating a chat client\"");
|
||||
System.out.println(" chat -s \"creating a chat server\"");
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
package mod_pPw;
|
||||
|
||||
public class Hasher
|
||||
{
|
||||
public String outputID;
|
||||
public byte decodeFactor = 0;
|
||||
private byte inputLenght = 0;
|
||||
private byte exceptionCounter = 0;
|
||||
private char currentChar;
|
||||
|
||||
public Hasher()
|
||||
{
|
||||
this.outputID = "";
|
||||
}
|
||||
|
||||
public String hash(String str)
|
||||
{
|
||||
this.outputID = "";
|
||||
this.inputLenght = ((byte)str.length());
|
||||
for (int i = 0; i < this.inputLenght; i++)
|
||||
{
|
||||
this.currentChar = ((char)(str.charAt(i) + this.decodeFactor));
|
||||
for (int index = 0; index < 2; index++)
|
||||
{
|
||||
while ((this.currentChar < '!') || (this.currentChar > '~'))
|
||||
{
|
||||
this.currentChar = ((char)(33 + this.exceptionCounter));
|
||||
this.exceptionCounter = ((byte)(this.exceptionCounter + 1));
|
||||
}
|
||||
this.outputID += this.currentChar;
|
||||
}
|
||||
}
|
||||
return this.outputID;
|
||||
}
|
||||
|
||||
public byte getDecodeFactor()
|
||||
{
|
||||
return this.decodeFactor;
|
||||
}
|
||||
|
||||
public void setDecodeFactor(byte decodeFactor)
|
||||
{
|
||||
this.decodeFactor = decodeFactor;
|
||||
}
|
||||
}
|
||||
package mod_ppw;
|
||||
|
||||
public class Hasher
|
||||
{
|
||||
public String outputID;
|
||||
public byte decodeFactor = 0;
|
||||
private byte inputLenght = 0;
|
||||
private byte exceptionCounter = 0;
|
||||
private char currentChar;
|
||||
|
||||
public Hasher()
|
||||
{
|
||||
this.outputID = "";
|
||||
}
|
||||
|
||||
public String hash(String str)
|
||||
{
|
||||
this.outputID = "";
|
||||
this.inputLenght = ((byte)str.length());
|
||||
for (int i = 0; i < this.inputLenght; i++)
|
||||
{
|
||||
this.currentChar = ((char)(str.charAt(i) + this.decodeFactor));
|
||||
for (int index = 0; index < 2; index++)
|
||||
{
|
||||
while ((this.currentChar < '!') || (this.currentChar > '~'))
|
||||
{
|
||||
this.currentChar = ((char)(33 + this.exceptionCounter));
|
||||
this.exceptionCounter = ((byte)(this.exceptionCounter + 1));
|
||||
}
|
||||
this.outputID += this.currentChar;
|
||||
}
|
||||
}
|
||||
return this.outputID;
|
||||
}
|
||||
|
||||
public byte getDecodeFactor()
|
||||
{
|
||||
return this.decodeFactor;
|
||||
}
|
||||
|
||||
public void setDecodeFactor(byte decodeFactor)
|
||||
{
|
||||
this.decodeFactor = decodeFactor;
|
||||
}
|
||||
}
|
|
@ -1,38 +1,39 @@
|
|||
package mod_pPw;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import basics.BasicMod;
|
||||
|
||||
public class PPW
|
||||
extends BasicMod
|
||||
{
|
||||
Scanner scn;
|
||||
Hasher hash;
|
||||
|
||||
public void init()
|
||||
{
|
||||
setModName("PPW");
|
||||
setVersion(0.1D);
|
||||
System.out.println("PPW: Start init");
|
||||
|
||||
this.scn = new Scanner(System.in);
|
||||
this.hash = new Hasher();
|
||||
System.out.println("PPW: Exit init");
|
||||
}
|
||||
|
||||
public void checkInput(String input)
|
||||
{
|
||||
String givenID = "";
|
||||
String givenLM = "";
|
||||
if (input.equalsIgnoreCase("ppw"))
|
||||
{
|
||||
System.out.println("Please enter your private password ID");
|
||||
givenID = this.scn.nextLine();
|
||||
System.out.println("Please enter you personal parameter (1-100) ");
|
||||
givenLM = this.scn.nextLine();
|
||||
this.hash.setDecodeFactor(Byte.parseByte(givenLM));
|
||||
System.out.println("Your encrypted password is:" + this.hash.hash(givenID));
|
||||
}
|
||||
}
|
||||
}
|
||||
package mod_ppw;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import basics.BasicMod;
|
||||
|
||||
public class PPW extends BasicMod {
|
||||
Scanner scn;
|
||||
Hasher hash;
|
||||
|
||||
public int init()
|
||||
{
|
||||
|
||||
modName = "PPW";
|
||||
version = 0.1D;
|
||||
|
||||
System.out.println("PPWINT: Start init");
|
||||
|
||||
this.scn = new Scanner(System.in);
|
||||
this.hash = new Hasher();
|
||||
System.out.println("PPW: Exit init");
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void checkInput(String input)
|
||||
{
|
||||
String givenID = "";
|
||||
String givenLM = "";
|
||||
if (input.equalsIgnoreCase("ppw"))
|
||||
{
|
||||
System.out.println("Please enter your private password ID");
|
||||
givenID = this.scn.nextLine();
|
||||
System.out.println("Please enter you personal parameter (1-100) ");
|
||||
givenLM = this.scn.nextLine();
|
||||
this.hash.setDecodeFactor(Byte.parseByte(givenLM));
|
||||
System.out.println("Your encrypted password is:" + this.hash.hash(givenID));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,8 @@ import java.io.File;
|
|||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import basics.BasicGuiApp;
|
||||
import basics.BasicMod;
|
||||
|
@ -24,13 +25,11 @@ public class QuickLaunch extends BasicMod {
|
|||
private File textfile;
|
||||
private BufferedReader br;
|
||||
private BufferedWriter bw;
|
||||
private ArrayList<Shortcut> shortcuts;
|
||||
private String tmpSh = ".";
|
||||
private String tmpPa = ".";
|
||||
private Map<String, String> shortcuts;
|
||||
|
||||
public void init() {
|
||||
public int init() {
|
||||
try {
|
||||
this.setModName("QL");
|
||||
modName = "QL";
|
||||
|
||||
System.out.println("QL: Starting QuickLaunch");
|
||||
this.textfile = new File(SettingManager.getJarDirectory()+File.separator+"File.txt");
|
||||
|
@ -40,7 +39,7 @@ public class QuickLaunch extends BasicMod {
|
|||
this.textfile.createNewFile();
|
||||
System.out.println("QL: File.txt created");
|
||||
}
|
||||
shortcuts = new ArrayList<Shortcut>();
|
||||
shortcuts = new HashMap<String, String>();
|
||||
|
||||
System.out.println("QL: Finished Initialisation");
|
||||
if(SettingManager.isLoadFileOnBoot()){
|
||||
|
@ -50,16 +49,17 @@ public class QuickLaunch extends BasicMod {
|
|||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void checkInput(String input) throws IOException {
|
||||
public void checkInput(String input){
|
||||
if (input.equalsIgnoreCase("/cos")){
|
||||
this.centerOnScreen();
|
||||
} else if (input.equalsIgnoreCase("/cu")) {
|
||||
this.checkForUpdates();
|
||||
} else if (input.equalsIgnoreCase("exit")) {
|
||||
} else if (input.equalsIgnoreCase("exit") || input.equalsIgnoreCase("/x")) {
|
||||
System.exit(-1);
|
||||
} else if ((input.equalsIgnoreCase("help")) || (input.equalsIgnoreCase("/?"))) {
|
||||
} else if (input.equalsIgnoreCase("help") || input.equalsIgnoreCase("/?")) {
|
||||
this.writeHelp();
|
||||
} else if (input.equalsIgnoreCase("loadFile") || input.equalsIgnoreCase("/lf")) {
|
||||
this.loadFile();
|
||||
|
@ -74,18 +74,15 @@ public class QuickLaunch extends BasicMod {
|
|||
} else if (input.equalsIgnoreCase("/c")) {
|
||||
this.showSettings();
|
||||
} else {
|
||||
int i = 0;
|
||||
for (Shortcut sh : shortcuts) {
|
||||
if (input.equalsIgnoreCase(sh.getShortcut())){
|
||||
i = shortcuts.indexOf(sh);
|
||||
//Runtime.getRuntime().exec("cmd /c \"" + shortcuts.get(i).getPath() + "\"");
|
||||
ProcessBuilder pb = new ProcessBuilder(TokenConverter.convert(shortcuts.get(i).getPath()));
|
||||
pb.start();
|
||||
System.out.println("'" + shortcuts.get(i).getPath() + "' started");
|
||||
//MainGui.addNotification("'" + shortcuts.get(i).getPath() + "' started", 2);
|
||||
break;
|
||||
if(shortcuts.containsKey(input)) {
|
||||
try {
|
||||
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(shortcuts.get(input).split(";"));
|
||||
pb.start();
|
||||
}catch (IOException io){
|
||||
//TODO
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,24 +101,26 @@ public class QuickLaunch extends BasicMod {
|
|||
}).start();
|
||||
}
|
||||
|
||||
private void loadFile() throws IOException {
|
||||
private void loadFile() {
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(this.textfile))){
|
||||
System.out.println("loading shortcuts");
|
||||
this.br = new BufferedReader(new FileReader(this.textfile));
|
||||
shortcuts.clear();
|
||||
tmpSh = "";
|
||||
tmpPa = "";
|
||||
while (this.tmpSh != null) {
|
||||
this.tmpSh = this.br.readLine();
|
||||
if (this.tmpSh == null) break;
|
||||
System.out.println(this.tmpSh);
|
||||
tmpPa = this.br.readLine();
|
||||
System.out.println(this.tmpPa);
|
||||
shortcuts.add(new Shortcut(tmpSh, tmpPa));
|
||||
String tmpSh = ".";
|
||||
String tmpPa = ".";
|
||||
while (tmpSh != null) {
|
||||
tmpSh = br.readLine();
|
||||
if (tmpSh == null) break;
|
||||
System.out.println(tmpSh);
|
||||
tmpPa = br.readLine();
|
||||
System.out.println(tmpPa);
|
||||
shortcuts.put(tmpSh, tmpPa);
|
||||
System.out.println("shortcut added");
|
||||
}}catch (IOException io){
|
||||
//TODO
|
||||
}
|
||||
br.close();
|
||||
|
||||
try{
|
||||
MainGui.addNotification("All shortcuts loaded", 2);
|
||||
MainGui.addNotification("All shortcuts loaded", 2);
|
||||
}catch(NullPointerException npe){
|
||||
//will always fail when file gets read on boot
|
||||
}
|
||||
|
@ -129,36 +128,31 @@ public class QuickLaunch extends BasicMod {
|
|||
|
||||
}
|
||||
|
||||
private void saveFile(boolean silent) throws IOException {
|
||||
this.bw = new BufferedWriter(new FileWriter(this.textfile));
|
||||
|
||||
int i = 0;
|
||||
while (i <= shortcuts.size() - 1) {
|
||||
this.bw.write(shortcuts.get(i).getShortcut());
|
||||
this.bw.newLine();
|
||||
this.bw.write(shortcuts.get(i).getPath());
|
||||
this.bw.newLine();
|
||||
++i;
|
||||
private void saveFile(boolean silent) {
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(this.textfile))) {
|
||||
for (String key : shortcuts.keySet()) {
|
||||
bw.write(key);
|
||||
bw.newLine();
|
||||
bw.write(shortcuts.get(key));
|
||||
bw.newLine();
|
||||
}
|
||||
}catch (IOException io){
|
||||
//TODO
|
||||
}
|
||||
this.bw.close();
|
||||
if(!silent) {
|
||||
MainGui.addNotification("Data has been written", 2);
|
||||
MainGui.addNotification("Data has been written", 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void showShortcuts() {
|
||||
Stage stage = new Stage();
|
||||
ShortcutWindow sw = new ShortcutWindow(shortcuts);
|
||||
Scene s = new Scene(sw);
|
||||
stage.setScene(s);
|
||||
stage.setResizable(false);
|
||||
stage.initStyle(StageStyle.UNDECORATED);
|
||||
stage.showAndWait();
|
||||
try {
|
||||
saveFile(true);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Stage stage = new Stage();
|
||||
ShortcutWindow sw = new ShortcutWindow(shortcuts);
|
||||
Scene s = new Scene(sw);
|
||||
stage.setScene(s);
|
||||
stage.setResizable(false);
|
||||
stage.initStyle(StageStyle.UNDECORATED);
|
||||
stage.showAndWait();
|
||||
saveFile(true);
|
||||
}
|
||||
|
||||
private void getFilePath(){
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package mod_quicklaunch;
|
||||
|
||||
public class Shortcut {
|
||||
|
||||
private String shortcut;
|
||||
private String path;
|
||||
|
||||
public Shortcut(String shortcut,String path){
|
||||
this.shortcut = shortcut;
|
||||
this.path = path;
|
||||
}
|
||||
public String getShortcut() {
|
||||
return shortcut;
|
||||
}
|
||||
public void setShortcut(String shortcut) {
|
||||
this.shortcut = shortcut;
|
||||
}
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ public class ShortcutEntryPane extends Pane{
|
|||
private TextField shortcutField;
|
||||
private TextField pathField;
|
||||
|
||||
public ShortcutEntryPane(Shortcut cut,int layoutY) {
|
||||
public ShortcutEntryPane(int layoutY) {
|
||||
this.setPrefWidth(600);
|
||||
this.setPrefHeight(35);
|
||||
this.setLayoutX(0);
|
||||
|
@ -26,7 +26,7 @@ public class ShortcutEntryPane extends Pane{
|
|||
|
||||
|
||||
shortcutField = new TextField();
|
||||
shortcutField.setText(cut.getShortcut());
|
||||
shortcutField.setText("");
|
||||
shortcutField.setPrefWidth(92);
|
||||
shortcutField.setPrefHeight(27);
|
||||
shortcutField.setLayoutX(8);
|
||||
|
@ -36,7 +36,7 @@ public class ShortcutEntryPane extends Pane{
|
|||
shortcutField.setStyle("-fx-text-fill: gray");
|
||||
|
||||
pathField = new TextField();
|
||||
pathField.setText(cut.getPath());
|
||||
pathField.setText("");
|
||||
pathField.setPrefWidth(497);
|
||||
pathField.setPrefHeight(27);
|
||||
pathField.setLayoutX(100);
|
||||
|
@ -56,7 +56,13 @@ public class ShortcutEntryPane extends Pane{
|
|||
public String getPath() {
|
||||
return pathField.getText();
|
||||
}
|
||||
|
||||
|
||||
ShortcutEntryPane setFieldContent(String shortcut, String path){
|
||||
shortcutField.setText(shortcut);
|
||||
pathField.setText(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checkBox.isSelected();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mod_quicklaunch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
|
@ -29,7 +30,7 @@ public class ShortcutWindow extends AnchorPane {
|
|||
ScrollPane scrollPane;
|
||||
private ArrayList<ShortcutEntryPane> shortcutEntries;
|
||||
|
||||
public ShortcutWindow(ArrayList<Shortcut> currentShortcuts) {
|
||||
public ShortcutWindow(Map<String, String> currentShortcuts) {
|
||||
|
||||
this.setPrefWidth(600);
|
||||
this.setMaxWidth(600);
|
||||
|
@ -55,7 +56,7 @@ public class ShortcutWindow extends AnchorPane {
|
|||
addButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
public void handle(ActionEvent event) {
|
||||
shortcutEntries.add(new ShortcutEntryPane(new Shortcut("",""), shortcutEntries.size()*35));
|
||||
shortcutEntries.add(new ShortcutEntryPane(shortcutEntries.size()*35));
|
||||
shortcutEntries.get(shortcutEntries.size()-1).setEditable(true);
|
||||
shortcutRootPane.setPrefHeight(shortcutRootPane.getPrefHeight()+35);
|
||||
shortcutRootPane.getChildren().add(shortcutEntries.get(shortcutEntries.size()-1));
|
||||
|
@ -145,8 +146,8 @@ public class ShortcutWindow extends AnchorPane {
|
|||
saveButton.setGraphic(ResourceManager.getSaveImage());
|
||||
editButton.fire();
|
||||
currentShortcuts.clear();
|
||||
for(int i = 0;i < shortcutEntries.size();i++) {
|
||||
currentShortcuts.add(new Shortcut(shortcutEntries.get(i).getShortcut(),shortcutEntries.get(i).getPath()));
|
||||
for (ShortcutEntryPane shortcutEntry : shortcutEntries) {
|
||||
currentShortcuts.put(shortcutEntry.getShortcut(), shortcutEntry.getPath());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -197,11 +198,12 @@ public class ShortcutWindow extends AnchorPane {
|
|||
scrollPane.setLayoutX(0);
|
||||
scrollPane.setLayoutY(40);
|
||||
|
||||
shortcutEntries = new ArrayList<ShortcutEntryPane>();
|
||||
shortcutEntries = new ArrayList<>();
|
||||
int y = 0;
|
||||
for(int i = 0;i<currentShortcuts.size();i++) {
|
||||
shortcutEntries.add(new ShortcutEntryPane(currentShortcuts.get(i), y));
|
||||
shortcutRootPane.getChildren().add(shortcutEntries.get(i));
|
||||
for(String key : currentShortcuts.keySet()){
|
||||
ShortcutEntryPane sep = new ShortcutEntryPane(y).setFieldContent(key, currentShortcuts.get(key));
|
||||
shortcutEntries.add(sep);
|
||||
shortcutRootPane.getChildren().add(sep);
|
||||
y+=35;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package mod_quicklaunch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TokenConverter {
|
||||
|
||||
public static String[] convert(String input){
|
||||
ArrayList<String> tokens = new ArrayList<String>();
|
||||
String tmp = "";
|
||||
for(int i = 0;i < input.length();i++){
|
||||
char a = input.charAt(i);
|
||||
if(!(a == ';')){
|
||||
tmp += a;
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
tokens.add(tmp);
|
||||
tmp = "";
|
||||
}
|
||||
}
|
||||
tokens.add(tmp);
|
||||
|
||||
String[] returnArray = tokens.toArray(new String[tokens.size()]);
|
||||
|
||||
|
||||
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue