fix path problem

This commit is contained in:
sirjonasxx 2018-09-27 15:53:39 +02:00
parent 072bf1d273
commit ebe253fe95
6 changed files with 37 additions and 17 deletions

Binary file not shown.

View File

@ -60,10 +60,6 @@ public class ExtensionItemContainer extends GridPane {
add(authorLabel, 2, 0); add(authorLabel, 2, 0);
add(versionLabel, 3, 0); add(versionLabel, 3, 0);
// getChildren().addAll(indexLabel, packetLabel, delayLabel, destinationLabel);
ExitButton exitButton = new ExitButton(); ExitButton exitButton = new ExitButton();
Tooltip delete = new Tooltip("Close connection with this extension"); Tooltip delete = new Tooltip("Close connection with this extension");
Tooltip.install(exitButton,delete); Tooltip.install(exitButton,delete);

View File

@ -0,0 +1,21 @@
package main.ui.extensions;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
/**
* Created by Jonas on 27/09/18.
*/
public class ExtensionItemContainerProducer {
private VBox parent;
private ScrollPane scrollPane;
public ExtensionItemContainerProducer(VBox parent, ScrollPane scrollPane) {
this.parent = parent;
this.scrollPane = scrollPane;
}
}

View File

@ -71,9 +71,6 @@ public class GEarthExtension {
} }
private GEarthExtension(HPacket extensionInfo, Socket connection, OnDisconnectedCallback onDisconnectedCallback) { private GEarthExtension(HPacket extensionInfo, Socket connection, OnDisconnectedCallback onDisconnectedCallback) {
this.title = extensionInfo.readString(); this.title = extensionInfo.readString();
this.author = extensionInfo.readString(); this.author = extensionInfo.readString();
this.version = extensionInfo.readString(); this.version = extensionInfo.readString();

View File

@ -1,14 +1,17 @@
package main.ui.extensions.executer; package main.ui.extensions.executer;
import main.misc.OSValidator;
/** /**
* Created by Jonas on 22/09/18. * Created by Jonas on 22/09/18.
*/ */
public class ExtensionRunnerFactory { public class ExtensionRunnerFactory {
public static ExtensionRunner get() { private static ExtensionRunner runner = obtain();
public static ExtensionRunner get() {
return runner;
}
private static ExtensionRunner obtain() {
return new NormalExtensionRunner(); return new NormalExtensionRunner();
} }
} }

View File

@ -1,5 +1,7 @@
package main.ui.extensions.executer; package main.ui.extensions.executer;
import main.Main;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.*; import java.nio.file.*;
@ -11,16 +13,17 @@ import java.util.Random;
*/ */
public class NormalExtensionRunner implements ExtensionRunner { public class NormalExtensionRunner implements ExtensionRunner {
String jarPath = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent();
@Override @Override
public void runAllExtensions(int port) { public void runAllExtensions(int port) {
if (dirExists(ExecutionInfo.EXTENSIONSDIRECTORY)){ if (dirExists(ExecutionInfo.EXTENSIONSDIRECTORY)){
File folder = File folder =
new File(FileSystems.getDefault().getPath(".").toString() + new File(jarPath +
FileSystems.getDefault().getSeparator() + FileSystems.getDefault().getSeparator()+
ExecutionInfo.EXTENSIONSDIRECTORY); ExecutionInfo.EXTENSIONSDIRECTORY);
File[] childs = folder.listFiles(); File[] childs = folder.listFiles();
for (File file : childs) { for (File file : childs) {
tryRunExtension(file.getPath(), port); tryRunExtension(file.getPath(), port);
} }
@ -44,7 +47,7 @@ public class NormalExtensionRunner implements ExtensionRunner {
Path originalPath = Paths.get(path); Path originalPath = Paths.get(path);
Path newPath = Paths.get( Path newPath = Paths.get(
FileSystems.getDefault().getPath(".").toString(), jarPath,
ExecutionInfo.EXTENSIONSDIRECTORY, ExecutionInfo.EXTENSIONSDIRECTORY,
newname newname
); );
@ -65,7 +68,7 @@ public class NormalExtensionRunner implements ExtensionRunner {
} }
private void tryRunExtension(String path, int port) { public void tryRunExtension(String path, int port) {
try { try {
Runtime.getRuntime().exec( Runtime.getRuntime().exec(
ExecutionInfo.getExecutionCommand(getFileExtension(path)) ExecutionInfo.getExecutionCommand(getFileExtension(path))
@ -89,12 +92,12 @@ public class NormalExtensionRunner implements ExtensionRunner {
} }
private boolean dirExists(String dir) { private boolean dirExists(String dir) {
return Files.isDirectory(Paths.get(FileSystems.getDefault().getPath(".").toString(), dir)); return Files.isDirectory(Paths.get(jarPath, dir));
} }
private void createDirectory(String dir) { private void createDirectory(String dir) {
if (!dirExists(dir)) { if (!dirExists(dir)) {
try { try {
Files.createDirectories(Paths.get(FileSystems.getDefault().getPath(".").toString(), dir)); Files.createDirectories(Paths.get(jarPath, dir));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }