diff --git a/pom.xml b/pom.xml
index 3926ebb..fc232a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,8 +24,14 @@
0.0.4
nl.andrewlalis.crystalkeep.CrystalKeep
+ crystalkeep.exe
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
@@ -40,14 +46,6 @@
javafx-fxml
${javafx.version}
-
-
- org.projectlombok
- lombok
- 1.18.20
- provided
- true
-
org.junit.jupiter
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
new file mode 100644
index 0000000..a2d95fd
--- /dev/null
+++ b/src/main/java/module-info.java
@@ -0,0 +1,8 @@
+module crystalkeep {
+ requires javafx.fxml;
+ requires javafx.controls;
+
+ opens nl.andrewlalis.crystalkeep;
+
+ exports nl.andrewlalis.crystalkeep.control to javafx.fxml;
+}
\ No newline at end of file
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/CrystalKeep.java b/src/main/java/nl/andrewlalis/crystalkeep/CrystalKeep.java
index 7d06dba..d978a34 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/CrystalKeep.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/CrystalKeep.java
@@ -22,7 +22,7 @@ public class CrystalKeep extends Application {
@Override
public void start(Stage stage) throws Exception {
- URL url = CrystalKeep.class.getClassLoader().getResource("ui/crystalkeep.fxml");
+ URL url = getClass().getResource("/nl/andrewlalis/crystalkeep/ui/crystalkeep.fxml");
FXMLLoader loader = new FXMLLoader(url);
Model model = new Model();
var scene = new Scene(loader.load());
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/Cluster.java b/src/main/java/nl/andrewlalis/crystalkeep/model/Cluster.java
index 72fa186..4f2f313 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/Cluster.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/Cluster.java
@@ -1,28 +1,37 @@
package nl.andrewlalis.crystalkeep.model;
-import lombok.Getter;
-import lombok.Setter;
-
import java.util.*;
-@Getter
public class Cluster implements Comparable, CrystalItem {
- @Setter
private String name;
private final Set shards;
private final Set clusters;
- @Setter
- private Cluster parent;
- public Cluster(String name, Set shards, Set clusters, Cluster parent) {
+ public Cluster(String name, Set shards, Set clusters) {
this.name = name;
this.shards = shards;
this.clusters = clusters;
- this.parent = parent;
}
public Cluster(String name) {
- this(name, new HashSet<>(), new HashSet<>(), null);
+ this(name, new HashSet<>(), new HashSet<>());
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Set getShards() {
+ return shards;
+ }
+
+ public Set getClusters() {
+ return clusters;
}
public void addShard(Shard shard) {
@@ -31,7 +40,6 @@ public class Cluster implements Comparable, CrystalItem {
public void addCluster(Cluster cluster) {
this.clusters.add(cluster);
- cluster.setParent(this);
}
public List getClustersOrdered() {
@@ -56,12 +64,12 @@ public class Cluster implements Comparable, CrystalItem {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Cluster cluster = (Cluster) o;
- return getName().equals(cluster.getName()) && Objects.equals(getParent(), cluster.getParent());
+ return getName().equals(cluster.getName());
}
@Override
public int hashCode() {
- return Objects.hash(getName(), getParent());
+ return Objects.hash(getName());
}
@Override
@@ -80,6 +88,6 @@ public class Cluster implements Comparable, CrystalItem {
@Override
public String getIconPath() {
- return "ui/images/cluster_node_icon.png";
+ return "/nl/andrewlalis/crystalkeep/ui/images/cluster_node_icon.png";
}
}
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/Model.java b/src/main/java/nl/andrewlalis/crystalkeep/model/Model.java
index 3f02fc1..cf57180 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/Model.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/Model.java
@@ -1,16 +1,18 @@
package nl.andrewlalis.crystalkeep.model;
-import lombok.Getter;
import java.util.HashSet;
import java.util.Set;
-@Getter
public class Model {
private Cluster activeCluster;
private final Set listeners = new HashSet<>();
+ public Cluster getActiveCluster() {
+ return activeCluster;
+ }
+
public void addListener(ModelListener listener) {
this.listeners.add(listener);
}
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/Shard.java b/src/main/java/nl/andrewlalis/crystalkeep/model/Shard.java
index a73f159..f57b616 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/Shard.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/Shard.java
@@ -1,7 +1,5 @@
package nl.andrewlalis.crystalkeep.model;
-import lombok.Getter;
-import lombok.Setter;
import nl.andrewlalis.crystalkeep.model.shards.ShardType;
import java.time.LocalDateTime;
@@ -17,9 +15,7 @@ import java.util.Objects;
* decide which shard type to deserialize.
*
*/
-@Getter
public abstract class Shard implements Comparable, CrystalItem {
- @Setter
private String name;
private final LocalDateTime createdAt;
private final ShardType type;
@@ -30,6 +26,23 @@ public abstract class Shard implements Comparable, CrystalItem {
this.type = type;
}
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public LocalDateTime getCreatedAt() {
+ return createdAt;
+ }
+
+ public ShardType getType() {
+ return type;
+ }
+
@Override
public int compareTo(Shard o) {
int r = this.getName().compareTo(o.getName());
@@ -57,6 +70,6 @@ public abstract class Shard implements Comparable, CrystalItem {
@Override
public String getIconPath() {
- return "ui/images/shard_node_icon.png";
+ return "/nl/andrewlalis/crystalkeep/ui/images/shard_node_icon.png";
}
}
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterLoader.java b/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterLoader.java
index d38d5e0..71e47da 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterLoader.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterLoader.java
@@ -15,7 +15,7 @@ public class ClusterLoader {
public Cluster loadDefault() throws IOException {
InputStream is = new FileInputStream(DEFAULT_CLUSTER.toFile());
- return ClusterSerializer.readCluster(is, null);
+ return ClusterSerializer.readCluster(is);
}
public void saveDefault(Cluster cluster) throws IOException {
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializer.java b/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializer.java
index de9e58d..ac451dd 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializer.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializer.java
@@ -39,20 +39,12 @@ public class ClusterSerializer {
*/
public static void writeCluster(Cluster cluster, OutputStream os) throws IOException {
ByteUtils.writeLengthPrefixed(cluster.getName(), os);
-
os.write(ByteUtils.toBytes(cluster.getClusters().size()));
- Cluster[] children = new Cluster[cluster.getClusters().size()];
- cluster.getClusters().toArray(children);
- Arrays.sort(children);
- for (Cluster child : children) {
+ for (Cluster child : cluster.getClustersOrdered()) {
writeCluster(child, os);
}
-
os.write(ByteUtils.toBytes(cluster.getShards().size()));
- Shard[] shards = new Shard[cluster.getShards().size()];
- cluster.getShards().toArray(shards);
- Arrays.sort(shards);
- for (Shard shard : shards) {
+ for (Shard shard : cluster.getShardsOrdered()) {
writeShard(shard, os);
}
}
@@ -60,16 +52,15 @@ public class ClusterSerializer {
/**
* Reads a cluster from an input stream.
* @param is The input stream to read from.
- * @param parent The parent cluster of this cluster. This may be null.
* @return The cluster that was read.
* @throws IOException If data could not be read from the stream.
*/
- public static Cluster readCluster(InputStream is, Cluster parent) throws IOException {
+ public static Cluster readCluster(InputStream is) throws IOException {
String name = ByteUtils.readLengthPrefixedString(is);
- Cluster cluster = new Cluster(name, new HashSet<>(), new HashSet<>(), parent);
+ Cluster cluster = new Cluster(name, new HashSet<>(), new HashSet<>());
int childCount = toInt(is.readNBytes(4));
for (int i = 0; i < childCount; i++) {
- cluster.addCluster(readCluster(is, cluster));
+ cluster.addCluster(readCluster(is));
}
int shardCount = toInt(is.readNBytes(4));
for (int i = 0; i < shardCount; i++) {
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/shards/LoginCredentialsShard.java b/src/main/java/nl/andrewlalis/crystalkeep/model/shards/LoginCredentialsShard.java
index baa3720..984d5eb 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/shards/LoginCredentialsShard.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/shards/LoginCredentialsShard.java
@@ -1,7 +1,5 @@
package nl.andrewlalis.crystalkeep.model.shards;
-import lombok.Getter;
-import lombok.Setter;
import nl.andrewlalis.crystalkeep.model.Shard;
import nl.andrewlalis.crystalkeep.model.serialization.ByteUtils;
import nl.andrewlalis.crystalkeep.model.serialization.ShardSerializer;
@@ -10,8 +8,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
-@Getter
-@Setter
public class LoginCredentialsShard extends Shard {
private String username;
private String password;
@@ -22,6 +18,22 @@ public class LoginCredentialsShard extends Shard {
this.password = password;
}
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
@Override
public String toString() {
return super.toString() + ", username=\"" + this.username + "\", password=\"" + this.password + "\"";
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/shards/ShardType.java b/src/main/java/nl/andrewlalis/crystalkeep/model/shards/ShardType.java
index 6ec3a4b..62a8827 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/shards/ShardType.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/shards/ShardType.java
@@ -1,6 +1,5 @@
package nl.andrewlalis.crystalkeep.model.shards;
-import lombok.Getter;
import nl.andrewlalis.crystalkeep.model.Shard;
/**
@@ -22,13 +21,16 @@ public enum ShardType {
*/
LOGIN_CREDENTIALS(2);
- @Getter
private final int value;
ShardType(int value) {
this.value = value;
}
+ public int getValue() {
+ return value;
+ }
+
public static ShardType valueOf(int value) {
for (var type : values()) {
if (type.getValue() == value) return type;
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/model/shards/TextShard.java b/src/main/java/nl/andrewlalis/crystalkeep/model/shards/TextShard.java
index 7ab6c08..47bfdf9 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/model/shards/TextShard.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/model/shards/TextShard.java
@@ -1,7 +1,5 @@
package nl.andrewlalis.crystalkeep.model.shards;
-import lombok.Getter;
-import nl.andrewlalis.crystalkeep.model.Cluster;
import nl.andrewlalis.crystalkeep.model.Shard;
import nl.andrewlalis.crystalkeep.model.serialization.ByteUtils;
import nl.andrewlalis.crystalkeep.model.serialization.ShardSerializer;
@@ -10,7 +8,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
-@Getter
public class TextShard extends Shard {
private String text;
@@ -19,6 +16,14 @@ public class TextShard extends Shard {
this.text = text;
}
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
@Override
public String toString() {
return super.toString() + ", text=\"" + this.text + "\"";
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/view/ClusterTreeItem.java b/src/main/java/nl/andrewlalis/crystalkeep/view/ClusterTreeItem.java
index 9245c6f..f17606e 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/view/ClusterTreeItem.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/view/ClusterTreeItem.java
@@ -1,21 +1,18 @@
package nl.andrewlalis.crystalkeep.view;
import javafx.scene.control.TreeItem;
-import javafx.scene.image.ImageView;
-import lombok.Getter;
import nl.andrewlalis.crystalkeep.model.Cluster;
import nl.andrewlalis.crystalkeep.model.CrystalItem;
public class ClusterTreeItem extends TreeItem {
- @Getter
private final Cluster cluster;
public ClusterTreeItem(Cluster cluster) {
super(cluster);
this.cluster = cluster;
- ImageView clusterIcon = new ImageView("ui/images/cluster_node_icon.png");
- clusterIcon.setFitHeight(16);
- clusterIcon.setPreserveRatio(true);
- super.setGraphic(clusterIcon);
+ }
+
+ public Cluster getCluster() {
+ return cluster;
}
}
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/view/CrystalItemTreeCell.java b/src/main/java/nl/andrewlalis/crystalkeep/view/CrystalItemTreeCell.java
index c18bbcf..859ed74 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/view/CrystalItemTreeCell.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/view/CrystalItemTreeCell.java
@@ -3,10 +3,13 @@ package nl.andrewlalis.crystalkeep.view;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TreeCell;
+import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import nl.andrewlalis.crystalkeep.model.CrystalItem;
import nl.andrewlalis.crystalkeep.model.Shard;
+import java.io.InputStream;
+
public class CrystalItemTreeCell extends TreeCell {
private final ContextMenu contextMenu;
@@ -21,10 +24,13 @@ public class CrystalItemTreeCell extends TreeCell {
if (!empty) {
this.setText(item.getName());
- ImageView icon = new ImageView(item.getIconPath());
- icon.setFitHeight(16);
- icon.setPreserveRatio(true);
- this.setGraphic(icon);
+ InputStream is = getClass().getResourceAsStream(item.getIconPath());
+ if (is != null) {
+ ImageView icon = new ImageView(new Image(is));
+ icon.setFitHeight(16);
+ icon.setPreserveRatio(true);
+ this.setGraphic(icon);
+ }
if (item instanceof Shard) {
this.setContextMenu(this.contextMenu);
}
diff --git a/src/main/java/nl/andrewlalis/crystalkeep/view/ShardTreeItem.java b/src/main/java/nl/andrewlalis/crystalkeep/view/ShardTreeItem.java
index 9ec06a5..09121e0 100644
--- a/src/main/java/nl/andrewlalis/crystalkeep/view/ShardTreeItem.java
+++ b/src/main/java/nl/andrewlalis/crystalkeep/view/ShardTreeItem.java
@@ -1,16 +1,18 @@
package nl.andrewlalis.crystalkeep.view;
import javafx.scene.control.TreeItem;
-import lombok.Getter;
import nl.andrewlalis.crystalkeep.model.CrystalItem;
import nl.andrewlalis.crystalkeep.model.Shard;
public class ShardTreeItem extends TreeItem {
- @Getter
private final Shard shard;
public ShardTreeItem(Shard shard) {
super(shard);
this.shard = shard;
}
+
+ public Shard getShard() {
+ return shard;
+ }
}
diff --git a/src/main/resources/ui/clusters_view.fxml b/src/main/resources/nl/andrewlalis/crystalkeep/ui/clusters_view.fxml
similarity index 100%
rename from src/main/resources/ui/clusters_view.fxml
rename to src/main/resources/nl/andrewlalis/crystalkeep/ui/clusters_view.fxml
diff --git a/src/main/resources/ui/crystalkeep.fxml b/src/main/resources/nl/andrewlalis/crystalkeep/ui/crystalkeep.fxml
similarity index 100%
rename from src/main/resources/ui/crystalkeep.fxml
rename to src/main/resources/nl/andrewlalis/crystalkeep/ui/crystalkeep.fxml
diff --git a/src/main/resources/ui/images/cluster_node_icon.png b/src/main/resources/nl/andrewlalis/crystalkeep/ui/images/cluster_node_icon.png
similarity index 100%
rename from src/main/resources/ui/images/cluster_node_icon.png
rename to src/main/resources/nl/andrewlalis/crystalkeep/ui/images/cluster_node_icon.png
diff --git a/src/main/resources/ui/images/shard_node_icon.png b/src/main/resources/nl/andrewlalis/crystalkeep/ui/images/shard_node_icon.png
similarity index 100%
rename from src/main/resources/ui/images/shard_node_icon.png
rename to src/main/resources/nl/andrewlalis/crystalkeep/ui/images/shard_node_icon.png
diff --git a/src/test/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializerTest.java b/src/test/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializerTest.java
index 8248f8a..7af4f6a 100644
--- a/src/test/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializerTest.java
+++ b/src/test/java/nl/andrewlalis/crystalkeep/model/serialization/ClusterSerializerTest.java
@@ -17,6 +17,10 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
+/**
+ * Tests the functionality of the {@link ClusterSerializer}, which handles
+ * transforming key model components to and from byte arrays for storage.
+ */
public class ClusterSerializerTest {
private static List testShardIOData() {
return List.of(
@@ -92,7 +96,7 @@ public class ClusterSerializerTest {
"Cluster name does not match expected."
);
- Cluster loaded = ClusterSerializer.readCluster(new ByteArrayInputStream(data), null);
+ Cluster loaded = ClusterSerializer.readCluster(new ByteArrayInputStream(data));
assertEquals(c, loaded, "Loaded cluster should equal original cluster.");
bos.reset();
ClusterSerializer.writeCluster(loaded, bos);