Cleaned up adding attributes slightly, made attribute types more readable.

This commit is contained in:
Andrew Lalis 2021-02-08 18:18:43 +01:00
parent cac3381c54
commit f541a994b9
3 changed files with 24 additions and 8 deletions

View File

@ -44,6 +44,7 @@ public class AddAttributeAction extends AbstractAction {
return;
}
Relation r = selectedRelations.get(0);
Attribute createdAttribute;
Component c = (Component) e.getSource();
String name = JOptionPane.showInputDialog(c, "Enter the name of the attribute.", "Attribute Name", JOptionPane.PLAIN_MESSAGE);
if (name == null) return;
@ -105,11 +106,11 @@ public class AddAttributeAction extends AbstractAction {
eligibleAttributes.toArray(new Attribute[0]),
eligibleAttributes.get(0)
);
if (fkAttribute != null) {
r.addAttribute(new ForeignKeyAttribute(r, type, name, fkAttribute), index);
}
if (fkAttribute == null) return;
createdAttribute = new ForeignKeyAttribute(r, type, name, fkAttribute);
} else {
r.addAttribute(new Attribute(r, type, name), index);
createdAttribute = new Attribute(r, type, name);
}
r.addAttribute(createdAttribute, index);
}
}

View File

@ -31,8 +31,9 @@ public class AddRelationAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
Component c = (Component) e.getSource();
String name = JOptionPane.showInputDialog(
(Component) e.getSource(),
c,
"Enter the name of the relation.",
"Add Relation",
JOptionPane.PLAIN_MESSAGE

View File

@ -1,7 +1,21 @@
package nl.andrewlalis.erme.model;
import lombok.Getter;
public enum AttributeType {
PLAIN,
ID_KEY,
PARTIAL_ID_KEY
PLAIN("Plain"),
ID_KEY("Identifier"),
PARTIAL_ID_KEY("Partial Identifier");
@Getter
private final String name;
AttributeType(String name) {
this.name = name;
}
@Override
public String toString() {
return this.getName();
}
}