diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index b9f9aaf9cfafa3e1459049fb7d46467dbecba16c..2462535806df872bdedaa3225f393c7d10a0292d 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -8095,6 +8095,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_ARTIFACT); } else if (command.equals(actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_COMMUNICATION_ARTIFACT); + } else if (command.equals(actions[TGUIAction.TMLARCHI_PORT_ARTIFACT].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLARCHI_PORT_ARTIFACT); diff --git a/src/ui/TGComponentManager.java b/src/ui/TGComponentManager.java index 2716b92c39a512aac39c36d04c6ab2d62ad96ac2..fb7dd749178956cd5aeb0a16a61dc9836f40d1bf 100755 --- a/src/ui/TGComponentManager.java +++ b/src/ui/TGComponentManager.java @@ -241,6 +241,7 @@ public class TGComponentManager { public static final int TMLARCHI_DMANODE = 1107; public static final int TMLARCHI_CPNODE = 1108; public static final int TMLARCHI_EVENT_ARTIFACT = 1109; + public static final int TMLARCHI_PORT_ARTIFACT = 1110; public static final int TMLCTD_CCOMPONENT = 1200; public static final int TMLCTD_CPORT = 1201; @@ -991,6 +992,9 @@ public class TGComponentManager { case TMLARCHI_COMMUNICATION_ARTIFACT: tgc = new TMLArchiCommunicationArtifact(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case TMLARCHI_PORT_ARTIFACT: + tgc = new TMLArchiPortArtifact(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; case TMLARCHI_EVENT_ARTIFACT: tgc = new TMLArchiEventArtifact(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; @@ -1600,6 +1604,8 @@ public class TGComponentManager { return TMLARCHI_ARTIFACT; } else if (tgc instanceof TMLArchiCommunicationArtifact) { return TMLARCHI_COMMUNICATION_ARTIFACT; + } else if (tgc instanceof TMLArchiPortArtifact) { + return TMLARCHI_PORT_ARTIFACT; } else if (tgc instanceof TMLArchiEventArtifact) { return TMLARCHI_EVENT_ARTIFACT; diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index 8f09f8f0e7328384bd4381083fccef2699df5d27..f6fc4ca8d5e6fc193755014016da539003180e79 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -205,12 +205,13 @@ public class TGUIAction extends AbstractAction { public static final int TMLAD_READ_REQUEST_ARG = 335; public static final int TMLARCHI_EDIT = 216; - public static final int TMLARCHI_LINK = 217; - public static final int TMLARCHI_CPUNODE = 218; + public static final int TMLARCHI_LINK = 217; + public static final int TMLARCHI_CPUNODE = 218; public static final int TMLARCHI_BUSNODE = 221; public static final int TMLARCHI_CPNODE = 392; - public static final int TMLARCHI_ARTIFACT = 219; + public static final int TMLARCHI_ARTIFACT = 219; public static final int TMLARCHI_COMMUNICATION_ARTIFACT = 222; + public static final int TMLARCHI_PORT_ARTIFACT = 412; public static final int TMLARCHI_EVENT_ARTIFACT = 395; public static final int TMLARCHI_HWANODE = 223; public static final int TMLARCHI_MEMORYNODE = 224; @@ -546,7 +547,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 = 412; + public static final int NB_ACTION = 413; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -898,6 +899,7 @@ public class TGUIAction extends AbstractAction { actions[TMLARCHI_CPNODE] = new TAction("add-tmlarchi-cpnode", "Add a Communication pattern node", IconManager.imgic1102, IconManager.imgic1102, "CP node", "Add a communication pattern node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_ARTIFACT] = new TAction("add-tmlarchi-artifact", "Map a task", IconManager.imgic702, IconManager.imgic702, "Map a task", "Map a task onto a node in the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_COMMUNICATION_ARTIFACT] = new TAction("add-tmlarchi-communication-artifact", "Map a channel", IconManager.imgic702, IconManager.imgic702, "Map a channel", "Map a channel onto a node in the currently opened DIPLODOCUS architecture diagram", 0); + actions[TMLARCHI_PORT_ARTIFACT] = new TAction("add-tmlarchi-port-artifact", "Map a port", IconManager.imgic702, IconManager.imgic702, "Map a port", "Map a port onto a node in the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_EVENT_ARTIFACT] = new TAction("add-tmlarchi-event-artifact", "Map an event / request", IconManager.imgic702, IconManager.imgic702, "Map an event/request", "Map an event or a request onto a node in the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_BRIDGENODE] = new TAction("add-tmlarchi-bridgenode", "Add a Bridge node", IconManager.imgic1104, IconManager.imgic1104, "Bridge node", "Add a bridge node to the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_HWANODE] = new TAction("add-tmlarchi-hwanode", "Add a hardware accelerator node", IconManager.imgic1106, IconManager.imgic1106, "Hardware accelerator node", "Add a hardware accelerator node to the currently opened DIPLODOCUS architecture diagram", 0); diff --git a/src/ui/tmldd/TMLArchiCPNode.java b/src/ui/tmldd/TMLArchiCPNode.java index a2b03554600855cb6deff4cb27f40378e328292c..94d785daea5191507a348404ef5f5db89aa4299f 100755 --- a/src/ui/tmldd/TMLArchiCPNode.java +++ b/src/ui/tmldd/TMLArchiCPNode.java @@ -296,4 +296,58 @@ public class TMLArchiCPNode extends TMLArchiCommunicationNode implements Swallow } + public boolean addSwallowedTGComponent( TGComponent tgc, int x, int y ) { + + if( tgc instanceof TMLArchiCommunicationArtifact ) { + // Make it an internal component + // It's one of my son + //Set its coordinates + tgc.setFather(this); + tgc.setDrawingZone(true); + //System.out.println("Internal component"); + //tgc.setCdRectangle((width/2) - tgc.getWidth(), (width/2), spacePt, height-spacePt); + //System.out.println("cdRect comp swallow"); + ((TMLArchiCommunicationArtifact)tgc).resizeWithFather(); + //tgc.setCdRectangle(0, width - tgc.getWidth(), 0, height - tgc.getHeight()); + //tgc.setCd(x, y); + //add it + addInternalComponent( tgc, 0 ); + return true; + } + else { + if( tgc instanceof TMLArchiPortArtifact ) { + tgc.setFather( this ); + tgc.setDrawingZone( true ); + ( (TMLArchiPortArtifact)tgc ).resizeWithFather(); + addInternalComponent( tgc, 0 ); + return true; + } + return false; + } + } + + public void hasBeenResized() { + + for( int i = 0; i < nbInternalTGComponent; i++ ) { + if( tgcomponent[i] instanceof TMLArchiCommunicationArtifact ) { + ( (TMLArchiCommunicationArtifact)tgcomponent[i] ).resizeWithFather(); + } + else { + if( tgcomponent[i] instanceof TMLArchiPortArtifact ) { + ( (TMLArchiPortArtifact)tgcomponent[i] ).resizeWithFather(); + } + } + } + } + + public ArrayList<TMLArchiPortArtifact> getPortArtifactList() { + + ArrayList<TMLArchiPortArtifact> v = new ArrayList<TMLArchiPortArtifact>(); + for( int i = 0; i < nbInternalTGComponent; i++ ) { + if( tgcomponent[i] instanceof TMLArchiPortArtifact ) { + v.add( (TMLArchiPortArtifact)(tgcomponent[i]) ); + } + } + return v; + } } diff --git a/src/ui/tmldd/TMLArchiDiagramToolBar.java b/src/ui/tmldd/TMLArchiDiagramToolBar.java index 6062fd2a303519a52dbb04ea778c860600353172..001cb57f8174ee23e79650bdf538f2ff7087f42a 100755 --- a/src/ui/tmldd/TMLArchiDiagramToolBar.java +++ b/src/ui/tmldd/TMLArchiDiagramToolBar.java @@ -72,6 +72,7 @@ public class TMLArchiDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.TMLARCHI_BRIDGENODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_ARTIFACT].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT].setEnabled(b); + mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_EVENT_ARTIFACT].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_MEMORYNODE].setEnabled(b); mgui.actions[TGUIAction.TMLARCHI_DMANODE].setEnabled(b); @@ -137,6 +138,8 @@ public class TMLArchiDiagramToolBar extends TToolBar { } button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]); button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]); + button.addMouseListener(mgui.mouseHandler); this.addSeparator(); diff --git a/src/ui/tmldd/TMLArchiPortArtifact.java b/src/ui/tmldd/TMLArchiPortArtifact.java new file mode 100644 index 0000000000000000000000000000000000000000..0c25f4fae69aa31e4f814783d5d5dc15ba1921b9 --- /dev/null +++ b/src/ui/tmldd/TMLArchiPortArtifact.java @@ -0,0 +1,330 @@ +/**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 TMLArchiPortArtifact + * Communication Artifact of a deployment diagram + * Creation: 22/11/2007 + * @version 1.0 22/11/2007 + * @author Ludovic APVRILLE + * @see + */ + +package ui.tmldd; + +import java.awt.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class TMLArchiPortArtifact extends TGCWithoutInternalComponent implements SwallowedTGComponent, WithAttributes { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int textY2 = 35; + protected int space = 5; + protected int fileX = 20; + protected int fileY = 25; + protected int cran = 5; + + protected String oldValue = ""; + protected String referenceCommunicationName = "TMLCommunication"; + protected String portName = "name"; + protected String typeName = "port"; + protected int priority = 5; // Between 0 and 10 + + public TMLArchiPortArtifact(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 = 75; + height = 40; + minWidth = 75; + + nbConnectingPoint = 0; + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + + value = ""; + portName = "name"; + referenceCommunicationName = "TMLCommunication"; + + makeFullValue(); + + //setPriority(((TMLArchiDiagramPanel)tdp).getPriority(getFullValue(), priority); + + myImageIcon = IconManager.imgic702; + } + + public int getPriority() { + return priority; + } + + public void setPriority(int _priority) { + priority = _priority; + } + + + public void internalDrawing(Graphics g) { + + if (oldValue.compareTo(value) != 0) { + setValue(value, g); + } + + g.drawRect(x, y, width, height); + + //g.drawRoundRect(x, y, width, height, arc, arc); + g.drawLine(x+width-space-fileX, y + space, x+width-space-fileX, y+space+fileY); + g.drawLine(x+width-space-fileX, y + space, x+width-space-cran, y+space); + g.drawLine(x+width-space-cran, y+space, x+width-space, y+space + cran); + g.drawLine(x+width-space, y+space + cran, x+width-space, y+space+fileY); + g.drawLine(x+width-space, y+space+fileY, x+width-space-fileX, y+space+fileY); + g.drawLine(x+width-space-cran, y+space, x+width-space-cran, y+space+cran); + g.drawLine(x+width-space-cran, y+space+cran, x + width-space, y+space+cran); + + g.drawImage(IconManager.img9, x+width-space-fileX + 3, y + space + 7, null); + + g.drawString(value, x + textX , y + textY); + + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.ITALIC)); + g.drawString(typeName, x + textX , y + textY + 20); + g.setFont(f); + + } + + public void setValue(String val, Graphics g) { + oldValue = value; + int w = g.getFontMetrics().stringWidth(value); + int w1 = Math.max(minWidth, w + 2 * textX + fileX + space); + + //System.out.println("width=" + width + " w1=" + w1 + " w2=" + w2 + " value=" + value); + if (w1 != width) { + width = w1; + resizeWithFather(); + } + //System.out.println("width=" + width + " w1=" + w1 + " value=" + value); + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof TMLArchiCommunicationNode)) { + //System.out.println("cdRect comp"); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + //setCd(Math.min(x, father.getWidth() - getWidth()), Math.min(y, father.getHeight() - getHeight())); + setMoveCd(x, y); + } + } + + + public boolean editOndoubleClick(JFrame frame) { + String tmp; + boolean error = false; + + JDialogPortArtifact dialog = new JDialogPortArtifact(frame, "Setting port artifact attributes", this); + dialog.setSize(700, 600); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + if (dialog.getReferenceCommunicationName() == null) { + return false; + } + + if (dialog.getReferenceCommunicationName().length() != 0) { + tmp = dialog.getReferenceCommunicationName(); + referenceCommunicationName = tmp; + + } + + if (dialog.getCommunicationName().length() != 0) { + tmp = dialog.getCommunicationName(); + + if (!TAttribute.isAValidId(tmp, false, false)) { + error = true; + } else { + portName = tmp; + } + } + + if (dialog.getTypeName().length() != 0) { + typeName = dialog.getTypeName(); + } + + priority = dialog.getPriority(); + + ((TMLArchiDiagramPanel)tdp).setPriority(getFullValue(), priority); + + + if (error) { + JOptionPane.showMessageDialog(frame, + "Name is non-valid", + "Error", + JOptionPane.INFORMATION_MESSAGE); + } + + makeFullValue(); + + return !error; + + } + + private void makeFullValue() { + value = referenceCommunicationName + "::" + portName; + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.TMLARCHI_PORT_ARTIFACT; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info value=\"" + value + "\" portName=\"" + portName + "\" referenceCommunicationName=\""); + sb.append(referenceCommunicationName); + /*sb.append("\" priority=\""); + sb.append(priority);*/ + sb.append("\" typeName=\"" + typeName); + 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; + int t1id; + String svalue = null, sname = null, sreferenceCommunication = null, stype = null; + //String prio = null; + + 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("info")) { + svalue = elt.getAttribute("value"); + sname = elt.getAttribute("portName"); + sreferenceCommunication = elt.getAttribute("referenceCommunicationName"); + stype = elt.getAttribute("typeName"); + //prio = elt.getAttribute("priority"); + } + if (svalue != null) { + value = svalue; + } + if (sname != null){ + portName = sname; + } + if (sreferenceCommunication != null) { + referenceCommunicationName = sreferenceCommunication; + } + if (stype != null){ + typeName = stype; + } + + /*if ((prio != null) && (prio.trim().length() > 0)) { + priority = Integer.decode(prio).intValue(); + }*/ + } + } + } + } + + } catch (Exception e) { + System.out.println("Channel artifact"); + throw new MalformedModelingException(); + } + makeFullValue(); + } + + public DesignPanel getDesignPanel() { + return tdp.getGUI().getDesignPanel(value); + } + + public String getReferenceCommunicationName() { + return referenceCommunicationName; + } + + public void setReferenceCommunicationName(String _referenceCommunicationName) { + referenceCommunicationName = _referenceCommunicationName; + makeFullValue(); + } + + public String getPortName() { + return portName; + } + + + public String getFullValue() { + String tmp = getValue(); + tmp += " (" + getTypeName() + ")"; + return tmp; + } + + public String getTypeName() { + return typeName; + } + + public String getAttributes() { + return "Priority = " + priority; + } + +} diff --git a/src/ui/window/JDialogPortArtifact.java b/src/ui/window/JDialogPortArtifact.java new file mode 100755 index 0000000000000000000000000000000000000000..90fa6673231476e1c434063bf0443d65c21c40c4 --- /dev/null +++ b/src/ui/window/JDialogPortArtifact.java @@ -0,0 +1,298 @@ +/**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 JDialogTMLTaskArtifact + * Dialog for managing artifacts on hw nodes + * Creation: 19/09/2007 + * @version 1.0 19/09/2007 + * @author Ludovic APVRILLE + * @see + */ + +package ui.window; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +//import javax.swing.event.*; +import java.util.*; + +import ui.*; + +import ui.tmldd.*; + +import myutil.*; + + +public class JDialogPortArtifact extends javax.swing.JDialog implements ActionListener { + + private boolean regularClose; + private boolean emptyList = false; + + private JPanel panel2; + private Frame frame; + private TMLArchiPortArtifact artifact; + + protected JComboBox referenceCommunicationName, priority; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogPortArtifact(Frame _frame, String _title, TMLArchiPortArtifact _artifact) { + super(_frame, _title, true); + frame = _frame; + artifact = _artifact; + + //System.out.println("New window"); + + TraceManager.addDev("init components"); + + initComponents(); + + TraceManager.addDev("my init components"); + + myInitComponents(); + + TraceManager.addDev("pack"); + pack(); + } + + private void myInitComponents() { + selectPriority(); + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("Artifact attributes")); + panel2.setPreferredSize(new Dimension(650, 350)); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("Port:"), c2); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + TraceManager.addDev("Getting communications"); + Vector<String> list = artifact.getTDiagramPanel().getMGUI().getAllTMLCommunicationNames(); + Vector<String> portsList = new Vector<String>(); + int index = 0; + if (list.size() == 0) { + list.add("No communication to map"); + emptyList = true; + } else { + + index = 0;//indexOf(list, artifact.getFullValue()); + //parse each entry of list. Entry is in format AppName::chIn__chOut + for( String s: list ) { + String[] temp1 = s.split("__"); + String[] temp2 = temp1[0].split( "::" ); + String chOut = temp2[0] + "::" + temp1[1]; + String chIn = temp2[0] + "::" + temp2[1]; + if( !portsList.contains( chOut ) ) { + portsList.add( chOut ); + } + if( !portsList.contains( chIn ) ) { + portsList.add( chIn ); + } + } + } + + TraceManager.addDev("Got communications"); + + referenceCommunicationName = new JComboBox(portsList); + referenceCommunicationName.setSelectedIndex(index); + referenceCommunicationName.addActionListener(this); + //referenceTaskName.setEditable(true); + //referenceTaskName.setFont(new Font("times", Font.PLAIN, 12)); + panel2.add(referenceCommunicationName, c1); + + list = new Vector<String>(); + for(int i=0; i<11; i++) { + list.add(""+i); + } + priority = new JComboBox(list); + priority.setSelectedIndex(artifact.getPriority()); + panel2.add(priority, c1); + + /*c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("Name:"), c2); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + taskName = new JTextField(artifact.getTaskName(), 30); + taskName.setEditable(true); + taskName.setFont(new Font("times", Font.PLAIN, 12)); + panel2.add(taskName, c1);*/ + + // main panel; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + 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) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + if (evt.getSource() == referenceCommunicationName) { + selectPriority(); + } + + + 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 selectPriority() { + //System.out.println("Select priority"); + int index = ((TMLArchiDiagramPanel)artifact.getTDiagramPanel()).getMaxPriority((String)(referenceCommunicationName.getSelectedItem())); + priority.setSelectedIndex(index); + } + + public void closeDialog() { + regularClose = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public String getReferenceCommunicationName() { + if (emptyList) { + return null; + } + String tmp = (String)(referenceCommunicationName.getSelectedItem()); + int index = tmp.indexOf("::"); + if (index == -1) { + return tmp; + } + return tmp.substring(0, index); + } + + public String getCommunicationName() { + String tmp = (String)(referenceCommunicationName.getSelectedItem()); + int index = tmp.indexOf("::"); + if (index == -1) { + return tmp; + } + tmp = tmp.substring(index+2, tmp.length()); + + index = tmp.indexOf("("); + if (index > -1) { + tmp = tmp.substring(0, index).trim(); + } + //System.out.println("tmp=" + tmp); + return tmp; + } + + public String getTypeName() { + String tmp = (String)(referenceCommunicationName.getSelectedItem()); + int index1 = tmp.indexOf("("); + int index2 = tmp.indexOf(")"); + if ((index1 > -1) && (index2 > index1)) { + return tmp.substring(index1+1, index2); + } + return ""; + } + + + public int indexOf(Vector<String> _list, String name) { + int i = 0; + for(String s : _list) { + if (s.equals(name)) { + return i; + } + i++; + } + return 0; + } + + public int getPriority() { + return priority.getSelectedIndex(); + } + +} diff --git a/src/ui/window/JDialogSelectCPDiagrams.java b/src/ui/window/JDialogSelectCPDiagrams.java index 6e274e9eefbfc236e37b13ab71d357aa6f5b7dd4..53bc620ca058bf840355141f1433ac0402fcf62e 100755 --- a/src/ui/window/JDialogSelectCPDiagrams.java +++ b/src/ui/window/JDialogSelectCPDiagrams.java @@ -53,6 +53,8 @@ import javax.swing.*; import javax.swing.event.*; import java.util.*; +import myutil.*; + import ui.*; import ui.tmldd.*; import ui.tmlcp.*; @@ -85,6 +87,8 @@ public class JDialogSelectCPDiagrams extends javax.swing.JDialog implements Acti super(f, title, true); + TraceManager.addDev( "Printing list of components: " + Arrays.toString( componentList.toArray()) ); + back = _back; if( ( validated == null ) || ( ignored == null ) ) { val = makeNewVal( componentList ); //componentList must already contain something. Val contains a list of all TMLArchiNodes