Skip to content

Commit 357f1e1

Browse files
committed
Improvements
1 parent 049408f commit 357f1e1

File tree

15 files changed

+390
-286
lines changed

15 files changed

+390
-286
lines changed

.idea/GitCommitMessageStorage.xml

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Zylva is an enhanced entity-relationship (EER) model diagram application develop
44

55
> [!CAUTION]
66
>
7-
> This is still a pre-release, which may contain severe bugs.
8-
> Suggestions and contributions to possible improvements are highly appreciated!
7+
> The application has only been tested by me, its author.
8+
> It may contain severe bugs I haven't identified yet.
9+
> Suggestions and contributions to possible improvements are highly appreciated.
910
1011
# Easy and fast controls!
1112

@@ -65,8 +66,10 @@ java -jar .../ZylvaEERD.jar
6566
- Undo/Redo.
6667
- Normalization.
6768
- More languages.
69+
- Complete the documentation.
6870
- Adding more personalization tools.
6971
- Expanding the app to more types of diagrams.
72+
- Provide all possible derivations of a diagram.
7073
- Optimization and improvements in the performance.
7174
- Adding the possibility of using a command-line interface.
7275
- Adding the possibility of having various *tabs* open at the same time.

bdd/src/com/iroumec/bdd/EERDiagram.java

Lines changed: 171 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -35,152 +35,6 @@
3535

