diff --git a/src/ui/tmlsd/TMLSDControllerInstance.java b/src/ui/tmlsd/TMLSDControllerInstance.java index d4201972ce4e0112597282d9b3ae4ee0de7ac765..14be4f3eae8d024dfb2eb28a279ac4b68cd34d06 100755 --- a/src/ui/tmlsd/TMLSDControllerInstance.java +++ b/src/ui/tmlsd/TMLSDControllerInstance.java @@ -96,6 +96,7 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC public boolean editOndoubleClick(JFrame frame) { //Get the list of ArchiPanels, then ArchiDiagramPanels then CPU nodes + boolean mappedUnitExists = false; TDiagramPanel ttdp = getTDiagramPanel(); Vector<TMLArchiNode> availableCPUs = new Vector<TMLArchiNode>(); Vector<TMLArchiPanel> archiPanels = getTDiagramPanel().getMGUI().getTMLArchiDiagramPanels(); @@ -108,19 +109,32 @@ public class TMLSDControllerInstance extends TMLSDInstance implements SwallowTGC for( int k = 0; k < archiComponentsList.size(); k++ ) { if( archiComponentsList.get(k) instanceof TMLArchiCPUNode ) { availableCPUs.addElement( (TMLArchiNode) archiComponentsList.get(k) ); - TraceManager.addDev( "Found cpu node: " + archiComponentsList.get(k) ); + //TraceManager.addDev( "Found cpu node: " + archiComponentsList.get(k) ); + if( mappedUnit.equals( ((TMLArchiNode)archiComponentsList.get(k)).getName()) ) { + mappedUnitExists = true; + } } + if( archiComponentsList.get(k) instanceof TMLArchiHWANode ) { + availableCPUs.addElement( (TMLArchiNode) archiComponentsList.get(k) ); + //TraceManager.addDev( "Found cpu node: " + archiComponentsList.get(k) ); + if( mappedUnit.equals( ((TMLArchiNode)archiComponentsList.get(k)).getName()) ) { + mappedUnitExists = true; + } + } + } + if( !mappedUnitExists ) { + mappedUnit = ""; } JDialogTMLCPControllerInstance jdab = new JDialogTMLCPControllerInstance( myAttributes, availableCPUs, null, frame, - "Setting properties of " + name, "Attribute", this.name ); + "Setting properties of " + name, "Attribute", name, mappedUnit ); setJDialogOptions(jdab); jdab.setSize(650, 575); GraphicLib.centerOnParent(jdab); jdab.setVisible(true); // blocked until dialog has been closed - this.name = jdab.getName(); - this.mappedUnit = jdab.getMappedUnit(); - TraceManager.addDev( "Mapping done succesfully on " + this.mappedUnit ); + name = jdab.getName(); + mappedUnit = jdab.getMappedUnit(); + TraceManager.addDev( "Mapping done succesfully on " + mappedUnit ); //makeValue(); //if (oldValue.equals(value)) { //return false; diff --git a/src/ui/tmlsd/TMLSDInstance.java b/src/ui/tmlsd/TMLSDInstance.java index 7b5bf71bf79857abd2b0aef4198213e12fc84650..6839ca43787ae4977ded6a3e8bdab3dfc9bceee1 100755 --- a/src/ui/tmlsd/TMLSDInstance.java +++ b/src/ui/tmlsd/TMLSDInstance.java @@ -368,6 +368,9 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements protected String translateExtraParam() { TAttribute a; StringBuffer sb = new StringBuffer( "<extraparam>\n" ); + sb.append( "<Mapping mappedOn=\"" ); + sb.append( "" + mappedUnit ); + sb.append( "\" />\n" ); sb.append( "<Actor data=\"" ); sb.append( ""+isActor ); sb.append( "\" />\n" ); @@ -412,6 +415,9 @@ public abstract class TMLSDInstance extends TGCWithInternalComponent implements //System.out.println(n2); if( n2.getNodeType() == Node.ELEMENT_NODE ) { elt = (Element) n2; + if( elt.getTagName().equals("Mapping") ) { + mappedUnit = elt.getAttribute("mappedOn"); + } if( elt.getTagName().equals("Actor") ) { if( elt.getAttribute("data").compareTo("true") == 0 ) { isActor = true; diff --git a/src/ui/tmlsd/TMLSDStorageInstance.java b/src/ui/tmlsd/TMLSDStorageInstance.java index 56239419b0e57c5dd5088e8857766f8637006df9..0fcd435cbead89915fd8730f3f518b6d838f7a15 100755 --- a/src/ui/tmlsd/TMLSDStorageInstance.java +++ b/src/ui/tmlsd/TMLSDStorageInstance.java @@ -96,6 +96,7 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp public boolean editOndoubleClick(JFrame frame) { //Get the list of ArchiPanels, then ArchiDiagramPanels then Memory nodes + boolean mappedUnitExists = false; TDiagramPanel ttdp = getTDiagramPanel(); Vector<TMLArchiNode> availableMemories = new Vector<TMLArchiNode>(); Vector<TMLArchiPanel> archiPanels = getTDiagramPanel().getMGUI().getTMLArchiDiagramPanels(); @@ -105,18 +106,24 @@ public class TMLSDStorageInstance extends TMLSDInstance implements SwallowTGComp for( int k = 0; k < archiComponentsList.size(); k++ ) { if( archiComponentsList.get(k) instanceof TMLArchiMemoryNode ) { availableMemories.addElement( (TMLArchiNode) archiComponentsList.get(k) ); + if( mappedUnit.equals( ((TMLArchiNode)archiComponentsList.get(k)).getName()) ) { + mappedUnitExists = true; + } } } + if( !mappedUnitExists ) { + mappedUnit = ""; + } JDialogTMLCPStorageInstance jdab = new JDialogTMLCPStorageInstance( myAttributes, availableMemories, null, frame, - "Setting properties of " + name, "Attribute", this.name ); + "Setting properties of " + name, "Attribute", name, mappedUnit ); setJDialogOptions(jdab); jdab.setSize(650, 575); GraphicLib.centerOnParent(jdab); jdab.setVisible(true); // blocked until dialog has been closed - this.name = jdab.getName(); - this.mappedUnit = jdab.getMappedUnit(); - TraceManager.addDev( "Mapping done succesfully on " + this.mappedUnit ); + name = jdab.getName(); + mappedUnit = jdab.getMappedUnit(); + TraceManager.addDev( "Mapping done succesfully on " + mappedUnit ); //makeValue(); //if (oldValue.equals(value)) { //return false; diff --git a/src/ui/tmlsd/TMLSDTransferInstance.java b/src/ui/tmlsd/TMLSDTransferInstance.java index 6050dea605a3d60a7d06f5d2e963de7b913745ed..eeb7b359ddf19f2ed2ed17087edbe2052eb5a4e6 100755 --- a/src/ui/tmlsd/TMLSDTransferInstance.java +++ b/src/ui/tmlsd/TMLSDTransferInstance.java @@ -96,10 +96,9 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom public boolean editOndoubleClick(JFrame frame) { //Get the list of ArchiPanels, then ArchiDiagramPanels then Memory nodes + boolean mappedUnitExists = false; TDiagramPanel ttdp = getTDiagramPanel(); Vector<TMLArchiNode> availableTransferUnits = new Vector<TMLArchiNode>(); -// Vector<TMLArchiBridgeNode> availableBridges = new Vector<TMLArchiBridgeNode>(); - // Vector<TMLArchiDMANode> availableDMAs = new Vector<TMLArchiDMANode>(); Vector<TMLArchiPanel> archiPanels = getTDiagramPanel().getMGUI().getTMLArchiDiagramPanels(); for( TMLArchiPanel panel: archiPanels ) { @@ -110,27 +109,39 @@ public class TMLSDTransferInstance extends TMLSDInstance implements SwallowTGCom for( int k = 0; k < archiComponentsList.size(); k++ ) { if( archiComponentsList.get(k) instanceof TMLArchiBUSNode ) { availableTransferUnits.addElement( (TMLArchiNode) archiComponentsList.get(k) ); - TraceManager.addDev( "Found bus node: " + archiComponentsList.get(k) ); + //TraceManager.addDev( "Found bus node: " + archiComponentsList.get(k) ); + if( mappedUnit.equals( ((TMLArchiNode)archiComponentsList.get(k)).getName()) ) { + mappedUnitExists = true; + } } if( archiComponentsList.get(k) instanceof TMLArchiBridgeNode ) { availableTransferUnits.addElement( (TMLArchiNode) archiComponentsList.get(k) ); - TraceManager.addDev( "Found bridge node: " + archiComponentsList.get(k) ); + //TraceManager.addDev( "Found bridge node: " + archiComponentsList.get(k) ); + if( mappedUnit.equals( ((TMLArchiNode)archiComponentsList.get(k)).getName()) ) { + mappedUnitExists = true; + } } if( archiComponentsList.get(k) instanceof TMLArchiDMANode ) { availableTransferUnits.addElement( (TMLArchiNode) archiComponentsList.get(k) ); - TraceManager.addDev( "Found dma node: " + archiComponentsList.get(k) ); + //TraceManager.addDev( "Found dma node: " + archiComponentsList.get(k) ); + if( mappedUnit.equals( ((TMLArchiNode)archiComponentsList.get(k)).getName()) ) { + mappedUnitExists = true; + } } } + if( !mappedUnitExists ) { + mappedUnit = ""; + } JDialogTMLCPTransferInstance jdab = new JDialogTMLCPTransferInstance( myAttributes, availableTransferUnits, null, frame, - "Setting properties of " + name, "Attribute", this.name ); + "Setting properties of " + name, "Attribute", name, mappedUnit ); setJDialogOptions(jdab); jdab.setSize(650, 575); GraphicLib.centerOnParent(jdab); jdab.setVisible(true); // blocked until dialog has been closed - this.name = jdab.getName(); - this.mappedUnit = jdab.getMappedUnit(); - TraceManager.addDev( "Mapping done succesfully on " + this.mappedUnit ); + name = jdab.getName(); + mappedUnit = jdab.getMappedUnit(); + TraceManager.addDev( "Mapping done succesfully on " + mappedUnit ); //makeValue(); //if (oldValue.equals(value)) { //return false; diff --git a/src/ui/window/JDialogTMLCPControllerInstance.java b/src/ui/window/JDialogTMLCPControllerInstance.java index 784ee70fe33bd9d17d1f9554414700fa759a19aa..fbcb5f60dd288b32a803a11938b69f5e57418722 100755 --- a/src/ui/window/JDialogTMLCPControllerInstance.java +++ b/src/ui/window/JDialogTMLCPControllerInstance.java @@ -62,8 +62,8 @@ public class JDialogTMLCPControllerInstance extends JDialogTMLSDInstance impleme /** Creates new form */ public JDialogTMLCPControllerInstance( Vector _attributes, Vector<TMLArchiNode> _availableUnits, Vector _forbidden, Frame f, String title, - String attrib, String _name ) { - super(_attributes, _availableUnits, _forbidden, f, title, attrib, _name ); + String attrib, String _name, String _mappedUnit ) { + super(_attributes, _availableUnits, _forbidden, f, title, attrib, _name, _mappedUnit ); } @Override protected void initComponents() { @@ -250,8 +250,8 @@ public class JDialogTMLCPControllerInstance extends JDialogTMLSDInstance impleme //TMLArchiMemoryNode mem = (TMLArchiMemoryNode) memoriesPar.get(j); availableUnits.add( ( (TMLArchiNode) unitsPar.get(j)).getName() ); } - referenceMemoriesName = new JComboBox( availableUnits ); - panel3.add( referenceMemoriesName, c3); + referenceUnitsName = new JComboBox( availableUnits ); + panel3.add( referenceUnitsName, c3); // third line panel3 c3.gridwidth = GridBagConstraints.REMAINDER; //end row diff --git a/src/ui/window/JDialogTMLCPExecutionInstance.java b/src/ui/window/JDialogTMLCPExecutionInstance.java deleted file mode 100755 index 9ec6d28f4833f4097e91a172e1aa2e00e8e97c43..0000000000000000000000000000000000000000 --- a/src/ui/window/JDialogTMLCPExecutionInstance.java +++ /dev/null @@ -1,665 +0,0 @@ -/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici -* -* ludovic.apvrille AT telecom-paristech.fr -* andrea.enrici AT telecom-paristech.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 JDialogTMLCPStorageInstance -* Dialog for managing attributes, mapping and name of a SD instance -* Creation: 25/07/2014 -* @version 1.0 25/07/2014 -* @author Ludovic APVRILLE, Andrea ENRICI -* @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 JDialogTMLCPStorageInstance extends javax.swing.JDialog implements ActionListener, ListSelectionListener { - - private Vector attributes, attributesPar, forbidden, initValues; - private Vector memoriesPar; - private Vector<String> mappedMemories = new Vector<String>(); - private Vector<String> availableMemories = new Vector<String>(); - private boolean checkKeyword, checkJavaKeyword; - - private boolean cancelled = false; - - private JPanel panel1, panel2; - - private Frame frame; - private int tab; - - private String attrib; // "Attributes", "Gates", etc. - - //Name panel - private JTextField nameOfInstance; - - // Panel1 - private JComboBox accessBox, typeBox; - private JTextField identifierText; - private JTextField initialValue; - private JButton addButton; - - //Panel2 - private JList listAttribute; - private JButton upButton; - private JButton downButton; - private JButton removeButton; - - //Panel 3 - private JButton removeMappingButton; - private JComboBox referenceMemoriesName; - - - // Mapping of storage units - private JPanel panel3, panel4; - private JButton addMappingButton; - private JList listStorageUnits; - - // Main Panel - private JButton closeButton; - private JButton cancelButton; - - private String name = ""; - - /** Creates new form */ - public JDialogTMLCPStorageInstance( Vector _attributes, Vector<TMLArchiMemoryNode> _memories, Vector _forbidden, Frame f, String title, - String attrib, String _name ) { - super(f, title, true); - frame = f; - attributesPar = _attributes; - memoriesPar = _memories; - this.name = _name; - forbidden = _forbidden; - initValues = new Vector(); - this.attrib = attrib; - - attributes = new Vector(); - - for( int i = 0; i < attributesPar.size(); i++ ) { - attributes.addElement( ( (TAttribute)( attributesPar.elementAt(i) ) ).makeClone() ); - } - - initComponents(); - myInitComponents(); - pack(); - } - - private void myInitComponents() { - removeButton.setEnabled(false); - upButton.setEnabled(false); - downButton.setEnabled(false); - removeMappingButton.setEnabled(false); - } - - private void initComponents() { - JTabbedPane tabbedPane = new JTabbedPane(); - Container c = getContentPane(); - - JPanel namePanel = new JPanel(); - JPanel panelAttr = new JPanel(new BorderLayout()); - JPanel panelMethod = new JPanel(new BorderLayout()); - GridBagLayout gridbag0 = new GridBagLayout(); - GridBagLayout gridbag1 = new GridBagLayout(); - GridBagLayout gridbag2 = new GridBagLayout(); - GridBagLayout gridbag3 = new GridBagLayout(); - GridBagLayout gridbag4 = new GridBagLayout(); - GridBagLayout gridbag5 = new GridBagLayout(); - GridBagLayout gridbag6 = new GridBagLayout(); - GridBagLayout gridbag7 = new GridBagLayout(); - GridBagConstraints c0 = new GridBagConstraints(); - GridBagConstraints c1 = new GridBagConstraints(); - GridBagConstraints c2 = new GridBagConstraints(); - GridBagConstraints c3 = new GridBagConstraints(); - GridBagConstraints c4 = new GridBagConstraints(); - GridBagConstraints c5 = new GridBagConstraints(); - GridBagConstraints c6 = new GridBagConstraints(); - GridBagConstraints c7 = new GridBagConstraints(); - - setFont(new Font("Helvetica", Font.PLAIN, 14)); - c.setLayout(gridbag0); - - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - - //Name panel - namePanel.add( new JLabel( "Name of storage instance:" ) ); - nameOfInstance = new JTextField( this.name, 30 ); - namePanel.add( nameOfInstance ); - - //Panel1 - - panel1 = new JPanel(); - panel1.setLayout(gridbag1); - panel1.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib + "s")); - panel1.setPreferredSize(new Dimension(300, 250)); - - panel2 = new JPanel(); - panel2.setLayout(gridbag2); - panel2.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); - panel2.setPreferredSize(new Dimension(300, 250)); - - // first line panel1 - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.anchor = GridBagConstraints.CENTER; - panel1.add(new JLabel("access"), c1); - panel1.add(new JLabel("identifier"), c1); - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" "), c1); - panel1.add(new JLabel("initial value"), c1); - } - panel1.add(new JLabel(" "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - panel1.add(new JLabel("type"), c1); - - // second line panel1 - c1.gridwidth = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - c1.anchor = GridBagConstraints.CENTER; - accessBox = new JComboBox(); - panel1.add(accessBox, c1); - identifierText = new JTextField(); - identifierText.setColumns(15); - identifierText.setEditable(true); - panel1.add(identifierText, c1); - - initialValue = new JTextField(); - initialValue.setColumns(5); - initialValue.setEditable(true); - - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" = "), c1); - panel1.add(initialValue, c1); - } - - panel1.add(new JLabel(" : "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - typeBox = new JComboBox(); - typeBox.addActionListener(this); - panel1.add(typeBox, c1); - - // third line panel1 - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - // fourth line panel2 - c1.gridheight = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - addButton = new JButton("Add / Modify " + attrib); - addButton.addActionListener(this); - panel1.add(addButton, c1); - - // 1st line panel2 - listAttribute = new JList(attributes); - //listAttribute.setFixedCellWidth(150); - //listAttribute.setFixedCellHeight(20); - listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - listAttribute.addListSelectionListener(this); - JScrollPane scrollPane = new JScrollPane(listAttribute); - scrollPane.setSize(300, 250); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 5; - c2.weighty = 10.0; - c2.weightx = 10.0; - panel2.add(scrollPane, c2); - - // 2nd line panel2 - c2.weighty = 1.0; - c2.weightx = 1.0; - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 1; - panel2.add(new JLabel(""), c2); - - // third line panel2 - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.HORIZONTAL; - upButton = new JButton("Up"); - upButton.addActionListener(this); - panel2.add(upButton, c2); - - downButton = new JButton("Down"); - downButton.addActionListener(this); - panel2.add(downButton, c2); - - removeButton = new JButton("Remove " + attrib); - removeButton.addActionListener(this); - panel2.add(removeButton, c2); - - // Mapping - panel3 = new JPanel(); - panel3.setLayout(gridbag3); - panel3.setBorder(new javax.swing.border.TitledBorder("Available storage units")); - panel3.setPreferredSize(new Dimension(300, 250)); - - panel4 = new JPanel(); - panel4.setLayout(gridbag2); - panel4.setBorder(new javax.swing.border.TitledBorder("Mapped storage unit")); - panel4.setPreferredSize(new Dimension(300, 250)); - - // first line panel3 - c3.gridwidth = 1; - c3.gridheight = 1; - c3.weighty = 1.0; - c3.weightx = 1.0; - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - c3.fill = GridBagConstraints.BOTH; - c3.gridheight = 3; - panel3.add(new JLabel(" "), c3); - - c3.gridwidth = 1; - c3.gridheight = 1; - c3.weighty = 1.0; - c3.weightx = 1.0; - c3.anchor = GridBagConstraints.CENTER; - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - panel3.add(new JLabel("Storage unit:"), c3); - - // second line panel3 - c3.fill = GridBagConstraints.HORIZONTAL; - - for( int j = 0; j < memoriesPar.size(); j++ ) { - TMLArchiMemoryNode mem = (TMLArchiMemoryNode) memoriesPar.get(j); - availableMemories.add( mem.getName() ); - } - referenceMemoriesName = new JComboBox( availableMemories ); - panel3.add( referenceMemoriesName, c3); - - // third line panel3 - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - c3.fill = GridBagConstraints.BOTH; - c3.gridheight = 3; - panel3.add( new JLabel(" "), c3 ); - - // fourth line panel3 - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - c3.fill = GridBagConstraints.BOTH; - c3.gridheight = 3; - - // fifth line panel3 - c3.gridheight = 1; - c3.fill = GridBagConstraints.HORIZONTAL; - addMappingButton = new JButton("Map storage unit"); - addMappingButton.addActionListener(this); - panel3.add( addMappingButton, c3 ); - - // 1st line panel4 - - listStorageUnits = new JList( mappedMemories ); - listStorageUnits.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - listStorageUnits.addListSelectionListener( this ); - scrollPane = new JScrollPane( listStorageUnits ); - scrollPane.setSize( 300, 250 ); - c4.gridwidth = GridBagConstraints.REMAINDER; //end row - c4.fill = GridBagConstraints.BOTH; - c4.gridheight = 5; - c4.weighty = 10.0; - c4.weightx = 10.0; - panel4.add(scrollPane, c4); - - // 2nd line panel4 - c4.weighty = 1.0; - c4.weightx = 1.0; - c4.fill = GridBagConstraints.BOTH; - c4.gridheight = 1; - panel4.add(new JLabel(""), c4); - - // third line panel4 - c4.gridwidth = GridBagConstraints.REMAINDER; //end row - c4.fill = GridBagConstraints.HORIZONTAL; - removeMappingButton = new JButton( "Remove storage unit" ); - removeMappingButton.addActionListener( this ); - panel4.add( removeMappingButton, c4 ); - - // main panel; - panelAttr.add(panel1, BorderLayout.WEST); - panelAttr.add(panel2, BorderLayout.EAST); - tabbedPane.addTab("Attributes", panelAttr); - - //if (hasMethods) { - panelMethod.add(panel3, BorderLayout.WEST); - panelMethod.add(panel4, BorderLayout.EAST); - tabbedPane.addTab("Mapping", panelMethod); - //} - - tabbedPane.setSelectedIndex(tab); - - //c.add(panel1, c0); - //c.add(panel2, c0); - - c0.gridwidth = 1; - c0.gridheight = 10; - c0.weighty = 1.0; - c0.weightx = 1.0; - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - - c.add(namePanel, c0); - - c.add(tabbedPane, 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; - } - - - //String command = evt.getActionCommand(); - - // Compare the action command to the known actions. - if (evt.getSource() == closeButton) { - closeDialog(); - } else if (evt.getSource() == addButton) { - addAttribute(); - } else if (evt.getSource() == cancelButton) { - cancelDialog(); - } else if (evt.getSource() == removeButton) { - removeAttribute(); - } else if (evt.getSource() == downButton) { - downAttribute(); - } else if (evt.getSource() == upButton) { - upAttribute(); - } else if (evt.getSource() == addMappingButton) { - addMappedUnit(); - } else if (evt.getSource() == removeMappingButton) { - removeMappedUnit(); - } - } - - public void addAccess(String s) { - accessBox.addItem(s); - } - - public void addType(String s) { - initValues.add(new Boolean(true)); - typeBox.addItem(s); - } - - public void addType(String s, boolean b) { - initValues.add(new Boolean(b)); - typeBox.addItem(s); - } - - public void enableInitialValue(boolean b) { - initialValue.setEnabled(b); - } - - public void enableRTLOTOSKeyword(boolean b) { - checkKeyword = !b; - } - - public void enableJavaKeyword(boolean b) { - checkJavaKeyword = !b; - } - - public void addAttribute() { - Object o1 = accessBox.getSelectedItem(); - Object o2 = typeBox.getSelectedItem(); - String s = identifierText.getText(); - String value = initialValue.getText(); - TAttribute a; - - if( s.length() > 0 ) { - if( ( TAttribute.isAValidId( s, checkKeyword, checkJavaKeyword ) ) && ( TAttribute.notIn(s, forbidden ) ) ) { - int i = TAttribute.getAccess(o1.toString()); - int j = TAttribute.getAvatarType(o2.toString()); - if( ( j == TAttribute.ARRAY_NAT ) && ( value.length() < 1 ) ) { - value = "2"; - } - if ((i != -1) && (j!= -1)) { - if ((value.length() < 1) || (initialValue.isEnabled() == false)) { - value = ""; - } - else { - if( !TAttribute.isAValidInitialValue(j, value) ) { - JOptionPane.showMessageDialog( frame, "The initial value is not valid", "Error", JOptionPane.INFORMATION_MESSAGE ); - return; - } - } - if( j == TAttribute.OTHER ) { - a = new TAttribute(i, s, value, o2.toString()); - a.isAvatar = true; - //System.out.println("New attribute: " + o2.toString()); - } - else { - a = new TAttribute(i, s, value, j); - a.isAvatar = true; - } - //checks whether the same attribute already belongs to the list - int index = attributes.size(); - if( attributes.contains(a) ) { - index = attributes.indexOf(a); - a = (TAttribute)(attributes.elementAt(index)); - a.setAccess(i); - if( j == TAttribute.OTHER ) { - a.setTypeOther(o2.toString()); - } - a.setType(j); - a.setInitialValue(value); - //attributes.removeElementAt(index); - } - else { - attributes.add(index, a); - } - listAttribute.setListData(attributes); - identifierText.setText(""); - } - else { - JOptionPane.showMessageDialog( frame, "Bad access / type", "Error", JOptionPane.INFORMATION_MESSAGE); - return; - } - } - else { - JOptionPane.showMessageDialog( frame, "Bad identifier: identifier already in use, or invalid identifier", - "Error", JOptionPane.INFORMATION_MESSAGE); - return; - } - } - else { - JOptionPane.showMessageDialog( frame, "Bad identifier", "Error", JOptionPane.INFORMATION_MESSAGE ); - return; - } - } //End of method - - public void addMappedUnit() { - - //TraceManager.addDev( "**************************" ); - //TraceManager.addDev( referenceMemoriesName.getSelectedItem().toString() ); - //TraceManager.addDev( "**************************" ); - removeMappingButton.setEnabled( true ); - String s = referenceMemoriesName.getSelectedItem().toString(); - mappedMemories.add(s); - listStorageUnits.setListData( mappedMemories ); - } - - public void removeMappedUnit() { - mappedMemories.removeElementAt( 0 ); - listStorageUnits.setListData( mappedMemories ); - removeMappingButton.setEnabled( false ); - } - - public void removeAttribute() { - int i = listAttribute.getSelectedIndex() ; - if (i!= -1) { - TAttribute a = (TAttribute)(attributes.elementAt(i)); - a.setAccess(-1); - attributes.removeElementAt(i); - listAttribute.setListData(attributes); - } - } - - public void downAttribute() { - int i = listAttribute.getSelectedIndex(); - if ((i!= -1) && (i != attributes.size() - 1)) { - Object o = attributes.elementAt(i); - attributes.removeElementAt(i); - attributes.insertElementAt(o, i+1); - listAttribute.setListData(attributes); - listAttribute.setSelectedIndex(i+1); - } - } - - public void upAttribute() { - int i = listAttribute.getSelectedIndex(); - //TraceManager.addDev("Selected index = " + i); - if (i > 0) { - //TraceManager.addDev("Modifying ..."); - Object o = attributes.elementAt(i); - attributes.removeElementAt(i); - attributes.insertElementAt(o, i-1); - listAttribute.setListData(attributes); - listAttribute.setSelectedIndex(i-1); - } - } - - public void closeDialog() { - cancelled = false; - attributesPar.removeAllElements(); - for(int i=0; i<attributes.size(); i++) { - attributesPar.addElement(attributes.elementAt(i)); - } - this.name = nameOfInstance.getText(); - if( mappedMemories.size() > 1 ) { - JOptionPane.showMessageDialog( frame, "Only one memory can be mapped per storage unit", "Error", JOptionPane.INFORMATION_MESSAGE ); - return; - } - dispose(); - } - - public boolean hasBeenCancelled() { - return cancelled; - } - - public void cancelDialog() { - cancelled = true; - dispose(); - } - - public void valueChanged(ListSelectionEvent e) { - int i = listAttribute.getSelectedIndex() ; - if (i == -1) { - removeButton.setEnabled(false); - upButton.setEnabled(false); - downButton.setEnabled(false); - identifierText.setText(""); - //initialValue.setText(""); - } else { - TAttribute a = (TAttribute)(attributes.elementAt(i)); - identifierText.setText(a.getId()); - initialValue.setText(a.getInitialValue()); - select(accessBox, a.getStringAccess(a.getAccess())); - if (a.getType() == TAttribute.OTHER) { - select(typeBox, a.getTypeOther()); - } else { - select(typeBox, a.getStringAvatarType(a.getType())); - } - removeButton.setEnabled(true); - if (i > 0) { - upButton.setEnabled(true); - } else { - upButton.setEnabled(false); - } - if (i != attributes.size() - 1) { - downButton.setEnabled(true); - } else { - downButton.setEnabled(false); - } - } - - } //End of method - - public void select(JComboBox jcb, String text) { - String s; - for(int i=0; i<jcb.getItemCount(); i++) { - s = (String)(jcb.getItemAt(i)); - //System.out.println("String found: *" + s + "* *" + text + "*"); - if (s.equals(text)) { - jcb.setSelectedIndex(i); - return; - } - } - } - - public String getName() { - return this.name; - } - - public String getMappedMemory() { - if( mappedMemories.size() == 1 ) { - return mappedMemories.get(0); - } - return ""; - } -} //End of class diff --git a/src/ui/window/JDialogTMLCPSDInstance.java b/src/ui/window/JDialogTMLCPSDInstance.java deleted file mode 100755 index d8587f690ac6914564d342fa183d94e82a9946f2..0000000000000000000000000000000000000000 --- a/src/ui/window/JDialogTMLCPSDInstance.java +++ /dev/null @@ -1,711 +0,0 @@ -/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici -* -* ludovic.apvrille AT telecom-paristech.fr -* andrea.enrici AT telecom-paristech.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 JDialogTMLCPSDInstance -* Dialog for managing attributes, methods and signals of instances of Sequence Diagrams -* Creation: 25/07/2014 -* @version 1.0 25/07/2014 -* @author Ludovic APVRILLE, Andrea ENRICI -* @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 JDialogTMLCPSDInstance extends javax.swing.JDialog implements ActionListener, ListSelectionListener { - - private Vector attributes, attributesPar, forbidden, initValues; - private Vector memoriesPar; - private boolean checkKeyword, checkJavaKeyword; - - private boolean cancelled = false; - - private JPanel panel1, panel2; - - private Frame frame; - private int tab; - - private String attrib; // "Attributes", "Gates", etc. - - //Name panel - private JTextField nameOfInstance; - - // Panel1 - private JComboBox accessBox, typeBox; - private JTextField identifierText; - private JTextField initialValue; - private JButton addButton; - - //Panel2 - private JList listAttribute; - private JButton upButton; - private JButton downButton; - private JButton removeButton; - - //Panel 3 - private JButton removeMappingButton; - private JComboBox referenceMemoriesName; - - - // Mapping of storage units -// private boolean hasMemories = false; - private JPanel panel3, panel4; - private JTextField methodText; - private JButton addMappingButton; - private JList listMethod, listStorageUnits; - private JButton upMethodButton; - private JButton downMethodButton; - private JButton removeMethodButton; - private JCheckBox implementationProvided; - private Vector<String> memories; - - // Main Panel - private JButton closeButton; - private JButton cancelButton; - - private String name = ""; - - /** Creates new form */ - public JDialogTMLCPSDInstance( Vector _attributes, Vector<TMLArchiMemoryNode> _memories, Vector _forbidden, Frame f, String title, - String attrib, String _name ) { - super(f, title, true); - frame = f; - attributesPar = _attributes; - memoriesPar = _memories; - this.name = _name; - forbidden = _forbidden; - initValues = new Vector(); - this.attrib = attrib; - - attributes = new Vector(); - - for( int i = 0; i < attributesPar.size(); i++ ) { - attributes.addElement( ( (TAttribute)( attributesPar.elementAt(i) ) ).makeClone() ); - } - - initComponents(); - myInitComponents(); - pack(); - } - - private void myInitComponents() { - removeButton.setEnabled(false); - upButton.setEnabled(false); - downButton.setEnabled(false); - removeMappingButton.setEnabled(false); - } - - private void initComponents() { - JTabbedPane tabbedPane = new JTabbedPane(); - Container c = getContentPane(); - - JPanel namePanel = new JPanel(); - JPanel panelAttr = new JPanel(new BorderLayout()); - JPanel panelMethod = new JPanel(new BorderLayout()); - GridBagLayout gridbag0 = new GridBagLayout(); - GridBagLayout gridbag1 = new GridBagLayout(); - GridBagLayout gridbag2 = new GridBagLayout(); - GridBagLayout gridbag3 = new GridBagLayout(); - GridBagLayout gridbag4 = new GridBagLayout(); - GridBagLayout gridbag5 = new GridBagLayout(); - GridBagLayout gridbag6 = new GridBagLayout(); - GridBagLayout gridbag7 = new GridBagLayout(); - GridBagConstraints c0 = new GridBagConstraints(); - GridBagConstraints c1 = new GridBagConstraints(); - GridBagConstraints c2 = new GridBagConstraints(); - GridBagConstraints c3 = new GridBagConstraints(); - GridBagConstraints c4 = new GridBagConstraints(); - GridBagConstraints c5 = new GridBagConstraints(); - GridBagConstraints c6 = new GridBagConstraints(); - GridBagConstraints c7 = new GridBagConstraints(); - - setFont(new Font("Helvetica", Font.PLAIN, 14)); - c.setLayout(gridbag0); - - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - - //Name panel - namePanel.add( new JLabel( "Name of storage instance:" ) ); - nameOfInstance = new JTextField( this.name, 30 ); - namePanel.add( nameOfInstance ); - - //Panel1 - - panel1 = new JPanel(); - panel1.setLayout(gridbag1); - panel1.setBorder(new javax.swing.border.TitledBorder("Adding " + attrib + "s")); - panel1.setPreferredSize(new Dimension(300, 250)); - - panel2 = new JPanel(); - panel2.setLayout(gridbag2); - panel2.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib + "s")); - panel2.setPreferredSize(new Dimension(300, 250)); - - // first line panel1 - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - c1.gridwidth = 1; - c1.gridheight = 1; - c1.weighty = 1.0; - c1.weightx = 1.0; - c1.anchor = GridBagConstraints.CENTER; - panel1.add(new JLabel("access"), c1); - panel1.add(new JLabel("identifier"), c1); - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" "), c1); - panel1.add(new JLabel("initial value"), c1); - } - panel1.add(new JLabel(" "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - panel1.add(new JLabel("type"), c1); - - // second line panel1 - c1.gridwidth = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - c1.anchor = GridBagConstraints.CENTER; - accessBox = new JComboBox(); - panel1.add(accessBox, c1); - identifierText = new JTextField(); - identifierText.setColumns(15); - identifierText.setEditable(true); - panel1.add(identifierText, c1); - - initialValue = new JTextField(); - initialValue.setColumns(5); - initialValue.setEditable(true); - - if (attrib.equals("Attribute") || attrib.equals("Variable")) { - panel1.add(new JLabel(" = "), c1); - panel1.add(initialValue, c1); - } - - panel1.add(new JLabel(" : "), c1); - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - typeBox = new JComboBox(); - typeBox.addActionListener(this); - panel1.add(typeBox, c1); - - // third line panel1 - c1.gridwidth = GridBagConstraints.REMAINDER; //end row - c1.fill = GridBagConstraints.BOTH; - c1.gridheight = 3; - panel1.add(new JLabel(" "), c1); - - // fourth line panel2 - c1.gridheight = 1; - c1.fill = GridBagConstraints.HORIZONTAL; - addButton = new JButton("Add / Modify " + attrib); - addButton.addActionListener(this); - panel1.add(addButton, c1); - - // 1st line panel2 - listAttribute = new JList(attributes); - //listAttribute.setFixedCellWidth(150); - //listAttribute.setFixedCellHeight(20); - listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - listAttribute.addListSelectionListener(this); - JScrollPane scrollPane = new JScrollPane(listAttribute); - scrollPane.setSize(300, 250); - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 5; - c2.weighty = 10.0; - c2.weightx = 10.0; - panel2.add(scrollPane, c2); - - // 2nd line panel2 - c2.weighty = 1.0; - c2.weightx = 1.0; - c2.fill = GridBagConstraints.BOTH; - c2.gridheight = 1; - panel2.add(new JLabel(""), c2); - - // third line panel2 - c2.gridwidth = GridBagConstraints.REMAINDER; //end row - c2.fill = GridBagConstraints.HORIZONTAL; - upButton = new JButton("Up"); - upButton.addActionListener(this); - panel2.add(upButton, c2); - - downButton = new JButton("Down"); - downButton.addActionListener(this); - panel2.add(downButton, c2); - - removeButton = new JButton("Remove " + attrib); - removeButton.addActionListener(this); - panel2.add(removeButton, c2); - - // Methods - panel3 = new JPanel(); - panel3.setLayout(gridbag3); - panel3.setBorder(new javax.swing.border.TitledBorder("Available storage units")); - panel3.setPreferredSize(new Dimension(300, 250)); - - panel4 = new JPanel(); - panel4.setLayout(gridbag2); - panel4.setBorder(new javax.swing.border.TitledBorder("Mapped storage unit")); - panel4.setPreferredSize(new Dimension(300, 250)); - - // first line panel3 - c3.gridwidth = 1; - c3.gridheight = 1; - c3.weighty = 1.0; - c3.weightx = 1.0; - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - c3.fill = GridBagConstraints.BOTH; - c3.gridheight = 3; - panel3.add(new JLabel(" "), c3); - - c3.gridwidth = 1; - c3.gridheight = 1; - c3.weighty = 1.0; - c3.weightx = 1.0; - c3.anchor = GridBagConstraints.CENTER; - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - panel3.add(new JLabel("Storage unit:"), c3); - - // second line panel3 - c3.fill = GridBagConstraints.HORIZONTAL; - - memories = new Vector<String>(); - for( int j = 0; j < memoriesPar.size(); j++ ) { - TMLArchiMemoryNode mem = (TMLArchiMemoryNode) memoriesPar.get(j); - memories.add( mem.getName() ); - } - referenceMemoriesName = new JComboBox( memories ); - panel3.add( referenceMemoriesName, c3); - - - /*methodText = new JTextField(); - methodText.setColumns(50); - methodText.setEditable(true); - panel3.add(methodText, c3);*/ - - // third line panel3 - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - c3.fill = GridBagConstraints.BOTH; - c3.gridheight = 3; - panel3.add( new JLabel(" "), c3 ); - - // fourth line panel3 - c3.gridwidth = GridBagConstraints.REMAINDER; //end row - c3.fill = GridBagConstraints.BOTH; - c3.gridheight = 3; - /*implementationProvided = new JCheckBox("Implementation provided by user"); - implementationProvided.setSelected(false); - panel3.add(implementationProvided, c3);*/ - - - // fifth line panel3 - c3.gridheight = 1; - c3.fill = GridBagConstraints.HORIZONTAL; - addMappingButton = new JButton("Map storage unit"); - addMappingButton.addActionListener(this); - panel3.add( addMappingButton, c3 ); - - // 1st line panel4 - listStorageUnits = new JList( memories ); - listStorageUnits.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - listStorageUnits.addListSelectionListener( this ); - scrollPane = new JScrollPane( listStorageUnits ); - scrollPane.setSize( 300, 250 ); - c4.gridwidth = GridBagConstraints.REMAINDER; //end row - c4.fill = GridBagConstraints.BOTH; - c4.gridheight = 5; - c4.weighty = 10.0; - c4.weightx = 10.0; - panel4.add(scrollPane, c4); - - // 2nd line panel4 - c4.weighty = 1.0; - c4.weightx = 1.0; - c4.fill = GridBagConstraints.BOTH; - c4.gridheight = 1; - panel4.add(new JLabel(""), c4); - - // third line panel4 - c4.gridwidth = GridBagConstraints.REMAINDER; //end row - c4.fill = GridBagConstraints.HORIZONTAL; - removeMappingButton = new JButton( "Remove storage unit" ); - removeMappingButton.addActionListener( this ); - panel4.add( removeMappingButton, c4 ); - /*upMethodButton = new JButton("Up"); - upMethodButton.addActionListener(this); - panel4.add(upMethodButton, c4); - - downMethodButton = new JButton("Down"); - downMethodButton.addActionListener(this); - panel4.add(downMethodButton, c4); - - removeMethodButton = new JButton("Remove method"); - removeMethodButton.addActionListener(this); - panel4.add(removeMethodButton, c4);*/ - - - // main panel; - panelAttr.add(panel1, BorderLayout.WEST); - panelAttr.add(panel2, BorderLayout.EAST); - tabbedPane.addTab("Attributes", panelAttr); - - //if (hasMethods) { - panelMethod.add(panel3, BorderLayout.WEST); - panelMethod.add(panel4, BorderLayout.EAST); - tabbedPane.addTab("Mapping", panelMethod); - //} - - tabbedPane.setSelectedIndex(tab); - - //c.add(panel1, c0); - //c.add(panel2, c0); - - c0.gridwidth = 1; - c0.gridheight = 10; - c0.weighty = 1.0; - c0.weightx = 1.0; - c0.gridwidth = GridBagConstraints.REMAINDER; //end row - - c.add(namePanel, c0); - - c.add(tabbedPane, 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; - } - - - //String command = evt.getActionCommand(); - - // Compare the action command to the known actions. - if (evt.getSource() == closeButton) { - closeDialog(); - } else if (evt.getSource() == addButton) { - addAttribute(); - } else if (evt.getSource() == cancelButton) { - cancelDialog(); - } else if (evt.getSource() == removeButton) { - removeAttribute(); - } else if (evt.getSource() == downButton) { - downAttribute(); - } else if (evt.getSource() == upButton) { - upAttribute(); - } else if (evt.getSource() == addMappingButton) { - addMappedUnit(); - } else if (evt.getSource() == removeMappingButton) { - removeMappedUnit(); - } - } - - public void addAccess(String s) { - accessBox.addItem(s); - } - - public void addType(String s) { - initValues.add(new Boolean(true)); - typeBox.addItem(s); - } - - public void addType(String s, boolean b) { - initValues.add(new Boolean(b)); - typeBox.addItem(s); - } - - public void enableInitialValue(boolean b) { - initialValue.setEnabled(b); - } - - public void enableRTLOTOSKeyword(boolean b) { - checkKeyword = !b; - } - - public void enableJavaKeyword(boolean b) { - checkJavaKeyword = !b; - } - - public void addAttribute() { - Object o1 = accessBox.getSelectedItem(); - Object o2 = typeBox.getSelectedItem(); - String s = identifierText.getText(); - String value = initialValue.getText(); - TAttribute a; - - if( s.length() > 0 ) { - if( ( TAttribute.isAValidId( s, checkKeyword, checkJavaKeyword ) ) && ( TAttribute.notIn(s, forbidden ) ) ) { - int i = TAttribute.getAccess(o1.toString()); - int j = TAttribute.getAvatarType(o2.toString()); - if( ( j == TAttribute.ARRAY_NAT ) && ( value.length() < 1 ) ) { - value = "2"; - } - if ((i != -1) && (j!= -1)) { - if ((value.length() < 1) || (initialValue.isEnabled() == false)) { - value = ""; - } - else { - if( !TAttribute.isAValidInitialValue(j, value) ) { - JOptionPane.showMessageDialog( frame, "The initial value is not valid", "Error", JOptionPane.INFORMATION_MESSAGE ); - return; - } - } - if( j == TAttribute.OTHER ) { - a = new TAttribute(i, s, value, o2.toString()); - a.isAvatar = true; - //System.out.println("New attribute: " + o2.toString()); - } - else { - a = new TAttribute(i, s, value, j); - a.isAvatar = true; - } - //checks whether the same attribute already belongs to the list - int index = attributes.size(); - if( attributes.contains(a) ) { - index = attributes.indexOf(a); - a = (TAttribute)(attributes.elementAt(index)); - a.setAccess(i); - if( j == TAttribute.OTHER ) { - a.setTypeOther(o2.toString()); - } - a.setType(j); - a.setInitialValue(value); - //attributes.removeElementAt(index); - } - else { - attributes.add(index, a); - } - listAttribute.setListData(attributes); - identifierText.setText(""); - } - else { - JOptionPane.showMessageDialog( frame, "Bad access / type", "Error", JOptionPane.INFORMATION_MESSAGE); - return; - } - } - else { - JOptionPane.showMessageDialog( frame, "Bad identifier: identifier already in use, or invalid identifier", - "Error", JOptionPane.INFORMATION_MESSAGE); - return; - } - } - else { - JOptionPane.showMessageDialog( frame, "Bad identifier", "Error", JOptionPane.INFORMATION_MESSAGE ); - return; - } - } //End of method - - public void addMappedUnit() { - - TraceManager.addDev( "**************************" ); - TraceManager.addDev( referenceMemoriesName.getSelectedItem().toString() ); - TraceManager.addDev( "**************************" ); - removeMappingButton.setEnabled( true ); - String s = referenceMemoriesName.getSelectedItem().toString();//methodText.getText(); - memories.add(s); - listStorageUnits.setListData( memories ); - } - - public void removeMappedUnit() { - memories.removeElementAt( 0 ); - listStorageUnits.setListData( memories ); - removeMappingButton.setEnabled( false ); - } - - public void removeAttribute() { - int i = listAttribute.getSelectedIndex() ; - if (i!= -1) { - TAttribute a = (TAttribute)(attributes.elementAt(i)); - a.setAccess(-1); - attributes.removeElementAt(i); - listAttribute.setListData(attributes); - } - } - - public void downAttribute() { - int i = listAttribute.getSelectedIndex(); - if ((i!= -1) && (i != attributes.size() - 1)) { - Object o = attributes.elementAt(i); - attributes.removeElementAt(i); - attributes.insertElementAt(o, i+1); - listAttribute.setListData(attributes); - listAttribute.setSelectedIndex(i+1); - } - } - - public void upAttribute() { - int i = listAttribute.getSelectedIndex(); - //TraceManager.addDev("Selected index = " + i); - if (i > 0) { - //TraceManager.addDev("Modifying ..."); - Object o = attributes.elementAt(i); - attributes.removeElementAt(i); - attributes.insertElementAt(o, i-1); - listAttribute.setListData(attributes); - listAttribute.setSelectedIndex(i-1); - } - } - - public void closeDialog() { - cancelled = false; - attributesPar.removeAllElements(); - for(int i=0; i<attributes.size(); i++) { - attributesPar.addElement(attributes.elementAt(i)); - } - memoriesPar.removeAllElements(); - for( int i=0; i < memories.size(); i++ ) { - memoriesPar.addElement( memories.elementAt(i) ); - } - this.name = nameOfInstance.getText(); - TraceManager.addDev( "The text entered is " + this.name ); - dispose(); - } - - public boolean hasBeenCancelled() { - return cancelled; - } - - public void cancelDialog() { - cancelled = true; - dispose(); - } - - public void valueChanged(ListSelectionEvent e) { - int i = listAttribute.getSelectedIndex() ; - if (i == -1) { - removeButton.setEnabled(false); - upButton.setEnabled(false); - downButton.setEnabled(false); - identifierText.setText(""); - //initialValue.setText(""); - } else { - TAttribute a = (TAttribute)(attributes.elementAt(i)); - identifierText.setText(a.getId()); - initialValue.setText(a.getInitialValue()); - select(accessBox, a.getStringAccess(a.getAccess())); - if (a.getType() == TAttribute.OTHER) { - select(typeBox, a.getTypeOther()); - } else { - select(typeBox, a.getStringAvatarType(a.getType())); - } - removeButton.setEnabled(true); - if (i > 0) { - upButton.setEnabled(true); - } else { - upButton.setEnabled(false); - } - if (i != attributes.size() - 1) { - downButton.setEnabled(true); - } else { - downButton.setEnabled(false); - } - } - - /*i = listMethod.getSelectedIndex() ; - if (i == -1) { - removeMethodButton.setEnabled(false); - upMethodButton.setEnabled(false); - downMethodButton.setEnabled(false); - methodText.setText(""); - //initialValue.setText(""); - } else { - String am = memories.elementAt(i); - methodText.setText( am ); - TraceManager.addDev("Implementation of " + am + " is: " + am.isImplementationProvided()); - implementationProvided.setSelected(am.isImplementationProvided()); - removeMethodButton.setEnabled(true); - if (i > 0) { - upMethodButton.setEnabled(true); - } else { - upMethodButton.setEnabled(false); - } - if (i != memories.size() - 1) { - downMethodButton.setEnabled(true); - } else { - downMethodButton.setEnabled(false); - } - }*/ - - } //End of method - - public void select(JComboBox jcb, String text) { - String s; - for(int i=0; i<jcb.getItemCount(); i++) { - s = (String)(jcb.getItemAt(i)); - //System.out.println("String found: *" + s + "* *" + text + "*"); - if (s.equals(text)) { - jcb.setSelectedIndex(i); - return; - } - } - } - - public String getName() { - return this.name; - } -} //End of class diff --git a/src/ui/window/JDialogTMLCPStorageInstance.java b/src/ui/window/JDialogTMLCPStorageInstance.java index 2aff3262b5d9e72cfe56f1cf5a92506a260cf9a0..e449b6459e2a835588296d790044a786a423a3ed 100755 --- a/src/ui/window/JDialogTMLCPStorageInstance.java +++ b/src/ui/window/JDialogTMLCPStorageInstance.java @@ -62,8 +62,8 @@ public class JDialogTMLCPStorageInstance extends JDialogTMLSDInstance implements /** Creates new form */ public JDialogTMLCPStorageInstance( Vector _attributes, Vector<TMLArchiNode> _availableUnits, Vector _forbidden, Frame f, String title, - String attrib, String _name ) { - super( _attributes, _availableUnits, _forbidden, f, title, attrib, _name ); + String attrib, String _name, String _mappedUnit ) { + super( _attributes, _availableUnits, _forbidden, f, title, attrib, _name, _mappedUnit ); } @Override protected void initComponents() { @@ -249,8 +249,8 @@ public class JDialogTMLCPStorageInstance extends JDialogTMLSDInstance implements for( int j = 0; j < unitsPar.size(); j++ ) { availableUnits.add( ( (TMLArchiNode) unitsPar.get(j)).getName() ); } - referenceMemoriesName = new JComboBox( availableUnits ); - panel3.add( referenceMemoriesName, c3); + referenceUnitsName = new JComboBox( availableUnits ); + panel3.add( referenceUnitsName, c3); // third line panel3 c3.gridwidth = GridBagConstraints.REMAINDER; //end row @@ -343,6 +343,10 @@ public class JDialogTMLCPStorageInstance extends JDialogTMLSDInstance implements for(int i=0; i<attributes.size(); i++) { attributesPar.addElement(attributes.elementAt(i)); } + unitsPar.removeAllElements(); + for( int i = 0; i < mappedUnits.size(); i++ ) { + unitsPar.addElement( mappedUnits.elementAt(i) ); + } this.name = nameOfInstance.getText(); if( mappedUnits.size() > 1 ) { JOptionPane.showMessageDialog( frame, "Only one Memory unit can be mapped per each Storage instance", diff --git a/src/ui/window/JDialogTMLCPTransferInstance.java b/src/ui/window/JDialogTMLCPTransferInstance.java index 9179c11e03e07ce183a943b76687d3dca3c16d65..6572277084e36cdc106c166e2d420ace41265cd7 100755 --- a/src/ui/window/JDialogTMLCPTransferInstance.java +++ b/src/ui/window/JDialogTMLCPTransferInstance.java @@ -62,8 +62,8 @@ public class JDialogTMLCPTransferInstance extends JDialogTMLSDInstance implement /** Creates new form */ public JDialogTMLCPTransferInstance( Vector _attributes, Vector<TMLArchiNode> _availableUnits, Vector _forbidden, Frame f, String title, - String attrib, String _name ) { - super( _attributes, _availableUnits, _forbidden, f, title, attrib, _name ); + String attrib, String _name, String _mappedUnit ) { + super( _attributes, _availableUnits, _forbidden, f, title, attrib, _name, _mappedUnit ); } @Override protected void initComponents() { @@ -250,8 +250,8 @@ public class JDialogTMLCPTransferInstance extends JDialogTMLSDInstance implement //TMLArchiMemoryNode mem = (TMLArchiMemoryNode) unitsPar.get(j); availableUnits.add( ((TMLArchiNode) unitsPar.get(j)).getName() ); } - referenceMemoriesName = new JComboBox( availableUnits ); - panel3.add( referenceMemoriesName, c3); + referenceUnitsName = new JComboBox( availableUnits ); + panel3.add( referenceUnitsName, c3); // third line panel3 c3.gridwidth = GridBagConstraints.REMAINDER; //end row diff --git a/src/ui/window/JDialogTMLSDInstance.java b/src/ui/window/JDialogTMLSDInstance.java index 3f3f5d87fc9ac72e7dfe605ea331394f03e2672e..1ed1e2eb452f5980434d8968ec662744e51ce848 100755 --- a/src/ui/window/JDialogTMLSDInstance.java +++ b/src/ui/window/JDialogTMLSDInstance.java @@ -92,7 +92,7 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement //Panel 3 protected JButton removeMappingButton; - protected JComboBox referenceMemoriesName; + protected JComboBox referenceUnitsName; // Mapping of storage units @@ -108,7 +108,7 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement /** Creates new form */ public JDialogTMLSDInstance( Vector _attributes, Vector<TMLArchiNode> _availableUnits, Vector _forbidden, Frame f, String title, - String attrib, String _name ) { + String attrib, String _name, String _mappedUnit ) { super(f, title, true); frame = f; attributesPar = _attributes; @@ -117,6 +117,10 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement forbidden = _forbidden; initValues = new Vector(); this.attrib = attrib; + mappedUnits.removeAllElements(); + if( _mappedUnit.length() > 0 ) { + mappedUnits.add( 0, _mappedUnit ); + } attributes = new Vector(); @@ -133,7 +137,12 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement removeButton.setEnabled(false); upButton.setEnabled(false); downButton.setEnabled(false); - removeMappingButton.setEnabled(false); + if( mappedUnits.size() > 0 ) { + removeMappingButton.setEnabled(true); + } + else { + removeMappingButton.setEnabled(false); + } } protected abstract void initComponents(); @@ -266,18 +275,19 @@ public abstract class JDialogTMLSDInstance extends javax.swing.JDialog implement public void addMappedUnit() { //TraceManager.addDev( "**************************" ); - //TraceManager.addDev( referenceMemoriesName.getSelectedItem().toString() ); + //TraceManager.addDev( referenceUnitsName.getSelectedItem().toString() ); //TraceManager.addDev( "**************************" ); - removeMappingButton.setEnabled( true ); - String s = referenceMemoriesName.getSelectedItem().toString(); - mappedUnits.add(s); + mappedUnits.add( referenceUnitsName.getSelectedItem().toString() ); listMappedUnits.setListData( mappedUnits ); + removeMappingButton.setEnabled( true ); } public void removeMappedUnit() { - mappedUnits.removeElementAt( 0 ); + mappedUnits.removeElementAt( listMappedUnits.getSelectedIndex() ); listMappedUnits.setListData( mappedUnits ); - removeMappingButton.setEnabled( false ); + if( mappedUnits.size() == 0 ) { + removeMappingButton.setEnabled( false ); + } } public void removeAttribute() {