From 120521b1bdc48da89a0a9846506a277e38c58bf8 Mon Sep 17 00:00:00 2001 From: apvrille <ludovic.apvrille@eurecom.fr> Date: Fri, 1 Mar 2019 16:29:07 +0100 Subject: [PATCH] Adding Help Window --- src/main/java/help/HelpEntry.java | 134 +++- src/main/java/help/HelpManager.java | 13 +- src/main/java/ui/GTURTLEModeling.java | 14 +- src/main/java/ui/MainGUI.java | 647 +++++++++--------- src/main/java/ui/tree/DiagramTreeModel.java | 9 + .../java/ui/tree/DiagramTreeRenderer.java | 9 + src/main/java/ui/tree/HelpTree.java | 123 ++++ src/main/java/ui/tree/JDiagramTree.java | 4 + src/main/java/ui/window/JFrameHelp.java | 115 ++++ src/main/resources/help/helpTable.txt | 6 +- ttool/src/test/java/help/HelpTests.java | 8 +- 11 files changed, 745 insertions(+), 337 deletions(-) create mode 100755 src/main/java/ui/tree/HelpTree.java create mode 100644 src/main/java/ui/window/JFrameHelp.java diff --git a/src/main/java/help/HelpEntry.java b/src/main/java/help/HelpEntry.java index d3880a2287..bbb09a79eb 100644 --- a/src/main/java/help/HelpEntry.java +++ b/src/main/java/help/HelpEntry.java @@ -39,9 +39,16 @@ package help; +import myutil.GenericTree; import myutil.TraceManager; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.util.Vector; +import java.util.stream.Collectors; /** @@ -51,20 +58,29 @@ import java.util.Vector; * * @author Ludovic APVRILLE */ -public class HelpEntry { - public String pathToHTMLFile; +public class HelpEntry implements GenericTree { + + public HelpEntry linkToParent; + Vector<HelpEntry> entries; + public String masterKeyword; public String[] keywords; - public String htmlContent; - public HelpEntry linkToParent; - Vector<HelpEntry> entries; + public String pathToHTMLFile; + public String htmlContent; public HelpEntry() { } + public String getMasterKeyword() { + if (masterKeyword == null) { + return "Help not loaded"; + } + return masterKeyword; + } + // Infos are: file of name, master key, list of keywords public boolean fillInfos(String infos) { infos = infos.trim(); @@ -78,18 +94,33 @@ public class HelpEntry { pathToHTMLFile = splitted[0] + ".html"; masterKeyword = splitted[1]; - keywords = new String[splitted.length - 2]; - for (int i = 0; i < splitted.length - 2; i++) { - keywords[i] = splitted[i + 2]; + keywords = new String[splitted.length - 1]; + for (int i = 0; i < splitted.length - 1; i++) { + keywords[i] = splitted[i + 1]; } //TraceManager.addDev("Infos ok"); return true; } + public String getToolTip() { + if (keywords == null) { + return ""; + } + + if (keywords.length == 0) { + return ""; + } + + String ret = ""; + for (int i=1; i<keywords.length; i++) { + ret += keywords[i] + " "; + } + return ret; + } + public int getNbInHierarchy() { - if (linkToParent == null) { - return 0; + if (linkToParent == null) { return 0; } return 1 + linkToParent.getNbInHierarchy(); } @@ -98,6 +129,7 @@ public class HelpEntry { if (entries == null) { entries = new Vector<>(); } + entries.add(he); } public boolean hasKids() { @@ -115,15 +147,80 @@ public class HelpEntry { return entries.size(); } + public HelpEntry getKid(int index) { + if (entries == null) { + return null; + } + return entries.get(index); + } + + public int getIndexOfKid(HelpEntry he) { + if (entries == null) { + return 0; + } + return entries.indexOf(he); + } + + public String getHTMLContent() { + if (htmlContent == null) { + try { + URL url = HelpManager.getURL(pathToHTMLFile); + URLConnection conn = url.openConnection(); + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); + htmlContent = reader.lines().collect(Collectors.joining("\n")); + //TraceManager.addDev("htmlcontent=" + getHTMLContent()); + + htmlContent = filterHTMLContent(htmlContent); + + } catch (Exception e) { + TraceManager.addDev("Exception when retreiving HTML of " + pathToHTMLFile); + return ""; + } + } + + return htmlContent; + } + + + private String filterHTMLContent(String input) { + + int index = input.indexOf("<meta http-equiv="); + if (index == -1) { + return input; + } + String ret1 = input.substring(0, index); + String ret2 = input.substring(index+17, input.length()); + + index = ret2.indexOf("/>"); + if (index == -1) { + return input; + } + + ret2 = ret2.substring(index+2, ret2.length()); + + return ret1 + ret2; + } + public HelpEntry getFather() { return linkToParent; } public String toString() { - return masterKeyword + " " + keywords.toString(); + if ((masterKeyword == null) || (keywords == null)) { + return "Help"; + } + + /*String ret = masterKeyword + " ("; + for(int i=1; i<keywords.length; i++) { + ret += keywords[i] + " "; + } + ret += ")";*/ + + return masterKeyword.substring(0,1).toUpperCase() + masterKeyword.substring(1, masterKeyword.length()); } public String printHierarchy(int n) { + String s = getHTMLContent(); String ret = ""; for (int i = 0; i < n; i++) { ret += " "; @@ -138,4 +235,19 @@ public class HelpEntry { } + public int getChildCount() { + //TraceManager.addDev("GetChild count in " + toString() + " = " + getNbOfKids()); + return getNbOfKids(); + } + + + public Object getChild(int index) { + return getKid(index); + } + + public int getIndexOfChild(Object child) { + return getIndexOfKid((HelpEntry)child); + } + + } diff --git a/src/main/java/help/HelpManager.java b/src/main/java/help/HelpManager.java index 2a5cbd3a8a..42fa5b0584 100644 --- a/src/main/java/help/HelpManager.java +++ b/src/main/java/help/HelpManager.java @@ -73,6 +73,10 @@ public class HelpManager extends HelpEntry { return true; } + + // Setup the root entry + fillInfos("none Help TTool help"); + //File file = getContent(PATH_TO_INDEX); URL url = getURL(PATH_TO_INDEX); @@ -175,15 +179,19 @@ public class HelpManager extends HelpEntry { // Next section! // We must locate the correct father + //TraceManager.addDev("Next section"); father = entry; - int nbOfAncestors = inHierarchy - currentN; + int nbOfAncestors = currentN - inHierarchy + 1; + //TraceManager.addDev("Next section ancestors:" + nbOfAncestors); while (nbOfAncestors > 0) { father = father.getFather(); if (father == null) { return null; } + nbOfAncestors--; } father.addKid(newNode); + newNode.linkToParent = father; return newNode; } @@ -227,7 +235,8 @@ public class HelpManager extends HelpEntry { } public String printHierarchy() { - String top = "root\n"; + String top = "Help tree\n root has " + getNbOfKids() + " nodes.\n"; + for (HelpEntry he : entries) { top += he.printHierarchy(1); } diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index 1879270b65..135af30a7f 100644 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -216,6 +216,7 @@ public class GTURTLEModeling { private SearchTree st; private SyntaxAnalysisTree mcvdt; private InvariantDataTree idt; + private HelpTree ht; private List<CheckingError> checkingErrors; private List<CheckingError> warnings; @@ -276,6 +277,7 @@ public class GTURTLEModeling { st = new SearchTree(mgui); gt = new GraphTree(mgui); stt = new SimulationTraceTree(mgui); + ht = new HelpTree(mgui); /*if (!Charset.isSupported("UTF-8")) { ErrorGUI.exit(ErrorGUI.ERROR_CHARSET); @@ -2643,7 +2645,7 @@ public class GTURTLEModeling { } public int getChildCount() { - return panels.size() + 5; + return panels.size() + 6; } public Object getChild(int index) { @@ -2657,8 +2659,10 @@ public class GTURTLEModeling { return gt; } else if (index == (panels.size() + 3)) { return idt; - } else { + } else if (index == (panels.size() + 4)) { return st; + } else { + return ht; } } @@ -2685,8 +2689,12 @@ public class GTURTLEModeling { return panels.size() + 3; } + if (child == ht) { + return panels.size() + 4; + } + - return panels.size() + 4; + return panels.size() + 5; } // Projection management diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 1a04715f85..91e7248549 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -39,13 +39,13 @@ package ui; -import help.HelpManager; -import myutil.*; import avatartranslator.AvatarSpecification; import common.ConfigurationTTool; import common.SpecConfigTTool; import graph.AUTGraph; import graph.RG; +import help.HelpEntry; +import help.HelpManager; import launcher.RemoteExecutionThread; import launcher.RshClient; import myutil.*; @@ -80,6 +80,8 @@ import ui.osad.TURTLEOSActivityDiagramPanel; import ui.prosmd.ProactiveSMDPanel; import ui.req.Requirement; import ui.req.RequirementDiagramPanel; +import ui.syscams.SysCAMSComponentTaskDiagramPanel; +import ui.syscams.SysCAMSCompositeComponent; import ui.tmlad.TMLActivityDiagramPanel; import ui.tmlcd.TMLTaskDiagramPanel; import ui.tmlcompd.TMLCCompositeComponent; @@ -94,7 +96,6 @@ import ui.ucd.UseCaseDiagramPanel; import ui.util.DefaultText; import ui.util.IconManager; import ui.window.*; -import ui.syscams.*; import javax.imageio.ImageIO; import javax.swing.*; @@ -331,13 +332,14 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per private JFrameAvatarInteractiveSimulation jfais; // Help - HelpManager helpManager; + private HelpManager helpManager; + private JFrameHelp helpFrame; // Invariants - Invariant currentInvariant; + private Invariant currentInvariant; // Thread for autosave - PeriodicBehaviorThread pbt; + private PeriodicBehaviorThread pbt; private TMLArchiPanel tmlap; // USed to retrieve the currently opened architecture panel @@ -348,8 +350,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per public MainGUI(boolean _openLast, boolean _turtleOn, boolean _systemcOn, boolean _lotosOn, boolean _proactiveOn, boolean _tpnOn, boolean _osOn, boolean - _uppaalOn, boolean _ncOn, boolean _avatarOn, boolean _proverifOn, boolean - _avatarOnly, boolean _experimental) { + _uppaalOn, boolean _ncOn, boolean _avatarOn, boolean _proverifOn, boolean + _avatarOnly, boolean _experimental) { openLast = _openLast; TraceManager.addDev("openLast=" + openLast); turtleOn = _turtleOn; @@ -391,9 +393,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } public boolean isSystemcOn() { - return systemcOn; + return systemcOn; } - + public void build() { // Swing look and feel @@ -654,13 +656,13 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per p = getPoint(tdp); } //TraceManager.addDev("Change made!"); - + // Issue #81: For tests when gtm could be null - if ( gtm != null && - type != TDiagramPanel.SELECT_COMPONENT ) { // Issue #105 - gtm.saveOperation(p); + if (gtm != null && + type != TDiagramPanel.SELECT_COMPONENT) { // Issue #105 + gtm.saveOperation(p); } - + dtree.toBeUpdated(); } @@ -705,6 +707,21 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return experimentalOn; } + + public HelpManager getHelpManager() { + return helpManager; + } + + public void openHelpFrame(HelpEntry he) { + if (helpFrame == null) { + helpFrame = new JFrameHelp("Help", he); + helpFrame.setVisible(true); + return; + } + helpFrame.setHelpEntry(he); + } + + public void periodicAction() { //TraceManager.addDev("Autosaving "); if (file == null) { @@ -818,7 +835,6 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } - public void showInFinder(RG inputGraph) { TraceManager.addDev("in show in finder"); if (inputGraph.fileName == null) { @@ -1172,7 +1188,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return index; } - public int addSysCAMSComponentDesignPanel(String name, int index) { + public int addSysCAMSComponentDesignPanel(String name, int index) { if (index == -1) { index = tabs.size(); } @@ -1188,20 +1204,20 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return index; } - public int addELNDesignPanel(String name, int index) { - if (index == -1) { - index = tabs.size(); - } - ELNDesignPanel elndp = new ELNDesignPanel(this); - tabs.add(index, elndp); - mainTabbedPane.add(elndp.tabbedPane, index); - mainTabbedPane.setToolTipTextAt(index, "Open ELN design diagrams"); - mainTabbedPane.setTitleAt(index, name); - mainTabbedPane.setIconAt(index, IconManager.imgic1208); - //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams"); - elndp.init(); - //ystem.out.println("Design added"); - return index; + public int addELNDesignPanel(String name, int index) { + if (index == -1) { + index = tabs.size(); + } + ELNDesignPanel elndp = new ELNDesignPanel(this); + tabs.add(index, elndp); + mainTabbedPane.add(elndp.tabbedPane, index); + mainTabbedPane.setToolTipTextAt(index, "Open ELN design diagrams"); + mainTabbedPane.setTitleAt(index, name); + mainTabbedPane.setIconAt(index, IconManager.imgic1208); + //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams"); + elndp.init(); + //ystem.out.println("Design added"); + return index; } //Return the list of all the TMLArchiDiagramPanels @@ -1604,18 +1620,18 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return index; } - public int createSysCAMSComponentDesign(String name) { + public int createSysCAMSComponentDesign(String name) { int index = addSysCAMSComponentDesignPanel(name, -1); mainTabbedPane.setSelectedIndex(index); return index; } - public int createELN(String name) { + public int createELN(String name) { int index = addELNDesignPanel(name, -1); mainTabbedPane.setSelectedIndex(index); return index; } - + public int createADD(String name) { int index = addADDPanel(name, -1); mainTabbedPane.setSelectedIndex(index); @@ -1809,6 +1825,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per public void start() { start(true); } + public void start(boolean show) { // Main window is ready to be drawn on screen if (frame == null) { @@ -1847,7 +1864,6 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per //split.setDividerLocation(0.2); - } public void newTurtleModeling() { @@ -1995,7 +2011,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per public void newTMLComponentDesign() { //TraceManager.addDev("NEW DESIGN"); - addTMLComponentDesignPanel("DIPLODOCUS_C_Design", -1); + addTMLComponentDesignPanel("Application", -1); tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0); mainTabbedPane.setSelectedIndex(tabs.size() - 1); //paneAction(null); @@ -2020,7 +2036,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per //frame.repaint(); } - public void newSysCAMS() { + public void newSysCAMS() { //TraceManager.addDev("NEW DESIGN"); addSysCAMSComponentDesignPanel("SystemC_AMS", -1); //tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0); @@ -2028,14 +2044,14 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per //paneAction(null); //frame.repaint(); } - + public void newELN() { - //TraceManager.addDev("NEW DESIGN"); - addELNDesignPanel("ELN", -1); + //TraceManager.addDev("NEW DESIGN"); + addELNDesignPanel("ELN", -1); // tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0); - mainTabbedPane.setSelectedIndex(tabs.size() - 1); - //paneAction(null); - //frame.repaint(); + mainTabbedPane.setSelectedIndex(tabs.size() - 1); + //paneAction(null); + //frame.repaint(); } public void newADD() { @@ -2541,7 +2557,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per actions[TGUIAction.ACT_OPEN_LAST].setName(TGUIAction.ACT_OPEN_LAST, ConfigurationTTool.LastOpenFile); // is the new name already in the list of opened files? - for(int i=0; i<ConfigurationTTool.LastOpenFiles.length; i++) { + for (int i = 0; i < ConfigurationTTool.LastOpenFiles.length; i++) { if (ConfigurationTTool.LastOpenFiles[i].compareTo(ConfigurationTTool.LastOpenFile) == 0) { ConfigurationTTool.LastOpenFiles[i] = ""; } @@ -2677,7 +2693,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } if (!checkFileForOpen(tmpFile)) { - JOptionPane.showMessageDialog(frame, "File " + tmpFile.getAbsolutePath() + " could not be opened ", "File Error", JOptionPane + JOptionPane.showMessageDialog(frame, "File " + tmpFile.getAbsolutePath() + " could not be opened ", "File Error", JOptionPane .INFORMATION_MESSAGE); return; } @@ -2702,9 +2718,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per File tmpDir = _f; config = new File(tmpDir.getAbsolutePath() + "/project_config.xml"); try { - SpecConfigTTool.loadConfigFile(config); + SpecConfigTTool.loadConfigFile(config); } catch (MalformedConfigurationException e) { - System.err.println(e.getMessage() + " : Can't load config file."); + System.err.println(e.getMessage() + " : Can't load config file."); } SpecConfigTTool.setDirConfig(tmpDir); } else { @@ -2719,32 +2735,32 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per // open the new TURTLE modeling newTurtleModeling(); - // gtm.enableUndo(false); + // gtm.enableUndo(false); - // Update configuration + // Update configuration updateLastOpenFile(file); - // Issue #41: Moved to common method + // Issue #41: Moved to common method loadModels(data, "loaded"); - // // load the new TURTLE modeling - // try { - // gtm.loadModelingFromXML(s); - // //gtm.saveOperation(tcdp); - // frame.setTitle("TTool: " + file.getAbsolutePath()); - // makeLotosFile(); - // - // if (gtm.getCheckingErrors().size() > 0) { - // JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE); - // - // } - // } catch (MalformedModelingException mme) { - // JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE); - // frame.setTitle("TToolt: unamed project"); - // } - // - // gtm.enableUndo(true); - // gtm.saveOperation(getCurrentSelectedPoint()); - // dtree.forceUpdate(); + // // load the new TURTLE modeling + // try { + // gtm.loadModelingFromXML(s); + // //gtm.saveOperation(tcdp); + // frame.setTitle("TTool: " + file.getAbsolutePath()); + // makeLotosFile(); + // + // if (gtm.getCheckingErrors().size() > 0) { + // JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE); + // + // } + // } catch (MalformedModelingException mme) { + // JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE); + // frame.setTitle("TToolt: unamed project"); + // } + // + // gtm.enableUndo(true); + // gtm.saveOperation(getCurrentSelectedPoint()); + // dtree.forceUpdate(); if (getCurrentTDiagramPanel() != null) getCurrentTDiagramPanel().repaint(); @@ -2809,7 +2825,6 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } - // close current modeling closeTurtleModeling(); @@ -3544,12 +3559,12 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return false; } - public void issueError(String error, String title){ - JOptionPane.showMessageDialog(frame, - error, - title, - JOptionPane.INFORMATION_MESSAGE); - } + public void issueError(String error, String title) { + JOptionPane.showMessageDialog(frame, + error, + title, + JOptionPane.INFORMATION_MESSAGE); + } public boolean checkModelingSyntax(TURTLEPanel tp, boolean automatic) { //String msg = ""; @@ -3874,7 +3889,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per setMode(MainGUI.GEN_SYSTEMC_OK); setMode(MainGUI.MODEL_OK); ret = true; - if ((!automatic) && (getCheckingWarnings().size() > 0)){ + if ((!automatic) && (getCheckingWarnings().size() > 0)) { JOptionPane.showMessageDialog(frame, "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code", "Syntax analysis successful on TML designs", @@ -3912,7 +3927,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per setMode(MainGUI.GEN_SYSTEMC_OK); setMode(MainGUI.MODEL_OK); ret = true; - if ((!automatic) && (getCheckingWarnings().size() > 0)){ + if ((!automatic) && (getCheckingWarnings().size() > 0)) { JOptionPane.showMessageDialog(frame, "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code", "Syntax analysis successful on TML designs", @@ -3928,81 +3943,81 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } } } else if (tp instanceof SysCAMSComponentDesignPanel) { - SysCAMSComponentDesignPanel syscamscdp = (SysCAMSComponentDesignPanel) tp; - JDialogSelectSysCAMSComponent.validated = syscamscdp.validated; - JDialogSelectSysCAMSComponent.ignored = syscamscdp.ignored; - Vector<TGComponent> syscamsComponentsToValidate = new Vector<TGComponent>(); - JDialogSelectSysCAMSComponent jdssyscamsc = new JDialogSelectSysCAMSComponent(frame, syscamsComponentsToValidate, syscamscdp.syscamsctdp.getComponentList(), "Choosing SystemC-AMS components to validate"); - if (!automatic) { - GraphicLib.centerOnParent(jdssyscamsc); - jdssyscamsc.setVisible(true); // Blocked until dialog has been closed - } else { - jdssyscamsc.closeDialog(); - } - if (syscamsComponentsToValidate.size() > 0) { - syscamscdp.validated = JDialogSelectSysCAMSComponent.validated; - syscamscdp.ignored = JDialogSelectSysCAMSComponent.ignored; + SysCAMSComponentDesignPanel syscamscdp = (SysCAMSComponentDesignPanel) tp; + JDialogSelectSysCAMSComponent.validated = syscamscdp.validated; + JDialogSelectSysCAMSComponent.ignored = syscamscdp.ignored; + Vector<TGComponent> syscamsComponentsToValidate = new Vector<TGComponent>(); + JDialogSelectSysCAMSComponent jdssyscamsc = new JDialogSelectSysCAMSComponent(frame, syscamsComponentsToValidate, syscamscdp.syscamsctdp.getComponentList(), "Choosing SystemC-AMS components to validate"); + if (!automatic) { + GraphicLib.centerOnParent(jdssyscamsc); + jdssyscamsc.setVisible(true); // Blocked until dialog has been closed + } else { + jdssyscamsc.closeDialog(); + } + if (syscamsComponentsToValidate.size() > 0) { + syscamscdp.validated = JDialogSelectSysCAMSComponent.validated; + syscamscdp.ignored = JDialogSelectSysCAMSComponent.ignored; // b = gtm.translateSysCAMSComponentDesign(syscamsComponentsToValidate, syscamscdp, jdssyscamsc.getOptimize()); - expandToWarnings(); - expandToErrors(); - if (b) { - //setMode(MainGUI.MODEL_OK); - setMode(MainGUI.GEN_SYSTEMC_OK); - setMode(MainGUI.MODEL_OK); - ret = true; - if (!automatic) { - JOptionPane.showMessageDialog(frame, - "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code", - "Syntax analysis successful on SystemC-AMS designs", - JOptionPane.INFORMATION_MESSAGE); - } - } else { - if (!automatic) { - JOptionPane.showMessageDialog(frame, - "The SystemC-AMS design contains several errors", - "Syntax analysis failed", - JOptionPane.INFORMATION_MESSAGE); - } - } - } + expandToWarnings(); + expandToErrors(); + if (b) { + //setMode(MainGUI.MODEL_OK); + setMode(MainGUI.GEN_SYSTEMC_OK); + setMode(MainGUI.MODEL_OK); + ret = true; + if (!automatic) { + JOptionPane.showMessageDialog(frame, + "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code", + "Syntax analysis successful on SystemC-AMS designs", + JOptionPane.INFORMATION_MESSAGE); + } + } else { + if (!automatic) { + JOptionPane.showMessageDialog(frame, + "The SystemC-AMS design contains several errors", + "Syntax analysis failed", + JOptionPane.INFORMATION_MESSAGE); + } + } + } } else if (tp instanceof ELNDesignPanel) { - ELNDesignPanel elndp = (ELNDesignPanel) tp; - JDialogSelectELNComponent.validated = elndp.validated; - JDialogSelectELNComponent.ignored = elndp.ignored; - Vector<TGComponent> ELNComponentsToValidate = new Vector<TGComponent>(); - JDialogSelectELNComponent jdselnc = new JDialogSelectELNComponent(frame, ELNComponentsToValidate, elndp.elndp.getComponentList(), "Choosing ELN components to validate"); - if (!automatic) { - GraphicLib.centerOnParent(jdselnc); - jdselnc.setVisible(true); // Blocked until dialog has been closed - } else { - jdselnc.closeDialog(); - } - if (ELNComponentsToValidate.size() > 0) { - elndp.validated = JDialogSelectELNComponent.validated; - elndp.ignored = JDialogSelectELNComponent.ignored; + ELNDesignPanel elndp = (ELNDesignPanel) tp; + JDialogSelectELNComponent.validated = elndp.validated; + JDialogSelectELNComponent.ignored = elndp.ignored; + Vector<TGComponent> ELNComponentsToValidate = new Vector<TGComponent>(); + JDialogSelectELNComponent jdselnc = new JDialogSelectELNComponent(frame, ELNComponentsToValidate, elndp.elndp.getComponentList(), "Choosing ELN components to validate"); + if (!automatic) { + GraphicLib.centerOnParent(jdselnc); + jdselnc.setVisible(true); // Blocked until dialog has been closed + } else { + jdselnc.closeDialog(); + } + if (ELNComponentsToValidate.size() > 0) { + elndp.validated = JDialogSelectELNComponent.validated; + elndp.ignored = JDialogSelectELNComponent.ignored; // b = gtm.translateSysCAMSComponentDesign(syscamsComponentsToValidate, syscamscdp, jdssyscamsc.getOptimize()); - expandToWarnings(); - expandToErrors(); - if (b) { - //setMode(MainGUI.MODEL_OK); - setMode(MainGUI.GEN_SYSTEMC_OK); - setMode(MainGUI.MODEL_OK); - ret = true; - if (!automatic) { - JOptionPane.showMessageDialog(frame, - "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code", - "Syntax analysis successful on ELN designs", - JOptionPane.INFORMATION_MESSAGE); - } - } else { - if (!automatic) { - JOptionPane.showMessageDialog(frame, - "The ELN design contains several errors", - "Syntax analysis failed", - JOptionPane.INFORMATION_MESSAGE); - } - } - } + expandToWarnings(); + expandToErrors(); + if (b) { + //setMode(MainGUI.MODEL_OK); + setMode(MainGUI.GEN_SYSTEMC_OK); + setMode(MainGUI.MODEL_OK); + ret = true; + if (!automatic) { + JOptionPane.showMessageDialog(frame, + "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code", + "Syntax analysis successful on ELN designs", + JOptionPane.INFORMATION_MESSAGE); + } + } else { + if (!automatic) { + JOptionPane.showMessageDialog(frame, + "The ELN design contains several errors", + "Syntax analysis failed", + JOptionPane.INFORMATION_MESSAGE); + } + } + } } else if (tp instanceof TMLArchiPanel) { tmlap = (TMLArchiPanel) tp; JDialogSelectTMLNodes.validated = tmlap.validated; @@ -4029,7 +4044,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per setMode(MainGUI.GEN_SYSTEMC_OK); setMode(MainGUI.MODEL_OK); ret = true; - if ((!automatic) && (getCheckingWarnings().size() > 0)){ + if ((!automatic) && (getCheckingWarnings().size() > 0)) { JOptionPane.showMessageDialog(frame, "0 error, " + getCheckingWarnings().size() + " warning(s). You can now perform verifications (safety, security, performance) or generate executable code", "Syntax analysis successful on TML mapping", @@ -4071,7 +4086,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per setMode(MainGUI.GEN_SYSTEMC_OK); setMode(MainGUI.MODEL_OK); ret = true; - if ((!automatic) && (getCheckingWarnings().size() > 0)){ + if ((!automatic) && (getCheckingWarnings().size() > 0)) { JOptionPane.showMessageDialog(frame, "0 error, " + getCheckingWarnings().size() + " warning(s). You can now perform verifications (safety, security, performance) or generate executable code", "Syntax analysis successful on TML mapping", @@ -4331,7 +4346,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp; String name = getCurrentTDiagramPanel().getName(); - + return tmlcomp.getAllOutChannels(name); } @@ -6102,7 +6117,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per for (int i = 0; i < tabs.size(); i++) { tp = tabs.elementAt(i); if (tp instanceof AvatarRequirementPanel) { - ((AvatarRequirementPanel)(tp)).updateReferences(); + ((AvatarRequirementPanel) (tp)).updateReferences(); } } @@ -6275,35 +6290,35 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per return ll; } - + public List<TGComponent> getAllSysCAMSComponents() { - TURTLEPanel tp; - List<TGComponent> ll = new LinkedList<TGComponent>(); - - for (int i = 0; i < tabs.size(); i++) { - tp = tabs.elementAt(i); - - if (tp instanceof SysCAMSComponentDesignPanel) { - ll.addAll(((SysCAMSComponentDesignPanel) tp).syscamsctdp.getComponentList()); - } - } - - return ll; + TURTLEPanel tp; + List<TGComponent> ll = new LinkedList<TGComponent>(); + + for (int i = 0; i < tabs.size(); i++) { + tp = tabs.elementAt(i); + + if (tp instanceof SysCAMSComponentDesignPanel) { + ll.addAll(((SysCAMSComponentDesignPanel) tp).syscamsctdp.getComponentList()); + } + } + + return ll; } public List<TGComponent> getAllELNComponents() { - TURTLEPanel tp; - List<TGComponent> ll = new LinkedList<TGComponent>(); - - for (int i = 0; i < tabs.size(); i++) { - tp = tabs.elementAt(i); - - if (tp instanceof ELNDesignPanel) { - ll.addAll(((ELNDesignPanel) tp).elndp.getComponentList()); - } - } - - return ll; + TURTLEPanel tp; + List<TGComponent> ll = new LinkedList<TGComponent>(); + + for (int i = 0; i < tabs.size(); i++) { + tp = tabs.elementAt(i); + + if (tp instanceof ELNDesignPanel) { + ll.addAll(((ELNDesignPanel) tp).elndp.getComponentList()); + } + } + + return ll; } public ArrayList<SysCAMSComponentTaskDiagramPanel> getAllPanelsReferencingSysCAMSCompositeComponent(SysCAMSCompositeComponent syscamscc) { @@ -6457,15 +6472,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } } - public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent tmlcc) { - TURTLEPanel tp; - - for (int i = 0; i < tabs.size(); i++) { - tp = tabs.elementAt(i); - if (tp instanceof SysCAMSComponentDesignPanel) { - ((SysCAMSComponentDesignPanel) tp).syscamsctdp.updateReferenceToSysCAMSCompositeComponent(tmlcc); - } - } + public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent tmlcc) { + TURTLEPanel tp; + + for (int i = 0; i < tabs.size(); i++) { + tp = tabs.elementAt(i); + if (tp instanceof SysCAMSComponentDesignPanel) { + ((SysCAMSComponentDesignPanel) tp).syscamsctdp.updateReferenceToSysCAMSCompositeComponent(tmlcc); + } + } } public TMLCCompositeComponent getCompositeComponent(String name) { @@ -6601,15 +6616,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per tp.tabbedPane.setTitleAt(0, name); } - public void setSysCAMSComponentTaskDiagramName(int indexDesign, String name) { - TURTLEPanel tp = tabs.elementAt(indexDesign); - tp.tabbedPane.setTitleAt(0, name); + public void setSysCAMSComponentTaskDiagramName(int indexDesign, String name) { + TURTLEPanel tp = tabs.elementAt(indexDesign); + tp.tabbedPane.setTitleAt(0, name); + } + + public void setELNDiagramName(int indexDesign, String name) { + TURTLEPanel tp = tabs.elementAt(indexDesign); + tp.tabbedPane.setTitleAt(0, name); } - - public void setELNDiagramName(int indexDesign, String name) { - TURTLEPanel tp = tabs.elementAt(indexDesign); - tp.tabbedPane.setTitleAt(0, name); - } public void setTMLArchitectureDiagramName(int indexDesign, String name) { TURTLEPanel tp = tabs.elementAt(indexDesign); @@ -7309,7 +7324,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per setPanelMode(); return true; } - + public boolean createSysCAMS(int index, String s) { return createSysCAMS(tabs.elementAt(index), s); } @@ -7323,7 +7338,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per setPanelMode(); return true; } - + public boolean createELN(int index, String s) { return createELN(tabs.elementAt(index), s); } @@ -7439,29 +7454,29 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } public SysCAMSComponentTaskDiagramPanel getSysCAMSPanel(int index, int indexTab, String s) { - TURTLEPanel tp = tabs.elementAt(index); - return getSysCAMSPanel(tp, indexTab, s); + TURTLEPanel tp = tabs.elementAt(index); + return getSysCAMSPanel(tp, indexTab, s); } - + public SysCAMSComponentTaskDiagramPanel getSysCAMSPanel(TURTLEPanel tp, int indexTab, String s) { - if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) { - return (SysCAMSComponentTaskDiagramPanel) (tp.panelAt(indexTab)); - } - return null; + if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) { + return (SysCAMSComponentTaskDiagramPanel) (tp.panelAt(indexTab)); + } + return null; } - + public ELNDiagramPanel getELNPanel(int index, int indexTab, String s) { - TURTLEPanel tp = tabs.elementAt(index); - return getELNPanel(tp, indexTab, s); + TURTLEPanel tp = tabs.elementAt(index); + return getELNPanel(tp, indexTab, s); } - + public ELNDiagramPanel getELNPanel(TURTLEPanel tp, int indexTab, String s) { - if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) { - return (ELNDiagramPanel) (tp.panelAt(indexTab)); - } - return null; + if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) { + return (ELNDiagramPanel) (tp.panelAt(indexTab)); + } + return null; } - + public AvatarRDPanel getAvatarRDPanel(int index, int indexTab, String s) { TURTLEPanel tp = tabs.elementAt(index); return getAvatarRDPanel(tp, indexTab, s); @@ -8196,33 +8211,33 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } public boolean newSysCAMSComponentTaskName(TURTLEPanel tp, String old, String niou) { - JTabbedPane jtp = tp.tabbedPane; - for (int i = 0; i < jtp.getTabCount(); i++) { - if (jtp.getTitleAt(i).equals(niou)) { - return false; - } - } - TraceManager.addDev("old " + old + " niou " + niou); - for (int i = 0; i < jtp.getTabCount(); i++) { - TraceManager.addDev("Tab " + i + " = " + mainTabbedPane.getTitleAt(i)); - if (jtp.getTitleAt(i).equals(old)) { - jtp.setTitleAt(i, niou); - jtp.setToolTipTextAt(i, "Opens the SystemC-AMS diagram of " + niou); - TDiagramPanel tdp; - //change panel name - for (int j = 0; j < tp.panels.size(); j++) { - tdp = tp.panels.elementAt(j); - if (tdp.getName().equals(old)) { - tdp.setName(niou); - } - } - - return true; - } - } - // internal error - ErrorGUI.exit(ErrorGUI.ERROR_TAB); - return false; + JTabbedPane jtp = tp.tabbedPane; + for (int i = 0; i < jtp.getTabCount(); i++) { + if (jtp.getTitleAt(i).equals(niou)) { + return false; + } + } + TraceManager.addDev("old " + old + " niou " + niou); + for (int i = 0; i < jtp.getTabCount(); i++) { + TraceManager.addDev("Tab " + i + " = " + mainTabbedPane.getTitleAt(i)); + if (jtp.getTitleAt(i).equals(old)) { + jtp.setTitleAt(i, niou); + jtp.setToolTipTextAt(i, "Opens the SystemC-AMS diagram of " + niou); + TDiagramPanel tdp; + //change panel name + for (int j = 0; j < tp.panels.size(); j++) { + tdp = tp.panels.elementAt(j); + if (tdp.getName().equals(old)) { + tdp.setName(niou); + } + } + + return true; + } + } + // internal error + ErrorGUI.exit(ErrorGUI.ERROR_TAB); + return false; } public void cloneTab(int index) { @@ -8233,7 +8248,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } catch (MalformedModelingException mme) { JOptionPane.showMessageDialog(frame, "Modeling could not be loaded (unsupported xml format) ", "Error when loading modeling", JOptionPane - .INFORMATION_MESSAGE); + .INFORMATION_MESSAGE); frame.setTitle("TTool: unamed project"); } catch (UnsupportedEncodingException mme) { JOptionPane.showMessageDialog(frame, "Modeling could not be loaded (unsupported encoding format) ", "Error when loading modeling", @@ -8345,7 +8360,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per /** * Check if a name is already used by another TURTLEPanel tab * - * @param name the name to be checked + * @param name the name to be checked * @return true if the name matches another tab name * @author Fabien Tessier */ @@ -8492,18 +8507,18 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per TURTLEPanel tp; // Issue #81: For tests - if ( tabs != null ) { - for (int i = 0; i < tabs.size(); i++) { - tp = tabs.elementAt(i); - index = tp.panels.indexOf(tdp); - if (index > -1) { - p.x = i; - p.y = index; - return p; - } - } - } - + if (tabs != null) { + for (int i = 0; i < tabs.size(); i++) { + tp = tabs.elementAt(i); + index = tp.panels.indexOf(tdp); + if (index > -1) { + p.x = i; + p.y = index; + return p; + } + } + } + p.x = 0; p.y = 0; @@ -8620,67 +8635,67 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per //--------------------end DDD------------------------------------------------ public Vector<SysCAMSComponentTaskDiagramPanel> getListSysCAMSPanel() { - Vector<SysCAMSComponentTaskDiagramPanel> syscamsDiagram = new Vector<SysCAMSComponentTaskDiagramPanel>(); - TURTLEPanel tp = getTURTLEPanel("SystemC_AMS"); - if (tp != null) { - Vector<TDiagramPanel> ps = tp.panels; - for (TDiagramPanel panel : ps) { - if (panel instanceof SysCAMSComponentTaskDiagramPanel) { - syscamsDiagram.add((SysCAMSComponentTaskDiagramPanel) panel); - } - } - if (syscamsDiagram.size() == 0) - System.err.println("No SysCAMS Panel found : MainGUI.getListSysCAMSPanel()"); - return syscamsDiagram; - } else { - JDialog msg = new JDialog(); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "There is no SystemC-AMS panel. Please add one.", "Warning !", - JOptionPane.WARNING_MESSAGE); - return null; - } - } - + Vector<SysCAMSComponentTaskDiagramPanel> syscamsDiagram = new Vector<SysCAMSComponentTaskDiagramPanel>(); + TURTLEPanel tp = getTURTLEPanel("SystemC_AMS"); + if (tp != null) { + Vector<TDiagramPanel> ps = tp.panels; + for (TDiagramPanel panel : ps) { + if (panel instanceof SysCAMSComponentTaskDiagramPanel) { + syscamsDiagram.add((SysCAMSComponentTaskDiagramPanel) panel); + } + } + if (syscamsDiagram.size() == 0) + System.err.println("No SysCAMS Panel found : MainGUI.getListSysCAMSPanel()"); + return syscamsDiagram; + } else { + JDialog msg = new JDialog(); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "There is no SystemC-AMS panel. Please add one.", "Warning !", + JOptionPane.WARNING_MESSAGE); + return null; + } + } + public void syscamsExecutableCodeGeneration() { JDialogSysCAMSExecutableCodeGeneration jgen = new JDialogSysCAMSExecutableCodeGeneration(frame, this, "Executable Code generation, compilation and execution", "../SysCAMSGenerationCode/"); - + GraphicLib.centerOnParent(jgen, 500, 450); jgen.setVisible(true); dtree.toBeUpdated(); } - + public Vector<ELNDiagramPanel> getListELNPanel() { - Vector<ELNDiagramPanel> elnDiagram = new Vector<ELNDiagramPanel>(); - TURTLEPanel tp = getTURTLEPanel("ELN"); - if (tp != null) { - Vector<TDiagramPanel> ps = tp.panels; - for (TDiagramPanel panel : ps) { - if (panel instanceof ELNDiagramPanel) { - elnDiagram.add((ELNDiagramPanel) panel); - } - } - if (elnDiagram.size() == 0) - System.err.println("No ELN Panel found : MainGUI.getListELNPanel()"); - return elnDiagram; - } else { - JDialog msg = new JDialog(); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "There is no ELN panel. Please add one.", "Warning !", - JOptionPane.WARNING_MESSAGE); - return null; - } - } - + Vector<ELNDiagramPanel> elnDiagram = new Vector<ELNDiagramPanel>(); + TURTLEPanel tp = getTURTLEPanel("ELN"); + if (tp != null) { + Vector<TDiagramPanel> ps = tp.panels; + for (TDiagramPanel panel : ps) { + if (panel instanceof ELNDiagramPanel) { + elnDiagram.add((ELNDiagramPanel) panel); + } + } + if (elnDiagram.size() == 0) + System.err.println("No ELN Panel found : MainGUI.getListELNPanel()"); + return elnDiagram; + } else { + JDialog msg = new JDialog(); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "There is no ELN panel. Please add one.", "Warning !", + JOptionPane.WARNING_MESSAGE); + return null; + } + } + public void elnExecutableCodeGeneration() { JDialogELNExecutableCodeGeneration jgen = new JDialogELNExecutableCodeGeneration(frame, this, "Executable Code generation, compilation and execution", "../ELNGenerationCode/"); - + GraphicLib.centerOnParent(jgen, 500, 450); jgen.setVisible(true); dtree.toBeUpdated(); } - + public boolean selectMainTab(String id) { TURTLEPanel tp; @@ -9158,24 +9173,24 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per changeMade(tmltdp, TDiagramPanel.CHANGE_VALUE_COMPONENT); } } - + public void toggleELN() { - if (hidden == false) { - hidden = true; - } else { - hidden = false; - } + if (hidden == false) { + hidden = true; + } else { + hidden = false; + } } public boolean getHidden() { - return hidden; + return hidden; } - + public boolean isAValidTabName(String name) { boolean b1, b2;//, b3, b4, b5, b6, b7; b1 = (name.substring(0, 1)).matches("[a-zA-Z]"); b2 = name.matches("\\w*"); - return b1&&b2; + return b1 && b2; //return name.matches("((\\w)*(\\s)*)*"); } @@ -9237,7 +9252,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per private JPopupMenu menu; private JMenuItem rename, remove, moveRight, moveLeft, newDesign, newAnalysis, newDeployment, newRequirement/*, newTMLDesign*/, newTMLComponentDesign, newTMLArchi, newProactiveDesign, newTURTLEOSDesign, - newNCDesign, sort, clone, newAttackTree, newFaultTree, newAVATARBD, newAVATARRequirement, newMAD, newTMLCP, newTMLMethodo, newAvatarMethodo, newAVATARDD, newSysmlsecMethodo, newSysCAMS, newELN; + newNCDesign, sort, clone, newAttackTree, newFaultTree, newAVATARBD, newAVATARRequirement, newMAD, newTMLCP, newTMLMethodo, newAvatarMethodo, newAVATARDD, newSysmlsecMethodo, newSysCAMS, newELN; private JMenuItem newAVATARAnalysis; public PopupListener(MainGUI _mgui) { @@ -9296,7 +9311,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per newTMLArchi = createMenuItem("New Partitioning - Architecture and Mapping"); newTMLCP = createMenuItem("New Partitioning - Communication Pattern"); newSysCAMS = createMenuItem("New SystemC-AMS Block Diagram"); - newELN = createMenuItem("New ELN Diagram"); + newELN = createMenuItem("New ELN Diagram"); newProactiveDesign = createMenuItem("New Proactive Design"); newTURTLEOSDesign = createMenuItem("New TURTLE-OS Design"); newNCDesign = createMenuItem("New Network Calculus Design"); @@ -9536,9 +9551,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui); mgui.newSysCAMS(); } else if (e.getSource() == newELN) { - ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui); - mgui.newELN(); - } + ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui); + mgui.newELN(); + } } }; } @@ -9595,7 +9610,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per mainTabbedPane.setSelectedIndex(destinationPosition); changeMade(null, -1); - //frame.repaint(); + //frame.repaint(); } diff --git a/src/main/java/ui/tree/DiagramTreeModel.java b/src/main/java/ui/tree/DiagramTreeModel.java index e7ce5dbaea..7f9618f4c6 100755 --- a/src/main/java/ui/tree/DiagramTreeModel.java +++ b/src/main/java/ui/tree/DiagramTreeModel.java @@ -39,6 +39,7 @@ package ui.tree; +import help.HelpEntry; import myutil.GenericTree; import translator.GroupOfGates; import ui.*; @@ -178,6 +179,14 @@ public class DiagramTreeModel implements TreeModel { return false; } + if (node instanceof HelpEntry) { + return !((HelpEntry) node).hasKids(); + } + + if (node instanceof HelpTree) { + return false; + } + if (node instanceof TGComponent) { if (node instanceof AvatarBDBlock) { diff --git a/src/main/java/ui/tree/DiagramTreeRenderer.java b/src/main/java/ui/tree/DiagramTreeRenderer.java index 8dda1bd5f4..181a91fee8 100755 --- a/src/main/java/ui/tree/DiagramTreeRenderer.java +++ b/src/main/java/ui/tree/DiagramTreeRenderer.java @@ -41,6 +41,7 @@ package ui.tree; +import help.HelpEntry; import translator.CheckingError; import translator.GroupOfGates; import ui.*; @@ -336,6 +337,14 @@ public class DiagramTreeRenderer extends DefaultTreeCellRenderer { setIcon(IconManager.imgic5060); setToolTipText("Avatar Modeling Assumptions Diagram"); + } else if (value instanceof HelpTree) { + setIcon(IconManager.imgic33); + setToolTipText("Help on TTool"); + + } else if (value instanceof HelpEntry) { + setIcon(IconManager.imgic32); + setToolTipText(((HelpEntry)value).getToolTip()); + } else { setToolTipText(null); } diff --git a/src/main/java/ui/tree/HelpTree.java b/src/main/java/ui/tree/HelpTree.java new file mode 100755 index 0000000000..b47f27bfa5 --- /dev/null +++ b/src/main/java/ui/tree/HelpTree.java @@ -0,0 +1,123 @@ +/* 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. + */ + + + + +package ui.tree; + +import help.HelpEntry; +import myutil.GenericTree; +import myutil.TraceManager; +import ui.MainGUI; +import graph.RG; + +import java.util.List; + +/** + * Class HelpTree + * Creation: 19/03/2019 + * Version 2.0 19/03/2019 + * @author Ludovic APVRILLE + */ +public class HelpTree implements GenericTree { + + private MainGUI mgui; + private String name = "Help"; + + + public HelpTree(MainGUI _mgui) { + mgui = _mgui; + } + + // TREE MANAGEMENT + public String toString() { + //TraceManager.addDev("To String HelpTree"); + + if (mgui == null) { + return "Not loaded"; + } + + if (mgui.getHelpManager() == null) { + return "Not loaded"; + } + return mgui.getHelpManager().getMasterKeyword(); + } + + public int getChildCount() { + //TraceManager.addDev("GetChild count of HelpTree"); + + + int nb = mgui.getHelpManager().getNbOfKids(); + if (nb == 0) { + //TraceManager.addDev("GetChild count of HelpTree: returning" + 1); + return 1; + } + + + //TraceManager.addDev("GetChild count of HelpTree:" + nb); + return nb; + } + + public Object getChild(int index) { + //TraceManager.addDev("GetChild HelpTree with index=" + index); + + int nb = mgui.getHelpManager().getNbOfKids(); + + if (nb == 0) { + return "help not loaded yet"; + } + + HelpEntry he = mgui.getHelpManager().getKid(index); + if (he == null) { + return "Help not loaded"; + } + return he; + } + + public int getIndexOfChild(Object child) { + if (child instanceof String) { + return 0; + } + if (child instanceof HelpEntry) { + return mgui.getHelpManager().getIndexOfKid((HelpEntry)child); + } + + return 0; + } +} diff --git a/src/main/java/ui/tree/JDiagramTree.java b/src/main/java/ui/tree/JDiagramTree.java index 1a3b26f297..94ffd5c009 100755 --- a/src/main/java/ui/tree/JDiagramTree.java +++ b/src/main/java/ui/tree/JDiagramTree.java @@ -42,11 +42,13 @@ package ui.tree; //import java.awt.*; import common.*; +import help.HelpEntry; import translator.CheckingError; import tmltranslator.TMLCheckingError; import ui.*; import graph.RG; import myutil.*; +import ui.window.JFrameHelp; import javax.swing.*; import javax.swing.event.TreeExpansionEvent; @@ -432,6 +434,8 @@ public class JDiagramTree extends javax.swing.JTree implements ActionListener, M mgui.showAUT("Last RG", rg.data); }*/ + } else if (nodeInfo instanceof HelpEntry) { + mgui.openHelpFrame((HelpEntry)nodeInfo); } } diff --git a/src/main/java/ui/window/JFrameHelp.java b/src/main/java/ui/window/JFrameHelp.java new file mode 100644 index 0000000000..4c2e4a6d18 --- /dev/null +++ b/src/main/java/ui/window/JFrameHelp.java @@ -0,0 +1,115 @@ +/* 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. + */ + + + + +package ui.window; + + +import help.HelpEntry; +import myutil.TraceManager; +import ui.MainGUI; +import ui.util.IconManager; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +/** + * Class JFrameCode + * Creation: 20/04/2005 + * version 1.0 20/04/2005 + * @author Ludovic APVRILLE + */ +public class JFrameHelp extends JFrame implements ActionListener { + private JEditorPane pane; + private HelpEntry he; + private JPanel jp01; + + public JFrameHelp(String title, HelpEntry he) { + super(title); + this.he = he; + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + Container framePanel = getContentPane(); + framePanel.setLayout(new BorderLayout()); + Font f = new Font("Courrier", Font.BOLD, 12); + + jp01 = new JPanel(); + jp01.setLayout(new BorderLayout()); + jp01.setBorder(new javax.swing.border.TitledBorder("Help of: " + he.getMasterKeyword())); + pane = new JEditorPane("text/html;charset=UTF-8", he.getHTMLContent()); + pane.setEditable(false); + //TraceManager.addDev("HMLTContent:" + he.getHTMLContent()); + JScrollPane jsp1 = new JScrollPane(pane); + jsp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jp01.add(jsp1, BorderLayout.CENTER); + + framePanel.add(jp01, BorderLayout.CENTER); + + JButton button1 = new JButton("Close", IconManager.imgic27); + button1.addActionListener(this); + JPanel jp = new JPanel(); + jp.add(button1); + framePanel.add(jp, BorderLayout.SOUTH); + + pack(); + setSize(500,600); + } + + public void setHelpEntry(HelpEntry he) { + this.he = he; + jp01.setBorder(new javax.swing.border.TitledBorder("Help of: " + he.getMasterKeyword())); + pane.setText(he.getHTMLContent()); + setVisible(true); + } + + public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); + if (command.equals("Close")) { + setVisible (false); + return; + } + } + + +} // Class + diff --git a/src/main/resources/help/helpTable.txt b/src/main/resources/help/helpTable.txt index d04b2478ee..d2d4afb6fd 100644 --- a/src/main/resources/help/helpTable.txt +++ b/src/main/resources/help/helpTable.txt @@ -3,4 +3,8 @@ -- architecture architecture hardware os operating system --- cpu cpu processor cpu os ----clockdivider clock_divider clock divider cpu -- avatar avatar software embedded systems +-- mapping mapping tasks communication mapping +---taskmapping taskmapping tasks mapping +---communicationmapping communicationmapping communication mapping +- avatar avatar software embedded systems safety security +-- requirements requirements satified satisfy derivereqt diff --git a/ttool/src/test/java/help/HelpTests.java b/ttool/src/test/java/help/HelpTests.java index 546d2eceff..315fa7efd9 100644 --- a/ttool/src/test/java/help/HelpTests.java +++ b/ttool/src/test/java/help/HelpTests.java @@ -36,10 +36,10 @@ * knowledge of the CeCILL license and that you accept its terms. * * /** - * Class AvatarGuardTests - * Creation: 20/05/2015 - * @version 1.1 01/07/2015 - * @author Ludovic APVRILLE, Letitia LI + * Class HelpTests + * Creation: 01/03/2019 + * @version 1.1 01/03/2019 + * @author Ludovic APVRILLE * @see */ -- GitLab