MVC partie 2 + résolution de bugs
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
#Tue Apr 20 14:42:09 CEST 2021
|
#Thu Apr 22 12:13:10 CEST 2021
|
||||||
version=1.0.0
|
version=1.0.0
|
||||||
showHomeAtStartup=true
|
showHomeAtStartup=true
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.thinkode.appthinker.controllers;
|
||||||
|
|
||||||
|
import com.thinkode.appthinker.models.Argument;
|
||||||
|
import com.thinkode.appthinker.models.Method;
|
||||||
|
import com.thinkode.appthinker.views.ArgumentsPropertiesWindow;
|
||||||
|
|
||||||
|
public class ArgumentsPropertiesController {
|
||||||
|
|
||||||
|
private ArgumentsPropertiesWindow _argumentsPropertiesWindow;
|
||||||
|
private UmlDiagramController _umlDiagramController;
|
||||||
|
private ClassPropertiesController _classPropertiesController;
|
||||||
|
private Method _method;
|
||||||
|
|
||||||
|
public ArgumentsPropertiesController(UmlDiagramController umlDiagramController, ClassPropertiesController classPropertiesController, Method method) {
|
||||||
|
_umlDiagramController = umlDiagramController;
|
||||||
|
_classPropertiesController = classPropertiesController;
|
||||||
|
_method = method;
|
||||||
|
_argumentsPropertiesWindow = new ArgumentsPropertiesWindow();
|
||||||
|
_argumentsPropertiesWindow.setController(this);
|
||||||
|
_argumentsPropertiesWindow.initializeGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethodName() {
|
||||||
|
return _method.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute un argument à la méthode sélectionnée et rafraîchit la liste des arguments.
|
||||||
|
*/
|
||||||
|
public void addArgument() {
|
||||||
|
_argumentsPropertiesWindow.save();
|
||||||
|
_method.addArgument(new Argument());
|
||||||
|
_classPropertiesController.computeMinSize();
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
refreshArguments();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retire un argument à la méthode et rafraîchit la liste des arguments.
|
||||||
|
*/
|
||||||
|
public void removeArgument(int index) {
|
||||||
|
if (index != -1) {
|
||||||
|
_argumentsPropertiesWindow.save();
|
||||||
|
_method.removeArgument(index);
|
||||||
|
_classPropertiesController.computeMinSize();
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
refreshArguments();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monte l'argument
|
||||||
|
*/
|
||||||
|
public void goUpArgument(int index) {
|
||||||
|
if (_method.upArgument(index)) {
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
refreshArguments();
|
||||||
|
_argumentsPropertiesWindow.selectArgument(index - 1);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Baisse l'argument
|
||||||
|
*/
|
||||||
|
public void goDownArgument(int index) {
|
||||||
|
if (_method.downArgument(index)) {
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
refreshArguments();
|
||||||
|
_argumentsPropertiesWindow.selectArgument(index + 1);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshArguments() {
|
||||||
|
_argumentsPropertiesWindow.listArguments(_method.getArguments());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sauvegarde les modifications pour la méthode en cours et ferme la fenêtre.
|
||||||
|
*/
|
||||||
|
public void save(int index, String type, String name) {
|
||||||
|
_method.getArguments().get(index).setType(type);
|
||||||
|
_method.getArguments().get(index).setName(name);
|
||||||
|
//Rafraichissement de l'affichage
|
||||||
|
_classPropertiesController.computeMinSize();
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,264 @@
|
|||||||
|
package com.thinkode.appthinker.controllers;
|
||||||
|
|
||||||
|
import com.thinkode.appthinker.models.Argument;
|
||||||
|
import com.thinkode.appthinker.models.Attribute;
|
||||||
|
import com.thinkode.appthinker.models.Method;
|
||||||
|
import com.thinkode.appthinker.views.ClassPropertiesWindow;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class ClassPropertiesController {
|
||||||
|
|
||||||
|
private ClassPropertiesWindow _classPropertiesWindow;
|
||||||
|
private UmlDiagramController _umlDiagramController;
|
||||||
|
private com.thinkode.appthinker.models.Class _class;
|
||||||
|
|
||||||
|
public ClassPropertiesController(UmlDiagramController umlDiagramController, com.thinkode.appthinker.models.Class c) {
|
||||||
|
_class = c;
|
||||||
|
_umlDiagramController = umlDiagramController;
|
||||||
|
_classPropertiesWindow = new ClassPropertiesWindow();
|
||||||
|
_classPropertiesWindow.setController(this);
|
||||||
|
_classPropertiesWindow.initializeGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Donne à l'interface le nom de la classe
|
||||||
|
*/
|
||||||
|
public String getClassName() {
|
||||||
|
return _class.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paramètre la classe en cours d'édition comme classe principale
|
||||||
|
*/
|
||||||
|
public void setMainClass() {
|
||||||
|
_umlDiagramController.setMainClass(_class);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
refreshGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne si la classe en cours d'édition est la classe principale
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isMainClass() {
|
||||||
|
return _umlDiagramController.getMainClass() == _class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recalcule les dimensions minimum de la classe
|
||||||
|
*/
|
||||||
|
public void computeMinSize() {
|
||||||
|
_class.computeMinSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute un attribut à la classe et rafraîchit la liste des attributs.
|
||||||
|
*/
|
||||||
|
public void addAttribute() {
|
||||||
|
_classPropertiesWindow.saveAttributes();
|
||||||
|
_class.addAttribute(new Attribute());
|
||||||
|
refreshAttributes();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
refreshGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retire un attribut à la classe et rafraîchit la liste des attributs.
|
||||||
|
*/
|
||||||
|
public void removeAttribute(int index) {
|
||||||
|
if (index != -1) {
|
||||||
|
_classPropertiesWindow.saveAttributes();
|
||||||
|
_class.removeAttribute(index);
|
||||||
|
refreshAttributes();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
refreshGraphics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sauvegarde les informations d'un attribut
|
||||||
|
*/
|
||||||
|
public void saveAttribute(int index, String name, String access, String type, boolean isStatic, boolean isFinal, boolean isAbstract, boolean isSynchronized, boolean isVolatile, boolean isTransient) {
|
||||||
|
_class.getAttributes().get(index).setName(name);
|
||||||
|
_class.getAttributes().get(index).setAccess(access);
|
||||||
|
_class.getAttributes().get(index).setType(type);
|
||||||
|
_class.getAttributes().get(index).setStatic(isStatic);
|
||||||
|
_class.getAttributes().get(index).setFinal(isFinal);
|
||||||
|
_class.getAttributes().get(index).setAbstract(isAbstract);
|
||||||
|
_class.getAttributes().get(index).setSynchronized(isSynchronized);
|
||||||
|
_class.getAttributes().get(index).setVolatile(isVolatile);
|
||||||
|
_class.getAttributes().get(index).setTransient(isTransient);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go up the selected attribute
|
||||||
|
*/
|
||||||
|
public void goUpAttribute(int attributeRow) {
|
||||||
|
if (_class.upAttribute(attributeRow)) {
|
||||||
|
refreshGraphics();
|
||||||
|
refreshAttributes();
|
||||||
|
_classPropertiesWindow.selectAttribute(attributeRow - 1);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go down the selected attribute
|
||||||
|
*/
|
||||||
|
public void goDownAttribute(int attributeRow) {
|
||||||
|
if (_class.downAttribute(attributeRow)) {
|
||||||
|
refreshGraphics();
|
||||||
|
refreshAttributes();
|
||||||
|
_classPropertiesWindow.selectAttribute(attributeRow + 1);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the arguments properties window
|
||||||
|
*/
|
||||||
|
public void openArgumentsWindow(int methodRow) {
|
||||||
|
new ArgumentsPropertiesController(_umlDiagramController, this, _class.getMethods().get(methodRow));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh attributes
|
||||||
|
*/
|
||||||
|
public void refreshAttributes() {
|
||||||
|
_classPropertiesWindow.listAttributes(_class.getAttributes());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh methods
|
||||||
|
*/
|
||||||
|
public void refreshMethods() {
|
||||||
|
_classPropertiesWindow.listMethods(_class.getMethods());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute une méthode à la classe et rafraîchit la liste des méthodes.
|
||||||
|
*/
|
||||||
|
public void addMethod() {
|
||||||
|
_classPropertiesWindow.saveMethods();
|
||||||
|
_class.addMethod(new Method());
|
||||||
|
refreshMethods();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
refreshGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute une méthode à la classe à une position donnée et rafraîchit la liste des attributs.
|
||||||
|
*/
|
||||||
|
public void addMethod(int index) {
|
||||||
|
_classPropertiesWindow.saveMethods();
|
||||||
|
_class.addMethod(index, new Method());
|
||||||
|
refreshMethods();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
refreshGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute une méthode à la classe à une position donnée et rafraîchit la liste des attributs.
|
||||||
|
*/
|
||||||
|
private void addMethod(int index, Method m) {
|
||||||
|
_classPropertiesWindow.saveMethods();
|
||||||
|
_class.addMethod(index, m);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
refreshMethods();
|
||||||
|
refreshGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retire une méthode à la classe et rafraîchit la liste des méthodes.
|
||||||
|
*/
|
||||||
|
public void removeMethod(int index) {
|
||||||
|
if (index != -1) {
|
||||||
|
_classPropertiesWindow.saveMethods();
|
||||||
|
_class.removeMethod(index);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
refreshMethods();
|
||||||
|
refreshGraphics();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sauvegarde les informations d'une méthode
|
||||||
|
*/
|
||||||
|
public void saveMethod(int index, boolean isConstructor, String name, String access, String type, boolean isStatic, boolean isFinal, boolean isAbstract, boolean isSynchronized, boolean isVolatile, boolean isTransient) {
|
||||||
|
_class.getMethods().get(index).setConstructor(isConstructor);
|
||||||
|
_class.getMethods().get(index).setName(name);
|
||||||
|
_class.getMethods().get(index).setAccess(access);
|
||||||
|
_class.getMethods().get(index).setType(type);
|
||||||
|
_class.getMethods().get(index).setStatic(isStatic);
|
||||||
|
_class.getMethods().get(index).setFinal(isFinal);
|
||||||
|
_class.getMethods().get(index).setAbstract(isAbstract);
|
||||||
|
_class.getMethods().get(index).setSynchronized(isSynchronized);
|
||||||
|
_class.getMethods().get(index).setVolatile(isVolatile);
|
||||||
|
_class.getMethods().get(index).setTransient(isTransient);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Monter une méthode
|
||||||
|
*/
|
||||||
|
public void goUpMethod(int methodRow) {
|
||||||
|
if (_class.upMethod(methodRow)) {
|
||||||
|
refreshGraphics();
|
||||||
|
refreshMethods();
|
||||||
|
_classPropertiesWindow.selectMethod(methodRow - 1);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Baisser une méthode
|
||||||
|
*/
|
||||||
|
public void goDownMethod(int methodRow) {
|
||||||
|
if (_class.downMethod(methodRow)) {
|
||||||
|
refreshGraphics();
|
||||||
|
refreshMethods();
|
||||||
|
_classPropertiesWindow.selectMethod(methodRow + 1);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Surcharge la méthode sélectionnée
|
||||||
|
*/
|
||||||
|
public void overloadMethod(int index) {
|
||||||
|
if (index != -1) {
|
||||||
|
Method m = _class.getMethods().get(index);
|
||||||
|
java.util.List<Argument> args = new ArrayList<Argument>();
|
||||||
|
//On ajoute un argument de plus que la méthode à surcharger
|
||||||
|
args.addAll(m.getArguments());
|
||||||
|
args.add(new Argument());
|
||||||
|
Method m1 = new Method(m.getAccess(), m.getType(), m.getName(), args, m.isConstructor(), m.isStatic(), m.isFinal(), m.isAbstract(), m.isSynchronized(), m.isVolatile(), m.isTransient());
|
||||||
|
addMethod(index + 1, m1);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
//this.openArgumentsWindow(m1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sauvegarde l'ensemble de la classe.
|
||||||
|
*/
|
||||||
|
public void saveClass(String name) {
|
||||||
|
//Changement du nom de la classe
|
||||||
|
_class.setName(name);
|
||||||
|
//Sauvegarde des attributs et méthodes
|
||||||
|
_classPropertiesWindow.saveAttributes();
|
||||||
|
_classPropertiesWindow.saveMethods();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rafraîchit la classe graphiquement.
|
||||||
|
*/
|
||||||
|
public void refreshGraphics() {
|
||||||
|
this._class.computeMinSize();
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package com.thinkode.appthinker.controllers;
|
||||||
|
|
||||||
|
import com.thinkode.appthinker.models.Link;
|
||||||
|
import com.thinkode.appthinker.views.LinkPropertiesWindow;
|
||||||
|
|
||||||
|
public class LinkPropertiesController {
|
||||||
|
|
||||||
|
private LinkPropertiesWindow _linkPropertiesWindow;
|
||||||
|
private UmlDiagramController _umlDiagramController;
|
||||||
|
private Link _link;
|
||||||
|
|
||||||
|
public LinkPropertiesController(UmlDiagramController umlDiagramController, Link link) {
|
||||||
|
_umlDiagramController = umlDiagramController;
|
||||||
|
_link = link;
|
||||||
|
_linkPropertiesWindow = new LinkPropertiesWindow();
|
||||||
|
_linkPropertiesWindow.setController(this);
|
||||||
|
_linkPropertiesWindow.initializeGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLinkName() {
|
||||||
|
return _link.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkName(String name) {
|
||||||
|
_link.setName(name);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLinkStartName() {
|
||||||
|
return _link.getStart().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLinkEndName() {
|
||||||
|
return _link.getEnd().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Link.LinkType getLinkType() {
|
||||||
|
return _link.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkType(Link.LinkType type) {
|
||||||
|
_link.setType(type);
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
_linkPropertiesWindow.fillWindow();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLinkId() {
|
||||||
|
return _link.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLinkMinCardinalityStart() {
|
||||||
|
return _link.getMinCardinalityStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLinkMaxCardinalityStart() {
|
||||||
|
return _link.getMaxCardinalityStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getLinkMinCardinalityEnd() {
|
||||||
|
return _link.getMinCardinalityEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLinkMaxCardinalityEnd() {
|
||||||
|
return _link.getMaxCardinalityEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkMinCardinalityStart(int card) {
|
||||||
|
_link.setMinCardinalityStart(card);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkMaxCardinalityStart(int card) {
|
||||||
|
_link.setMaxCardinalityStart(card);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setLinkMinCardinalityEnd(int card) {
|
||||||
|
_link.setMinCardinalityEnd(card);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkMaxCardinalityEnd(int card) {
|
||||||
|
_link.setMaxCardinalityEnd(card);
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchDirection() {
|
||||||
|
_link.switchDirection();
|
||||||
|
_linkPropertiesWindow.save();
|
||||||
|
_linkPropertiesWindow.fillWindow();
|
||||||
|
_umlDiagramController.needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rafraîchit l'affichage.
|
||||||
|
*/
|
||||||
|
public void refresh() {
|
||||||
|
//Rafraîchissement du diagramme
|
||||||
|
_linkPropertiesWindow.repaint();
|
||||||
|
_umlDiagramController.refreshGraphics();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,8 +13,8 @@ public class UmlDiagramController {
|
|||||||
private UmlDiagram _umlDiagram;
|
private UmlDiagram _umlDiagram;
|
||||||
|
|
||||||
public UmlDiagramController(UmlDiagramFrame umlDiagramFrame, UmlDiagram umlDiagram) {
|
public UmlDiagramController(UmlDiagramFrame umlDiagramFrame, UmlDiagram umlDiagram) {
|
||||||
_umlDiagram = umlDiagram;
|
|
||||||
_umlDiagramFrame = umlDiagramFrame;
|
_umlDiagramFrame = umlDiagramFrame;
|
||||||
|
_umlDiagram = umlDiagram;
|
||||||
_umlDiagramFrame.setController(this);
|
_umlDiagramFrame.setController(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,10 +28,12 @@ public class UmlDiagramController {
|
|||||||
|
|
||||||
public void removeClass(Class a) {
|
public void removeClass(Class a) {
|
||||||
_umlDiagram.removeClass(a);
|
_umlDiagram.removeClass(a);
|
||||||
|
needToSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearClasses() {
|
public void clearClasses() {
|
||||||
_umlDiagram.clearClasses();
|
_umlDiagram.clearClasses();
|
||||||
|
needToSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Link> getLinksList() {
|
public List<Link> getLinksList() {
|
||||||
@@ -42,12 +44,64 @@ public class UmlDiagramController {
|
|||||||
return _umlDiagram.getMainClass();
|
return _umlDiagram.getMainClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMainClass(Class c) {
|
||||||
|
_umlDiagram.setMainClass(c);
|
||||||
|
}
|
||||||
|
|
||||||
public void addClass(int posX, int posY) {
|
public void addClass(int posX, int posY) {
|
||||||
_umlDiagram.addClass(new Class(posX, posY));
|
_umlDiagram.addClass(new Class(posX, posY));
|
||||||
|
needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resizeUp(Class a, int posY) {
|
||||||
|
a.resizeUp(posY);
|
||||||
|
needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resizeRight(Class a, int posX) {
|
||||||
|
a.resizeRight(posX);
|
||||||
|
needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resizeDown(Class a, int posY) {
|
||||||
|
a.resizeDown(posY);
|
||||||
|
needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resizeLeft(Class a, int posX) {
|
||||||
|
a.resizeLeft(posX);
|
||||||
|
needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosX(Class a, int posX) {
|
||||||
|
a.setPosX(posX);
|
||||||
|
needToSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosY(Class a, int posY) {
|
||||||
|
a.setPosY(posY);
|
||||||
|
needToSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLink(Class start, Class end, UmlDiagramFrame.ClassGrip gripStart, UmlDiagramFrame.ClassGrip gripEnd, int minCardStart, int maxCardStart, int minCardEnd, int maxCardEnd, Link.LinkType type) {
|
public void addLink(Class start, Class end, UmlDiagramFrame.ClassGrip gripStart, UmlDiagramFrame.ClassGrip gripEnd, int minCardStart, int maxCardStart, int minCardEnd, int maxCardEnd, Link.LinkType type) {
|
||||||
_umlDiagram.addLink(new Link(start, end, gripStart, gripEnd, minCardStart, maxCardStart, minCardEnd, maxCardEnd, type));
|
_umlDiagram.addLink(new Link(start, end, gripStart, gripEnd, minCardStart, maxCardStart, minCardEnd, maxCardEnd, type));
|
||||||
|
needToSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void needToSave() {
|
||||||
|
_umlDiagram.needsToSave(true);
|
||||||
|
_umlDiagramFrame.needWorkspaceRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshGraphics() {
|
||||||
|
_umlDiagramFrame.redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showClassWindow(Class c) {
|
||||||
|
new ClassPropertiesController(this, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showLinkWindow(Link l) {
|
||||||
|
new LinkPropertiesController(this, l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import com.thinkode.appthinker.views.HomeFrame;
|
|||||||
import com.thinkode.appthinker.views.UmlDiagramFrame;
|
import com.thinkode.appthinker.views.UmlDiagramFrame;
|
||||||
import com.thinkode.appthinker.views.Window;
|
import com.thinkode.appthinker.views.Window;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -40,10 +41,12 @@ public class WindowController {
|
|||||||
* Ouvre une composition dans la fenêtre
|
* Ouvre une composition dans la fenêtre
|
||||||
*/
|
*/
|
||||||
public void openComposition(int projectListId, int compositionListId) {
|
public void openComposition(int projectListId, int compositionListId) {
|
||||||
UmlDiagramFrame frame = new UmlDiagramFrame();
|
Composition composition = _projects.get(projectListId).getCompositions().get(compositionListId);
|
||||||
UmlDiagram comp = (UmlDiagram) _projects.get(projectListId).getCompositions().get(compositionListId);
|
if (composition instanceof UmlDiagram) {
|
||||||
UmlDiagramController umlController = new UmlDiagramController(frame, comp);
|
UmlDiagramFrame frame = new UmlDiagramFrame();
|
||||||
_atWindow.addCompositionFrame(comp.getName(), _projects.get(projectListId).getName(), frame);
|
new UmlDiagramController(frame, (UmlDiagram) composition);
|
||||||
|
_atWindow.addCompositionFrame(composition.getName(), _projects.get(projectListId).getName(), frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,6 +108,11 @@ public class WindowController {
|
|||||||
*/
|
*/
|
||||||
public void deleteProject(int projectListId) {
|
public void deleteProject(int projectListId) {
|
||||||
Project project = _projects.get(projectListId);
|
Project project = _projects.get(projectListId);
|
||||||
|
//Si le projet doit être sauvegardé
|
||||||
|
if (askForProjectSaved(project)) {
|
||||||
|
int response = _atWindow.showMessage("The project has not yet been saved or contains unsaved compositions. Do you want to save it before closing it ?", "Save before closing", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
if (response == JOptionPane.OK_OPTION) saveProject(projectListId);
|
||||||
|
}
|
||||||
for (Composition comp : project.getCompositions()) {
|
for (Composition comp : project.getCompositions()) {
|
||||||
deleteCompositionFrame(project.getName(), comp.getName());
|
deleteCompositionFrame(project.getName(), comp.getName());
|
||||||
}
|
}
|
||||||
@@ -229,13 +237,37 @@ public class WindowController {
|
|||||||
return _projects;
|
return _projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne le nom du projet sélectionné dans le Workspace
|
||||||
|
*/
|
||||||
|
public String getProjectName(int projectListId) {
|
||||||
|
return _projects.get(projectListId).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne si le projet nécessite d'être sauvegardé ou non
|
||||||
|
*/
|
||||||
|
public boolean askForProjectSaved(Project project) {
|
||||||
|
if (project.getPath() == null || project.isNeededToSave()) return true;
|
||||||
|
for (Composition comp : project.getCompositions()) {
|
||||||
|
if (comp.isNeededToSave()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne le nom de la composition sélectionnée dans le Workspace
|
||||||
|
*/
|
||||||
|
public String getCompositionName(int projectListId, int compositionListId) {
|
||||||
|
return _projects.get(projectListId).getCompositions().get(compositionListId).getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sauvegarder le projet
|
* Sauvegarder le projet
|
||||||
*/
|
*/
|
||||||
public void saveProject(int projectListId) {
|
public void saveProject(int projectListId) {
|
||||||
System.out.println("test");
|
|
||||||
_projects.get(projectListId).saveProject();
|
_projects.get(projectListId).saveProject();
|
||||||
|
refreshWorkspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -243,13 +275,26 @@ public class WindowController {
|
|||||||
*/
|
*/
|
||||||
public void saveAsProject(int projectListId) {
|
public void saveAsProject(int projectListId) {
|
||||||
_projects.get(projectListId).saveAsProject();
|
_projects.get(projectListId).saveAsProject();
|
||||||
|
refreshWorkspace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vérifie si la fenêtre contient des projets non-enregistrés avant la fermeture
|
||||||
|
*/
|
||||||
|
public boolean askForExit() {
|
||||||
|
boolean allProjectsSaved = true;
|
||||||
|
for (Project p : _projects) {
|
||||||
|
if (askForProjectSaved(p)) allProjectsSaved = false;
|
||||||
|
}
|
||||||
|
System.out.println(allProjectsSaved);
|
||||||
|
if (!allProjectsSaved) {
|
||||||
|
if (_atWindow.showMessage("The window contains unsaved projects. Do you want to force close ?", "Force closure ?", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.OK_OPTION)
|
||||||
|
return true;
|
||||||
|
else return false;
|
||||||
|
} else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Méthodes relatives à la barre de menu
|
//Méthodes relatives à la barre de menu
|
||||||
public void exitApplication() {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void launchAboutWindow() {
|
public void launchAboutWindow() {
|
||||||
AboutWindowController _atAboutWindowController = new AboutWindowController(new AboutWindow());
|
AboutWindowController _atAboutWindowController = new AboutWindowController(new AboutWindow());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class Composition implements Serializable {
|
|||||||
|
|
||||||
protected int _id;
|
protected int _id;
|
||||||
protected String _name;
|
protected String _name;
|
||||||
|
protected boolean _needToSave = true;
|
||||||
|
|
||||||
public Composition() {
|
public Composition() {
|
||||||
_id = _compositionId++;
|
_id = _compositionId++;
|
||||||
@@ -33,6 +34,7 @@ public class Composition implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
_name = name;
|
_name = name;
|
||||||
|
needsToSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,4 +45,20 @@ public class Composition implements Serializable {
|
|||||||
public int getId() {
|
public int getId() {
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne si la composition a besoin d'être sauvegardée
|
||||||
|
*
|
||||||
|
* @return Un booléen représentant l'affirmation
|
||||||
|
*/
|
||||||
|
public boolean isNeededToSave() {
|
||||||
|
return _needToSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inscrit si la composition a besoin d'être sauvegardée ou non
|
||||||
|
*/
|
||||||
|
public void needsToSave(boolean save) {
|
||||||
|
_needToSave = save;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class Project implements Serializable {
|
|||||||
private String _designation;
|
private String _designation;
|
||||||
private String _path;
|
private String _path;
|
||||||
private List<Composition> _compositions;
|
private List<Composition> _compositions;
|
||||||
|
protected boolean _needToSave = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur - Crée une instance de Projet.
|
* Constructeur - Crée une instance de Projet.
|
||||||
@@ -92,6 +93,7 @@ public class Project implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this._name = name;
|
this._name = name;
|
||||||
|
needsToSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,6 +112,7 @@ public class Project implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public void setAuthor(String author) {
|
public void setAuthor(String author) {
|
||||||
this._author = author;
|
this._author = author;
|
||||||
|
needsToSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -128,6 +131,7 @@ public class Project implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public void setVersion(String version) {
|
public void setVersion(String version) {
|
||||||
this._version = version;
|
this._version = version;
|
||||||
|
needsToSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,6 +150,7 @@ public class Project implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public void setDesignation(String designation) {
|
public void setDesignation(String designation) {
|
||||||
this._designation = designation;
|
this._designation = designation;
|
||||||
|
needsToSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,6 +169,7 @@ public class Project implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public void setPath(String path) {
|
public void setPath(String path) {
|
||||||
this._path = path;
|
this._path = path;
|
||||||
|
needsToSave(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,8 +198,13 @@ public class Project implements Serializable {
|
|||||||
try {
|
try {
|
||||||
final FileOutputStream fichier = new FileOutputStream(path);
|
final FileOutputStream fichier = new FileOutputStream(path);
|
||||||
oos = new ObjectOutputStream(fichier);
|
oos = new ObjectOutputStream(fichier);
|
||||||
|
for (Composition comp : this.getCompositions()) {
|
||||||
|
comp.needsToSave(false);
|
||||||
|
}
|
||||||
|
this.needsToSave(false);
|
||||||
oos.writeObject(this);
|
oos.writeObject(this);
|
||||||
oos.flush();
|
oos.flush();
|
||||||
|
|
||||||
} catch (final java.io.IOException e) {
|
} catch (final java.io.IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -236,6 +247,10 @@ public class Project implements Serializable {
|
|||||||
try {
|
try {
|
||||||
final FileOutputStream fichier = new FileOutputStream(path);
|
final FileOutputStream fichier = new FileOutputStream(path);
|
||||||
oos = new ObjectOutputStream(fichier);
|
oos = new ObjectOutputStream(fichier);
|
||||||
|
for (Composition comp : this.getCompositions()) {
|
||||||
|
comp.needsToSave(false);
|
||||||
|
}
|
||||||
|
this.needsToSave(false);
|
||||||
oos.writeObject(this);
|
oos.writeObject(this);
|
||||||
oos.flush();
|
oos.flush();
|
||||||
} catch (final java.io.IOException e) {
|
} catch (final java.io.IOException e) {
|
||||||
@@ -253,4 +268,20 @@ public class Project implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne si le projet a besoin d'être sauvegardé
|
||||||
|
*
|
||||||
|
* @return Un booléen représentant l'affirmation
|
||||||
|
*/
|
||||||
|
public boolean isNeededToSave() {
|
||||||
|
return _needToSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inscrit si le projet a besoin d'être sauvegardée ou non
|
||||||
|
*/
|
||||||
|
public void needsToSave(boolean save) {
|
||||||
|
_needToSave = save;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.thinkode.appthinker.views;
|
package com.thinkode.appthinker.views;
|
||||||
|
|
||||||
import com.thinkode.appthinker.AppThinker;
|
import com.thinkode.appthinker.AppThinker;
|
||||||
|
import com.thinkode.appthinker.controllers.ArgumentsPropertiesController;
|
||||||
import com.thinkode.appthinker.models.Argument;
|
import com.thinkode.appthinker.models.Argument;
|
||||||
import com.thinkode.appthinker.models.Method;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -22,21 +22,22 @@ import java.util.Vector;
|
|||||||
*/
|
*/
|
||||||
public class ArgumentsPropertiesWindow extends JDialog {
|
public class ArgumentsPropertiesWindow extends JDialog {
|
||||||
|
|
||||||
private UmlDiagramFrame _umlDiagram;
|
private ArgumentsPropertiesController _argumentsPropertiesController;
|
||||||
private Method _method;
|
|
||||||
private JTable _argumentsTable;
|
private JTable _argumentsTable;
|
||||||
private JScrollPane _scrollArguments;
|
private JScrollPane _scrollArguments;
|
||||||
private String[] _argumentsColumns = {"Name", "Type"};
|
private String[] _argumentsColumns = {"Name", "Type"};
|
||||||
private DefaultTableModel _argumentModel;
|
private DefaultTableModel _argumentModel;
|
||||||
private ClassPropertiesWindow _classProp;
|
|
||||||
|
|
||||||
public ArgumentsPropertiesWindow(ClassPropertiesWindow classProp, UmlDiagramFrame diagram, Method m) {
|
public ArgumentsPropertiesWindow() {
|
||||||
_method = m;
|
}
|
||||||
_umlDiagram = diagram;
|
|
||||||
_classProp = classProp;
|
|
||||||
|
|
||||||
|
public void setController(ArgumentsPropertiesController argumentsPropertiesController) {
|
||||||
|
_argumentsPropertiesController = argumentsPropertiesController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initializeGraphics() {
|
||||||
//Paramétrage de la fenêtre
|
//Paramétrage de la fenêtre
|
||||||
this.setTitle("Edit arguments - " + m.getName());
|
this.setTitle("Edit arguments - " + _argumentsPropertiesController.getMethodName());
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
this.setSize(new Dimension(800, 375));
|
this.setSize(new Dimension(800, 375));
|
||||||
Image img = null;
|
Image img = null;
|
||||||
@@ -75,7 +76,7 @@ public class ArgumentsPropertiesWindow extends JDialog {
|
|||||||
addArgument.addActionListener(new ActionListener() {
|
addArgument.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
addArgument();
|
_argumentsPropertiesController.addArgument();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
argumentsTableModifier.add(addArgument);
|
argumentsTableModifier.add(addArgument);
|
||||||
@@ -84,7 +85,7 @@ public class ArgumentsPropertiesWindow extends JDialog {
|
|||||||
removeArgument.addActionListener(new ActionListener() {
|
removeArgument.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
removeArgument();
|
_argumentsPropertiesController.removeArgument(_argumentsTable.getSelectedRow());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
argumentsTableModifier.add(removeArgument);
|
argumentsTableModifier.add(removeArgument);
|
||||||
@@ -93,12 +94,7 @@ public class ArgumentsPropertiesWindow extends JDialog {
|
|||||||
upArgument.addActionListener(new ActionListener() {
|
upArgument.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int selected = _argumentsTable.getSelectedRow();
|
_argumentsPropertiesController.goUpArgument(_argumentsTable.getSelectedRow());
|
||||||
if (_method.upArgument(selected)) {
|
|
||||||
_umlDiagram.repaint();
|
|
||||||
listArguments();
|
|
||||||
_argumentsTable.setRowSelectionInterval(selected - 1, selected - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
argumentsTableModifier.add(upArgument);
|
argumentsTableModifier.add(upArgument);
|
||||||
@@ -107,12 +103,7 @@ public class ArgumentsPropertiesWindow extends JDialog {
|
|||||||
downArgument.addActionListener(new ActionListener() {
|
downArgument.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int selected = _argumentsTable.getSelectedRow();
|
_argumentsPropertiesController.goDownArgument(_argumentsTable.getSelectedRow());
|
||||||
if (_method.downArgument(selected)) {
|
|
||||||
_umlDiagram.repaint();
|
|
||||||
listArguments();
|
|
||||||
_argumentsTable.setRowSelectionInterval(selected + 1, selected + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
argumentsTableModifier.add(downArgument);
|
argumentsTableModifier.add(downArgument);
|
||||||
@@ -124,7 +115,7 @@ public class ArgumentsPropertiesWindow extends JDialog {
|
|||||||
this.add(generalPanel, BorderLayout.CENTER);
|
this.add(generalPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
//Import des arguments dans le tableau
|
//Import des arguments dans le tableau
|
||||||
this.listArguments();
|
_argumentsPropertiesController.refreshArguments();
|
||||||
|
|
||||||
this.addWindowListener(new WindowListener() {
|
this.addWindowListener(new WindowListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -168,40 +159,21 @@ public class ArgumentsPropertiesWindow extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajoute un argument à la méthode sélectionnée et rafraîchit la liste des arguments.
|
* Sélectionne une ligne du tableau d'arguments
|
||||||
*/
|
*/
|
||||||
public void addArgument() {
|
public void selectArgument(int index) {
|
||||||
save();
|
_argumentsTable.setRowSelectionInterval(index, index);
|
||||||
_method.addArgument(new Argument());
|
|
||||||
_classProp.getEditingClass().computeMinSize();
|
|
||||||
_umlDiagram.repaint();
|
|
||||||
this.listArguments();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retire un argument à la méthode et rafraîchit la liste des arguments.
|
|
||||||
*/
|
|
||||||
public void removeArgument() {
|
|
||||||
int i = _argumentsTable.getSelectedRow();
|
|
||||||
if (i != -1) {
|
|
||||||
save();
|
|
||||||
_method.removeArgument(i);
|
|
||||||
_classProp.getEditingClass().computeMinSize();
|
|
||||||
_umlDiagram.repaint();
|
|
||||||
this.listArguments();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Affiche la liste des arguments de la méthode dans le tableau
|
* Affiche la liste des arguments de la méthode dans le tableau
|
||||||
*/
|
*/
|
||||||
public void listArguments() {
|
public void listArguments(java.util.List<Argument> arguments) {
|
||||||
//Import des attributs dans la table
|
//Import des attributs dans la table
|
||||||
_argumentModel.setDataVector((Object[][]) null, _argumentsColumns);
|
_argumentModel.setDataVector((Object[][]) null, _argumentsColumns);
|
||||||
for (Argument arg : _method.getArguments()) {
|
for (Argument arg : arguments) {
|
||||||
_argumentModel.addRow(new Object[]{arg.getName(), arg.getType()});
|
_argumentModel.addRow(new Object[]{arg.getName(), arg.getType()});
|
||||||
}
|
}
|
||||||
|
|
||||||
//On ajoute les contrôles pour chaque colonne
|
//On ajoute les contrôles pour chaque colonne
|
||||||
JComboBox typeComboBox = new JComboBox();
|
JComboBox typeComboBox = new JComboBox();
|
||||||
typeComboBox.setEditable(true);
|
typeComboBox.setEditable(true);
|
||||||
@@ -227,12 +199,7 @@ public class ArgumentsPropertiesWindow extends JDialog {
|
|||||||
//Enregistrement des attributs
|
//Enregistrement des attributs
|
||||||
for (int i = 0; i <= _argumentModel.getRowCount() - 1; i++) {
|
for (int i = 0; i <= _argumentModel.getRowCount() - 1; i++) {
|
||||||
Vector vect = (Vector) _argumentModel.getDataVector().elementAt(i);
|
Vector vect = (Vector) _argumentModel.getDataVector().elementAt(i);
|
||||||
System.out.println(vect);
|
_argumentsPropertiesController.save(i, vect.get(1).toString(), vect.get(0).toString());
|
||||||
_method.getArguments().get(i).setType(vect.get(1).toString());
|
|
||||||
_method.getArguments().get(i).setName(vect.get(0).toString());
|
|
||||||
}
|
}
|
||||||
//Rafraichissement de l'affichage
|
|
||||||
_classProp.getEditingClass().computeMinSize();
|
|
||||||
_umlDiagram.repaint();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.thinkode.appthinker.views;
|
package com.thinkode.appthinker.views;
|
||||||
|
|
||||||
import com.thinkode.appthinker.AppThinker;
|
import com.thinkode.appthinker.AppThinker;
|
||||||
import com.thinkode.appthinker.models.Argument;
|
import com.thinkode.appthinker.controllers.ClassPropertiesController;
|
||||||
import com.thinkode.appthinker.models.Attribute;
|
import com.thinkode.appthinker.models.Attribute;
|
||||||
import com.thinkode.appthinker.models.Class;
|
import com.thinkode.appthinker.models.Class;
|
||||||
import com.thinkode.appthinker.models.Method;
|
import com.thinkode.appthinker.models.Method;
|
||||||
@@ -11,7 +11,6 @@ import javax.swing.*;
|
|||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,19 +31,19 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
private JScrollPane _scrollMethods;
|
private JScrollPane _scrollMethods;
|
||||||
private String[] _methodsColumns = {"C", "Name", "Access modifier", "Type", "Arguments", "Static", "Final", "Abstract", "Synchronised", "Volatile", "Transient"};
|
private String[] _methodsColumns = {"C", "Name", "Access modifier", "Type", "Arguments", "Static", "Final", "Abstract", "Synchronised", "Volatile", "Transient"};
|
||||||
private DefaultTableModel _methodModel;
|
private DefaultTableModel _methodModel;
|
||||||
|
private JRadioButton _mainRadio;
|
||||||
|
|
||||||
|
private ClassPropertiesController _classPropertiesController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur - Crée une instance de la fenêtre de propriétés de classe à partir d'un diagramme et de la classe à modifier.
|
* Constructeur - Crée une instance de la fenêtre de propriétés de classe à partir d'un diagramme et de la classe à modifier.
|
||||||
*
|
|
||||||
* @param umlDiagram Le diagramme qui contient la classe.
|
|
||||||
* @param a La classe à modifier.
|
|
||||||
*/
|
*/
|
||||||
public ClassPropertiesWindow(UmlDiagramFrame umlDiagram, Class a) {
|
public ClassPropertiesWindow() {
|
||||||
_umlDiagram = umlDiagram;
|
}
|
||||||
_class = a;
|
|
||||||
|
|
||||||
|
public void initializeGraphics() {
|
||||||
//Paramétrage de la fenêtre
|
//Paramétrage de la fenêtre
|
||||||
this.setTitle("Edit properties - " + a.getName());
|
this.setTitle("Edit properties - " + _classPropertiesController.getClassName());
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
this.setSize(new Dimension(800, 375));
|
this.setSize(new Dimension(800, 375));
|
||||||
Image img = null;
|
Image img = null;
|
||||||
@@ -66,29 +65,26 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
namePan.setLayout(new BoxLayout(namePan, BoxLayout.X_AXIS));
|
namePan.setLayout(new BoxLayout(namePan, BoxLayout.X_AXIS));
|
||||||
JLabel nameLbl = new JLabel("Name : ");
|
JLabel nameLbl = new JLabel("Name : ");
|
||||||
_nameField = new JTextField();
|
_nameField = new JTextField();
|
||||||
|
_nameField.setText(_classPropertiesController.getClassName());
|
||||||
_nameField.setPreferredSize(new Dimension(300, 20));
|
_nameField.setPreferredSize(new Dimension(300, 20));
|
||||||
_nameField.setText(a.getName());
|
|
||||||
namePan.add(nameLbl);
|
namePan.add(nameLbl);
|
||||||
namePan.add(_nameField);
|
namePan.add(_nameField);
|
||||||
generalPanel.add(namePan);
|
generalPanel.add(namePan);
|
||||||
|
|
||||||
//Radio bouton pour définir la classe principale
|
//Radio bouton pour définir la classe principale
|
||||||
JRadioButton mainRadio = new JRadioButton("This is the main class");
|
_mainRadio = new JRadioButton("This is the main class");
|
||||||
mainRadio.setToolTipText("The main class is the entry point of the application. It appears in red on the diagram.");
|
_mainRadio.setToolTipText("The main class is the entry point of the application. It appears in red on the diagram.");
|
||||||
mainRadio.addActionListener(new ActionListener() {
|
_mainRadio.setSelected(_classPropertiesController.isMainClass());
|
||||||
|
_mainRadio.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
defineMainClass(a);
|
_classPropertiesController.setMainClass();
|
||||||
refreshGraphics();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ButtonGroup bg = new ButtonGroup();
|
ButtonGroup bg = new ButtonGroup();
|
||||||
bg.add(mainRadio);
|
bg.add(_mainRadio);
|
||||||
//if (_umlDiagram.getMainClass() == a) mainRadio.setSelected(true);
|
|
||||||
//else mainRadio.setSelected(false);
|
|
||||||
|
|
||||||
generalPanel.add(mainRadio);
|
|
||||||
|
|
||||||
|
generalPanel.add(_mainRadio);
|
||||||
|
|
||||||
JLabel attrLbl = new JLabel("Edit attributes");
|
JLabel attrLbl = new JLabel("Edit attributes");
|
||||||
generalPanel.add(attrLbl);
|
generalPanel.add(attrLbl);
|
||||||
@@ -111,7 +107,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
addAttribute.addActionListener(new ActionListener() {
|
addAttribute.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
addAttribute();
|
_classPropertiesController.addAttribute();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
attributesTableModifier.add(addAttribute);
|
attributesTableModifier.add(addAttribute);
|
||||||
@@ -120,7 +116,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
removeAttribute.addActionListener(new ActionListener() {
|
removeAttribute.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
removeAttribute();
|
_classPropertiesController.removeAttribute(_attributesTable.getSelectedRow());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
attributesTableModifier.add(removeAttribute);
|
attributesTableModifier.add(removeAttribute);
|
||||||
@@ -129,12 +125,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
upAttribute.addActionListener(new ActionListener() {
|
upAttribute.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int selected = _attributesTable.getSelectedRow();
|
_classPropertiesController.goUpAttribute(_attributesTable.getSelectedRow());
|
||||||
if (_class.upAttribute(selected)) {
|
|
||||||
refreshGraphics();
|
|
||||||
listAttributes();
|
|
||||||
_attributesTable.setRowSelectionInterval(selected - 1, selected - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
attributesTableModifier.add(upAttribute);
|
attributesTableModifier.add(upAttribute);
|
||||||
@@ -143,12 +134,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
downAttribute.addActionListener(new ActionListener() {
|
downAttribute.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int selected = _attributesTable.getSelectedRow();
|
_classPropertiesController.goDownAttribute(_attributesTable.getSelectedRow());
|
||||||
if (_class.downAttribute(selected)) {
|
|
||||||
refreshGraphics();
|
|
||||||
listAttributes();
|
|
||||||
_attributesTable.setRowSelectionInterval(selected + 1, selected + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
attributesTableModifier.add(downAttribute);
|
attributesTableModifier.add(downAttribute);
|
||||||
@@ -171,7 +157,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
Point p = e.getPoint();
|
Point p = e.getPoint();
|
||||||
int col = _methodsTable.columnAtPoint(p);
|
int col = _methodsTable.columnAtPoint(p);
|
||||||
int row = _methodsTable.rowAtPoint(p);
|
int row = _methodsTable.rowAtPoint(p);
|
||||||
if (col == 4) openArgumentsWindow(_class.getMethods().get(row));
|
if (col == 4) _classPropertiesController.openArgumentsWindow(_methodsTable.getSelectedRow());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -186,7 +172,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
addMethod.addActionListener(new ActionListener() {
|
addMethod.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
addMethod();
|
_classPropertiesController.addMethod();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
methodsTableModifier.add(addMethod);
|
methodsTableModifier.add(addMethod);
|
||||||
@@ -196,7 +182,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
removeMethod.addActionListener(new ActionListener() {
|
removeMethod.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
removeMethod();
|
_classPropertiesController.removeMethod(_methodsTable.getSelectedRow());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
methodsTableModifier.add(removeMethod);
|
methodsTableModifier.add(removeMethod);
|
||||||
@@ -205,12 +191,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
upMethod.addActionListener(new ActionListener() {
|
upMethod.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int selected = _methodsTable.getSelectedRow();
|
_classPropertiesController.goUpMethod(_methodsTable.getSelectedRow());
|
||||||
if (_class.upMethod(selected)) {
|
|
||||||
refreshGraphics();
|
|
||||||
listMethods();
|
|
||||||
_methodsTable.setRowSelectionInterval(selected - 1, selected - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
methodsTableModifier.add(upMethod);
|
methodsTableModifier.add(upMethod);
|
||||||
@@ -219,12 +200,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
downMethod.addActionListener(new ActionListener() {
|
downMethod.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
int selected = _methodsTable.getSelectedRow();
|
_classPropertiesController.goDownMethod(_methodsTable.getSelectedRow());
|
||||||
if (_class.downMethod(selected)) {
|
|
||||||
refreshGraphics();
|
|
||||||
listMethods();
|
|
||||||
_methodsTable.setRowSelectionInterval(selected + 1, selected + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
methodsTableModifier.add(downMethod);
|
methodsTableModifier.add(downMethod);
|
||||||
@@ -233,7 +209,7 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
overloadMethod.addActionListener(new ActionListener() {
|
overloadMethod.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
overloadMethod();
|
_classPropertiesController.overloadMethod(_methodsTable.getSelectedRow());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
methodsTableModifier.add(overloadMethod);
|
methodsTableModifier.add(overloadMethod);
|
||||||
@@ -244,10 +220,6 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
|
|
||||||
this.add(generalPanel, BorderLayout.CENTER);
|
this.add(generalPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
//Import des attributs et méthodes dans les tableaux
|
|
||||||
this.listAttributes();
|
|
||||||
this.listMethods();
|
|
||||||
|
|
||||||
this.addWindowListener(new WindowListener() {
|
this.addWindowListener(new WindowListener() {
|
||||||
@Override
|
@Override
|
||||||
public void windowOpened(WindowEvent e) {
|
public void windowOpened(WindowEvent e) {
|
||||||
@@ -257,8 +229,8 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
//On enregistre à la fermeture de la fenêtre
|
//On enregistre à la fermeture de la fenêtre
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
saveClass();
|
_classPropertiesController.saveClass(_nameField.getText());
|
||||||
refreshGraphics();
|
_classPropertiesController.refreshGraphics();
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,120 +260,36 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_classPropertiesController.refreshAttributes();
|
||||||
|
_classPropertiesController.refreshMethods();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setController(ClassPropertiesController classPropertiesController) {
|
||||||
* Définit la classe principale du diagramme.
|
_classPropertiesController = classPropertiesController;
|
||||||
*
|
|
||||||
* @param a La classe principale du diagramme.
|
|
||||||
*/
|
|
||||||
public void defineMainClass(Class a) {
|
|
||||||
//_umlDiagram.setMainClass(a);
|
|
||||||
//refreshGraphics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ouvre une fenêtre d'édition des arguments pour la méthode sélectionnée
|
* Sélectionne une ligne dans le tableau d'attribut
|
||||||
*
|
|
||||||
* @param m La méthode dans laquelle seront modifiés les arguments.
|
|
||||||
*/
|
*/
|
||||||
public void openArgumentsWindow(Method m) {
|
public void selectAttribute(int index) {
|
||||||
ArgumentsPropertiesWindow argsWin = new ArgumentsPropertiesWindow(this, _umlDiagram, m);
|
_attributesTable.setRowSelectionInterval(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Récupère la classe en cours d'édition.
|
* Sélectionne une ligne dans le tableau des méthodes
|
||||||
*
|
|
||||||
* @return La classe en cours d'édition.
|
|
||||||
*/
|
*/
|
||||||
public Class getEditingClass() {
|
public void selectMethod(int index) {
|
||||||
return _class;
|
_methodsTable.setRowSelectionInterval(index, index);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ajoute un attribut à la classe et rafraîchit la liste des attributs.
|
|
||||||
*/
|
|
||||||
public void addAttribute() {
|
|
||||||
this.saveAttributes();
|
|
||||||
_class.addAttribute(new Attribute());
|
|
||||||
this.listAttributes();
|
|
||||||
refreshGraphics();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retire un attribut à la classe et rafraîchit la liste des attributs.
|
|
||||||
*/
|
|
||||||
public void removeAttribute() {
|
|
||||||
int i = _attributesTable.getSelectedRow();
|
|
||||||
if (i != -1) {
|
|
||||||
this.saveAttributes();
|
|
||||||
_class.removeAttribute(i);
|
|
||||||
this.listAttributes();
|
|
||||||
refreshGraphics();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ajoute une méthode à la classe et rafraîchit la liste des méthodes.
|
|
||||||
*/
|
|
||||||
public void addMethod() {
|
|
||||||
this.saveMethods();
|
|
||||||
_class.addMethod(new Method());
|
|
||||||
this.listMethods();
|
|
||||||
refreshGraphics();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ajoute une méthode à la classe et rafraîchit la liste des méthodes.
|
|
||||||
*
|
|
||||||
* @param index Le rang d'insertion de la méthode.
|
|
||||||
* @param m La méthode à insérer.
|
|
||||||
*/
|
|
||||||
public void addMethod(int index, Method m) {
|
|
||||||
this.saveMethods();
|
|
||||||
_class.addMethod(index, m);
|
|
||||||
this.listMethods();
|
|
||||||
refreshGraphics();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retire une méthode à la classe et rafraîchit la liste des méthodes.
|
|
||||||
*/
|
|
||||||
public void removeMethod() {
|
|
||||||
int i = _methodsTable.getSelectedRow();
|
|
||||||
if (i != -1) {
|
|
||||||
this.saveMethods();
|
|
||||||
_class.removeMethod(i);
|
|
||||||
this.listMethods();
|
|
||||||
refreshGraphics();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* On surcharge la méthode avec un argument en plus qui peut être modifié par la suite.
|
|
||||||
*/
|
|
||||||
public void overloadMethod() {
|
|
||||||
int index = _methodsTable.getSelectedRow();
|
|
||||||
if (index != -1) {
|
|
||||||
Method m = _class.getMethods().get(index);
|
|
||||||
java.util.List<Argument> args = new ArrayList<Argument>();
|
|
||||||
//On ajoute un argument de plus que la méthode à surcharger
|
|
||||||
args.addAll(m.getArguments());
|
|
||||||
args.add(new Argument());
|
|
||||||
Method m1 = new Method(m.getAccess(), m.getType(), m.getName(), args, m.isConstructor(), m.isStatic(), m.isFinal(), m.isAbstract(), m.isSynchronized(), m.isVolatile(), m.isTransient());
|
|
||||||
this.addMethod(index + 1, m1);
|
|
||||||
this.openArgumentsWindow(m1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Affiche la liste des attributs de la classe dans le tableau
|
* Affiche la liste des attributs de la classe dans le tableau
|
||||||
*/
|
*/
|
||||||
public void listAttributes() {
|
public void listAttributes(java.util.List<Attribute> attributes) {
|
||||||
//Import des attributs dans la table
|
//Import des attributs dans la table
|
||||||
_attributeModel.setDataVector((Object[][]) null, _attributesColumns);
|
_attributeModel.setDataVector((Object[][]) null, _attributesColumns);
|
||||||
for (Attribute attr : _class.getAttributes()) {
|
for (Attribute attr : attributes) {
|
||||||
String access = (attr.getAccess() == "+") ? "PUBLIC" : (attr.getAccess() == "#") ? "PROTECTED" : "PRIVATE";
|
String access = (attr.getAccess() == "+") ? "PUBLIC" : (attr.getAccess() == "#") ? "PROTECTED" : "PRIVATE";
|
||||||
_attributeModel.addRow(new Object[]{attr.getName(), access, attr.getType(), attr.isStatic(), attr.isFinal(), attr.isAbstract(), attr.isSynchronized(), attr.isVolatile(), attr.isTransient()});
|
_attributeModel.addRow(new Object[]{attr.getName(), access, attr.getType(), attr.isStatic(), attr.isFinal(), attr.isAbstract(), attr.isSynchronized(), attr.isVolatile(), attr.isTransient()});
|
||||||
}
|
}
|
||||||
@@ -425,10 +313,10 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
/**
|
/**
|
||||||
* Affiche la liste des méthodes de la classe dans le tableau.
|
* Affiche la liste des méthodes de la classe dans le tableau.
|
||||||
*/
|
*/
|
||||||
public void listMethods() {
|
public void listMethods(java.util.List<Method> methods) {
|
||||||
//Import des méthodes dans la table
|
//Import des méthodes dans la table
|
||||||
_methodModel.setDataVector((Object[][]) null, _methodsColumns);
|
_methodModel.setDataVector((Object[][]) null, _methodsColumns);
|
||||||
for (Method meth : _class.getMethods()) {
|
for (Method meth : methods) {
|
||||||
String access = (meth.getAccess() == "-") ? "PRIVATE" : (meth.getAccess() == "#") ? "PROTECTED" : "PUBLIC";
|
String access = (meth.getAccess() == "-") ? "PRIVATE" : (meth.getAccess() == "#") ? "PROTECTED" : "PUBLIC";
|
||||||
_methodModel.addRow(new Object[]{meth.isConstructor(), meth.getName(), access, meth.getType(), "[EDIT]", meth.isStatic(), meth.isFinal(), meth.isAbstract(), meth.isSynchronized(), meth.isVolatile(), meth.isTransient()});
|
_methodModel.addRow(new Object[]{meth.isConstructor(), meth.getName(), access, meth.getType(), "[EDIT]", meth.isStatic(), meth.isFinal(), meth.isAbstract(), meth.isSynchronized(), meth.isVolatile(), meth.isTransient()});
|
||||||
}
|
}
|
||||||
@@ -463,15 +351,16 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
for (int i = 0; i <= _attributeModel.getRowCount() - 1; i++) {
|
for (int i = 0; i <= _attributeModel.getRowCount() - 1; i++) {
|
||||||
Vector vect = (Vector) _attributeModel.getDataVector().elementAt(i);
|
Vector vect = (Vector) _attributeModel.getDataVector().elementAt(i);
|
||||||
String access = vect.get(1).toString();
|
String access = vect.get(1).toString();
|
||||||
_class.getAttributes().get(i).setName(vect.get(0).toString());
|
_classPropertiesController.saveAttribute(i,
|
||||||
_class.getAttributes().get(i).setAccess((access == "PUBLIC") ? Attribute.PUBLIC : (access == "PROTECTED") ? Attribute.PROTECTED : Attribute.PRIVATE);
|
vect.get(0).toString(),
|
||||||
_class.getAttributes().get(i).setType(vect.get(2).toString());
|
(access == "PUBLIC") ? Attribute.PUBLIC : (access == "PROTECTED") ? Attribute.PROTECTED : Attribute.PRIVATE,
|
||||||
_class.getAttributes().get(i).setStatic((boolean) vect.get(3));
|
vect.get(2).toString(),
|
||||||
_class.getAttributes().get(i).setFinal((boolean) vect.get(4));
|
(boolean) vect.get(3),
|
||||||
_class.getAttributes().get(i).setAbstract((boolean) vect.get(5));
|
(boolean) vect.get(4),
|
||||||
_class.getAttributes().get(i).setSynchronized((boolean) vect.get(6));
|
(boolean) vect.get(5),
|
||||||
_class.getAttributes().get(i).setVolatile((boolean) vect.get(7));
|
(boolean) vect.get(6),
|
||||||
_class.getAttributes().get(i).setTransient((boolean) vect.get(8));
|
(boolean) vect.get(7),
|
||||||
|
(boolean) vect.get(8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,35 +373,17 @@ public class ClassPropertiesWindow extends JDialog {
|
|||||||
for (int i = 0; i <= _methodModel.getRowCount() - 1; i++) {
|
for (int i = 0; i <= _methodModel.getRowCount() - 1; i++) {
|
||||||
Vector vect = (Vector) _methodModel.getDataVector().elementAt(i);
|
Vector vect = (Vector) _methodModel.getDataVector().elementAt(i);
|
||||||
String access = vect.get(2).toString();
|
String access = vect.get(2).toString();
|
||||||
_class.getMethods().get(i).setConstructor((boolean) vect.get(0));
|
_classPropertiesController.saveMethod(i,
|
||||||
_class.getMethods().get(i).setName(vect.get(1).toString());
|
(boolean) vect.get(0),
|
||||||
_class.getMethods().get(i).setAccess((access == "PRIVATE") ? Method.PRIVATE : (access == "PROTECTED") ? Method.PROTECTED : Method.PUBLIC);
|
vect.get(1).toString(),
|
||||||
_class.getMethods().get(i).setType(vect.get(3).toString());
|
(access == "PRIVATE") ? Method.PRIVATE : (access == "PROTECTED") ? Method.PROTECTED : Method.PUBLIC,
|
||||||
_class.getMethods().get(i).setStatic((boolean) vect.get(5));
|
vect.get(3).toString(),
|
||||||
_class.getMethods().get(i).setFinal((boolean) vect.get(6));
|
(boolean) vect.get(5),
|
||||||
_class.getMethods().get(i).setAbstract((boolean) vect.get(7));
|
(boolean) vect.get(6),
|
||||||
_class.getMethods().get(i).setSynchronized((boolean) vect.get(8));
|
(boolean) vect.get(7),
|
||||||
_class.getMethods().get(i).setVolatile((boolean) vect.get(9));
|
(boolean) vect.get(8),
|
||||||
_class.getMethods().get(i).setTransient((boolean) vect.get(10));
|
(boolean) vect.get(9),
|
||||||
|
(boolean) vect.get(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sauvegarde l'ensemble de la classe.
|
|
||||||
*/
|
|
||||||
public void saveClass() {
|
|
||||||
//Changement du nom de la classe
|
|
||||||
_class.setName(_nameField.getText());
|
|
||||||
//Sauvegarde des attributs et méthodes
|
|
||||||
saveAttributes();
|
|
||||||
saveMethods();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rafraîchit la classe graphiquement.
|
|
||||||
*/
|
|
||||||
public void refreshGraphics() {
|
|
||||||
this._class.computeMinSize();
|
|
||||||
_umlDiagram.repaint();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ public class CompositionFrame extends JPanel implements MouseListener, MouseMoti
|
|||||||
_atCompositionListener = null;
|
_atCompositionListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Le workspace a besoin de se rafraîchir
|
||||||
|
*/
|
||||||
|
public void needWorkspaceRefresh() {
|
||||||
|
_atCompositionListener.refreshWorkspaceNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
//Evenements souris
|
//Evenements souris
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
|||||||
@@ -18,4 +18,9 @@ public interface CompositionListener {
|
|||||||
* Element size updated
|
* Element size updated
|
||||||
*/
|
*/
|
||||||
void elementSizeUpdated(int sizeX, int sizeY);
|
void elementSizeUpdated(int sizeX, int sizeY);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Need composition save
|
||||||
|
*/
|
||||||
|
void refreshWorkspaceNeeded();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,24 +3,30 @@ package com.thinkode.appthinker.views;
|
|||||||
import com.thinkode.appthinker.AppThinker;
|
import com.thinkode.appthinker.AppThinker;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CompositionWidget extends JTabbedPane implements ActionListener, CompositionListener, ChangeListener {
|
public class CompositionWidget extends JTabbedPane implements CompositionListener {
|
||||||
|
|
||||||
private ArrayList<String> _titlePans;
|
private ArrayList<String> _titlePans;
|
||||||
private ArrayList<String> _projectPans;
|
private ArrayList<String> _projectPans;
|
||||||
|
private CompositionWidgetListener _listener;
|
||||||
|
|
||||||
public CompositionWidget() {
|
public CompositionWidget() {
|
||||||
this.addChangeListener(this);
|
|
||||||
_titlePans = new ArrayList<String>();
|
_titlePans = new ArrayList<String>();
|
||||||
_projectPans = new ArrayList<String>();
|
_projectPans = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCompositionWidgetListener(CompositionWidgetListener listener) {
|
||||||
|
_listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCompositionWidgetListener() {
|
||||||
|
_listener = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajoute un nouvel onglet au composant contenant la composition à ajouter
|
* Ajoute un nouvel onglet au composant contenant la composition à ajouter
|
||||||
*
|
*
|
||||||
@@ -63,7 +69,7 @@ public class CompositionWidget extends JTabbedPane implements ActionListener, Co
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private JPanel createTitlePan(String title) {
|
private JPanel createTitlePan(String title, int index) {
|
||||||
JPanel titlePan = new JPanel();
|
JPanel titlePan = new JPanel();
|
||||||
titlePan.setOpaque(false);
|
titlePan.setOpaque(false);
|
||||||
titlePan.setLayout(new BorderLayout());
|
titlePan.setLayout(new BorderLayout());
|
||||||
@@ -77,7 +83,12 @@ public class CompositionWidget extends JTabbedPane implements ActionListener, Co
|
|||||||
titleButton.setPreferredSize(new Dimension(20, 20));
|
titleButton.setPreferredSize(new Dimension(20, 20));
|
||||||
titleButton.setToolTipText("<html>Close <b><i>" + title + "</i></b></html>");
|
titleButton.setToolTipText("<html>Close <b><i>" + title + "</i></b></html>");
|
||||||
titleButton.setBackground(new Color(105, 105, 114));
|
titleButton.setBackground(new Color(105, 105, 114));
|
||||||
titleButton.addActionListener(this);
|
titleButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
deleteCompositionFrame(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
titlePan.add(titleButton, BorderLayout.EAST);
|
titlePan.add(titleButton, BorderLayout.EAST);
|
||||||
return titlePan;
|
return titlePan;
|
||||||
}
|
}
|
||||||
@@ -94,11 +105,12 @@ public class CompositionWidget extends JTabbedPane implements ActionListener, Co
|
|||||||
if (_titlePans.get(j).equals(title)) occurence.add(j);
|
if (_titlePans.get(j).equals(title)) occurence.add(j);
|
||||||
}
|
}
|
||||||
//La composition ouverte n'a pas de doublon
|
//La composition ouverte n'a pas de doublon
|
||||||
if (occurence.size() == 1) this.setTabComponentAt(occurence.get(0), createTitlePan(title));
|
if (occurence.size() == 1)
|
||||||
|
this.setTabComponentAt(occurence.get(0), createTitlePan(title, occurence.get(0)));
|
||||||
//La composition ouverte a plusieurs doublons
|
//La composition ouverte a plusieurs doublons
|
||||||
else {
|
else {
|
||||||
for (int index : occurence) {
|
for (int index : occurence) {
|
||||||
this.setTabComponentAt(index, createTitlePan(title + " - " + _projectPans.get(index)));
|
this.setTabComponentAt(index, createTitlePan(title + " - " + _projectPans.get(index), index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,6 +144,13 @@ public class CompositionWidget extends JTabbedPane implements ActionListener, Co
|
|||||||
optimizeNames();
|
optimizeNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteCompositionFrame(int index) {
|
||||||
|
_titlePans.remove(index);
|
||||||
|
_projectPans.remove(index);
|
||||||
|
this.remove(index);
|
||||||
|
optimizeNames();
|
||||||
|
}
|
||||||
|
|
||||||
//Evenements de la composition
|
//Evenements de la composition
|
||||||
@Override
|
@Override
|
||||||
public void statusEmitted(String status) {
|
public void statusEmitted(String status) {
|
||||||
@@ -148,18 +167,8 @@ public class CompositionWidget extends JTabbedPane implements ActionListener, Co
|
|||||||
/*setSizeLabel(sizeX, sizeY);*/
|
/*setSizeLabel(sizeX, sizeY);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@java.lang.Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void refreshWorkspaceNeeded() {
|
||||||
JButton btn = (JButton) e.getSource();
|
_listener.refreshWorkspaceNeeded();
|
||||||
_titlePans.remove(this.getSelectedIndex());
|
|
||||||
_projectPans.remove(this.getSelectedIndex());
|
|
||||||
this.remove(this.getSelectedIndex());
|
|
||||||
optimizeNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
|
|
||||||
//System.out.println("Onglet cliqué !");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.thinkode.appthinker.views;
|
||||||
|
|
||||||
|
public interface CompositionWidgetListener {
|
||||||
|
/**
|
||||||
|
* Demande le rafraîchissement du Workspace
|
||||||
|
*/
|
||||||
|
void refreshWorkspaceNeeded();
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.thinkode.appthinker.views;
|
package com.thinkode.appthinker.views;
|
||||||
|
|
||||||
import com.thinkode.appthinker.AppThinker;
|
import com.thinkode.appthinker.AppThinker;
|
||||||
|
import com.thinkode.appthinker.controllers.LinkPropertiesController;
|
||||||
import com.thinkode.appthinker.models.Link;
|
import com.thinkode.appthinker.models.Link;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -18,8 +19,8 @@ import java.awt.event.WindowListener;
|
|||||||
*/
|
*/
|
||||||
public class LinkPropertiesWindow extends JDialog {
|
public class LinkPropertiesWindow extends JDialog {
|
||||||
|
|
||||||
private UmlDiagramFrame _umlDiagram;
|
private LinkPropertiesController _linkPropertiesController;
|
||||||
private Link _link;
|
|
||||||
private JPanel _generalPanel;
|
private JPanel _generalPanel;
|
||||||
private JLabel _fromClass;
|
private JLabel _fromClass;
|
||||||
private JLabel _toClass;
|
private JLabel _toClass;
|
||||||
@@ -41,15 +42,13 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur - Crée une instance de la fenêtre de propriétés de lin à partir d'un diagramme et du lien à modifier.
|
* Constructeur - Crée une instance de la fenêtre de propriétés de lin à partir d'un diagramme et du lien à modifier.
|
||||||
*
|
|
||||||
* @param umlDiagram Le diagramme qui contient la classe.
|
|
||||||
* @param a Le lien à modifier.
|
|
||||||
*/
|
*/
|
||||||
public LinkPropertiesWindow(UmlDiagramFrame umlDiagram, Link a) {
|
public LinkPropertiesWindow() {
|
||||||
_umlDiagram = umlDiagram;
|
}
|
||||||
_link = a;
|
|
||||||
|
public void initializeGraphics() {
|
||||||
//Paramétrage de la fenêtre
|
//Paramétrage de la fenêtre
|
||||||
this.setTitle("Edit properties - " + a.getName());
|
this.setTitle("Edit properties - " + _linkPropertiesController.getLinkName());
|
||||||
this.setModal(true);
|
this.setModal(true);
|
||||||
this.setSize(new Dimension(800, 375));
|
this.setSize(new Dimension(800, 375));
|
||||||
Image img = null;
|
Image img = null;
|
||||||
@@ -107,6 +106,10 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setController(LinkPropertiesController linkPropertiesController) {
|
||||||
|
_linkPropertiesController = linkPropertiesController;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Charge le contenu de la fenêtre en fonction du type de la relation.
|
* Charge le contenu de la fenêtre en fonction du type de la relation.
|
||||||
*/
|
*/
|
||||||
@@ -121,9 +124,9 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
switchPan.setLayout(new BoxLayout(switchPan, BoxLayout.X_AXIS));
|
switchPan.setLayout(new BoxLayout(switchPan, BoxLayout.X_AXIS));
|
||||||
JPanel classesPan = new JPanel();
|
JPanel classesPan = new JPanel();
|
||||||
classesPan.setLayout(new BoxLayout(classesPan, BoxLayout.Y_AXIS));
|
classesPan.setLayout(new BoxLayout(classesPan, BoxLayout.Y_AXIS));
|
||||||
_fromClass = new JLabel("From : " + _link.getStart().getName());
|
_fromClass = new JLabel("From : " + _linkPropertiesController.getLinkStartName());
|
||||||
classesPan.add(_fromClass);
|
classesPan.add(_fromClass);
|
||||||
_toClass = new JLabel("To : " + _link.getEnd().getName());
|
_toClass = new JLabel("To : " + _linkPropertiesController.getLinkEndName());
|
||||||
classesPan.add(_toClass);
|
classesPan.add(_toClass);
|
||||||
switchPan.add(classesPan);
|
switchPan.add(classesPan);
|
||||||
_generalPanel.add(switchPan);
|
_generalPanel.add(switchPan);
|
||||||
@@ -131,9 +134,7 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
_switchDirection.addActionListener(new ActionListener() {
|
_switchDirection.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
_link.switchDirection();
|
_linkPropertiesController.switchDirection();
|
||||||
save();
|
|
||||||
fillWindow();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
switchPan.add(_switchDirection);
|
switchPan.add(_switchDirection);
|
||||||
@@ -145,61 +146,52 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
typeRelation.setLayout(new FlowLayout());
|
typeRelation.setLayout(new FlowLayout());
|
||||||
ButtonGroup typeGroup = new ButtonGroup();
|
ButtonGroup typeGroup = new ButtonGroup();
|
||||||
_strongRelation = new JRadioButton("Strong");
|
_strongRelation = new JRadioButton("Strong");
|
||||||
if (_link.getType() == Link.LinkType.STRONG) _strongRelation.setSelected(true);
|
Link.LinkType type = _linkPropertiesController.getLinkType();
|
||||||
|
if (type == Link.LinkType.STRONG) _strongRelation.setSelected(true);
|
||||||
_strongRelation.addActionListener(new ActionListener() {
|
_strongRelation.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
_link.setType(Link.LinkType.STRONG);
|
_linkPropertiesController.setLinkType(Link.LinkType.STRONG);
|
||||||
_umlDiagram.repaint();
|
|
||||||
fillWindow();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
typeGroup.add(_strongRelation);
|
typeGroup.add(_strongRelation);
|
||||||
typeRelation.add(_strongRelation);
|
typeRelation.add(_strongRelation);
|
||||||
_weakRelation = new JRadioButton("Weak");
|
_weakRelation = new JRadioButton("Weak");
|
||||||
if (_link.getType() == Link.LinkType.WEAK) _weakRelation.setSelected(true);
|
if (type == Link.LinkType.WEAK) _weakRelation.setSelected(true);
|
||||||
_weakRelation.addActionListener(new ActionListener() {
|
_weakRelation.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
_link.setType(Link.LinkType.WEAK);
|
_linkPropertiesController.setLinkType(Link.LinkType.WEAK);
|
||||||
_umlDiagram.repaint();
|
|
||||||
fillWindow();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
typeGroup.add(_weakRelation);
|
typeGroup.add(_weakRelation);
|
||||||
typeRelation.add(_weakRelation);
|
typeRelation.add(_weakRelation);
|
||||||
_compositionRelation = new JRadioButton("AppThinker.Application.UI.Composition");
|
_compositionRelation = new JRadioButton("Composition");
|
||||||
if (_link.getType() == Link.LinkType.COMPOSITION) _compositionRelation.setSelected(true);
|
if (type == Link.LinkType.COMPOSITION) _compositionRelation.setSelected(true);
|
||||||
_compositionRelation.addActionListener(new ActionListener() {
|
_compositionRelation.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
_link.setType(Link.LinkType.COMPOSITION);
|
_linkPropertiesController.setLinkType(Link.LinkType.COMPOSITION);
|
||||||
_umlDiagram.repaint();
|
|
||||||
fillWindow();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
typeGroup.add(_compositionRelation);
|
typeGroup.add(_compositionRelation);
|
||||||
typeRelation.add(_compositionRelation);
|
typeRelation.add(_compositionRelation);
|
||||||
_aggregationRelation = new JRadioButton("Aggregation");
|
_aggregationRelation = new JRadioButton("Aggregation");
|
||||||
if (_link.getType() == Link.LinkType.AGGREGATION) _aggregationRelation.setSelected(true);
|
if (type == Link.LinkType.AGGREGATION) _aggregationRelation.setSelected(true);
|
||||||
_aggregationRelation.addActionListener(new ActionListener() {
|
_aggregationRelation.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
_link.setType(Link.LinkType.AGGREGATION);
|
_linkPropertiesController.setLinkType(Link.LinkType.AGGREGATION);
|
||||||
_umlDiagram.repaint();
|
|
||||||
fillWindow();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
typeGroup.add(_aggregationRelation);
|
typeGroup.add(_aggregationRelation);
|
||||||
typeRelation.add(_aggregationRelation);
|
typeRelation.add(_aggregationRelation);
|
||||||
_inheritanceRelation = new JRadioButton("Inheritance");
|
_inheritanceRelation = new JRadioButton("Inheritance");
|
||||||
if (_link.getType() == Link.LinkType.INHERITANCE) _inheritanceRelation.setSelected(true);
|
if (type == Link.LinkType.INHERITANCE) _inheritanceRelation.setSelected(true);
|
||||||
_inheritanceRelation.addActionListener(new ActionListener() {
|
_inheritanceRelation.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
_link.setType(Link.LinkType.INHERITANCE);
|
_linkPropertiesController.setLinkType(Link.LinkType.INHERITANCE);
|
||||||
_umlDiagram.repaint();
|
|
||||||
fillWindow();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
typeGroup.add(_inheritanceRelation);
|
typeGroup.add(_inheritanceRelation);
|
||||||
@@ -210,11 +202,11 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
_generalPanel.add(_contentPanel);
|
_generalPanel.add(_contentPanel);
|
||||||
|
|
||||||
//Affichage du nom de la classe de départ et d'arrivée
|
//Affichage du nom de la classe de départ et d'arrivée
|
||||||
_fromClass.setText("From : " + _link.getStart().getName());
|
_fromClass.setText("From : " + _linkPropertiesController.getLinkStartName());
|
||||||
_toClass.setText("To : " + _link.getEnd().getName());
|
_toClass.setText("To : " + _linkPropertiesController.getLinkEndName());
|
||||||
//Création du contenu selon le type de relation
|
//Création du contenu selon le type de relation
|
||||||
_generalPanel.remove(_contentPanel);
|
_generalPanel.remove(_contentPanel);
|
||||||
if (_link.getType() == Link.LinkType.STRONG || _link.getType() == Link.LinkType.WEAK) {
|
if (type == Link.LinkType.STRONG || type == Link.LinkType.WEAK) {
|
||||||
_contentPanel = new JPanel();
|
_contentPanel = new JPanel();
|
||||||
_contentPanel.setLayout(new BoxLayout(_contentPanel, BoxLayout.Y_AXIS));
|
_contentPanel.setLayout(new BoxLayout(_contentPanel, BoxLayout.Y_AXIS));
|
||||||
//Nom de la relation
|
//Nom de la relation
|
||||||
@@ -222,19 +214,19 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
namePan.setLayout(new BoxLayout(namePan, BoxLayout.X_AXIS));
|
namePan.setLayout(new BoxLayout(namePan, BoxLayout.X_AXIS));
|
||||||
JLabel lblName = new JLabel("Name : ");
|
JLabel lblName = new JLabel("Name : ");
|
||||||
namePan.add(lblName);
|
namePan.add(lblName);
|
||||||
_txtName = new JTextField(_link.getName());
|
_txtName = new JTextField(_linkPropertiesController.getLinkName());
|
||||||
namePan.add(_txtName);
|
namePan.add(_txtName);
|
||||||
_contentPanel.add(namePan);
|
_contentPanel.add(namePan);
|
||||||
//Cardinalités de départ et d'arrivée
|
//Cardinalités de départ et d'arrivée
|
||||||
JPanel cardsStart = new JPanel();
|
JPanel cardsStart = new JPanel();
|
||||||
cardsStart.setLayout(new BoxLayout(cardsStart, BoxLayout.X_AXIS));
|
cardsStart.setLayout(new BoxLayout(cardsStart, BoxLayout.X_AXIS));
|
||||||
JLabel lblCardStart = new JLabel("Cardinality (" + _link.getStart().getName() + ") : ");
|
JLabel lblCardStart = new JLabel("Cardinality (" + _linkPropertiesController.getLinkStartName() + ") : ");
|
||||||
cardsStart.add(lblCardStart);
|
cardsStart.add(lblCardStart);
|
||||||
JLabel minStartLbl = new JLabel(" Min ", SwingConstants.RIGHT);
|
JLabel minStartLbl = new JLabel(" Min ", SwingConstants.RIGHT);
|
||||||
cardsStart.add(minStartLbl);
|
cardsStart.add(minStartLbl);
|
||||||
_minCardinalityStart = new JSpinner();
|
_minCardinalityStart = new JSpinner();
|
||||||
_minCardinalityStart.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
_minCardinalityStart.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
||||||
_minCardinalityStart.setValue(_link.getMinCardinalityStart());
|
_minCardinalityStart.setValue(_linkPropertiesController.getLinkMinCardinalityStart());
|
||||||
cardsStart.add(_minCardinalityStart);
|
cardsStart.add(_minCardinalityStart);
|
||||||
JLabel maxStartLbl = new JLabel(" Max ", SwingConstants.RIGHT);
|
JLabel maxStartLbl = new JLabel(" Max ", SwingConstants.RIGHT);
|
||||||
cardsStart.add(maxStartLbl);
|
cardsStart.add(maxStartLbl);
|
||||||
@@ -242,10 +234,10 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
_maxCardinalityStart.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
_maxCardinalityStart.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
||||||
cardsStart.add(_maxCardinalityStart);
|
cardsStart.add(_maxCardinalityStart);
|
||||||
_maxStartLimited = new JCheckBox("Unlimited");
|
_maxStartLimited = new JCheckBox("Unlimited");
|
||||||
if (_link.getMaxCardinalityStart() == Link.CARD_UNLIMITED) {
|
if (_linkPropertiesController.getLinkMaxCardinalityStart() == Link.CARD_UNLIMITED) {
|
||||||
_maxCardinalityStart.setEnabled(false);
|
_maxCardinalityStart.setEnabled(false);
|
||||||
_maxStartLimited.setSelected(true);
|
_maxStartLimited.setSelected(true);
|
||||||
} else _maxCardinalityStart.setValue(_link.getMaxCardinalityStart());
|
} else _maxCardinalityStart.setValue(_linkPropertiesController.getLinkMaxCardinalityStart());
|
||||||
_maxStartLimited.addActionListener(new ActionListener() {
|
_maxStartLimited.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@@ -256,13 +248,13 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
_contentPanel.add(cardsStart);
|
_contentPanel.add(cardsStart);
|
||||||
JPanel cardsEnd = new JPanel();
|
JPanel cardsEnd = new JPanel();
|
||||||
cardsEnd.setLayout(new BoxLayout(cardsEnd, BoxLayout.X_AXIS));
|
cardsEnd.setLayout(new BoxLayout(cardsEnd, BoxLayout.X_AXIS));
|
||||||
JLabel lblCardEnd = new JLabel("Cardinality (" + _link.getEnd().getName() + ") : ");
|
JLabel lblCardEnd = new JLabel("Cardinality (" + _linkPropertiesController.getLinkEndName() + ") : ");
|
||||||
cardsEnd.add(lblCardEnd);
|
cardsEnd.add(lblCardEnd);
|
||||||
JLabel minEndLbl = new JLabel(" Min ", SwingConstants.RIGHT);
|
JLabel minEndLbl = new JLabel(" Min ", SwingConstants.RIGHT);
|
||||||
cardsEnd.add(minEndLbl);
|
cardsEnd.add(minEndLbl);
|
||||||
_minCardinalityEnd = new JSpinner();
|
_minCardinalityEnd = new JSpinner();
|
||||||
_minCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
_minCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
||||||
_minCardinalityEnd.setValue(_link.getMinCardinalityEnd());
|
_minCardinalityEnd.setValue(_linkPropertiesController.getLinkMinCardinalityEnd());
|
||||||
cardsEnd.add(_minCardinalityEnd);
|
cardsEnd.add(_minCardinalityEnd);
|
||||||
JLabel maxEndLbl = new JLabel(" Max ", SwingConstants.RIGHT);
|
JLabel maxEndLbl = new JLabel(" Max ", SwingConstants.RIGHT);
|
||||||
cardsEnd.add(maxEndLbl);
|
cardsEnd.add(maxEndLbl);
|
||||||
@@ -270,10 +262,10 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
_maxCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
_maxCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
||||||
cardsEnd.add(_maxCardinalityEnd);
|
cardsEnd.add(_maxCardinalityEnd);
|
||||||
_maxEndLimited = new JCheckBox("Unlimited");
|
_maxEndLimited = new JCheckBox("Unlimited");
|
||||||
if (_link.getMaxCardinalityEnd() == Link.CARD_UNLIMITED) {
|
if (_linkPropertiesController.getLinkMaxCardinalityEnd() == Link.CARD_UNLIMITED) {
|
||||||
_maxCardinalityEnd.setEnabled(false);
|
_maxCardinalityEnd.setEnabled(false);
|
||||||
_maxEndLimited.setSelected(true);
|
_maxEndLimited.setSelected(true);
|
||||||
} else _maxCardinalityEnd.setValue(_link.getMaxCardinalityEnd());
|
} else _maxCardinalityEnd.setValue(_linkPropertiesController.getLinkMaxCardinalityEnd());
|
||||||
_maxEndLimited.addActionListener(new ActionListener() {
|
_maxEndLimited.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@@ -282,29 +274,29 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
});
|
});
|
||||||
cardsEnd.add(_maxEndLimited);
|
cardsEnd.add(_maxEndLimited);
|
||||||
_contentPanel.add(cardsEnd);
|
_contentPanel.add(cardsEnd);
|
||||||
} else if (_link.getType() == Link.LinkType.COMPOSITION || _link.getType() == Link.LinkType.AGGREGATION) {
|
} else if (type == Link.LinkType.COMPOSITION || type == Link.LinkType.AGGREGATION) {
|
||||||
_contentPanel = new JPanel();
|
_contentPanel = new JPanel();
|
||||||
_contentPanel.setLayout(new BoxLayout(_contentPanel, BoxLayout.Y_AXIS));
|
_contentPanel.setLayout(new BoxLayout(_contentPanel, BoxLayout.Y_AXIS));
|
||||||
//Cardinalités de départ et d'arrivée
|
//Cardinalités de départ et d'arrivée
|
||||||
JPanel cardsEnd = new JPanel();
|
JPanel cardsEnd = new JPanel();
|
||||||
cardsEnd.setLayout(new BoxLayout(cardsEnd, BoxLayout.X_AXIS));
|
cardsEnd.setLayout(new BoxLayout(cardsEnd, BoxLayout.X_AXIS));
|
||||||
JLabel lblCardEnd = new JLabel("Cardinality (" + _link.getEnd().getName() + ") : ");
|
JLabel lblCardEnd = new JLabel("Cardinality (" + _linkPropertiesController.getLinkEndName() + ") : ");
|
||||||
cardsEnd.add(lblCardEnd);
|
cardsEnd.add(lblCardEnd);
|
||||||
JLabel minEndLbl = new JLabel("Min", SwingConstants.RIGHT);
|
JLabel minEndLbl = new JLabel("Min", SwingConstants.RIGHT);
|
||||||
cardsEnd.add(minEndLbl);
|
cardsEnd.add(minEndLbl);
|
||||||
_minCardinalityEnd = new JSpinner();
|
_minCardinalityEnd = new JSpinner();
|
||||||
_minCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
_minCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
||||||
_minCardinalityEnd.setValue(_link.getMinCardinalityEnd());
|
_minCardinalityEnd.setValue(_linkPropertiesController.getLinkMinCardinalityEnd());
|
||||||
cardsEnd.add(_minCardinalityEnd);
|
cardsEnd.add(_minCardinalityEnd);
|
||||||
JLabel maxEndLbl = new JLabel("Max", SwingConstants.RIGHT);
|
JLabel maxEndLbl = new JLabel("Max", SwingConstants.RIGHT);
|
||||||
cardsEnd.add(maxEndLbl);
|
cardsEnd.add(maxEndLbl);
|
||||||
_maxCardinalityEnd = new JSpinner();
|
_maxCardinalityEnd = new JSpinner();
|
||||||
_maxCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
_maxCardinalityEnd.setModel(new SpinnerNumberModel(0, 0, 9999, 1));
|
||||||
_maxEndLimited = new JCheckBox("Unlimited");
|
_maxEndLimited = new JCheckBox("Unlimited");
|
||||||
if (_link.getMaxCardinalityEnd() == Link.CARD_UNLIMITED) {
|
if (_linkPropertiesController.getLinkMaxCardinalityEnd() == Link.CARD_UNLIMITED) {
|
||||||
_maxCardinalityEnd.setEnabled(false);
|
_maxCardinalityEnd.setEnabled(false);
|
||||||
_maxEndLimited.setSelected(true);
|
_maxEndLimited.setSelected(true);
|
||||||
} else _maxCardinalityEnd.setValue(_link.getMaxCardinalityEnd());
|
} else _maxCardinalityEnd.setValue(_linkPropertiesController.getLinkMaxCardinalityEnd());
|
||||||
cardsEnd.add(_maxCardinalityEnd);
|
cardsEnd.add(_maxCardinalityEnd);
|
||||||
|
|
||||||
_maxEndLimited.addActionListener(new ActionListener() {
|
_maxEndLimited.addActionListener(new ActionListener() {
|
||||||
@@ -329,39 +321,39 @@ public class LinkPropertiesWindow extends JDialog {
|
|||||||
*/
|
*/
|
||||||
public void save() {
|
public void save() {
|
||||||
//Validation des changements pour les JSpinner et sauvegarde du nom de la relation et des cardinalités
|
//Validation des changements pour les JSpinner et sauvegarde du nom de la relation et des cardinalités
|
||||||
if (_link.getType() == Link.LinkType.INHERITANCE) {
|
Link.LinkType type = _linkPropertiesController.getLinkType();
|
||||||
_link.setName("inheritance" + _link.getId());
|
if (type == Link.LinkType.INHERITANCE) {
|
||||||
_link.setMinCardinalityStart(Link.CARD_NULL);
|
_linkPropertiesController.setLinkName("inheritance" + _linkPropertiesController.getLinkId());
|
||||||
_link.setMaxCardinalityStart(Link.CARD_NULL);
|
_linkPropertiesController.setLinkMinCardinalityStart(Link.CARD_NULL);
|
||||||
_link.setMinCardinalityEnd(Link.CARD_NULL);
|
_linkPropertiesController.setLinkMaxCardinalityStart(Link.CARD_NULL);
|
||||||
_link.setMaxCardinalityEnd(Link.CARD_NULL);
|
_linkPropertiesController.setLinkMinCardinalityEnd(Link.CARD_NULL);
|
||||||
|
_linkPropertiesController.setLinkMaxCardinalityEnd(Link.CARD_NULL);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
_minCardinalityEnd.commitEdit();
|
_minCardinalityEnd.commitEdit();
|
||||||
_maxCardinalityEnd.commitEdit();
|
_maxCardinalityEnd.commitEdit();
|
||||||
_link.setMinCardinalityEnd((Integer) _minCardinalityEnd.getValue());
|
_linkPropertiesController.setLinkMinCardinalityEnd((Integer) _minCardinalityEnd.getValue());
|
||||||
_link.setMaxCardinalityEnd((_maxEndLimited.isSelected()) ? Link.CARD_UNLIMITED : (Integer) _maxCardinalityEnd.getValue());
|
_linkPropertiesController.setLinkMaxCardinalityEnd((_maxEndLimited.isSelected()) ? Link.CARD_UNLIMITED : (Integer) _maxCardinalityEnd.getValue());
|
||||||
if (_link.getType() == Link.LinkType.STRONG || _link.getType() == Link.LinkType.WEAK) {
|
|
||||||
|
if (type == Link.LinkType.STRONG || type == Link.LinkType.WEAK) {
|
||||||
_minCardinalityStart.commitEdit();
|
_minCardinalityStart.commitEdit();
|
||||||
_maxCardinalityStart.commitEdit();
|
_maxCardinalityStart.commitEdit();
|
||||||
_link.setName(_txtName.getText());
|
_linkPropertiesController.setLinkName(_txtName.getText());
|
||||||
_link.setMinCardinalityStart((Integer) _minCardinalityStart.getValue());
|
_linkPropertiesController.setLinkMinCardinalityStart((Integer) _minCardinalityStart.getValue());
|
||||||
_link.setMaxCardinalityStart((_maxStartLimited.isSelected()) ? Link.CARD_UNLIMITED : (Integer) _maxCardinalityStart.getValue());
|
_linkPropertiesController.setLinkMaxCardinalityStart((_maxStartLimited.isSelected()) ? Link.CARD_UNLIMITED : (Integer) _maxCardinalityStart.getValue());
|
||||||
} else if (_link.getType() == Link.LinkType.COMPOSITION) {
|
} else if (type == Link.LinkType.COMPOSITION) {
|
||||||
_link.setName("composition" + _link.getId());
|
_linkPropertiesController.setLinkName("composition" + _linkPropertiesController.getLinkId());
|
||||||
_link.setMinCardinalityStart(Link.CARD_ONE);
|
_linkPropertiesController.setLinkMinCardinalityStart(Link.CARD_ONE);
|
||||||
_link.setMaxCardinalityStart(Link.CARD_ONE);
|
_linkPropertiesController.setLinkMaxCardinalityStart(Link.CARD_ONE);
|
||||||
} else {
|
} else {
|
||||||
_link.setName("aggregation" + _link.getId());
|
_linkPropertiesController.setLinkName("aggregation" + _linkPropertiesController.getLinkId());
|
||||||
_link.setMinCardinalityStart(Link.CARD_NULL);
|
_linkPropertiesController.setLinkMinCardinalityStart(Link.CARD_NULL);
|
||||||
_link.setMaxCardinalityStart(Link.CARD_ONE);
|
_linkPropertiesController.setLinkMaxCardinalityStart(Link.CARD_ONE);
|
||||||
}
|
}
|
||||||
|
_linkPropertiesController.refresh();
|
||||||
} catch (java.text.ParseException e) {
|
} catch (java.text.ParseException e) {
|
||||||
JOptionPane.showMessageDialog(this, "Please verify values for cardinalities.");
|
JOptionPane.showMessageDialog(this, "Please verify values for cardinalities.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Rafraîchissement du diagramme
|
|
||||||
this.repaint();
|
|
||||||
_umlDiagram.repaint();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ public class Splashscreen extends JFrame {
|
|||||||
*/
|
*/
|
||||||
public Splashscreen() {
|
public Splashscreen() {
|
||||||
this.setTitle("AppThinker - Starting");
|
this.setTitle("AppThinker - Starting");
|
||||||
this.setMinimumSize(new Dimension(600, 350));
|
int sizeX = 600;
|
||||||
|
int sizeY = 350;
|
||||||
|
this.setMinimumSize(new Dimension(sizeX, sizeY));
|
||||||
Image img = null;
|
Image img = null;
|
||||||
try {
|
try {
|
||||||
img = ImageIO.read(AppThinker.class.getResource("/com/thinkode/appthinker/img/logoAppThinker.png"));
|
img = ImageIO.read(AppThinker.class.getResource("/com/thinkode/appthinker/img/logoAppThinker.png"));
|
||||||
@@ -39,16 +41,16 @@ public class Splashscreen extends JFrame {
|
|||||||
img = ImageIO.read(AppThinker.class.getResource("/com/thinkode/appthinker/img/splashscreen.png"));
|
img = ImageIO.read(AppThinker.class.getResource("/com/thinkode/appthinker/img/splashscreen.png"));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
g2.drawImage(img, 0, 0, 600, 350, this);
|
g2.drawImage(img, 0, 0, sizeX, sizeY, this);
|
||||||
/*Informations du logiciel*/
|
/*Informations du logiciel*/
|
||||||
g2.setColor(new Color(63, 169, 245));
|
g2.setColor(new Color(63, 169, 245));
|
||||||
g2.setFont(new Font("Arial", Font.BOLD, 40));
|
g2.setFont(new Font("Arial", Font.BOLD, 40));
|
||||||
g2.drawString("AppThinker", 305, 45);
|
g2.drawString("AppThinker", sizeX - 250, 45);
|
||||||
g2.setFont(new Font("Arial", Font.PLAIN, 20));
|
g2.setFont(new Font("Arial", Font.PLAIN, 20));
|
||||||
g2.drawString("Make your ideas come true", 285, 280);
|
g2.drawString("Make your ideas come true", sizeX - 250, sizeY - 20);
|
||||||
g2.setFont(new Font("Arial", Font.BOLD, 10));
|
g2.setFont(new Font("Arial", Font.BOLD, 10));
|
||||||
g2.drawString("We're getting things ready...", 5, 295);
|
g2.drawString("We're getting things ready...", 5, sizeY - 5);
|
||||||
g2.drawString(AppThinker.developer + " © 2021 - Version " + AppThinker.version, 305, 295);
|
g2.drawString(AppThinker.developer + " © 2021 - Version " + AppThinker.version, sizeX - 250, sizeY - 5);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cette classe permet d'afficher les éléments UML de la composition.
|
* Cette classe permet d'afficher les éléments UML de la composition.
|
||||||
@@ -25,7 +24,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
private boolean _viewGrips = false;
|
private boolean _viewGrips = false;
|
||||||
private int gripSize = 8;
|
private int gripSize = 8;
|
||||||
|
|
||||||
private UmlDiagramController _compositionController;
|
private UmlDiagramController _umlDiagramController;
|
||||||
|
|
||||||
public enum ClassGrip {
|
public enum ClassGrip {
|
||||||
GRIP_N,
|
GRIP_N,
|
||||||
@@ -62,8 +61,8 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setController(UmlDiagramController atUmlDiagramController) {
|
public void setController(UmlDiagramController umlDiagramController) {
|
||||||
_compositionController = atUmlDiagramController;
|
_umlDiagramController = umlDiagramController;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,15 +84,15 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
FontMetrics metrics2 = _drawPanel.getFontMetrics(font2);
|
FontMetrics metrics2 = _drawPanel.getFontMetrics(font2);
|
||||||
|
|
||||||
g2.setColor(new Color(127, 158, 178));
|
g2.setColor(new Color(127, 158, 178));
|
||||||
g2.drawString(_compositionController.getName(), 10, 20);
|
g2.drawString(_umlDiagramController.getName(), 10, 20);
|
||||||
for (Class a : _compositionController.getClassesList()) {
|
for (Class a : _umlDiagramController.getClassesList()) {
|
||||||
g2.setFont(font1);
|
g2.setFont(font1);
|
||||||
int posX = a.getPosX() - (a.getSizeX() / 2);
|
int posX = a.getPosX() - (a.getSizeX() / 2);
|
||||||
int posY = a.getPosY() - (a.getSizeY() / 2);
|
int posY = a.getPosY() - (a.getSizeY() / 2);
|
||||||
//Dessin du rectangle
|
//Dessin du rectangle
|
||||||
g2.setColor(new Color(127, 158, 178));
|
g2.setColor(new Color(127, 158, 178));
|
||||||
g2.fillRect(posX, posY, a.getSizeX(), a.getSizeY());
|
g2.fillRect(posX, posY, a.getSizeX(), a.getSizeY());
|
||||||
if (a == _compositionController.getMainClass()) {
|
if (a == _umlDiagramController.getMainClass()) {
|
||||||
g2.setColor(new Color(173, 37, 8));
|
g2.setColor(new Color(173, 37, 8));
|
||||||
g2.drawRect(posX, posY, a.getSizeX(), a.getSizeY());
|
g2.drawRect(posX, posY, a.getSizeX(), a.getSizeY());
|
||||||
}
|
}
|
||||||
@@ -146,20 +145,20 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
if (_selected != null && _selected instanceof Class && _gripSelected != null) {
|
if (_selected != null && _selected instanceof Class && _gripSelected != null) {
|
||||||
Class b = (Class) _selected;
|
Class b = (Class) _selected;
|
||||||
System.out.println(b.getName());
|
System.out.println(b.getName());
|
||||||
List<ClassGrip> grips = Arrays.asList(ClassGrip.GRIP_N, ClassGrip.GRIP_NE, ClassGrip.GRIP_E, ClassGrip.GRIP_SE, ClassGrip.GRIP_S, ClassGrip.GRIP_SW, ClassGrip.GRIP_W, ClassGrip.GRIP_NW);
|
java.util.List<ClassGrip> grips = Arrays.asList(ClassGrip.GRIP_N, ClassGrip.GRIP_NE, ClassGrip.GRIP_E, ClassGrip.GRIP_SE, ClassGrip.GRIP_S, ClassGrip.GRIP_SW, ClassGrip.GRIP_W, ClassGrip.GRIP_NW);
|
||||||
List<List<Integer>> gripsPositions = b.getGripsPosition();
|
java.util.List<java.util.List<Integer>> gripsPositions = b.getGripsPosition();
|
||||||
g2.setColor(Color.RED);
|
g2.setColor(Color.RED);
|
||||||
g2.drawLine(gripsPositions.get(grips.indexOf(_gripSelected)).get(0) + gripSize / 2, gripsPositions.get(grips.indexOf(_gripSelected)).get(1) + gripSize / 2, _drawPanel.getMousePosition().x, _drawPanel.getMousePosition().y);
|
g2.drawLine(gripsPositions.get(grips.indexOf(_gripSelected)).get(0) + gripSize / 2, gripsPositions.get(grips.indexOf(_gripSelected)).get(1) + gripSize / 2, _drawPanel.getMousePosition().x, _drawPanel.getMousePosition().y);
|
||||||
}
|
}
|
||||||
//Récupération de la liste des positions des points d'accroche pour la classe en cours
|
//Récupération de la liste des positions des points d'accroche pour la classe en cours
|
||||||
List<List<Integer>> gripsPositions = a.getGripsPosition();
|
java.util.List<java.util.List<Integer>> gripsPositions = a.getGripsPosition();
|
||||||
for (Link l : _compositionController.getLinksList()) {
|
for (Link l : _umlDiagramController.getLinksList()) {
|
||||||
//Si le lien est sélectionné, on le dessine en rouge, sinon en noir
|
//Si le lien est sélectionné, on le dessine en rouge, sinon en noir
|
||||||
if (_selected instanceof Link && (Link) _selected == l) g2.setColor(Color.RED);
|
if (_selected instanceof Link && (Link) _selected == l) g2.setColor(Color.RED);
|
||||||
else g2.setColor(Color.BLACK);
|
else g2.setColor(Color.BLACK);
|
||||||
List<ClassGrip> grips = Arrays.asList(ClassGrip.GRIP_N, ClassGrip.GRIP_NE, ClassGrip.GRIP_E, ClassGrip.GRIP_SE, ClassGrip.GRIP_S, ClassGrip.GRIP_SW, ClassGrip.GRIP_W, ClassGrip.GRIP_NW);
|
java.util.List<ClassGrip> grips = Arrays.asList(ClassGrip.GRIP_N, ClassGrip.GRIP_NE, ClassGrip.GRIP_E, ClassGrip.GRIP_SE, ClassGrip.GRIP_S, ClassGrip.GRIP_SW, ClassGrip.GRIP_W, ClassGrip.GRIP_NW);
|
||||||
List<List<Integer>> gripsPositionsStart = l.getStart().getGripsPosition();
|
java.util.List<java.util.List<Integer>> gripsPositionsStart = l.getStart().getGripsPosition();
|
||||||
List<List<Integer>> gripsPositionsEnd = l.getEnd().getGripsPosition();
|
java.util.List<java.util.List<Integer>> gripsPositionsEnd = l.getEnd().getGripsPosition();
|
||||||
int startX = gripsPositionsStart.get(grips.indexOf(l.getGripStart())).get(0);
|
int startX = gripsPositionsStart.get(grips.indexOf(l.getGripStart())).get(0);
|
||||||
int startY = gripsPositionsStart.get(grips.indexOf(l.getGripStart())).get(1);
|
int startY = gripsPositionsStart.get(grips.indexOf(l.getGripStart())).get(1);
|
||||||
int endX = gripsPositionsEnd.get(grips.indexOf(l.getGripEnd())).get(0);
|
int endX = gripsPositionsEnd.get(grips.indexOf(l.getGripEnd())).get(0);
|
||||||
@@ -340,7 +339,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
*/
|
*/
|
||||||
public void removeClass(Class c) {
|
public void removeClass(Class c) {
|
||||||
//On supprime la classe principale
|
//On supprime la classe principale
|
||||||
_compositionController.removeClass(c);
|
_umlDiagramController.removeClass(c);
|
||||||
_selected = null;
|
_selected = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +362,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
*/
|
*/
|
||||||
public void select(int getX, int getY) {
|
public void select(int getX, int getY) {
|
||||||
//Si un élément est survolé, on le sélectionne
|
//Si un élément est survolé, on le sélectionne
|
||||||
for (Class c : _compositionController.getClassesList()) {
|
for (Class c : _umlDiagramController.getClassesList()) {
|
||||||
int posX = c.getPosX();
|
int posX = c.getPosX();
|
||||||
int posY = c.getPosY();
|
int posY = c.getPosY();
|
||||||
int sizeX = c.getSizeX();
|
int sizeX = c.getSizeX();
|
||||||
@@ -381,10 +380,10 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Link l : _compositionController.getLinksList()) {
|
for (Link l : _umlDiagramController.getLinksList()) {
|
||||||
List<ClassGrip> grips = Arrays.asList(ClassGrip.GRIP_N, ClassGrip.GRIP_NE, ClassGrip.GRIP_E, ClassGrip.GRIP_SE, ClassGrip.GRIP_S, ClassGrip.GRIP_SW, ClassGrip.GRIP_W, ClassGrip.GRIP_NW);
|
java.util.List<ClassGrip> grips = Arrays.asList(ClassGrip.GRIP_N, ClassGrip.GRIP_NE, ClassGrip.GRIP_E, ClassGrip.GRIP_SE, ClassGrip.GRIP_S, ClassGrip.GRIP_SW, ClassGrip.GRIP_W, ClassGrip.GRIP_NW);
|
||||||
List<List<Integer>> positionsStart = l.getStart().getGripsPosition();
|
java.util.List<java.util.List<Integer>> positionsStart = l.getStart().getGripsPosition();
|
||||||
List<List<Integer>> positionsEnd = l.getEnd().getGripsPosition();
|
java.util.List<java.util.List<Integer>> positionsEnd = l.getEnd().getGripsPosition();
|
||||||
float startX = positionsStart.get(grips.indexOf(l.getGripStart())).get(0);
|
float startX = positionsStart.get(grips.indexOf(l.getGripStart())).get(0);
|
||||||
float endX = positionsEnd.get(grips.indexOf(l.getGripEnd())).get(0);
|
float endX = positionsEnd.get(grips.indexOf(l.getGripEnd())).get(0);
|
||||||
float startY = positionsStart.get(grips.indexOf(l.getGripStart())).get(1);
|
float startY = positionsStart.get(grips.indexOf(l.getGripStart())).get(1);
|
||||||
@@ -414,7 +413,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
* @param a La classe à modifier.
|
* @param a La classe à modifier.
|
||||||
*/
|
*/
|
||||||
public void editClass(Class a) {
|
public void editClass(Class a) {
|
||||||
ClassPropertiesWindow prop = new ClassPropertiesWindow(this, a);
|
_umlDiagramController.showClassWindow(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -423,7 +422,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
* @param l Le lien à modifier.
|
* @param l Le lien à modifier.
|
||||||
*/
|
*/
|
||||||
public void editLink(Link l) {
|
public void editLink(Link l) {
|
||||||
LinkPropertiesWindow prop = new LinkPropertiesWindow(this, l);
|
_umlDiagramController.showLinkWindow(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -521,7 +520,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
break;
|
break;
|
||||||
//On essaie d'ajouter une classe
|
//On essaie d'ajouter une classe
|
||||||
case CLASS_TOOL:
|
case CLASS_TOOL:
|
||||||
_compositionController.addClass(e.getX(), e.getY());
|
_umlDiagramController.addClass(e.getX(), e.getY());
|
||||||
break;
|
break;
|
||||||
case STRONG_TOOL:
|
case STRONG_TOOL:
|
||||||
System.out.println("On ajoute une relation forte.");
|
System.out.println("On ajoute une relation forte.");
|
||||||
@@ -598,30 +597,30 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
if (_gripHovered != null) {
|
if (_gripHovered != null) {
|
||||||
switch (_gripHovered) {
|
switch (_gripHovered) {
|
||||||
case GRIP_N:
|
case GRIP_N:
|
||||||
a.resizeUp(posY);
|
_umlDiagramController.resizeUp(a, posY);
|
||||||
break;
|
break;
|
||||||
case GRIP_NE:
|
case GRIP_NE:
|
||||||
a.resizeUp(posY);
|
_umlDiagramController.resizeUp(a, posY);
|
||||||
a.resizeRight(posX);
|
_umlDiagramController.resizeRight(a, posX);
|
||||||
case GRIP_E:
|
case GRIP_E:
|
||||||
a.resizeRight(posX);
|
_umlDiagramController.resizeRight(a, posX);
|
||||||
break;
|
break;
|
||||||
case GRIP_SE:
|
case GRIP_SE:
|
||||||
a.resizeDown(posY);
|
_umlDiagramController.resizeDown(a, posY);
|
||||||
a.resizeRight(posX);
|
_umlDiagramController.resizeRight(a, posX);
|
||||||
case GRIP_S:
|
case GRIP_S:
|
||||||
a.resizeDown(posY);
|
_umlDiagramController.resizeDown(a, posY);
|
||||||
break;
|
break;
|
||||||
case GRIP_SW:
|
case GRIP_SW:
|
||||||
a.resizeDown(posY);
|
_umlDiagramController.resizeDown(a, posY);
|
||||||
a.resizeLeft(posX);
|
_umlDiagramController.resizeLeft(a, posX);
|
||||||
break;
|
break;
|
||||||
case GRIP_W:
|
case GRIP_W:
|
||||||
a.resizeLeft(posX);
|
_umlDiagramController.resizeLeft(a, posX);
|
||||||
break;
|
break;
|
||||||
case GRIP_NW:
|
case GRIP_NW:
|
||||||
a.resizeUp(posY);
|
_umlDiagramController.resizeUp(a, posY);
|
||||||
a.resizeLeft(posX);
|
_umlDiagramController.resizeLeft(a, posX);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_atCompositionListener.elementSizeUpdated(a.getSizeX(), a.getSizeY());
|
_atCompositionListener.elementSizeUpdated(a.getSizeX(), a.getSizeY());
|
||||||
@@ -629,8 +628,8 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
//Sinon on déplace
|
//Sinon on déplace
|
||||||
else {
|
else {
|
||||||
//On repositionne la classe en prenant en compte le décalage mesuré au clic de la souris
|
//On repositionne la classe en prenant en compte le décalage mesuré au clic de la souris
|
||||||
a.setPosX(posX - _shiftX);
|
_umlDiagramController.setPosX(a, posX - _shiftX);
|
||||||
a.setPosY(posY - _shiftY);
|
_umlDiagramController.setPosY(a, posY - _shiftY);
|
||||||
this.setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
this.setCursor(new Cursor(Cursor.MOVE_CURSOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -638,7 +637,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
//On est en train de créer un lien, on recherche le point d'accroche d'arrivée
|
//On est en train de créer un lien, on recherche le point d'accroche d'arrivée
|
||||||
if (_selected != null && _gripSelected != null) {
|
if (_selected != null && _gripSelected != null) {
|
||||||
Class selected = (Class) _selected;
|
Class selected = (Class) _selected;
|
||||||
for (Class hovered : _compositionController.getClassesList()) {
|
for (Class hovered : _umlDiagramController.getClassesList()) {
|
||||||
int posXSelected = hovered.getPosX();
|
int posXSelected = hovered.getPosX();
|
||||||
int posYSelected = hovered.getPosY();
|
int posYSelected = hovered.getPosY();
|
||||||
int sizeXSelected = hovered.getSizeX();
|
int sizeXSelected = hovered.getSizeX();
|
||||||
@@ -656,7 +655,7 @@ public class UmlDiagramFrame extends CompositionFrame implements UmlToolbarListe
|
|||||||
//Récupération du type de lien
|
//Récupération du type de lien
|
||||||
UmlToolbar.UmlTool tool = _umlToolbar.getCurrentTool();
|
UmlToolbar.UmlTool tool = _umlToolbar.getCurrentTool();
|
||||||
Link.LinkType type = (tool == UmlToolbar.UmlTool.STRONG_TOOL) ? Link.LinkType.STRONG : (tool == UmlToolbar.UmlTool.WEAK_TOOL) ? Link.LinkType.WEAK : (tool == UmlToolbar.UmlTool.COMPOSITION_TOOL) ? Link.LinkType.COMPOSITION : (tool == UmlToolbar.UmlTool.AGGREGATION_TOOL) ? Link.LinkType.AGGREGATION : Link.LinkType.INHERITANCE;
|
Link.LinkType type = (tool == UmlToolbar.UmlTool.STRONG_TOOL) ? Link.LinkType.STRONG : (tool == UmlToolbar.UmlTool.WEAK_TOOL) ? Link.LinkType.WEAK : (tool == UmlToolbar.UmlTool.COMPOSITION_TOOL) ? Link.LinkType.COMPOSITION : (tool == UmlToolbar.UmlTool.AGGREGATION_TOOL) ? Link.LinkType.AGGREGATION : Link.LinkType.INHERITANCE;
|
||||||
_compositionController.addLink((Class) _selected, (Class) _hovered, _gripSelected, _gripHovered, 0, 0, 0, 0, type);
|
_umlDiagramController.addLink((Class) _selected, (Class) _hovered, _gripSelected, _gripHovered, 0, 0, 0, 0, type);
|
||||||
_selected = null;
|
_selected = null;
|
||||||
_gripSelected = null;
|
_gripSelected = null;
|
||||||
_gripHovered = null;
|
_gripHovered = null;
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ import javax.imageio.ImageIO;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Affiche une fenêtre du logiciel.
|
* Affiche une fenêtre du logiciel.
|
||||||
*/
|
*/
|
||||||
public class Window extends JFrame implements MenuBarListener, WorkspaceListener {
|
public class Window extends JFrame implements MenuBarListener, WorkspaceListener, CompositionWidgetListener {
|
||||||
|
|
||||||
private final MenuBar _menubar;
|
private final MenuBar _menubar;
|
||||||
private final Statusbar _statusbar;
|
private final Statusbar _statusbar;
|
||||||
@@ -37,7 +39,13 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
this.setIconImage(img);
|
this.setIconImage(img);
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
|
this.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
quitClicked();
|
||||||
|
}
|
||||||
|
});
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
|
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
@@ -58,6 +66,7 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
|
|
||||||
//Ajout du Widget de visualisation des compositions
|
//Ajout du Widget de visualisation des compositions
|
||||||
_compositionWidget = new CompositionWidget();
|
_compositionWidget = new CompositionWidget();
|
||||||
|
_compositionWidget.addCompositionWidgetListener(this);
|
||||||
this.add(_compositionWidget, BorderLayout.CENTER);
|
this.add(_compositionWidget, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,11 +120,6 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
public void addCompositionFrame(String compositionName, String projectName, CompositionFrame composition) {
|
public void addCompositionFrame(String compositionName, String projectName, CompositionFrame composition) {
|
||||||
//Ajout de la composition au widget central
|
//Ajout de la composition au widget central
|
||||||
_compositionWidget.addCompositionFrame(compositionName, projectName, composition);
|
_compositionWidget.addCompositionFrame(compositionName, projectName, composition);
|
||||||
|
|
||||||
//Modification de la barre de statut
|
|
||||||
//Modification du titre et activation des fonctionnalités d'édition
|
|
||||||
//String projectPath = _mainWindowController.getProjectPath();
|
|
||||||
//this.setTitle((projectPath == null) ? "AppThinker - " + projectName + "*" : "AppThinker - " + projectName + " (" + projectPath + ")");
|
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +130,10 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
JOptionPane.showMessageDialog(this, message);
|
JOptionPane.showMessageDialog(this, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int showMessage(String message, String title, int option, int type) {
|
||||||
|
return JOptionPane.showOptionDialog(this, message, title, option, type, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public void setStatusMessage(String message) {
|
public void setStatusMessage(String message) {
|
||||||
_statusbar.setStatusMessage(message);
|
_statusbar.setStatusMessage(message);
|
||||||
}
|
}
|
||||||
@@ -180,6 +188,16 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
_mainWindowController.addUmlComposition(projectListId);
|
_mainWindowController.addUmlComposition(projectListId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String askForProjectName(int projectListId) {
|
||||||
|
return _mainWindowController.getProjectName(projectListId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean askForProjectSaved(Project project) {
|
||||||
|
return _mainWindowController.askForProjectSaved(project);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameProject(int projectListId, String newName) {
|
public void renameProject(int projectListId, String newName) {
|
||||||
_mainWindowController.renameProject(projectListId, newName);
|
_mainWindowController.renameProject(projectListId, newName);
|
||||||
@@ -200,6 +218,11 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
_mainWindowController.deleteProject(projectListId);
|
_mainWindowController.deleteProject(projectListId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String askForCompositionName(int projectListId, int compositionListId) {
|
||||||
|
return _mainWindowController.getCompositionName(projectListId, compositionListId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renameComposition(int projectListId, int compositionListId, String newName) {
|
public void renameComposition(int projectListId, int compositionListId, String newName) {
|
||||||
_mainWindowController.renameComposition(projectListId, compositionListId, newName);
|
_mainWindowController.renameComposition(projectListId, compositionListId, newName);
|
||||||
@@ -233,7 +256,7 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void quitClicked() {
|
public void quitClicked() {
|
||||||
_mainWindowController.exitApplication();
|
if (_mainWindowController.askForExit()) System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -245,4 +268,10 @@ public class Window extends JFrame implements MenuBarListener, WorkspaceListener
|
|||||||
public void checkUpdatesClicked() {
|
public void checkUpdatesClicked() {
|
||||||
_mainWindowController.checkForUpdates();
|
_mainWindowController.checkForUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Evenement du CompositionWidget
|
||||||
|
@java.lang.Override
|
||||||
|
public void refreshWorkspaceNeeded() {
|
||||||
|
_mainWindowController.refreshWorkspace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.thinkode.appthinker.models.Project;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
@@ -37,12 +38,12 @@ public class Workspace extends JPanel implements ActionListener, MouseListener,
|
|||||||
this.setPreferredSize(new Dimension(300, 10000));
|
this.setPreferredSize(new Dimension(300, 10000));
|
||||||
_actionPanel = new JPanel();
|
_actionPanel = new JPanel();
|
||||||
_actionPanel.setLayout(new BorderLayout());
|
_actionPanel.setLayout(new BorderLayout());
|
||||||
_actionPanel.setBackground(new Color(222, 222, 222));
|
_actionPanel.setBackground(new Color(238, 238, 238));
|
||||||
Border panelBorder = BorderFactory.createLineBorder(new Color(105, 105, 114), 1);
|
Border panelBorder = BorderFactory.createLineBorder(new Color(105, 105, 114), 1);
|
||||||
_actionPanel.setBorder(panelBorder);
|
_actionPanel.setBorder(panelBorder);
|
||||||
|
|
||||||
_homePage = new JPanel();
|
_homePage = new JPanel();
|
||||||
_homePage.setBackground(new Color(222, 222, 222));
|
_homePage.setBackground(new Color(238, 238, 238));
|
||||||
_homePage.setLayout(new FlowLayout(FlowLayout.LEFT));
|
_homePage.setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||||
JLabel imgHome = new JLabel(new ImageIcon(AppThinker.class.getResource("img/x16/homePage.png")));
|
JLabel imgHome = new JLabel(new ImageIcon(AppThinker.class.getResource("img/x16/homePage.png")));
|
||||||
_homePage.add(imgHome);
|
_homePage.add(imgHome);
|
||||||
@@ -51,7 +52,7 @@ public class Workspace extends JPanel implements ActionListener, MouseListener,
|
|||||||
_actionPanel.add(_homePage, BorderLayout.WEST);
|
_actionPanel.add(_homePage, BorderLayout.WEST);
|
||||||
|
|
||||||
_newProject = new JPanel();
|
_newProject = new JPanel();
|
||||||
_newProject.setBackground(new Color(222, 222, 222));
|
_newProject.setBackground(new Color(238, 238, 238));
|
||||||
_newProject.setLayout(new FlowLayout(FlowLayout.LEFT));
|
_newProject.setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||||
JLabel imgNewProject = new JLabel(new ImageIcon(AppThinker.class.getResource("img/x16/newProject.png")));
|
JLabel imgNewProject = new JLabel(new ImageIcon(AppThinker.class.getResource("img/x16/newProject.png")));
|
||||||
_newProject.add(imgNewProject);
|
_newProject.add(imgNewProject);
|
||||||
@@ -73,7 +74,7 @@ public class Workspace extends JPanel implements ActionListener, MouseListener,
|
|||||||
//Aucun projet n'est ouvert, on affiche le message par défaut
|
//Aucun projet n'est ouvert, on affiche le message par défaut
|
||||||
if (projects.size() == 0) {
|
if (projects.size() == 0) {
|
||||||
_contentPanel = new JPanel();
|
_contentPanel = new JPanel();
|
||||||
_contentPanel.setBackground(new Color(222, 222, 222));
|
_contentPanel.setBackground(new Color(238, 238, 238));
|
||||||
JLabel lbl2 = new JLabel("No project is open. Click on + to add a project.");
|
JLabel lbl2 = new JLabel("No project is open. Click on + to add a project.");
|
||||||
_contentPanel.add(lbl2);
|
_contentPanel.add(lbl2);
|
||||||
_scrollPane = new JScrollPane(_contentPanel);
|
_scrollPane = new JScrollPane(_contentPanel);
|
||||||
@@ -82,15 +83,26 @@ public class Workspace extends JPanel implements ActionListener, MouseListener,
|
|||||||
else {
|
else {
|
||||||
_root = new DefaultMutableTreeNode("Opened projects");
|
_root = new DefaultMutableTreeNode("Opened projects");
|
||||||
for (Project proj : projects) {
|
for (Project proj : projects) {
|
||||||
DefaultMutableTreeNode project = new DefaultMutableTreeNode(proj.getName());
|
String projectName;
|
||||||
|
if (_listener.askForProjectSaved(proj)) projectName = proj.getName() + "*";
|
||||||
|
else projectName = proj.getName();
|
||||||
|
DefaultMutableTreeNode project = new DefaultMutableTreeNode(projectName);
|
||||||
for (Composition comp : proj.getCompositions()) {
|
for (Composition comp : proj.getCompositions()) {
|
||||||
DefaultMutableTreeNode composition = new DefaultMutableTreeNode(comp.getName());
|
String lbl = (comp.isNeededToSave()) ? "<html><i>" + comp.getName() + "</i> (<b>" + comp.getClass().getSimpleName() + "</b>)</html>" : "<html>" + comp.getName() + " (<b>" + comp.getClass().getSimpleName() + "</b>)</html>";
|
||||||
|
DefaultMutableTreeNode composition = new DefaultMutableTreeNode(lbl);
|
||||||
project.add(composition);
|
project.add(composition);
|
||||||
}
|
}
|
||||||
_root.add(project);
|
_root.add(project);
|
||||||
}
|
}
|
||||||
_tree = new JTree(_root);
|
_tree = new JTree(_root);
|
||||||
_tree.expandPath(new TreePath(_root));
|
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) _tree.getCellRenderer();
|
||||||
|
renderer.setTextSelectionColor(Color.WHITE);
|
||||||
|
renderer.setBackgroundSelectionColor(new Color(63, 169, 245));
|
||||||
|
renderer.setBorderSelectionColor(new Color(63, 169, 245));
|
||||||
|
//Ouvrir tous les noeuds
|
||||||
|
for (int i = 0; i < _tree.getRowCount(); i++) {
|
||||||
|
_tree.expandRow(i);
|
||||||
|
}
|
||||||
JPopupMenu projectContextMenu = new JPopupMenu("Project actions");
|
JPopupMenu projectContextMenu = new JPopupMenu("Project actions");
|
||||||
JMenuItem addMenu = new JMenu("New");
|
JMenuItem addMenu = new JMenu("New");
|
||||||
addMenu.setIcon(new ImageIcon(AppThinker.class.getResource("img/x16/newComposition.png")));
|
addMenu.setIcon(new ImageIcon(AppThinker.class.getResource("img/x16/newComposition.png")));
|
||||||
@@ -115,7 +127,7 @@ public class Workspace extends JPanel implements ActionListener, MouseListener,
|
|||||||
_saveAsProject.setIcon(new ImageIcon(AppThinker.class.getResource("img/x16/saveAsProject.png")));
|
_saveAsProject.setIcon(new ImageIcon(AppThinker.class.getResource("img/x16/saveAsProject.png")));
|
||||||
_saveAsProject.addActionListener(this);
|
_saveAsProject.addActionListener(this);
|
||||||
projectContextMenu.add(_saveAsProject);
|
projectContextMenu.add(_saveAsProject);
|
||||||
_deleteProject = new JMenuItem("Delete project");
|
_deleteProject = new JMenuItem("Close project");
|
||||||
_deleteProject.setIcon(new ImageIcon(AppThinker.class.getResource("img/x16/closeProject.png")));
|
_deleteProject.setIcon(new ImageIcon(AppThinker.class.getResource("img/x16/closeProject.png")));
|
||||||
_deleteProject.addActionListener(this);
|
_deleteProject.addActionListener(this);
|
||||||
projectContextMenu.add(_deleteProject);
|
projectContextMenu.add(_deleteProject);
|
||||||
@@ -141,22 +153,22 @@ public class Workspace extends JPanel implements ActionListener, MouseListener,
|
|||||||
TreePath selPath = _tree.getPathForLocation(e.getX(), e.getY());
|
TreePath selPath = _tree.getPathForLocation(e.getX(), e.getY());
|
||||||
if (selRow != -1) {
|
if (selRow != -1) {
|
||||||
int path = selPath.getPathCount();
|
int path = selPath.getPathCount();
|
||||||
|
_tree.setSelectionPath(selPath);
|
||||||
|
DefaultMutableTreeNode selectedItem = (DefaultMutableTreeNode) _tree.getSelectionPath().getLastPathComponent();
|
||||||
if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON3) {
|
if (e.getClickCount() == 1 && e.getButton() == MouseEvent.BUTTON3) {
|
||||||
//Clic droit - Affichage des paramètres du projet/composition
|
//Clic droit - Affichage des paramètres du projet/composition
|
||||||
_tree.setSelectionPath(selPath);
|
|
||||||
if (path == 2) {
|
if (path == 2) {
|
||||||
projectContextMenu.show(_tree, e.getX(), e.getY());
|
projectContextMenu.show(_tree, e.getX(), e.getY());
|
||||||
_nameProject.setText(_tree.getSelectionPath().getLastPathComponent().toString());
|
_nameProject.setText(_listener.askForProjectName(_root.getIndex(selectedItem)));
|
||||||
} else {
|
} else {
|
||||||
compositionContextMenu.show(_tree, e.getX(), e.getY());
|
compositionContextMenu.show(_tree, e.getX(), e.getY());
|
||||||
_nameComposition.setText(_tree.getSelectionPath().getLastPathComponent().toString());
|
_nameComposition.setText(_listener.askForCompositionName(_root.getIndex(selectedItem.getParent()), selectedItem.getParent().getIndex(selectedItem)));
|
||||||
}
|
}
|
||||||
} else if (e.getClickCount() == 2) {
|
} else if (e.getClickCount() == 2) {
|
||||||
if (path == 2) {
|
if (path == 2) {
|
||||||
//Double-clic sur un projet
|
//Double-clic sur un projet
|
||||||
} else {
|
} else {
|
||||||
//Double clic sur une composition
|
//Double clic sur une composition
|
||||||
DefaultMutableTreeNode selectedItem = (DefaultMutableTreeNode) _tree.getSelectionPath().getLastPathComponent();
|
|
||||||
int compositionId = selectedItem.getParent().getIndex(selectedItem);
|
int compositionId = selectedItem.getParent().getIndex(selectedItem);
|
||||||
int projectId = _root.getIndex(selectedItem.getParent());
|
int projectId = _root.getIndex(selectedItem.getParent());
|
||||||
_listener.compositionDoubleClick(projectId, compositionId);
|
_listener.compositionDoubleClick(projectId, compositionId);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.thinkode.appthinker.views;
|
package com.thinkode.appthinker.views;
|
||||||
|
|
||||||
|
import com.thinkode.appthinker.models.Project;
|
||||||
|
|
||||||
public interface WorkspaceListener {
|
public interface WorkspaceListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +24,16 @@ public interface WorkspaceListener {
|
|||||||
*/
|
*/
|
||||||
void addUmlComposition(int projectListId);
|
void addUmlComposition(int projectListId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Demande le nom du projet sélectionné dans le Workspace
|
||||||
|
*/
|
||||||
|
String askForProjectName(int projectListId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Demande si le projet doit être sauvegardé ou non
|
||||||
|
*/
|
||||||
|
boolean askForProjectSaved(Project project);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renomme le projet sélectionné
|
* Renomme le projet sélectionné
|
||||||
*/
|
*/
|
||||||
@@ -42,6 +54,11 @@ public interface WorkspaceListener {
|
|||||||
*/
|
*/
|
||||||
void deleteProject(int projectListId);
|
void deleteProject(int projectListId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Demande le nom d'une composition sélectionnée dans le Workspace
|
||||||
|
*/
|
||||||
|
String askForCompositionName(int projectListId, int compositionListId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renomme la composition d'un projet
|
* Renomme la composition d'un projet
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user