diff --git a/doc/AVATAR/fig/logotpt.pdf b/doc/AVATAR/fig/logotpt.pdf new file mode 100644 index 0000000000000000000000000000000000000000..47bcada07880a6f6e21347293a9dd79197a0f34c Binary files /dev/null and b/doc/AVATAR/fig/logotpt.pdf differ diff --git a/src/main/java/ui/avatarbd/AvatarBDBlock.java b/src/main/java/ui/avatarbd/AvatarBDBlock.java index d2741139f1e38d452622f3888998564fd9f779bc..deda218d01c4b860558ff5c975783172cd8e899c 100644 --- a/src/main/java/ui/avatarbd/AvatarBDBlock.java +++ b/src/main/java/ui/avatarbd/AvatarBDBlock.java @@ -50,6 +50,7 @@ import ui.*; import ui.avatarsmd.AvatarSMDPanel; import ui.util.IconManager; import ui.window.JDialogAvatarBlock; +import ui.window.JDialogIDAndStereotype; import javax.swing.*; import java.awt.*; @@ -185,7 +186,8 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S graph.drawRect(this.x, this.y, this.width, this.height); // Draw inner rectangle - graph.setColor(ColorManager.AVATAR_BLOCK); + //graph.setColor(ColorManager.AVATAR_BLOCK); + graph.setColor(BLOCK_TYPE_COLOR.get(typeStereotype)); graph.fillRect(this.x + 1, this.y + 1, this.width - 1, this.height - 1); graph.setColor(c); @@ -209,11 +211,8 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S Font font = graph.getFont(); - String ster; - if (!this.isCryptoBlock()) - ster = "<<" + stereotype + ">>"; - else - ster = "<<" + stereotypeCrypto + ">>"; + + String ster = BLOCK_TYPE_STR.get(typeStereotype); if (this.rescaled && !this.tdp.isScaled()) { this.rescaled = false; @@ -574,45 +573,84 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S } // On the name ? if ((limitName == -1 && _y <= y + 2 * currentFontSize) || _y < limitName) { + JDialogIDAndStereotype dialog = new JDialogIDAndStereotype(frame, "Setting Block ID", BLOCK_TYPE_STR.toArray(new String[0]), getValue + (), typeStereotype, BLOCK_TYPE_COLOR.toArray(new Color[0]), ColorManager.AVATAR_BLOCK); + //dialog.setSize(400, 300); + GraphicLib.centerOnParent(dialog, 400, 300); + // dialog.show(); // blocked until dialog has been closed oldValue = value; + dialog.setVisible(true); + + if (dialog.hasBeenCancelled()) { + return false; + } - //String text = getName() + ": "; - String s = (String) JOptionPane.showInputDialog(frame, "Block name", - "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, - null, - getValue()); + String s = dialog.getName(); - if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { + if ((s != null) && (s.length() > 0)){ //boolean b; - if (!TAttribute.isAValidId(s, false, false)) { + if (!s.equals(oldValue)) { + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Block: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + if (!tdp.isAvatarBlockNameUnique(s)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Block: the new name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + setValue(s); + recalculateSize(); + + } + + /*if (!(tdp.actionOnDoubleClick(this))) { JOptionPane.showMessageDialog(frame, - "Could not change the name of the Block: the new name is not a valid name", + "Could not change the name of the Requirement: this name is already in use", "Error", JOptionPane.INFORMATION_MESSAGE); + setValue(oldValue); return false; - } + }*/ + + // Setting stereotype + s = dialog.getStereotype().trim(); - if (!tdp.isAvatarBlockNameUnique(s)) { + if (!TAttribute.isAValidId(s, false, false)) { JOptionPane.showMessageDialog(frame, - "Could not change the name of the Block: the new name is already in use", + "Could not use the new stereotype: the new stereotype name is not valid", "Error", JOptionPane.INFORMATION_MESSAGE); return false; } - setValue(s); - recalculateSize(); + int rgb = dialog.getColor(); - if (tdp.actionOnDoubleClick(this)) { - return true; + TraceManager.addDev("RGBColor:" + rgb + " vs default color:" + ColorManager.AVATAR_BLOCK.getRGB()); + + addStereotype(s, rgb); + + TraceManager.addDev("My stereotype=" + BLOCK_TYPE_STR.get(typeStereotype) + " color=" + BLOCK_TYPE_COLOR.get(typeStereotype).getRGB()); + + + if (isCryptoBlock()) { + addCryptoElements(); } else { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the Block: frame error", - "Error", - JOptionPane.INFORMATION_MESSAGE); - setValue(oldValue); + removeCryptoElements(); } + + return true; + } + + return false; } @@ -809,7 +847,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S protected String translateExtraParam() { StringBuffer sb = new StringBuffer("<extraparam>\n"); - sb.append("<reqType data=\""); + sb.append("<blockType data=\""); sb.append(BLOCK_TYPE_STR.get(typeStereotype)); sb.append("\" color=\""); sb.append(BLOCK_TYPE_COLOR.get(typeStereotype).getRGB()); @@ -921,10 +959,11 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S this.myAttributes.add(ta); } } - if (elt.getTagName().equals("reqType")) { + if (elt.getTagName().equals("blockType")) { // s = elt.getAttribute("data"); String tmp3 = elt.getAttribute("color"); + TraceManager.addDev("stereotype=" + s + " color=" + tmp3); int rgb = ColorManager.AVATAR_REQUIREMENT_TOP.getRGB(); try { rgb = Integer.decode(tmp3).intValue(); @@ -1025,6 +1064,7 @@ public class AvatarBDBlock extends TGCScalableWithInternalComponent implements S } public boolean addStereotype(String s, int rgb) { + TraceManager.addDev("Adding stereotype for " + s + " with color " + rgb); int index = -1; String sLower = s.toLowerCase(); for (int i=0; i<BLOCK_TYPE_STR.size(); i++) { diff --git a/src/main/java/ui/avatarrd/AvatarRDRequirement.java b/src/main/java/ui/avatarrd/AvatarRDRequirement.java index 659c305ed669785cb1b2143b8e9de2b07c1a9d8a..77da73244b12411900a0c08604f7a4d62316a8ad 100755 --- a/src/main/java/ui/avatarrd/AvatarRDRequirement.java +++ b/src/main/java/ui/avatarrd/AvatarRDRequirement.java @@ -397,7 +397,7 @@ public class AvatarRDRequirement extends TGCScalableWithInternalComponent implem getValue());*/ JDialogIDAndStereotype dialog = new JDialogIDAndStereotype(frame, "Setting Requirement ID", REQ_TYPE_STR.toArray(new String[0]), getValue - (), reqType, REQ_TYPE_COLOR.toArray(new Color[0])); + (), reqType, REQ_TYPE_COLOR.toArray(new Color[0]),ColorManager.AVATAR_REQUIREMENT_TOP); //dialog.setSize(400, 300); GraphicLib.centerOnParent(dialog, 400, 300); // dialog.show(); // blocked until dialog has been closed diff --git a/src/main/java/ui/window/JDialogIDAndStereotype.java b/src/main/java/ui/window/JDialogIDAndStereotype.java index 1c9809ad4acfd68386fb0f43ceaa330d0e8b341b..c941478b4817ee855f3271151180806d10fb1bd2 100644 --- a/src/main/java/ui/window/JDialogIDAndStereotype.java +++ b/src/main/java/ui/window/JDialogIDAndStereotype.java @@ -67,6 +67,7 @@ public class JDialogIDAndStereotype extends JDialogBase implements ActionListene private Color[] colors; private String currentName; private int currentStereotype; + private Color defaultColor; private JPanel panel1; @@ -84,7 +85,7 @@ public class JDialogIDAndStereotype extends JDialogBase implements ActionListene /** Creates new form */ public JDialogIDAndStereotype(Frame _f, String _title, String[] _availableStereotypes, String _currentName, - int _currentStereotype, Color[] _colors) { + int _currentStereotype, Color[] _colors, Color _defaultColor) { super(_f, _title, true); @@ -92,6 +93,7 @@ public class JDialogIDAndStereotype extends JDialogBase implements ActionListene colors = _colors; currentName = _currentName; currentStereotype = _currentStereotype; + defaultColor = _defaultColor; initComponents(); myInitComponents(); @@ -158,7 +160,7 @@ public class JDialogIDAndStereotype extends JDialogBase implements ActionListene panel1.add(colorButton, c1); useDefaultColor = new JButton("Use default color"); - useDefaultColor.setBackground(ColorManager.AVATAR_REQUIREMENT_TOP); + useDefaultColor.setBackground(defaultColor); useDefaultColor.addActionListener(this); panel1.add(useDefaultColor, c1); //panel1.setEditable(true); @@ -200,7 +202,7 @@ public class JDialogIDAndStereotype extends JDialogBase implements ActionListene } public void selectDefaultColor() { - colorButton.setBackground(ColorManager.AVATAR_REQUIREMENT_TOP); + colorButton.setBackground(defaultColor); } public void selectStereotype() {