3636
public final class EERDiagram extends Diagram {
3737

38-
@Override
39-
protected boolean addingIsValid(@NotNull Component component) {
40-
41-
Set<Class<?>> allowedTypes = Set.of(
42-
Relationship.class, Cardinality.class, Hierarchy.class, Discriminant.class,
43-
EntityWrapper.class, Attribute.class, Association.class, Line.class, Note.class
44-
);
45-
46-
if (allowedTypes.stream().noneMatch(type -> type.isInstance(component))) {
47-
throw new IllegalArgumentException(
48-
"The component must be a type of \n" + allowedTypes
49-
+ "\nProvided: " + component.getClass().getName()
50-
);
51-
}
52-
53-
return true;
54-
}
55-
56-
@Override
57-
public JPopupMenu getBackgroundPopupMenu() {
58-
59-
JPopupMenu backgroundPopupMenu = new JPopupMenu();
60-
61-
JMenuItem addEntity = new JMenuItem(LanguageManager.getMessage("action.addEntity"));
62-
addEntity.addActionListener(_ -> {
63-
EntityWrapper.addEntity(this);
64-
cleanSelectedComponents();
65-
});
66-
67-
JMenuItem addRelationship = new JMenuItem(LanguageManager.getMessage("action.addRelationship"));
68-
addRelationship.addActionListener(_ -> {
69-
Relationship.addRelationship(this, this.getSelectedComponents());
70-
cleanSelectedComponents();
71-
});
72-
73-
JMenuItem addDependency = new JMenuItem(LanguageManager.getMessage("action.addDependency"));
74-
addDependency.addActionListener(_ -> {
75-
Relationship.addDependency(this, this.getSelectedComponents());
76-
cleanSelectedComponents();
77-
});
78-
79-
JMenuItem addHierarchy = new JMenuItem(LanguageManager.getMessage("action.addHierarchy"));
80-
addHierarchy.addActionListener(_ -> {
81-
Hierarchy.addHierarchy(this, this.getSelectedComponents());
82-
cleanSelectedComponents();
83-
});
84-
85-
JMenuItem addNote = new JMenuItem(LanguageManager.getMessage("action.addNote"));
86-
addNote.addActionListener(_ -> {
87-
Note.addNote(this);
88-
cleanSelectedComponents();
89-
});
90-
91-
backgroundPopupMenu.add(addEntity);
92-
backgroundPopupMenu.add(addRelationship);
93-
backgroundPopupMenu.add(addDependency);
94-
backgroundPopupMenu.add(addHierarchy);
95-
backgroundPopupMenu.add(addNote);
96-
97-
return backgroundPopupMenu;
98-
}
99-
100-
@Override
101-
public List<JButton> getMainFrameKeys() {
102-
103-
List<JButton> out = super.getMainFrameKeys();
104-
105-
JButton addEntityKey = new JButton();
106-
addEntityKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), "actionE");
107-
addEntityKey.getActionMap().put("actionE", new AbstractAction() {
108-
@Override
109-
public void actionPerformed(ActionEvent e) {
110-
EntityWrapper.addEntity(EERDiagram.this);
111-
EERDiagram.this.cleanSelectedComponents();
112-
}
113-
});
114-
out.add(addEntityKey);
115-
116-
JButton addRelationshipKey = new JButton();
117-
addRelationshipKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK), "actionR");
118-
addRelationshipKey.getActionMap().put("actionR", new AbstractAction() {
119-
@Override
120-
public void actionPerformed(ActionEvent e) {
121-
Relationship.addRelationship(EERDiagram.this, EERDiagram.this.getSelectedComponents());
122-
EERDiagram.this.cleanSelectedComponents();
123-
}
124-
});
125-
out.add(addRelationshipKey);
126-
127-
JButton addDependencyKey= new JButton();
128-
addDependencyKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), "actionD");
129-
addDependencyKey.getActionMap().put("actionD", new AbstractAction() {
130-
@Override
131-
public void actionPerformed(ActionEvent e) {
132-
Relationship.addDependency(EERDiagram.this, EERDiagram.this.getSelectedComponents());
133-
EERDiagram.this.cleanSelectedComponents();
134-
}
135-
});
136-
out.add(addDependencyKey);
137-
138-
JButton addHierarchyKey= new JButton();
139-
addHierarchyKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK), "actionH");
140-
addHierarchyKey.getActionMap().put("actionH", new AbstractAction() {
141-
@Override
142-
public void actionPerformed(ActionEvent e) {
143-
Hierarchy.addHierarchy(EERDiagram.this, EERDiagram.this.getSelectedComponents());
144-
EERDiagram.this.cleanSelectedComponents();
145-
}
146-
});
147-
out.add(addHierarchyKey);
148-
149-
JButton addNoteKey= new JButton();
150-
addNoteKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK), "actionN");
151-
addNoteKey.getActionMap().put("actionN", new AbstractAction() {
152-
@Override
153-
public void actionPerformed(ActionEvent e) {
154-
Note.addNote(EERDiagram.this);
155-
EERDiagram.this.cleanSelectedComponents();
156-
}
157-
});
158-
out.add(addNoteKey);
159-
160-
return out;
161-
}
162-
163-
@Override
164-
public List<Item> getFileMenuItems() {
165-
List<Item> out = super.getFileMenuItems();
166-
167-
Item derivate = new Item("fileMenu.derivate");
168-
derivate.addActionListener(_ -> this.derivate());
169-
out.add(derivate);
170-
171-
return out;
172-
}
173-
174-
@Override
175-
public List<ResourceBundle> getResourceBundles(Locale currentLocale) {
176-
177-
List<ResourceBundle> out = super.getResourceBundles(currentLocale);
178-
179-
out.add(ResourceBundle.getBundle("EERresources/messages", currentLocale));
180-
181-
return out;
182-
}
183-
18438
private void derivate() {
18539
Map<String, Derivation> derivations = new HashMap<>();
18640

@@ -351,17 +205,6 @@ private void extractConstraints(String referencing, String referenced,
351205
addReferencialIntegrityConstraint(constraint, constraints);
352206
}
353207

354-
@Override
355-
public String getControls() {
356-
357-
return "\nCtrl + E: " + LanguageManager.getMessage("control.addEntity")
358-
+ "\nCtrl + R: " + LanguageManager.getMessage("control.addRelationship")
359-
+ "\nCtrl + D: " + LanguageManager.getMessage("control.addDependency")
360-
+ "\nCtrl + H: " + LanguageManager.getMessage("control.addHierarchy")
361-
+ "\nCtrl + N: " + LanguageManager.getMessage("control.addNote")
362-
+ super.getControls();
363-
}
364-
365208
private void exportDerivationToHTML(Collection<Derivation> derivations, Collection<Constraint> constraints) {
366209

367210
JFileChooser fileChooser = new JFileChooser();
@@ -551,4 +394,175 @@ private static String getHTMLStyles() {
551394
</style>
552395
""";
553396
}
397+
398+
/* -------------------------------------------------------------------------------------------------------------- */
399+
/* Overridden Methods */
400+
/* -------------------------------------------------------------------------------------------------------------- */
401+
402+
@Override
403+
protected boolean addingIsValid(@NotNull Component component) {
404+
405+
Set<Class<?>> allowedTypes = Set.of(
406+
Relationship.class, Cardinality.class, Hierarchy.class, Discriminant.class,
407+
EntityWrapper.class, Attribute.class, Association.class, Line.class, Note.class
408+
);
409+
410+
if (allowedTypes.stream().noneMatch(type -> type.isInstance(component))) {
411+
throw new IllegalArgumentException(
412+
"The component must be a type of \n" + allowedTypes
413+
+ "\nProvided: " + component.getClass().getName()
414+
);
415+
}
416+
417+
return true;
418+
}
419+
420+
/* -------------------------------------------------------------------------------------------------------------- */
421+
422+
@Override
423+
public JPopupMenu getBackgroundPopupMenu() {
424+
425+
JPopupMenu backgroundPopupMenu = new JPopupMenu();
426+
427+
JMenuItem addEntity = new JMenuItem(LanguageManager.getMessage("action.addEntity"));
428+
addEntity.addActionListener(_ -> {
429+
EntityWrapper.addEntity(this);
430+
cleanSelectedComponents();
431+
});
432+
433+
JMenuItem addRelationship = new JMenuItem(LanguageManager.getMessage("action.addRelationship"));
434+
addRelationship.addActionListener(_ -> {
435+
Relationship.addRelationship(this, this.getSelectedComponents());
436+
cleanSelectedComponents();
437+
});
438+
439+
JMenuItem addDependency = new JMenuItem(LanguageManager.getMessage("action.addDependency"));
440+
addDependency.addActionListener(_ -> {
441+
Relationship.addDependency(this, this.getSelectedComponents());
442+
cleanSelectedComponents();
443+
});
444+
445+
JMenuItem addHierarchy = new JMenuItem(LanguageManager.getMessage("action.addHierarchy"));
446+
addHierarchy.addActionListener(_ -> {
447+
Hierarchy.addHierarchy(this, this.getSelectedComponents());
448+
cleanSelectedComponents();
449+
});
450+
451+
JMenuItem addNote = new JMenuItem(LanguageManager.getMessage("action.addNote"));
452+
addNote.addActionListener(_ -> {
453+
Note.addNote(this);
454+
cleanSelectedComponents();
455+
});
456+
457+
backgroundPopupMenu.add(addEntity);
458+
backgroundPopupMenu.add(addRelationship);
459+
backgroundPopupMenu.add(addDependency);
460+
backgroundPopupMenu.add(addHierarchy);
461+
backgroundPopupMenu.add(addNote);
462+
463+
return backgroundPopupMenu;
464+
}
465+
466+
/* -------------------------------------------------------------------------------------------------------------- */
467+
468+
@Override
469+
public List<Item> getFileMenuItems() {
470+
List<Item> out = super.getFileMenuItems();
471+
472+
Item derivate = new Item("fileMenu.derivate");
473+
derivate.addActionListener(_ -> this.derivate());
474+
out.add(derivate);
475+
476+
return out;
477+
}
478+
479+
/* -------------------------------------------------------------------------------------------------------------- */
480+
481+
@Override
482+
public List<ResourceBundle> getResourceBundles(Locale currentLocale) {
483+
484+
List<ResourceBundle> out = super.getResourceBundles(currentLocale);
485+
486+
out.add(ResourceBundle.getBundle("EERresources/messages", currentLocale));
487+
488+
return out;
489+
}
490+
491+
/* -------------------------------------------------------------------------------------------------------------- */
492+
493+
@Override
494+
public String getControls() {
495+
496+
return "\nCtrl + E: " + LanguageManager.getMessage("control.addEntity")
497+
+ "\nCtrl + R: " + LanguageManager.getMessage("control.addRelationship")
498+
+ "\nCtrl + D: " + LanguageManager.getMessage("control.addDependency")
499+
+ "\nCtrl + H: " + LanguageManager.getMessage("control.addHierarchy")
500+
+ "\nCtrl + N: " + LanguageManager.getMessage("control.addNote")
501+
+ super.getControls();
502+
}
503+
504+
/* -------------------------------------------------------------------------------------------------------------- */
505+
506+
@Override
507+
public List<JButton> getMainFrameKeys() {
508+
509+
List<JButton> out = super.getMainFrameKeys();
510+
511+
JButton addEntityKey = new JButton();
512+
addEntityKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), "actionE");
513+
addEntityKey.getActionMap().put("actionE", new AbstractAction() {
514+
@Override
515+
public void actionPerformed(ActionEvent e) {
516+
EntityWrapper.addEntity(EERDiagram.this);
517+
EERDiagram.this.cleanSelectedComponents();
518+
}
519+
});
520+
out.add(addEntityKey);
521+
522+
JButton addRelationshipKey = new JButton();
523+
addRelationshipKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK), "actionR");
524+
addRelationshipKey.getActionMap().put("actionR", new AbstractAction() {
525+
@Override
526+
public void actionPerformed(ActionEvent e) {
527+
Relationship.addRelationship(EERDiagram.this, EERDiagram.this.getSelectedComponents());
528+
EERDiagram.this.cleanSelectedComponents();
529+
}
530+
});
531+
out.add(addRelationshipKey);
532+
533+
JButton addDependencyKey= new JButton();
534+
addDependencyKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), "actionD");
535+
addDependencyKey.getActionMap().put("actionD", new AbstractAction() {
536+
@Override
537+
public void actionPerformed(ActionEvent e) {
538+
Relationship.addDependency(EERDiagram.this, EERDiagram.this.getSelectedComponents());
539+
EERDiagram.this.cleanSelectedComponents();
540+
}
541+
});
542+
out.add(addDependencyKey);
543+
544+
JButton addHierarchyKey= new JButton();
545+
addHierarchyKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK), "actionH");
546+
addHierarchyKey.getActionMap().put("actionH", new AbstractAction() {
547+
@Override
548+
public void actionPerformed(ActionEvent e) {
549+
Hierarchy.addHierarchy(EERDiagram.this, EERDiagram.this.getSelectedComponents());
550+
EERDiagram.this.cleanSelectedComponents();
551+
}
552+
});
553+
out.add(addHierarchyKey);
554+
555+
JButton addNoteKey= new JButton();
556+
addNoteKey.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK), "actionN");
557+
addNoteKey.getActionMap().put("actionN", new AbstractAction() {
558+
@Override
559+
public void actionPerformed(ActionEvent e) {
560+
Note.addNote(EERDiagram.this);
561+
EERDiagram.this.cleanSelectedComponents();
562+
}
563+
});
564+
out.add(addNoteKey);
565+
566+
return out;
567+
}
554568
}

0 commit comments

Comments
 (0)