- adding directories/collections
pull/1/head
Ivan Olexyn 5 years ago
parent 2b9c9bde91
commit 3aa27887cb

@ -4,8 +4,8 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>300</y>
<x>530</x>
<y>550</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -17,8 +17,8 @@ bg=#90CAF9</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>260</y>
<x>530</x>
<y>510</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -31,8 +31,8 @@ bg=#90CAF9</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>20</x>
<y>260</y>
<x>210</x>
<y>510</y>
<w>130</w>
<h>30</h>
</coordinates>
@ -45,8 +45,8 @@ bg=#90CAF9</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>340</y>
<x>530</x>
<y>590</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -58,8 +58,8 @@ bg=#80CBC4</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>180</y>
<x>530</x>
<y>430</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -71,8 +71,8 @@ bg=#80CBC4</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>260</y>
<x>400</x>
<y>510</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -84,8 +84,8 @@ bg=#90CAF9</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>180</y>
<x>400</x>
<y>430</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -97,8 +97,8 @@ bg=#80CBC4</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>220</y>
<x>530</x>
<y>470</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -110,8 +110,8 @@ bg=#90CAF9</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>220</y>
<x>400</x>
<y>470</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -123,8 +123,8 @@ bg=#90CAF9</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>20</x>
<y>220</y>
<x>210</x>
<y>470</y>
<w>130</w>
<h>30</h>
</coordinates>
@ -136,8 +136,8 @@ bg=#90CAF9</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>140</y>
<x>530</x>
<y>390</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -148,8 +148,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>100</y>
<x>530</x>
<y>350</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -160,8 +160,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>20</x>
<y>100</y>
<x>210</x>
<y>350</y>
<w>130</w>
<h>30</h>
</coordinates>
@ -172,8 +172,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>20</y>
<x>530</x>
<y>270</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -185,8 +185,8 @@ bg=#80CBC4</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>100</y>
<x>400</x>
<y>350</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -197,8 +197,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>20</y>
<x>400</x>
<y>270</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -210,8 +210,8 @@ bg=#80CBC4</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>340</x>
<y>60</y>
<x>530</x>
<y>310</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -222,8 +222,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>60</y>
<x>400</x>
<y>310</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -234,8 +234,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>20</x>
<y>60</y>
<x>210</x>
<y>310</y>
<w>130</w>
<h>30</h>
</coordinates>
@ -246,8 +246,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>20</x>
<y>300</y>
<x>210</x>
<y>550</y>
<w>130</w>
<h>30</h>
</coordinates>
@ -255,4 +255,316 @@ halign=left</panel_attributes>
halign=left</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>590</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>550</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>510</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>470</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>430</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>390</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>350</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>310</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>480</x>
<y>270</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>590</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>550</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>510</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>470</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>430</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>390</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>350</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>310</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>350</x>
<y>270</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>400</x>
<y>590</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>400</x>
<y>550</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>590</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>400</x>
<y>390</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>390</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>430</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>270</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>210</x>
<y>640</y>
<w>40</w>
<h>30</h>
</coordinates>
<panel_attributes>
bg=#F6F6F6</panel_attributes>
<additional_attributes/>
</element>
</diagram>

