diff --git a/pom.xml b/pom.xml
index 03458a1..301ea88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.walksocket
ebonyrack
- 0.2.1
+ 0.2.2
jar
ebonyrack
diff --git a/src/main/java/com/walksocket/er/component/main/root/Workspace.java b/src/main/java/com/walksocket/er/component/main/root/Workspace.java
index 02ee489..72f19ea 100644
--- a/src/main/java/com/walksocket/er/component/main/root/Workspace.java
+++ b/src/main/java/com/walksocket/er/component/main/root/Workspace.java
@@ -179,6 +179,15 @@ public void readData() {
readConnectorNoteToTable();
readConnectorNoteToSequence();
readConnectorTableToTable();
+
+ if (positionedTables.size() == 0
+ && positionedSequences.size() == 0
+ && positionedNotes.size() == 0
+ && positionedConnectorsNoteToTable.size() == 0
+ && positionedConnectorsNoteToSequence.size() == 0
+ && positionedConnectorsNoteToTable.size() == 0) {
+ root.setVisible(true);
+ }
}
/**
diff --git a/src/main/java/com/walksocket/er/component/startup/root/Project.java b/src/main/java/com/walksocket/er/component/startup/root/Project.java
index 708fcba..924bde0 100644
--- a/src/main/java/com/walksocket/er/component/startup/root/Project.java
+++ b/src/main/java/com/walksocket/er/component/startup/root/Project.java
@@ -124,6 +124,9 @@ private JPanel getDataPanel() {
// write
var buttonWrite = new JButton("Write");
+ if (!(new File(cfgProject.dbPath)).exists()) {
+ buttonWrite.setEnabled(false);
+ }
buttonWrite.setToolTipText("Write all data out to json file.");
buttonWrite.addActionListener(actionEvent -> {
try {
@@ -154,12 +157,13 @@ private JPanel getDataPanel() {
throw new IOException(
String.format("Fail to write out to '%s'.", f.getAbsolutePath()));
}
- JOptionPane.showMessageDialog(this,
- String.format("Saved json:
%s",
- f.getAbsolutePath()));
cfgProject.lastWriteOutPath = f.getAbsolutePath();
Config.save();
+
+ JOptionPane.showMessageDialog(this,
+ String.format("Saved json:
%s",
+ f.getAbsolutePath()));
}
} catch (IOException e) {
Log.error(e);
@@ -204,12 +208,17 @@ private JPanel getDataPanel() {
if (!Dump.readFrom(cfgProject, f.getAbsolutePath())) {
throw new IOException(String.format("Fail to read from '%s'.", f.getAbsolutePath()));
}
+
+ cfgProject.lastReadFromPath = f.getAbsolutePath();
+ Config.save();
+
JOptionPane.showMessageDialog(this,
String.format("Read json:
%s",
f.getAbsolutePath()));
- cfgProject.lastReadFromPath = f.getAbsolutePath();
- Config.save();
+ // enable
+ buttonOpenReadonly.setEnabled(true);
+ buttonWrite.setEnabled(true);
}
} catch (IOException e) {
Log.error(e);
diff --git a/src/main/java/com/walksocket/er/sqlite/Bucket.java b/src/main/java/com/walksocket/er/sqlite/Bucket.java
index 9364b4f..b154763 100644
--- a/src/main/java/com/walksocket/er/sqlite/Bucket.java
+++ b/src/main/java/com/walksocket/er/sqlite/Bucket.java
@@ -31,11 +31,13 @@ public class Bucket {
private static Bucket bucket;
/**
- * init.
+ * create ddl.
*
- * @param con con
+ * @param con connection
+ * @throws SQLException
+ * @throws IOException
*/
- public static void init(Connection con) {
+ public static void createDdl(Connection con) throws SQLException, IOException {
try (var stream = App.class.getClassLoader()
.getResourceAsStream("database/create.sql")) {
// ----------
@@ -57,6 +59,19 @@ public static void init(Connection con) {
con.execute(q);
}
}
+ }
+ }
+
+
+ /**
+ * init.
+ *
+ * @param con con
+ */
+ public static void init(Connection con) {
+ try {
+ // ----------
+ createDdl(con);
// ----------
con.begin();
diff --git a/src/main/java/com/walksocket/er/sqlite/Dump.java b/src/main/java/com/walksocket/er/sqlite/Dump.java
index be4bca9..caab94c 100644
--- a/src/main/java/com/walksocket/er/sqlite/Dump.java
+++ b/src/main/java/com/walksocket/er/sqlite/Dump.java
@@ -46,7 +46,7 @@ public class Dump {
/**
* extension.
*/
- public static String EXTENSION = "ebjson";
+ public static String EXTENSION = "erjson";
/**
* classes.
@@ -123,6 +123,8 @@ public static boolean writeOut(CfgProject cfgProject, String path) {
*/
public static boolean readFrom(CfgProject cfgProject, String path) {
try (var con = new Connection(cfgProject.dbPath)) {
+ Bucket.createDdl(con);
+
con.begin();
var tmpClasses = new ArrayList<>(classes);