diff --git a/src/ui/AnalysisPanel.java b/src/ui/AnalysisPanel.java index cbbf2cce1cbb8aca03b08ca8d363e730e4959aee..5db16078dee3cb46042cb242c49947dc7d0b0103 100755 --- a/src/ui/AnalysisPanel.java +++ b/src/ui/AnalysisPanel.java @@ -36,22 +36,25 @@ The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. /** - * Class AnalysisPanel - * Managenemt of analysis panels - * Creation: 14/01/2005 - * @version 1.0 14/01/2005 - * @author Ludovic APVRILLE - * @see MainGUI - */ +* Class AnalysisPanel +* Managenemt of analysis panels +* Creation: 14/01/2005 +* @version 1.0 14/01/2005 +* @author Ludovic APVRILLE +* @see MainGUI +*/ package ui; import java.awt.*; import javax.swing.*; import javax.swing.event.*; +import java.util.*; + import ui.iod.*; import ui.sd.*; import ui.ucd.*; +import myutil.*; public class AnalysisPanel extends TURTLEPanel { public InteractionOverviewDiagramPanel iodp; @@ -121,7 +124,7 @@ public class AnalysisPanel extends TURTLEPanel { } - public boolean addIODiagram(String s) { + public boolean addIODiagram(String s) { InteractionOverviewDiagramToolBar toolBarIOD = new InteractionOverviewDiagramToolBar(mgui); toolbars.add(toolBarIOD); @@ -142,7 +145,7 @@ public class AnalysisPanel extends TURTLEPanel { tabbedPane.addTab(s, IconManager.imgic17, toolBarPanel, "Opens interaction overview diagram"); return true; - + } public boolean addUseCaseDiagram(String s) { @@ -167,7 +170,7 @@ public class AnalysisPanel extends TURTLEPanel { return true; } - + public String saveHeaderInXml() { return "<Modeling type=\"Analysis\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; } @@ -197,4 +200,103 @@ public class AnalysisPanel extends TURTLEPanel { public boolean isUCDEnabled() { return true; } + + public boolean isSDEnabled() { + return true; + } + + public void addInstancesToLastSD(UseCaseDiagramPanel _ucdp) { + TraceManager.addDev("Adding instances to last SD"); + + TDiagramPanel panel = (TDiagramPanel)(panels.get(panels.size()-1)); + if (!(panel instanceof SequenceDiagramPanel)) { + return; + } + + //TraceManager.addDev("Adding instances to last SD Step 2"); + + ListIterator iterator = _ucdp.getComponentList().listIterator(); + TGComponent tgc; + + // To determine whether an actor is on the left, or on the right + int middleX = 0; + int cptTotal = 0; + String systemName; + UCDBorder border = _ucdp.getFirstUCDBorder(); + if (border != null) { + middleX = border.getX() + border.getWidth()/2; + systemName = border.getValue(); + } else { + systemName = "System"; + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if ((tgc instanceof UCDActor) || (tgc instanceof UCDActorBox)) { + middleX = middleX + tgc.getX(); + cptTotal ++; + } + } + middleX = middleX / cptTotal; + } + + //TraceManager.addDev("Adding instances to last SD Step 3"); + + // Classify actors + LinkedList <TGComponent> actors = new LinkedList(); + iterator = _ucdp.getComponentList().listIterator(); + int i; + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if ((tgc instanceof UCDActor) || (tgc instanceof UCDActorBox)) { + for(i=0; i<actors.size(); i++) { + if (actors.get(i).getX() > tgc.getX()) { + break; + } + } + // added at index i + actors.add(i, tgc); + } + } + + //TraceManager.addDev("Adding instances to last SD Step 3 nb of actors = " + actors.size()); + + int initX = 100; + int initY = 100; + int stepX = 150; + SDInstance sdi; + boolean systemAdded = false; + // Add actors (and the system) + for(TGComponent elt: actors) { + if (elt.getX() > middleX && !systemAdded) { + sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); + sdi.setValue(systemName); + sdi.setActor(false); + panel.addComponent(sdi, initX, initY, false, true); + initX += stepX; + systemAdded = true; + } + sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); + sdi.setValue(elt.getValue()); + sdi.setActor(true); + panel.addComponent(sdi, initX, initY, false, true); + initX += stepX; + } + + if (!systemAdded) { + sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); + sdi.setValue(systemName); + sdi.setActor(false); + panel.addComponent(sdi, initX, initY, false, true); + initX += stepX; + systemAdded = true; + } + + while(initX > panel.getMaxX()) { + panel.setMaxX(panel.getMaxX() + panel.getIncrement()); + panel.updateSize(); + } + + panel.repaint(); + + TraceManager.addDev("initX = " + initX + " nb of components:" + panel.getComponentList().size()); + } } \ No newline at end of file diff --git a/src/ui/IconManager.java b/src/ui/IconManager.java index 4d096385147eb33211151a258ea06eb46712d047..f7b1002abb82be5f82241b41410b483540e21b04 100755 --- a/src/ui/IconManager.java +++ b/src/ui/IconManager.java @@ -101,7 +101,7 @@ public class IconManager { public static ImageIcon imgic500, imgic502, imgic504, imgic506, imgic508, imgic510; public static ImageIcon imgic512, imgic514, imgic516, imgic518, imgic520, imgic522, imgic524; - public static ImageIcon imgic600, imgic602, imgic604, imgic606, imgic608, imgic610, imgic612; + public static ImageIcon imgic600, imgic602, imgic604, imgic606, imgic608, imgic610, imgic612, imgic614; public static ImageIcon imgic700, imgic702; @@ -379,6 +379,7 @@ public class IconManager { private static String icon608 = "images/ucdextend.gif"; private static String icon610 = "images/ucdspecia.gif"; private static String icon612 = "images/ucdborder.gif"; + private static String icon614 = "images/ucdactorbox.gif"; // Deployment diagrams private static String icon700 = "images/ddnode.gif"; @@ -734,6 +735,7 @@ public class IconManager { imgic608 = getIcon(icon608); imgic610 = getIcon(icon610); imgic612 = getIcon(icon612); + imgic614 = getIcon(icon614); imgic700 = getIcon(icon700); imgic702 = getIcon(icon702); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 2e0ff38d88e41ed1540cab0ad965abf21870ad75..1825265fa647f54d5b11bd4ac523cc7ed8f85469 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -4611,6 +4611,41 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { return true; } + + public boolean createUniqueSequenceDiagram(TURTLEPanel tp, String s) { + int i; + for(i=0; i<1000; i++) { + if(!isSDCreated(tp, s+i)) { + break; + } + } + + + if (!(tp instanceof AnalysisPanel)) { + return false; + } + + ((AnalysisPanel)tp).addSequenceDiagram(s+i); + setPanelMode(); + return true; + } + + public boolean createSequenceDiagramFromUCD(TURTLEPanel tp, String s, UseCaseDiagramPanel _ucdp) { + if (!createUniqueSequenceDiagram(tp, s)) { + return false; + } + + if (!(tp instanceof AnalysisPanel)) { + return false; + } + + ((AnalysisPanel)tp).addInstancesToLastSD(_ucdp); + + return true; + } + + + public boolean createIODiagram(int index, String s) { return createIODiagram((TURTLEPanel)(tabs.elementAt(index)), s); } @@ -6338,6 +6373,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { actionOnButton(TGComponentManager.EDIT, -1); } else if (command.equals(actions[TGUIAction.UCD_ACTOR].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.UCD_ACTOR); + } else if (command.equals(actions[TGUIAction.UCD_ACTORBOX].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.UCD_ACTORBOX); } else if (command.equals(actions[TGUIAction.UCD_USECASE].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.UCD_USECASE); } else if (command.equals(actions[TGUIAction.UCD_BORDER].getActionCommand())) { diff --git a/src/ui/TDiagramPanel.java b/src/ui/TDiagramPanel.java index ca390ab807bc5f446019e34e140d10b573bbf40f..9782a2caf4c3710a6724e3be0a23de5a43954c4e 100755 --- a/src/ui/TDiagramPanel.java +++ b/src/ui/TDiagramPanel.java @@ -1439,6 +1439,10 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { captureSelected = new JMenuItem("Save as an Image"); captureSelected.addActionListener(menuAL); } + + public int getIncrement() { + return increment; + } public void popupAction(ActionEvent e) { if (e.getSource() == remove) { diff --git a/src/ui/TGComponentManager.java b/src/ui/TGComponentManager.java index 2a5f4e8b6e123f832b05979a38ae6158f8f39aed..b12f39ea31283044bc95cd9ec48718deddb76ff8 100755 --- a/src/ui/TGComponentManager.java +++ b/src/ui/TGComponentManager.java @@ -177,6 +177,7 @@ public class TGComponentManager { public static final int SD_COREGION = 600; public static final int UCD_ACTOR = 700; + public static final int UCD_ACTORBOX = 703; public static final int UCD_USECASE = 701; public static final int UCD_BORDER = 702; @@ -563,6 +564,9 @@ public class TGComponentManager { break; case UCD_ACTOR: tgc = new UCDActor(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case UCD_ACTORBOX: + tgc = new UCDActorBox(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; case UCD_USECASE: tgc = new UCDUseCase(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -1027,6 +1031,8 @@ public class TGComponentManager { return SD_COREGION; } else if (tgc instanceof UCDActor) { return UCD_ACTOR; + } else if (tgc instanceof UCDActorBox) { + return UCD_ACTORBOX; } else if (tgc instanceof UCDUseCase) { return UCD_USECASE; } else if (tgc instanceof UCDBorder) { diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index 37f8230c8af19348ae4eb8c0d3d8d52b177f3ddf..c2768bdb3dd6a8c1cfcde1ff252127950a869c81 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -148,6 +148,7 @@ public class TGUIAction extends AbstractAction { public static final int UCD_EDIT = 104; public static final int UCD_ACTOR = 105; + public static final int UCD_ACTORBOX = 333; public static final int UCD_USECASE = 106; public static final int UCD_CONNECTOR_ACTOR_UC = 107; public static final int UCD_CONNECTOR_INCLUDE = 108; @@ -452,7 +453,7 @@ public class TGUIAction extends AbstractAction { //Action for the help button created by Solange public static final int PRUEBA_1 = 205; - public static final int NB_ACTION = 333; + public static final int NB_ACTION = 334; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -678,6 +679,7 @@ public class TGUIAction extends AbstractAction { actions[UCD_EDIT] = new TAction("edit-ucd-diagram", "Edit use case diagram", IconManager.imgic100, IconManager.imgic101, "Edit use case diagram", "Make it possible to edit the currently opened use case diagram", 0); actions[UCD_ACTOR] = new TAction("add-actor", "Add an actor", IconManager.imgic600, IconManager.imgic600, "Actor", "Add an actor to the currently opened use case diagram", 0); + actions[UCD_ACTORBOX] = new TAction("add-actor-box", "Add an actor (box format)", IconManager.imgic614, IconManager.imgic614, "Actor (box format)", "Add an actor in box format to the currently opened use case diagram", 0); actions[UCD_USECASE] = new TAction("add-usecase", "Add a use case", IconManager.imgic602, IconManager.imgic602, "Add a use case", "Add a use case to the currently opened use case diagram", 0); actions[UCD_BORDER] = new TAction("add-border", "Add a border", IconManager.imgic612, IconManager.imgic612, "Add a border", "Add a border to the currently opened use case diagram", 0); actions[UCD_CONNECTOR_ACTOR_UC] = new TAction("add-connector-actor-uc", "actor <-> use case", IconManager.imgic604, IconManager.imgic604, "Actor <-> use case", "Add a connector between an actor and a use case of the currently opened use case diagram", 0); diff --git a/src/ui/TURTLEPanel.java b/src/ui/TURTLEPanel.java index 85be283eab6f668955ee8438634744ebcd80fa9c..bbdef23aa4dcc8b852daec26f3f9843421e21dcf 100755 --- a/src/ui/TURTLEPanel.java +++ b/src/ui/TURTLEPanel.java @@ -239,6 +239,10 @@ public abstract class TURTLEPanel implements GenericTree { public boolean isUCDEnabled() { return false; } + + public boolean isSDEnabled() { + return false; + } public boolean isReqEnabled() { return false; diff --git a/src/ui/TURTLEPanelPopupListener.java b/src/ui/TURTLEPanelPopupListener.java index 9e36a5befe62d7f720bfce8c1ead70d67a1d4fc1..7d2757ff7884a34f221eaf5b855d95b612f36912 100755 --- a/src/ui/TURTLEPanelPopupListener.java +++ b/src/ui/TURTLEPanelPopupListener.java @@ -50,7 +50,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; - +import ui.ucd.*; import myutil.*; @@ -59,7 +59,7 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t private JPopupMenu menu; protected MainGUI mgui; - private JMenuItem rename, remove, moveRight, moveLeft, sort, newucd, newreq, + private JMenuItem rename, remove, moveRight, moveLeft, sort, newucd, newsd, newsdfromucd, newreq, newebrdd, newprosmd, newavatarrd, newavatarpd; private JMenuItem newatd; @@ -93,11 +93,13 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t moveLeft = createMenuItem("Move to the left"); moveRight = createMenuItem("Move to the right"); sort = createMenuItem("Sort"); - newucd = createMenuItem("New use case diagram"); - newreq = createMenuItem("New requirement diagram"); + newucd = createMenuItem("New Use Case Diagram"); + newsd = createMenuItem("New Sequence Diagram"); + newsdfromucd = createMenuItem("New Sequence Diagram (from Use Case Diagram)"); + newreq = createMenuItem("New Requirement Diagram"); newebrdd = createMenuItem("New Event-Based Requirement Description Diagram"); - newprosmd = createMenuItem("New ProActive state machine diagram"); - newatd = createMenuItem("New attack tree diagram"); + newprosmd = createMenuItem("New ProActive State Machine Diagram"); + newatd = createMenuItem("New Attack Tree Diagram"); newavatarrd = createMenuItem("New AVATAR Requirement Diagram"); newavatarpd = createMenuItem("New AVATAR Parametric Diagram"); @@ -111,6 +113,8 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t menu.add(sort); menu.addSeparator(); menu.add(newucd); + menu.add(newsd); + menu.add(newsdfromucd); menu.addSeparator(); menu.add(newreq); menu.add(newebrdd); @@ -157,6 +161,8 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t } newucd.setEnabled(tp.isUCDEnabled()); + newsd.setEnabled(tp.isSDEnabled()); + newsdfromucd.setEnabled(tp.isSDEnabled() && (mgui.getCurrentTDiagramPanel() instanceof UseCaseDiagramPanel)); newreq.setEnabled(tp.isReqEnabled()); newebrdd.setEnabled(tp.isReqEnabled()); newprosmd.setEnabled(tp.isProSMDEnabled()); @@ -180,19 +186,25 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t } else if (ac.equals("Sort")) { GraphicLib.sortJTabbedPane(tp.tabbedPane, tp.panels, 1, tp.tabbedPane.getTabCount()); mgui.changeMade(null, -1); - } else if (ac.equals("New use case diagram")) { - mgui.createUseCaseDiagram(tp, "Use Case diagram"); + } else if (ac.equals("New Use Case Diagram")) { + mgui.createUseCaseDiagram(tp, "Use Case Diagram"); + mgui.changeMade(null, -1); + } else if (ac.equals("New Sequence Diagram")) { + mgui.createUniqueSequenceDiagram(tp, "MyScenario"); + mgui.changeMade(null, -1); + } else if (item == newsdfromucd) { + mgui.createSequenceDiagramFromUCD(tp, "ScenarioFromUCD", (UseCaseDiagramPanel)(mgui.getCurrentTDiagramPanel())); mgui.changeMade(null, -1); - } else if (ac.equals("New requirement diagram")) { - mgui.createRequirementDiagram(tp, "Requirement diagram"); + } else if (ac.equals("New Requirement Diagram")) { + mgui.createRequirementDiagram(tp, "Requirement Diagram"); mgui.changeMade(null, -1); - } else if (ac.equals("New attack tree diagram")) { + } else if (ac.equals("New Attack Tree Diagram")) { mgui.createAttackTreeDiagram(tp, "Attack Tree"); mgui.changeMade(null, -1); } else if (ac.equals("New Event-Based Requirement Description Diagram")) { mgui.createEBRDD(tp, "EBRDD"); mgui.changeMade(null, -1); - } else if (ac.equals("New ProActive state machine diagram")) { + } else if (ac.equals("New ProActive State Machine Diagram")) { mgui.createProActiveSMD(tp, "ProActive SMD"); mgui.changeMade(null, -1); } else if (e.getSource() == newavatarrd) { diff --git a/src/ui/sd/SDInstance.java b/src/ui/sd/SDInstance.java index 5cd95dee4a7586124071486fec3554cf3d9f1a44..cad9851a4661231e4c9d0a8c34641cccba0f7209 100755 --- a/src/ui/sd/SDInstance.java +++ b/src/ui/sd/SDInstance.java @@ -48,10 +48,14 @@ package ui.sd; import java.awt.*; import javax.swing.*; +import org.w3c.dom.*; import java.awt.event.*; import myutil.*; import ui.*; +import ui.window.*; + + public class SDInstance extends TGCWithInternalComponent implements SwallowTGComponent { //private int lineLength = 5; @@ -59,6 +63,10 @@ public class SDInstance extends TGCWithInternalComponent implements SwallowTGCom private int spacePt = 10; private int wText = 10, hText = 15; private int increaseSlice = 250; + private boolean isActor; + private static int heightActor = 30; + private static int widthActor = 16; + public SDInstance(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); @@ -85,6 +93,7 @@ public class SDInstance extends TGCWithInternalComponent implements SwallowTGCom value = "Instance name"; name = "instance"; + isActor = false; myImageIcon = IconManager.imgic500; @@ -99,18 +108,37 @@ public class SDInstance extends TGCWithInternalComponent implements SwallowTGCom g.drawString(value, x - (wText / 2) + width/2, y - 3); g.drawLine(x - (wText / 2) + width/2, y-2, x + (wText / 2) + width/2, y-2); g.drawLine(x+(width/2), y, x+(width/2), y +height); + + if (isActor) { + int xtmp = x + (width-widthActor) / 2; + int ytmp = y-hText; + // Head + g.drawOval(xtmp+(widthActor/4)-1, ytmp-heightActor, 2+widthActor/2, 2+widthActor/2); + //Body + g.drawLine(xtmp+widthActor/2, ytmp-heightActor/3, xtmp+widthActor/2, ytmp-(2*heightActor)/3); + //Arms + g.drawLine(xtmp, ytmp-(heightActor/2) - 2, xtmp+widthActor, ytmp-(heightActor/2) - 2); + //Left leg + g.drawLine(xtmp+widthActor, ytmp, xtmp+widthActor/2, ytmp-heightActor/3); + //right leg + g.drawLine(xtmp, ytmp, xtmp+widthActor/2, ytmp-heightActor/3); + } } public TGComponent isOnOnlyMe(int _x, int _y) { - //System.out.println("coucou"); if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { return this; } - //System.out.println("youp"); + if (GraphicLib.isInRectangle(_x, _y, x + (width/2) - (wText/2) , y-hText, wText, hText)) { return this; } - //System.out.println("KO"); + + if (isActor) { + if (GraphicLib.isInRectangle(_x, _y, x + (width-widthActor) / 2, y-heightActor-hText, widthActor, heightActor)) { + return this; + } + } return null; } @@ -149,31 +177,39 @@ public class SDInstance extends TGCWithInternalComponent implements SwallowTGCom } public boolean editOndoubleClick(JFrame frame) { - String oldValue = value; + String oldValue = value; + + JDialogSDInstance jdsdi = new JDialogSDInstance(frame, value, isActor, "Instance attributes"); + jdsdi.setSize(300, 250); + GraphicLib.centerOnParent(jdsdi); + jdsdi.show(); // blocked until dialog has been closed + + String text = getName() + ": "; if (hasFather()) { text = getTopLevelName() + " / " + text; } - String s = (String)JOptionPane.showInputDialog(frame, text, - "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, - null, - getValue()); - - if (s != null) { - s = s.trim(); - } - - if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { - if (!TAttribute.isAValidId(s, false, false)) { - JOptionPane.showMessageDialog(frame, - "Could not change the name of the instance: the new name is not a valid name", - "Error", - JOptionPane.INFORMATION_MESSAGE); - return false; - } - setValue(s); - return true; - } + + if (jdsdi.hasBeenUpdated()) { + isActor = jdsdi.isAnActor(); + String s = jdsdi.getInstanceName(); + + if (s != null) { + s = s.trim(); + } + + if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the instance: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + setValue(s); + return true; + } + } return false; } @@ -436,5 +472,50 @@ public class SDInstance extends TGCWithInternalComponent implements SwallowTGCom tgc.setCdRectangle((width/2) + ((SDTimerCancellation)tgc).getLineLength() - tgc.getWidth()/2, (width/2) + ((SDTimerCancellation)tgc).getLineLength() - tgc.getWidth()/2, spacePt - tgc.getHeight()/2, height-spacePt-tgc.getHeight() / 2); } } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<Actor data=\""); + sb.append(""+isActor); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + NodeList nli; + Node n1, n2; + Element elt; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("Actor")) { + if (elt.getAttribute("data").compareTo("true") == 0) { + isActor = true; + } + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void setActor(boolean b) { + isActor = b; + } } \ No newline at end of file diff --git a/src/ui/ucd/TGConnectingPointActorUCD.java b/src/ui/ucd/TGConnectingPointActorUCD.java index 58925ed05bb4d16d22e89b43ade683c4e6f008c4..5f2802cb8ba03edcf30fbb8c0ba65baa10439c71 100755 --- a/src/ui/ucd/TGConnectingPointActorUCD.java +++ b/src/ui/ucd/TGConnectingPointActorUCD.java @@ -55,12 +55,9 @@ public class TGConnectingPointActorUCD extends TGConnectingPointWidthHeight{ } public boolean isCompatibleWith(int type) { - //System.out.println("is compatible with " + type); if ((type == TGComponentManager.CONNECTOR_ACTOR_UCD) || (type == TGComponentManager.CONNECTOR_SPECIA_UCD)){ - //System.out.println("is compatible with:true"); return true; } - //System.out.println("is compatible with:false"); return false; } } \ No newline at end of file diff --git a/src/ui/ucd/UCDActorBox.java b/src/ui/ucd/UCDActorBox.java new file mode 100755 index 0000000000000000000000000000000000000000..562ea2bf6c5d65ea207684ca4c8646ddf8ef18b0 --- /dev/null +++ b/src/ui/ucd/UCDActorBox.java @@ -0,0 +1,134 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class UCDActorBox + * Actor in a box + * Creation: 04/01/2011 + * @version 1.0 04/01/2011 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ucd; + +import java.awt.*; + +import myutil.*; +import ui.*; + +public class UCDActorBox extends TGCOneLineText { + /*protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5;*/ + protected int w, h; //w1; + protected final static String STEREOTYPE = "<<Actor>>"; + protected int space = 4; + + public UCDActorBox(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 40; + height = 50; + minWidth = 40; + + nbConnectingPoint = 24; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + int i; + for(int j=0; j<24; j = j + 12) { + for(i=0; i<5; i++) { + connectingPoint[i + j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.0, ((double)(i))/4); + } + connectingPoint[5+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 0.0); + connectingPoint[6+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 0.5, 1.0); + for(i=0; i<5; i++) { + connectingPoint[i+7+j] = new TGConnectingPointActorUCD(this, 0, 0, true, true, 1.0, ((double)i)/4); + } + } + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + + value = "Actor"; + name = "actor"; + + myImageIcon = IconManager.imgic600; + } + + public void internalDrawing(Graphics g) { + w = g.getFontMetrics().stringWidth(value); + int w1 = g.getFontMetrics().stringWidth(STEREOTYPE); + if (!tdp.isScaled()) { + width = Math.max(Math.max(w, w1) + space, minWidth); + } + h = g.getFontMetrics().getHeight(); + g.drawString(STEREOTYPE, x + ((width - w1) / 2), y + h + space/2); + g.drawString(value, x + ((width - w) / 2) , y + height - h); + g.drawRect(x, y, width, height); + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + /*if (GraphicLib.isInRectangle(_x, _y, x + width / 2 - w / 2, y +height - h, w, h)) { + return this; + }*/ + return null; + } + + public int getMyCurrentMinX() { + return Math.min(x + width / 2 - w / 2, x); + + } + + public int getMyCurrentMaxX() { + return Math.max(x + width / 2 + w / 2, x + width); + } + + public String getActorName() { + return value; + } + + + public int getType() { + return TGComponentManager.UCD_ACTORBOX; + } +} \ No newline at end of file diff --git a/src/ui/ucd/UseCaseDiagramPanel.java b/src/ui/ucd/UseCaseDiagramPanel.java index 59b5a77791110342d4bdddcdec53a21a1ceb5833..7c1919f8377796e478489fecb1a0e0d9b02d343e 100755 --- a/src/ui/ucd/UseCaseDiagramPanel.java +++ b/src/ui/ucd/UseCaseDiagramPanel.java @@ -46,6 +46,7 @@ knowledge of the CeCILL license and that you accept its terms. package ui.ucd; +import java.util.*; import ui.*; @@ -138,5 +139,19 @@ public class UseCaseDiagramPanel extends TDiagramPanel { } }*/ } + + public UCDBorder getFirstUCDBorder() { + TGComponent tgc; + + ListIterator iterator = getComponentList().listIterator(); + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc instanceof UCDBorder) { + return (UCDBorder)tgc; + } + } + + return null; + } } \ No newline at end of file diff --git a/src/ui/ucd/UseCaseDiagramToolBar.java b/src/ui/ucd/UseCaseDiagramToolBar.java index bc15b5e8dd1aed6d69f991e6945a2a3e27d02b50..dff461f560e8ece610201055dd13f7647a77a67c 100755 --- a/src/ui/ucd/UseCaseDiagramToolBar.java +++ b/src/ui/ucd/UseCaseDiagramToolBar.java @@ -63,6 +63,7 @@ public class UseCaseDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); mgui.actions[TGUIAction.CONNECTOR_COMMENT].setEnabled(b); mgui.actions[TGUIAction.UCD_ACTOR].setEnabled(b); + mgui.actions[TGUIAction.UCD_ACTORBOX].setEnabled(b); mgui.actions[TGUIAction.UCD_USECASE].setEnabled(b); mgui.actions[TGUIAction.UCD_BORDER].setEnabled(b); mgui.actions[TGUIAction.UCD_CONNECTOR_ACTOR_UC].setEnabled(b); @@ -98,6 +99,8 @@ public class UseCaseDiagramToolBar extends TToolBar { this.addSeparator(); button = this.add(mgui.actions[TGUIAction.UCD_ACTOR]); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.UCD_ACTORBOX]); button.addMouseListener(mgui.mouseHandler); this.addSeparator(); diff --git a/src/ui/window/JDialogSDInstance.java b/src/ui/window/JDialogSDInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..e80c1df005a5ede7b9c41eed9030f0994023de5b --- /dev/null +++ b/src/ui/window/JDialogSDInstance.java @@ -0,0 +1,189 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class JDialoSDInstance + * Dialog for managing parameters of instances of SD + * Creation: 04/01/2011 + * @version 1.0 04/01/2011 + * @author Ludovic APVRILLE + * @see + */ + +package ui.window; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.util.*; + +import ui.*; +import ui.tmlcd.*; + +public class JDialogSDInstance extends javax.swing.JDialog implements ActionListener { + + private JPanel panel1; + private Frame frame; + + private String name; + private boolean isActor; + + private boolean data; + + // Panel1 + private JTextField instanceName; + private JCheckBox actor; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogSDInstance(Frame f, String _name, boolean _isActor, String _title) { + super(f, _title, true); + frame = f; + + name = _name; + isActor = _isActor; + + data = false; + + myInitComponents(); + initComponents(); + //setComponents(); + pack(); + } + + + private void myInitComponents() { + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + GridBagConstraints c1 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + panel1 = new JPanel(); + panel1.setLayout(gridbag1); + panel1.setBorder(new javax.swing.border.TitledBorder("Setting parameters")); + panel1.setPreferredSize(new Dimension(250, 100)); + + // first line panel1 + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("instance:"), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + instanceName = new JTextField(name); + panel1.add(instanceName, c1); + + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + actor = new JCheckBox("actor?"); + panel1.add(actor, c1); + actor.setSelected(isActor); + + // main panel; + c0.gridwidth = 1; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + + c.add(panel1, c0); + + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + } + + + public void closeDialog() { + data = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public String getInstanceName() { + return instanceName.getText(); + } + + public boolean isAnActor() { + return actor.isSelected(); + } + + public boolean hasBeenUpdated() { + return data; + } + + +}