Skip to content

Commit

Permalink
Version 0.2.2.
Browse files Browse the repository at this point in the history
* Modify new project invisible.
* Modify 'Write' and 'Read'.
  • Loading branch information
shigenobu committed Nov 30, 2023
1 parent d928bc3 commit 3fec9ab
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.walksocket</groupId>
<artifactId>ebonyrack</artifactId>
<version>0.2.1</version>
<version>0.2.2</version>
<packaging>jar</packaging>

<name>ebonyrack</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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("<html>Saved json:<br /><u>%s</u></html>",
f.getAbsolutePath()));

cfgProject.lastWriteOutPath = f.getAbsolutePath();
Config.save();

JOptionPane.showMessageDialog(this,
String.format("<html>Saved json:<br /><u>%s</u></html>",
f.getAbsolutePath()));
}
} catch (IOException e) {
Log.error(e);
Expand Down Expand Up @@ -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("<html>Read json:<br /><u>%s</u></html>",
f.getAbsolutePath()));

cfgProject.lastReadFromPath = f.getAbsolutePath();
Config.save();
// enable
buttonOpenReadonly.setEnabled(true);
buttonWrite.setEnabled(true);
}
} catch (IOException e) {
Log.error(e);
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/com/walksocket/er/sqlite/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
// ----------
Expand All @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/walksocket/er/sqlite/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Dump {
/**
* extension.
*/
public static String EXTENSION = "ebjson";
public static String EXTENSION = "erjson";

/**
* classes.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3fec9ab

Please sign in to comment.