ready to launch

pull/1/head
Ivan Olexyn 4 years ago
parent d0f1f61378
commit 6942061f70

@ -1,13 +0,0 @@
package com.olexyn.ensync;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

@ -4,6 +4,9 @@ import com.olexyn.ensync.artifacts.SyncDirectory;
import com.olexyn.ensync.artifacts.SyncMap;
import java.io.File;
import java.util.Map;
import java.util.Map.Entry;
import static com.olexyn.ensync.Main.MAP_OF_SYNCMAPS;
public class Flow implements Runnable {
@ -17,20 +20,30 @@ public class Flow implements Runnable {
public void run() {
while (true) {
synchronized (MAP_OF_SYNCMAPS) {
readOrMakeStateFile();
for (var syncMapEntry : MAP_OF_SYNCMAPS.entrySet()) {
for (Entry<String, SyncMap> syncMapEntry : MAP_OF_SYNCMAPS.entrySet()) {
for (Entry<String, SyncDirectory> SDEntry : syncMapEntry.getValue().syncDirectories.entrySet()) {
for (var SDEntry : syncMapEntry.getValue().syncDirectories.entrySet()) {
doSyncDirectory(SDEntry.getValue());
}
}
}
try {
long pause = 2000;
System.out.println("Pausing... for " + pause + "ms.");
Thread.sleep(pause);
} catch (InterruptedException ignored) {}
}
}
SyncDirectory SD = SDEntry.getValue();
private void doSyncDirectory(SyncDirectory SD) {
state = "READ";
SD.readFreshState();
@ -46,22 +59,6 @@ public class Flow implements Runnable {
}
}
}
try {
long pause = 2000;
System.out.println("Pausing... for "+pause+ "ms.");
Thread.sleep(pause);
} catch (InterruptedException ignored) {
}
}
}
public String getState() {
return state == null ? "NONE" : state;
}

@ -8,38 +8,13 @@ import java.util.HashMap;
public class Main{
final public static Thread UI_THREAD = new Thread(new UI(), "ui");
final public static Thread FLOW_THREAD = new Thread(new Flow(), "flow");
final public static HashMap<String, SyncMap> MAP_OF_SYNCMAPS = new HashMap<>();
public static void main(String[] args) {
UI_THREAD.start();
FLOW_THREAD.start();
}
}

@ -10,7 +10,7 @@ import java.util.List;
import java.util.Map;
/**
* A SyncDirectory is an occurrence of a particular directory somewhere across the filesystems.
* A SyncDirectory is a singular occurrence of a directory in the filesystems.
*/
public class SyncDirectory {
@ -18,7 +18,7 @@ public class SyncDirectory {
private SyncDirectory thisSD = this;
private SyncMap syncMap;
private final SyncMap syncMap;
public String path = null;
public Map<String, SyncFile> listCreated = new HashMap<>();
@ -59,11 +59,7 @@ public class SyncDirectory {
filemap.put(filePath, file);
}
return filemap;
}
@ -86,9 +82,7 @@ public class SyncDirectory {
filemap.put(sFilePath, sfile);
}
return filemap;
}

@ -10,34 +10,26 @@ public class SyncFile extends File {
public long timeModifiedFromStateFile = 0;
public String relativePath;
private SyncDirectory sd;
private final SyncDirectory sd;
public SyncFile(SyncDirectory sd , String pathname) {
public SyncFile(SyncDirectory sd, String pathname) {
super(pathname);
this.sd = sd;
relativePath = this.getPath().replace(sd.path, "");
}
public void setTimeModifiedFromStateFile(long value){
public void setTimeModifiedFromStateFile(long value) {
timeModifiedFromStateFile = value;
}
public long getTimeModifiedFromStateFile(){
public long getTimeModifiedFromStateFile() {
SyncFile record = sd.readStateFile().get(this.getPath());
return record == null ? 0 : record.timeModifiedFromStateFile;
}
/**
* If File exists on Disk get the TimeModified from there.
* Else try to read it from StateFile.
@ -54,10 +46,6 @@ public class SyncFile extends File {
if (sd.readStateFile().get(this.getPath())!=null){
return getTimeModifiedFromStateFile();
}
return 0;
}
}

@ -8,7 +8,8 @@ import java.util.HashMap;
import java.util.Map;
/**
* A SyncMap is the set of such SyncDirectories. The purpose of the SyncMap is to help syncronize the SyncDirectories.
* A SyncMap is a map of SyncDirectories. <br>
* It synchronizes the SyncDirectories it contains.
*/
public class SyncMap {

@ -9,27 +9,17 @@ import javafx.stage.Stage;
public class UI extends Application implements Runnable {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("layout.fxml"));
// in IDEA add ";?.fxml;?.css" to File|Settings|Compiler settings
Parent root = FXMLLoader.load(getClass().getResource("/fxml/layout.fxml"));
Scene scene = new Scene(root, 500, 500);
primaryStage.setTitle("EnSync");
primaryStage.setScene(scene);
primaryStage.show();
}
@Override
public void run() {
UI.launch();

Loading…
Cancel
Save