diff --git a/pom.xml b/pom.xml
index e3f01f0..3803775 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,17 +6,43 @@
nl.andrewlalis
EntityRelationMappingEditor
- 1.0-SNAPSHOT
+ 1.0.0
org.apache.maven.plugins
maven-compiler-plugin
+ 3.8.1
8
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.1.1
+
+
+
+ nl.andrewlalis.erme.EntityRelationMappingEditor
+
+
+
+ jar-with-dependencies
+
+ false
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
diff --git a/src/main/java/nl/andrewlalis/erme/EntityRelationMappingEditor.java b/src/main/java/nl/andrewlalis/erme/EntityRelationMappingEditor.java
index 6d98ac4..797af34 100644
--- a/src/main/java/nl/andrewlalis/erme/EntityRelationMappingEditor.java
+++ b/src/main/java/nl/andrewlalis/erme/EntityRelationMappingEditor.java
@@ -4,6 +4,7 @@ import com.formdev.flatlaf.FlatLightLaf;
import nl.andrewlalis.erme.view.EditorFrame;
public class EntityRelationMappingEditor {
+ public static final String VERSION = "1.0.0";
public static void main(String[] args) {
if (!FlatLightLaf.install()) {
diff --git a/src/main/java/nl/andrewlalis/erme/control/actions/ExitAction.java b/src/main/java/nl/andrewlalis/erme/control/actions/ExitAction.java
index 7361ca1..fdeb888 100644
--- a/src/main/java/nl/andrewlalis/erme/control/actions/ExitAction.java
+++ b/src/main/java/nl/andrewlalis/erme/control/actions/ExitAction.java
@@ -1,6 +1,7 @@
package nl.andrewlalis.erme.control.actions;
import javax.swing.*;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
@@ -23,6 +24,15 @@ public class ExitAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
- System.exit(0);
+ int choice = JOptionPane.showConfirmDialog(
+ (Component) e.getSource(),
+ "Are you sure you want to quit?\nAll unsaved data will be lost.",
+ "Confirm Exit",
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE
+ );
+ if (choice == JOptionPane.OK_OPTION) {
+ System.exit(0);
+ }
}
}
diff --git a/src/main/java/nl/andrewlalis/erme/control/actions/ExportToImageAction.java b/src/main/java/nl/andrewlalis/erme/control/actions/ExportToImageAction.java
index 74803b7..0a24b23 100644
--- a/src/main/java/nl/andrewlalis/erme/control/actions/ExportToImageAction.java
+++ b/src/main/java/nl/andrewlalis/erme/control/actions/ExportToImageAction.java
@@ -42,6 +42,15 @@ public class ExportToImageAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
+ if (this.model.getRelations().isEmpty()) {
+ JOptionPane.showMessageDialog(
+ (Component) e.getSource(),
+ "Model is empty. Add some relations before exporting to an image.",
+ "Model Empty",
+ JOptionPane.WARNING_MESSAGE
+ );
+ return;
+ }
JFileChooser fileChooser = new JFileChooser(this.lastSelectedFile);
fileChooser.setFileFilter(new FileNameExtensionFilter(
"Image files", ImageIO.getReaderFileSuffixes()
diff --git a/src/main/java/nl/andrewlalis/erme/control/actions/RedoAction.java b/src/main/java/nl/andrewlalis/erme/control/actions/RedoAction.java
index ab59821..26efda8 100644
--- a/src/main/java/nl/andrewlalis/erme/control/actions/RedoAction.java
+++ b/src/main/java/nl/andrewlalis/erme/control/actions/RedoAction.java
@@ -16,7 +16,7 @@ public class RedoAction extends AbstractAction {
}
public RedoAction() {
- super("Redo");
+ super("Redo (WIP)");
this.putValue(Action.SHORT_DESCRIPTION, "Redoes a previously undone action.");
this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
this.setEnabled(false);
diff --git a/src/main/java/nl/andrewlalis/erme/control/actions/UndoAction.java b/src/main/java/nl/andrewlalis/erme/control/actions/UndoAction.java
index 727403d..c1030ac 100644
--- a/src/main/java/nl/andrewlalis/erme/control/actions/UndoAction.java
+++ b/src/main/java/nl/andrewlalis/erme/control/actions/UndoAction.java
@@ -16,7 +16,7 @@ public class UndoAction extends AbstractAction {
}
public UndoAction() {
- super("Undo");
+ super("Undo (WIP)");
this.putValue(Action.SHORT_DESCRIPTION, "Undo the last action.");
this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK));
this.setEnabled(false);
diff --git a/src/main/java/nl/andrewlalis/erme/view/EditorFrame.java b/src/main/java/nl/andrewlalis/erme/view/EditorFrame.java
index b37b36a..c4d06bb 100644
--- a/src/main/java/nl/andrewlalis/erme/view/EditorFrame.java
+++ b/src/main/java/nl/andrewlalis/erme/view/EditorFrame.java
@@ -1,6 +1,6 @@
package nl.andrewlalis.erme.view;
-import nl.andrewlalis.erme.model.*;
+import nl.andrewlalis.erme.model.MappingModel;
import javax.swing.*;
import java.awt.*;
@@ -11,23 +11,10 @@ import java.awt.*;
public class EditorFrame extends JFrame {
public EditorFrame() {
super("ER-Mapping Editor");
- MappingModel model = new MappingModel();
- Relation usersRelation = new Relation(model, new Point(50, 50), "Users");
- usersRelation.addAttribute(new Attribute(usersRelation, AttributeType.ID_KEY, "username"));
- usersRelation.addAttribute(new Attribute(usersRelation, AttributeType.PLAIN, "fullName"));
- usersRelation.addAttribute(new Attribute(usersRelation, AttributeType.PLAIN, "language"));
- usersRelation.addAttribute(new Attribute(usersRelation, AttributeType.PLAIN, "verified"));
- usersRelation.addAttribute(new Attribute(usersRelation, AttributeType.PARTIAL_ID_KEY, "partialKey"));
- model.addRelation(usersRelation);
- Relation tokensRelation = new Relation(model, new Point(50, 120), "Tokens");
- tokensRelation.addAttribute(new Attribute(tokensRelation, AttributeType.ID_KEY, "tokenCode"));
- tokensRelation.addAttribute(new ForeignKeyAttribute(tokensRelation, AttributeType.PLAIN, "username", "Users", "username"));
- tokensRelation.addAttribute(new Attribute(tokensRelation, AttributeType.PLAIN, "expirationDate"));
- model.addRelation(tokensRelation);
-
- this.setContentPane(new DiagramPanel(model));
+ this.setContentPane(new DiagramPanel(new MappingModel()));
this.setJMenuBar(new EditorMenuBar());
- this.setMinimumSize(new Dimension(500, 500));
+ this.setMinimumSize(new Dimension(400, 400));
+ this.setPreferredSize(new Dimension(800, 800));
this.pack();
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setLocationRelativeTo(null);
diff --git a/src/main/java/nl/andrewlalis/erme/view/EditorMenuBar.java b/src/main/java/nl/andrewlalis/erme/view/EditorMenuBar.java
index 5d5d67c..0d290a2 100644
--- a/src/main/java/nl/andrewlalis/erme/view/EditorMenuBar.java
+++ b/src/main/java/nl/andrewlalis/erme/view/EditorMenuBar.java
@@ -1,5 +1,6 @@
package nl.andrewlalis.erme.view;
+import nl.andrewlalis.erme.EntityRelationMappingEditor;
import nl.andrewlalis.erme.control.actions.*;
import nl.andrewlalis.erme.control.actions.edits.AddAttributeAction;
import nl.andrewlalis.erme.control.actions.edits.AddRelationAction;
@@ -7,6 +8,9 @@ import nl.andrewlalis.erme.control.actions.edits.RemoveAttributeAction;
import nl.andrewlalis.erme.control.actions.edits.RemoveRelationAction;
import javax.swing.*;
+import java.awt.*;
+import java.io.IOException;
+import java.net.URI;
/**
* The menu bar that's visible atop the application.
@@ -44,7 +48,28 @@ public class EditorMenuBar extends JMenuBar {
private JMenu buildHelpMenu() {
JMenu menu = new JMenu("Help");
- menu.add("About");
+ JMenuItem instructionsItem = new JMenuItem("GitHub (Instructions)");
+ instructionsItem.addActionListener(e -> {
+ try {
+ Desktop.getDesktop().browse(URI.create("https://github.com/andrewlalis/EntityRelationMappingEditor"));
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
+ }
+ });
+ menu.add(instructionsItem);
+ JMenuItem aboutItem = new JMenuItem("About");
+ aboutItem.addActionListener(e -> JOptionPane.showMessageDialog(
+ (Component) e.getSource(),
+ "Entity-Relation Mapping Editor\n" +
+ "by Andrew Lalis\n" +
+ "Version " + EntityRelationMappingEditor.VERSION + "\n" +
+ "To report bugs or make suggestions, please visit the GitHub\n" +
+ "repository for this application and create a new issue.\n\n" +
+ "Thank you for using the ERME!",
+ "About ERME",
+ JOptionPane.INFORMATION_MESSAGE
+ ));
+ menu.add(aboutItem);
return menu;
}
}