@ -4,8 +4,8 @@
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>870</y>
<x>580</x>
<y>820</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -16,8 +16,8 @@ halign=left</panel_attributes>
<element>
<id>Relation</id>
<coordinates>
<x>780</x>
<y>870</y>
<x>730</x>
<y>820</y>
<w>100</w>
<h>30</h>
</coordinates>
@ -27,20 +27,20 @@ halign=left</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>870</y>
<w>230</w>
<x>810</x>
<y>820</y>
<w>280</w>
<h>30</h>
</coordinates>
<panel_attributes>addDirectoryButton
<panel_attributes>addDirectoryButton-name1234
fg=red</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>800</y>
<x>580</x>
<y>750</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -51,8 +51,8 @@ halign=left</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>800</y>
<x>810</x>
<y>750</y>
<w>320</w>
<h>30</h>
</coordinates>
@ -63,8 +63,8 @@ fg=red</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>310</x>
<y>800</y>
<x>260</x>
<y>750</y>
<w>130</w>
<h>30</h>
</coordinates>
@ -75,8 +75,8 @@ halign=left</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>740</y>
<x>810</x>
<y>690</y>
<w>320</w>
<h>30</h>
</coordinates>
@ -87,8 +87,8 @@ fg=red</panel_attributes>
<element>
<id>Relation</id>
<coordinates>
<x>430</x>
<y>740</y>
<x>380</x>
<y>690</y>
<w>450</w>
<h>90</h>
</coordinates>
@ -98,8 +98,8 @@ fg=red</panel_attributes>
<element>
<id>Relation</id>
<coordinates>
<x>780</x>
<y>800</y>
<x>730</x>
<y>750</y>
<w>100</w>
<h>30</h>
</coordinates>
@ -109,8 +109,8 @@ fg=red</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>940</y>
<x>580</x>
<y>890</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -121,8 +121,8 @@ halign=left</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>770</y>
<x>810</x>
<y>720</y>
<w>320</w>
<h>30</h>
</coordinates>
@ -133,8 +133,8 @@ fg=red</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>630</x>
<y>680</y>
<x>580</x>
<y>630</y>
<w>160</w>
<h>30</h>
</coordinates>
@ -145,8 +145,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>500</x>
<y>800</y>
<x>450</x>
<y>750</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -157,8 +157,8 @@ halign=left</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>500</x>
<y>680</y>
<x>450</x>
<y>630</y>
<w>70</w>
<h>30</h>
</coordinates>
@ -169,8 +169,8 @@ halign=left</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>940</y>
<x>810</x>
<y>890</y>
<w>190</w>
<h>30</h>
</coordinates>
@ -181,8 +181,8 @@ fg=red</panel_attributes>
<element>
<id>Relation</id>
<coordinates>
<x>780</x>
<y>940</y>
<x>730</x>
<y>890</y>
<w>100</w>
<h>30</h>
</coordinates>
@ -192,8 +192,8 @@ fg=red</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>680</y>
<x>810</x>
<y>630</y>
<w>300</w>
<h>30</h>
</coordinates>
@ -204,8 +204,8 @@ fg=red</panel_attributes>
<element>
<id>Relation</id>
<coordinates>
<x>560</x>
<y>770</y>
<x>510</x>
<y>720</y>
<w>320</w>
<h>60</h>
</coordinates>
@ -215,8 +215,8 @@ fg=red</panel_attributes>
<element>
<id>Relation</id>
<coordinates>
<x>780</x>
<y>680</y>
<x>730</x>
<y>630</y>
<w>100</w>
<h>30</h>
</coordinates>
@ -226,8 +226,8 @@ fg=red</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>650</y>
<x>810</x>
<y>600</y>
<w>300</w>
<h>30</h>
</coordinates>
@ -238,8 +238,8 @@ fg=red</panel_attributes>
<element>
<id>Relation</id>
<coordinates>
<x>560</x>
<y>650</y>
<x>510</x>
<y>600</y>
<w>320</w>
<h>60</h>
</coordinates>
@ -249,8 +249,8 @@ fg=red</panel_attributes>
<element>
<id>UMLClass</id>
<coordinates>
<x>310</x>
<y>870</y>
<x>260</x>
<y>820</y>
<w>130</w>
<h>30</h>
</coordinates>
@ -261,20 +261,20 @@ halign=left</panel_attributes>
<element>
<id>UMLNote</id>
<coordinates>
<x>860</x>
<y>840</y>
<w>230</w>
<x>810</x>
<y>790</y>
<w>280</w>
<h>30</h>
</coordinates>
<panel_attributes>addDirectoryTextField
<panel_attributes>addDirectoryTextField-name1234
fg=red</panel_attributes>
<additional_attributes/>
</element>
<element>
<id>Relation</id>
<coordinates>
<x>430</x>
<y>840</y>
<x>380</x>
<y>790</y>
<w>450</w>
<h>60</h>
</coordinates>

