diff --git a/src/main/java/tmltranslator/modelcompiler/TMLModelCompiler.java b/src/main/java/tmltranslator/modelcompiler/TMLModelCompiler.java old mode 100755 new mode 100644 diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index 886ec68137328ddad5e873f946216fbf86cea070..193b576fb119c132dd225e13368e170b049bd982 100755 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -487,6 +487,7 @@ public class GTURTLEModeling { try { if( directory.equals("") ) { + JOptionPane.showMessageDialog( mgui.frame, "No directory for C code generation found in config.xml. The C code cannot be generated.", "Control code generation failed", JOptionPane.INFORMATION_MESSAGE ); diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 88b27cc164df5d2f5430e944aeffd8b67ff0c1e5..9fc481d16cf09edbad6e0b953d47391011b0a39e 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -1,26 +1,26 @@ /* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici - * + * * 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, @@ -31,7 +31,7 @@ * 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. */ @@ -317,7 +317,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe private ArrayList<RunningInfo> runningIDs; private ArrayList<LoadInfo> loadIDs; private ConcurrentHashMap<Integer, ArrayList<SimulationTransaction>> transactionMap = new ConcurrentHashMap<Integer, ArrayList<SimulationTransaction>>(); - private ConcurrentHashMap<Integer, ConcurrentHashMap<String, String>> latencyMap = new ConcurrentHashMap<Integer, ConcurrentHashMap<String,String>>(); + private ConcurrentHashMap<Integer, ConcurrentHashMap<String, String>> latencyMap = new ConcurrentHashMap<Integer, ConcurrentHashMap<String,String>>(); private ConcurrentHashMap<String, String> statusMap = new ConcurrentHashMap<String, String>(); private JFrameInteractiveSimulation jfis; private JFrameAvatarInteractiveSimulation jfais; @@ -1001,7 +1001,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe //ystem.out.println("Design added"); return index; } - + public int addSystemCAMSPanel(String name, int index) { //ajout CD -----Mark if (index == -1) { index = tabs.size(); @@ -1495,7 +1495,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe private void addTURTLEPanel() { //TraceManager.addDev("New TURTLE Panels"); - // Issue #41 Ordering of tabbed panes + // Issue #41 Ordering of tabbed panes mainTabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane(); mainTabbedPane.setBackground(ColorManager.MainTabbedPane); mainTabbedPane.setForeground(Color.black); @@ -1534,6 +1534,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe } public void firstDiag() { + TURTLEPanel tp = getCurrentTURTLEPanel(); if (tp == null) { return; @@ -5302,6 +5303,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe File file = selectFileForCapture(); if (file == null) return; + Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); Rectangle screenRect = new Rectangle(screenSize); @@ -5498,6 +5500,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe int returnVal = jfcimg.showSaveDialog(frame); if (returnVal == JFileChooser.CANCEL_OPTION) return null; + if(returnVal == JFileChooser.APPROVE_OPTION) { file = jfcimg.getSelectedFile(); file = FileUtils.addFileExtensionIfMissing(file, TImgFilter.getExtension()); @@ -5519,6 +5522,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Pe int returnVal = jfcimgsvg.showSaveDialog(frame); if (returnVal == JFileChooser.CANCEL_OPTION) return null; + if(returnVal == JFileChooser.APPROVE_OPTION) { file = jfcimgsvg.getSelectedFile(); file = FileUtils.addFileExtensionIfMissing(file, TSVGFilter.getExtension()); diff --git a/src/main/java/ui/networkmodelloader/JDialogLoadingNetworkModel.java b/src/main/java/ui/networkmodelloader/JDialogLoadingNetworkModel.java index a637c9fe3070d2ef8889fb4f579e27db7d958ed9..9cd1151efffac74bc565511e8f61a2ad6a2c2f65 100644 --- a/src/main/java/ui/networkmodelloader/JDialogLoadingNetworkModel.java +++ b/src/main/java/ui/networkmodelloader/JDialogLoadingNetworkModel.java @@ -1,26 +1,26 @@ /* 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, @@ -31,7 +31,7 @@ * 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. */ @@ -154,9 +154,9 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac JPanel options = new JPanel(); - JLabel infoModels = new JLabel("Not loaded"); - options.add(infoModels); - + JLabel infoModels = new JLabel("Not loaded"); + options.add(infoModels); + featureList = new JComboBox<String>(FEATURES); featureList.addActionListener(this); options.add(featureList); @@ -268,7 +268,6 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac //nm.type = NetworkModel.stringToNetworkModelType(inputLine.substring(5, inputLine.length()).trim()); } } - } if (inputLine.startsWith("-PROPS")) { if (nm != null) { @@ -314,6 +313,7 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac // Wait 5seconds before refreshing panel Thread.sleep(5000); panel.repaint(); + } } catch (Exception e) { jta.append("Error when retreiving file: " + url + "\n No internet connection?\n No right for the Java Virtual Machine to use http connections?\n\n"); @@ -371,6 +371,7 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac public void loadDone() { jta.append("Model transfered, opening it in TTool\n"); this.dispose(); + SwingUtilities.invokeLater(new Runnable() { public void run() { File dir = new File(filePath.replace(".xml", "")); diff --git a/src/main/java/ui/window/JDialogPerformancePragma.java b/src/main/java/ui/window/JDialogPerformancePragma.java index 1ae0fd6bd1bfc77adcb5513335800543f91c76d3..d4e0979e3a6eca6ee3b355dd569ea2d4078eae59 100644 --- a/src/main/java/ui/window/JDialogPerformancePragma.java +++ b/src/main/java/ui/window/JDialogPerformancePragma.java @@ -1,26 +1,26 @@ /* 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, @@ -31,7 +31,7 @@ * 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. */ @@ -58,9 +58,9 @@ import java.util.HashMap; * @author Ludovic APVRILLE, Letitia LI */ public class JDialogPerformancePragma extends JDialogBase implements ActionListener { - + protected String text; - + //components protected JTextArea textarea; protected JButton close; @@ -68,21 +68,21 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe protected JMenuBar menuBar; protected JMenu help; protected JPopupMenu helpPopup; - public HashMap<String, java.util.List<String>> blockAttributeMap = new HashMap<String, java.util.List<String>>(); + public HashMap<String, java.util.List<String>> blockAttributeMap = new HashMap<String, java.util.List<String>>(); /** Creates new form */ public JDialogPerformancePragma(Frame f, String title, String _text) { super(f, title, true); text = _text; - + initComponents(); pack(); } -//Suggestion Panel code from: http://stackoverflow.com/questions/10873748/how-to-show-autocomplete-as-i-type-in-jtextarea + //Suggestion Panel code from: http://stackoverflow.com/questions/10873748/how-to-show-autocomplete-as-i-type-in-jtextarea public class SuggestionPanel { - //Form list of all blocks - //For each block, create a list of all states and signals - + //Form list of all blocks + //For each block, create a list of all states and signals + private JList list; private JPopupMenu popupMenu; private String subWord; @@ -95,12 +95,12 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe popupMenu.removeAll(); popupMenu.setOpaque(false); popupMenu.setBorder(null); - + popupMenu.add(list = createSuggestionList(linePosition ,position, subWord), BorderLayout.CENTER); - //Show popupMenu only if there are matching suggestions - if (list.getModel().getSize() >0){ + //Show popupMenu only if there are matching suggestions + if (list.getModel().getSize() >0){ popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y); - } + } } public void hide() { @@ -110,53 +110,53 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe } } - private JList createSuggestionList(int linePosition, final int position, final String subWord) { - ArrayList<String> matches = new ArrayList<String>(); - if (linePosition<6){ - matches.add("Latency("); - } - - else if (!subWord.contains(".")){ - for (String block: blockAttributeMap.keySet()){ - if (block.startsWith(subWord)){ - matches.add(block); - } - } - } - else { - String block = subWord.split("\\.")[0]; - if (blockAttributeMap.containsKey(block)){ - for (String attr: blockAttributeMap.get(block)){ - if (attr.startsWith(subWord.split("\\.")[1])){ - matches.add(block+"."+attr); - } - } - } - } - String[] data = new String[matches.size()]; + private JList createSuggestionList(int linePosition, final int position, final String subWord) { + ArrayList<String> matches = new ArrayList<String>(); + if (linePosition<6){ + matches.add("Latency("); + } + + else if (!subWord.contains(".")){ + for (String block: blockAttributeMap.keySet()){ + if (block.startsWith(subWord)){ + matches.add(block); + } + } + } + else { + String block = subWord.split("\\.")[0]; + if (blockAttributeMap.containsKey(block)){ + for (String attr: blockAttributeMap.get(block)){ + if (attr.startsWith(subWord.split("\\.")[1])){ + matches.add(block+"."+attr); + } + } + } + } + String[] data = new String[matches.size()]; data = matches.toArray(data); JList<String> list = new JList<>(data); list.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - insertSelection(); + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + insertSelection(); + } } - } - }); - + }); + return list; } - + public boolean insertSelection() { - //Note that it will not add if the selection will not fit on the current line - if (!popupMenu.isVisible()){ - return false; - } + //Note that it will not add if the selection will not fit on the current line + if (!popupMenu.isVisible()){ + return false; + } if (list.getSelectedValue() != null) { try { final String selectedSuggestion = ((String) list.getSelectedValue()).substring(subWord.length()); @@ -184,22 +184,22 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe final int position = textarea.getCaretPosition(); list.setSelectedIndex(index); SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - textarea.setCaretPosition(position); - } - }); + @Override + public void run() { + textarea.setCaretPosition(position); + } + }); } } - private SuggestionPanel suggestion; - protected void showSuggestionLater() { + private SuggestionPanel suggestion; + protected void showSuggestionLater() { SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - showSuggestion(); - } + @Override + public void run() { + showSuggestion(); + } - }); + }); } protected void showSuggestion() { @@ -231,23 +231,23 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe if (subWord.length() < 1) { return; } - start=Math.max(0,position-1); - while (start>0){ - //Find previous new line position - if (!String.valueOf(text.charAt(start)).matches(".")){ - break; - } - else { - start--; - } - } + start=Math.max(0,position-1); + while (start>0){ + //Find previous new line position + if (!String.valueOf(text.charAt(start)).matches(".")){ + break; + } + else { + start--; + } + } suggestion = new SuggestionPanel(textarea, position, subWord, location, position-start-1); SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - textarea.requestFocusInWindow(); - } - }); + @Override + public void run() { + textarea.requestFocusInWindow(); + } + }); } private void hideSuggestion() { @@ -257,7 +257,7 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe } protected void initComponents() { - + Container c = getContentPane(); Font f = new Font("Helvetica", Font.PLAIN, 14); setFont(f); @@ -297,7 +297,6 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe helpPopup.add(new JLabel(" time after simulation")); helpPopup.setPreferredSize(new Dimension(600,250)); - textarea = new JTextArea(); textarea.setEditable(true); @@ -305,74 +304,74 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe textarea.setTabSize(3); textarea.append(text); textarea.setFont(new Font("times", Font.PLAIN, 12)); - JMenuBar menuBar = new JMenuBar(); - menuBar.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); - help = new JMenu("?"); - menuBar.add(help); - setJMenuBar(menuBar); - textarea.addKeyListener(new KeyListener() { - @Override - public void keyTyped(KeyEvent e) { - if (e.getKeyChar() == KeyEvent.VK_ENTER || e.getKeyChar() == KeyEvent.VK_TAB) { - if (suggestion != null) { - if (suggestion.insertSelection()) { - e.consume(); - final int position = textarea.getCaretPosition(); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - try { - textarea.getDocument().remove(position - 1, 1); - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - }); + JMenuBar menuBar = new JMenuBar(); + menuBar.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + help = new JMenu("?"); + menuBar.add(help); + setJMenuBar(menuBar); + textarea.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent e) { + if (e.getKeyChar() == KeyEvent.VK_ENTER || e.getKeyChar() == KeyEvent.VK_TAB) { + if (suggestion != null) { + if (suggestion.insertSelection()) { + e.consume(); + final int position = textarea.getCaretPosition(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + textarea.getDocument().remove(position - 1, 1); + } catch (BadLocationException e) { + e.printStackTrace(); + } + } + }); + } } } } - } - @Override - public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) { - suggestion.moveDown(); - } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) { - suggestion.moveUp(); - } else if (Character.isWhitespace(e.getKeyChar())) { - hideSuggestion(); + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) { + suggestion.moveDown(); + } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) { + suggestion.moveUp(); + } else if (Character.isWhitespace(e.getKeyChar())) { + hideSuggestion(); + } + else if (Character.isLetter(e.getKeyChar())){ + showSuggestionLater(); + } } - else if (Character.isLetter(e.getKeyChar())){ - showSuggestionLater(); + + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) { + e.consume(); + } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) { + e.consume(); + } } - } + }); - @Override - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) { - e.consume(); - } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) { - e.consume(); - } - } - }); - JScrollPane jsp = new JScrollPane(textarea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setPreferredSize(new Dimension(300, 300)); c.add(jsp, BorderLayout.CENTER); - + close = new JButton("Ok", IconManager.imgic25); cancel = new JButton("Cancel", IconManager.imgic27); - - help.setPreferredSize(new Dimension(30,30)); + + help.setPreferredSize(new Dimension(30,30)); close.setPreferredSize(new Dimension(150, 30)); cancel.setPreferredSize(new Dimension(150, 30)); - + close.addActionListener(this); cancel.addActionListener(this); help.addMouseListener(new MouseAdapter() { @@ -384,42 +383,43 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe JPanel jp = new JPanel(); jp.add(close); jp.add(cancel); - + c.add(jp, BorderLayout.SOUTH); - + } - - public void actionPerformed(ActionEvent evt) { - String command = evt.getActionCommand(); - + + public void actionPerformed(ActionEvent evt) { + //String command = evt.getActionCommand(); + // Compare the action command to the known actions. - if (command.equals("Cancel")) { + if (evt.getSource() == cancel) { cancel(); - } else if (command.equals("Ok")) { + } else if (evt.getSource() == close) { close(); } - + } - + public void cancel() { dispose(); } - + public void close() { text = textarea.getText(); dispose(); } public void help(){ - if (!helpPopup.isVisible()){ - helpPopup.show(help, 20, 20); - } - else { - helpPopup.setVisible(false); - } + if (!helpPopup.isVisible()){ + helpPopup.show(help, 20, 20); + } + else { + helpPopup.setVisible(false); + } } + public String getText() { return text; } - - + + } diff --git a/ttool/launch_configurations/config.xml b/ttool/launch_configurations/config.xml index f29d34ab0a2f82dc06cb61747f9a3aa411b8aeba..89ffe884f2f75069a1cfc89daea093baa088e8f3 100755 --- a/ttool/launch_configurations/config.xml +++ b/ttool/launch_configurations/config.xml @@ -68,11 +68,15 @@ <PLUGIN_JAVA_CODE_GENERATOR data="../plugins/CustomizerAvatarCodeGeneration.jar" /> +<<<<<<< HEAD <<<<<<< Upstream, based on origin/project_manager <LastOpenFile data="/home/satan/ZigBeeTutorial.ttool/ZigBeeTutorial.xml"/> ======= <LastOpenFile data="/home/dblouin/Projets/TTool/git/TTool/modeling/DIPLODOCUS/ZigBeeTutorial.xml"/> >>>>>>> 4749348 Issue #98: Fixed default C Code generation directory +======= +<LastOpenFile data="/home/dblouin/Projets/TTool/git/TTool/modeling/DIPLODOCUS/ZigBeeTutorial.xml"/> +>>>>>>> ac0a9cec52efa7fb18b9e7e8f72519b069f3c727