- Connected UI to logic.

- Added Threads for UI/logic.
- Removing SyncDir(s) causes Exceptions due to ConcurrentMod.
pull/1/head
Ivan Olexyn 5 years ago
parent 4c3be08ec8
commit a208653312

@ -6,27 +6,23 @@ import com.olexyn.ensync.artifacts.SyncMap;
import java.io.File;
import java.util.Map;
public class Flow {
public class Flow implements Runnable{
public void start() {
public void run() {
Tools tools = new Tools();
Execute x = new Execute();
SyncMap syncMap = new SyncMap("test");
syncMap.addDirectory("/home/user/test/a");
syncMap.addDirectory("/home/user/test/b");
//syncMap.addDirectory("/home/user/test/c");
for (Map.Entry<String, SyncMap> mapEntry : Main.sync.syncMaps.entrySet()) {
for (Map.Entry<String, SyncDirectory> entry : syncMap.syncDirectories.entrySet()) {
for (Map.Entry<String, SyncDirectory> entry : mapEntry.getValue().syncDirectories.entrySet()) {
SyncDirectory syncDirectory = entry.getValue();
String path = syncDirectory.path;
String stateFilePath = syncDirectory.stateFilePath(path);
@ -41,7 +37,7 @@ public class Flow {
while (true) {
for (Map.Entry<String, SyncDirectory> entry : syncMap.syncDirectories.entrySet()) {
for (Map.Entry<String, SyncDirectory> entry : mapEntry.getValue().syncDirectories.entrySet()) {
SyncDirectory syncDirectory = entry.getValue();
@ -58,20 +54,19 @@ public class Flow {
syncDirectory.doModify();
syncDirectory.writeStateFile(path);
}
try {
System.out.println("Pausing...");
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
}
}

@ -16,12 +16,15 @@ import javafx.stage.Stage;
import javafx.stage.Window;
public class Main extends UI {
public class Main{
public static Sync sync = new Sync();
final public static Sync sync = new Sync();
final private static Flow flow = new Flow();
final private static UI ui = new UI();
@ -34,7 +37,22 @@ public class Main extends UI {
sync.syncMaps.put("test", new SyncMap("test"));
UI.main(args);
Thread uiThread = new Thread(ui, "ui");
uiThread.start();
Thread flowThread = new Thread(flow, "flow");
flowThread.start();
}
}

@ -127,6 +127,7 @@ public class Controller implements Initializable {
nodeList.addAll(gridPane.getChildren());
//TODO fix ConcurrentModificationException. This will possibly resolve further errors.
for (Node node : nodeList) {

@ -7,7 +7,7 @@ import javafx.scene.Scene;
import javafx.stage.Stage;
public class UI extends Application {
public class UI extends Application implements Runnable {
@ -29,11 +29,11 @@ public class UI extends Application {
primaryStage.show();
}
public static void main(String[] args) {
UI.launch(args);
}
@Override
public void run() {
UI.launch();
}
}

Loading…
Cancel
Save