@ -4,12 +4,10 @@ import com.olexyn.ensync.artifacts.SyncDirectory;
import com.olexyn.ensync.artifacts.SyncMap;
import java.io.File;
import java.util.Map;
public class Flow implements Runnable {
private String state;
@ -17,15 +15,14 @@ public class Flow implements Runnable{
initialize();
while (true) {
initialize();
for (var syncMapEntry : Main.SYNC.entrySet()) {
while (true) {
for (var syncDirectoryEntry : syncMapEntry.getValue().syncDirectories.entrySet()) {
SyncDirectory syncDirectory = syncDirectoryEntry.getValue();
@ -47,13 +44,15 @@ public class Flow implements Runnable{
}
}
try {
System.out.println("Pausing...");
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
}
}
}

@ -4,7 +4,6 @@ import com.olexyn.ensync.artifacts.SyncMap;
import com.olexyn.ensync.ui.UI;
import java.util.HashMap;
import java.util.Map;
public class Main{
@ -14,23 +13,23 @@ public class Main{
final public static Thread uiThread = new Thread(new UI(), "ui");
final public static Thread UI_THREAD = new Thread(new UI(), "ui");
final public static Thread flowThread = new Thread(new Flow(), "flow");
final public static Thread FLOW_THREAD = new Thread(new Flow(), "flow");
final public static Map<String, SyncMap> SYNC = new HashMap<>();
final public static HashMap<String, SyncMap> SYNC = new HashMap<>();
public static void main(String[] args) {
SYNC.put("test", new SyncMap("test"));
uiThread.start();
flowThread.start();
UI_THREAD.start();
FLOW_THREAD.start();

@ -0,0 +1,56 @@
package com.olexyn.ensync.ui;
import com.olexyn.ensync.artifacts.SyncMap;
import static com.olexyn.ensync.Main.SYNC;
import static com.olexyn.ensync.Main.FLOW_THREAD;
import static com.olexyn.ensync.Main.UI_THREAD;
import java.io.File;
/**
* Connect the Controller and the Flow
*/
public class Bridge {
void newCollection(String collectionName){
SYNC.put(collectionName, new SyncMap(collectionName));
}
void removeCollection(String collectionName){
SYNC.remove(collectionName);
}
void addDirectory(String collectionName, File diretory){
SYNC.get(collectionName).addDirectory(diretory.getAbsolutePath());
//TODO pause syning when adding
}
/**
* This works, because a directory, which here is an unique ablsolute path,
* is only supposed to present once across entire SYNC.
*/
void removeDirectory(String directoryAbsolutePath){
//TODO fix ConcurrentModificationException. This will possibly resolve further errors.
while (true) {
if (FLOW_THREAD.getState().equals(Thread.State.TIMED_WAITING)) {
try {
FLOW_THREAD.wait();
} catch (InterruptedException e) {
for (var syncMap : SYNC.entrySet()){
syncMap.getValue().removeDirectory(directoryAbsolutePath);
}
FLOW_THREAD.notify();
break;
}
}
}
}
}

@ -1,7 +1,6 @@
package com.olexyn.ensync.ui;
import com.olexyn.ensync.Main;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
@ -28,6 +27,10 @@ public class Controller implements Initializable {
final static int COLUMN_COUNT = 5; // How many columns should the GridPane have? Adjust if necessary.
final static Text SPACE = new Text(""); // Placeholder
int collection_count = 0;
Bridge bridge = new Bridge();
@FXML
protected GridPane gridPane;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
@ -53,14 +56,14 @@ public class Controller implements Initializable {
}
private void newCollection() {
private void newCollection() {
String collectionName = "name" + collection_count++;
bridge.newCollection(collectionName);
TextField collectionStateTextField = new TextField();
collectionStateTextField.setText("STATE");
@ -85,26 +88,33 @@ public class Controller implements Initializable {
List<Node> payload = new ArrayList<>();
payload.addAll(Arrays.asList(new Text(""), new Text(""), collectionStateTextField, new Text(""), removeCollectionButton));
payload.addAll(Arrays.asList(addDirectoryTextField, new Text(""), new Text(""), new Text(""), addDirectoryButton));
insertPayload(nodeList, payload, "newCollectionButton", -4);
redraw(gridPane, nodeList);
}
@FXML
protected GridPane gridPane;
/**
* For the order & number of Nodes see ui-design.png .
* Remove the "Remove-Collection-Line" and the consecutive lines until and including the "Add-Directory-Line".
* The !=null expression protects from Text("") placeholders, who have id==null.
*/
private void removeCollection(String collectionName) {
List<Node> nodeList = new ArrayList<>(gridPane.getChildren());
bridge.removeCollection(collectionName);
here : for (Node node : nodeList) {
List<Node> nodeList = new ArrayList<>(gridPane.getChildren());
here:
for (Node node : nodeList) {
if (node.getId() != null && node.getId().equals("removeCollectionButton-" + collectionName)) {
int i = nodeList.indexOf(node) - 4;
while (i < nodeList.size()) {
nodeList.remove(i);
if (nodeList.get(i).getId() != null && nodeList.get(i).getId().equals("addDirectoryButton-" + collectionName)) {
nodeList.remove(i);
break here;
@ -118,15 +128,6 @@ public class Controller implements Initializable {
}
private List<Node> fillBlanks() {
List<Node> out = new ArrayList<>();
return out;
}
/**
*
*/
@ -138,26 +139,28 @@ public class Controller implements Initializable {
directoryChooser.setTitle("Select Directory.");
directoryChooser.setInitialDirectory(new File(System.getProperty("user.home")));
File dir = directoryChooser.showDialog(stage);
File directory = directoryChooser.showDialog(stage);
if (directory != null) {
bridge.addDirectory(collectionName, directory);
if (dir != null) {
TextField directoryPathTextField = new TextField();
directoryPathTextField.setText(dir.getAbsolutePath());
directoryPathTextField.setText(directory.getAbsolutePath());
directoryPathTextField.setDisable(true);
directoryPathTextField.setId("directoryPathTextField-" + dir.getAbsolutePath());
directoryPathTextField.setId("directoryPathTextField-" + directory.getAbsolutePath());
// TODO for now there is only one SyncMap "test".
// Main.SYNC.get("test").addDirectory(dir.getAbsolutePath());
TextField directoryStateTextField = new TextField();
directoryStateTextField.setText("STATE");
directoryStateTextField.setStyle("-fx-text-fill: green");
directoryStateTextField.setDisable(true);
directoryStateTextField.setId("directoryStateTextField-" + dir.getAbsolutePath());
directoryStateTextField.setId("directoryStateTextField-" + directory.getAbsolutePath());
Button removeDirectoryButton = new Button("Remove");
removeDirectoryButton.setId("removeDirectoryButton-" + dir.getAbsolutePath());
removeDirectoryButton.setOnAction(event -> { this.removeDirectory(removeDirectoryButton.getId());});
removeDirectoryButton.setId("removeDirectoryButton-" + directory.getAbsolutePath());
removeDirectoryButton.setOnAction(event -> { this.removeDirectory(directory.getAbsolutePath());});
List<Node> nodeList = new ArrayList<>(gridPane.getChildren());
@ -196,32 +199,28 @@ public class Controller implements Initializable {
private void redraw(GridPane gridPane, List<Node> nodeList) {
gridPane.getChildren().clear();
int col = 0;
int row = 0;
int col = 0, row = 0;
for (Node node : nodeList) {
if ((nodeList.indexOf(node) + 0) % COLUMN_COUNT == 0) {
if (nodeList.indexOf(node) % COLUMN_COUNT == 0) {
row++;
col = 0;
}
gridPane.add(node, col, row);
col++;
}
}
private void removeDirectory(String id) {
private void removeDirectory(String directoryAbsolutePath) {
bridge.removeDirectory(directoryAbsolutePath);
List<Node> nodeList = new ArrayList<>(gridPane.getChildren());
//TODO fix ConcurrentModificationException. This will possibly resolve further errors.
for (Node node : nodeList) {
if (node.getId() != null && node.getId().equals(id)) {
if (node.getId() != null && node.getId().equals("removeDirectoryButton-" +directoryAbsolutePath)) {
int i = nodeList.indexOf(node) - 4;
for (int j = 0; j < 5; j++) {
nodeList.remove(i);
@ -229,39 +228,10 @@ public class Controller implements Initializable {
break;
}
}
redraw(gridPane, nodeList);
/*
String path = id.replace("removeButton", "");
while (true) {
if (Main.flowThread.getState().equals(Thread.State.TIMED_WAITING)) {
try {
Main.flowThread.wait();
} catch (InterruptedException e) {
Main.SYNC.get("test").removeDirectory(path);
Main.flowThread.notify();
break;
}
}
}
*/
}
}
class Placeholder extends Text{
static int count =0;
Placeholder(String label, String name){
super(label);
this.setId("placeholder-"+name+"-"+count++);
}
}

Loading…
Cancel
Save