diff --git a/src/ui/ConfigurationTTool.java b/src/ui/ConfigurationTTool.java index 9929a83a322065140b589e17114e1db78a19b319..8ed3564edb0fd9acc80e3434a00995391bf843db 100755 --- a/src/ui/ConfigurationTTool.java +++ b/src/ui/ConfigurationTTool.java @@ -130,6 +130,11 @@ public class ConfigurationTTool { public static String AVATARExecutableSoclibCodeCompileCommand = ""; public static String AVATARExecutableSoclibCodeExecuteCommand = ""; public static String AVATARExecutableSoclibTraceFile = ""; + + + // Ontology + public static String RequirementOntologyWebsite = ""; + public static String AttackOntologyWebsite = ""; public static String LastOpenFile = ""; public static boolean LastOpenFileDefined = false; @@ -189,11 +194,11 @@ public class ConfigurationTTool { //sb.append("data = " + data); write = true; /*try { - FileOutputStream fos = new FileOutputStream(f); - fos.write(data.getBytes()); - fos.close(); + FileOutputStream fos = new FileOutputStream(f); + fos.write(data.getBytes()); + fos.close(); } catch (Exception e) { - throw new MalformedConfigurationException("Saving file failed"); + throw new MalformedConfigurationException("Saving file failed"); }*/ } } @@ -362,6 +367,11 @@ public class ConfigurationTTool { sb.append("NCDirectory: " + NCDirectory + "\n"); + // Ontology + sb.append("\nOntologies:\n"); + sb.append("Requirement ontology website: " + RequirementOntologyWebsite + "\n"); + sb.append("Attack ontology website: " + AttackOntologyWebsite + "\n"); + sb.append("\nCustom external commands:\n"); sb.append("ExternalCommand1Host: " + ExternalCommand1Host + "\n"); @@ -539,80 +549,90 @@ public class ConfigurationTTool { AVATARExecutableSoclibTraceFile(nl); if (systemcOn) { - nl = doc.getElementsByTagName("SystemCHost"); - if (nl.getLength() > 0) - SystemCHost(nl); - nl = doc.getElementsByTagName("SystemCCodeCompileCommand"); - if (nl.getLength() > 0) - SystemCCodeCompileCommand(nl); - nl = doc.getElementsByTagName("SystemCCodeExecuteCommand"); - if (nl.getLength() > 0) - SystemCCodeExecuteCommand(nl); - nl = doc.getElementsByTagName("SystemCCodeInteractiveExecuteCommand"); - if (nl.getLength() > 0) - SystemCCodeInteractiveExecuteCommand(nl); - nl = doc.getElementsByTagName("GTKWavePath"); - if (nl.getLength() > 0) - GTKWavePath(nl); - } - - nl = doc.getElementsByTagName("TMLCodeDirectory"); - if (nl.getLength() > 0) - TMLCodeDirectory(nl); - - nl = doc.getElementsByTagName("VCDPath"); - if (nl.getLength() > 0) - VCDPath(nl); - - nl = doc.getElementsByTagName("UPPAALCodeDirectory"); - if (nl.getLength() > 0) - UPPAALCodeDirectory(nl); - - nl = doc.getElementsByTagName("UPPAALVerifierPath"); - if (nl.getLength() > 0) - UPPAALVerifierPath(nl); - - nl = doc.getElementsByTagName("UPPAALVerifierHost"); - if (nl.getLength() > 0) - UPPAALVerifierHost(nl); - - nl = doc.getElementsByTagName("ProVerifCodeDirectory"); - if (nl.getLength() > 0) - ProVerifCodeDirectory(nl); - - nl = doc.getElementsByTagName("ProVerifVerifierPath"); - if (nl.getLength() > 0) - ProVerifVerifierPath(nl); - - nl = doc.getElementsByTagName("ProVerifVerifierHost"); - if (nl.getLength() > 0) - ProVerifVerifierHost(nl); - - nl = doc.getElementsByTagName("ExternalCommand1Host"); - if (nl.getLength() > 0) - ExternalCommand1Host(nl); - - nl = doc.getElementsByTagName("ExternalCommand1"); + nl = doc.getElementsByTagName("SystemCHost"); if (nl.getLength() > 0) - ExternalCommand1(nl); - - nl = doc.getElementsByTagName("ExternalCommand2Host"); + SystemCHost(nl); + nl = doc.getElementsByTagName("SystemCCodeCompileCommand"); if (nl.getLength() > 0) - ExternalCommand2Host(nl); - - nl = doc.getElementsByTagName("ExternalCommand2"); + SystemCCodeCompileCommand(nl); + nl = doc.getElementsByTagName("SystemCCodeExecuteCommand"); if (nl.getLength() > 0) - ExternalCommand2(nl); - - nl = doc.getElementsByTagName("LastOpenFile"); + SystemCCodeExecuteCommand(nl); + nl = doc.getElementsByTagName("SystemCCodeInteractiveExecuteCommand"); if (nl.getLength() > 0) - LastOpenFile(nl); - - nl = doc.getElementsByTagName("LastWindowAttributes"); + SystemCCodeInteractiveExecuteCommand(nl); + nl = doc.getElementsByTagName("GTKWavePath"); if (nl.getLength() > 0) - LastWindowAttributes(nl); - - + GTKWavePath(nl); + } + + nl = doc.getElementsByTagName("TMLCodeDirectory"); + if (nl.getLength() > 0) + TMLCodeDirectory(nl); + + nl = doc.getElementsByTagName("VCDPath"); + if (nl.getLength() > 0) + VCDPath(nl); + + nl = doc.getElementsByTagName("UPPAALCodeDirectory"); + if (nl.getLength() > 0) + UPPAALCodeDirectory(nl); + + nl = doc.getElementsByTagName("UPPAALVerifierPath"); + if (nl.getLength() > 0) + UPPAALVerifierPath(nl); + + nl = doc.getElementsByTagName("UPPAALVerifierHost"); + if (nl.getLength() > 0) + UPPAALVerifierHost(nl); + + nl = doc.getElementsByTagName("ProVerifCodeDirectory"); + if (nl.getLength() > 0) + ProVerifCodeDirectory(nl); + + nl = doc.getElementsByTagName("ProVerifVerifierPath"); + if (nl.getLength() > 0) + ProVerifVerifierPath(nl); + + nl = doc.getElementsByTagName("ProVerifVerifierHost"); + if (nl.getLength() > 0) + ProVerifVerifierHost(nl); + + + // Ontologies + nl = doc.getElementsByTagName("RequirementOntologyWebsite"); + if (nl.getLength() > 0) + RequirementOntologyWebsite(nl); + + nl = doc.getElementsByTagName("AttackOntologyWebsite"); + if (nl.getLength() > 0) + AttackOntologyWebsite(nl); + + nl = doc.getElementsByTagName("ExternalCommand1Host"); + if (nl.getLength() > 0) + ExternalCommand1Host(nl); + + nl = doc.getElementsByTagName("ExternalCommand1"); + if (nl.getLength() > 0) + ExternalCommand1(nl); + + nl = doc.getElementsByTagName("ExternalCommand2Host"); + if (nl.getLength() > 0) + ExternalCommand2Host(nl); + + nl = doc.getElementsByTagName("ExternalCommand2"); + if (nl.getLength() > 0) + ExternalCommand2(nl); + + nl = doc.getElementsByTagName("LastOpenFile"); + if (nl.getLength() > 0) + LastOpenFile(nl); + + nl = doc.getElementsByTagName("LastWindowAttributes"); + if (nl.getLength() > 0) + LastWindowAttributes(nl); + + } catch (Exception e) { throw new MalformedConfigurationException(e.getMessage()); } @@ -861,7 +881,7 @@ public class ConfigurationTTool { } } - private static void JavaHeader(NodeList nl) throws MalformedConfigurationException { + private static void JavaHeader(NodeList nl) throws MalformedConfigurationException { try { Element elt = (Element)(nl.item(0)); JavaHeader = elt.getAttribute("data"); @@ -921,7 +941,7 @@ public class ConfigurationTTool { } } - private static void NCDirectory(NodeList nl) throws MalformedConfigurationException { + private static void NCDirectory(NodeList nl) throws MalformedConfigurationException { try { Element elt = (Element)(nl.item(0)); NCDirectory = elt.getAttribute("data"); @@ -984,7 +1004,7 @@ public class ConfigurationTTool { } } - private static void TMLCodeDirectory(NodeList nl) throws MalformedConfigurationException { + private static void TMLCodeDirectory(NodeList nl) throws MalformedConfigurationException { try { Element elt = (Element)(nl.item(0)); TMLCodeDirectory = elt.getAttribute("data"); @@ -1137,7 +1157,7 @@ public class ConfigurationTTool { } } - private static void ProVerifCodeDirectory(NodeList nl) throws MalformedConfigurationException { + private static void ProVerifCodeDirectory(NodeList nl) throws MalformedConfigurationException { try { Element elt = (Element)(nl.item(0)); ProVerifCodeDirectory = elt.getAttribute("data"); @@ -1163,6 +1183,24 @@ public class ConfigurationTTool { throw new MalformedConfigurationException(e.getMessage()); } } + + private static void RequirementOntologyWebsite(NodeList nl) throws MalformedConfigurationException { + try { + Element elt = (Element)(nl.item(0)); + RequirementOntologyWebsite = elt.getAttribute("data"); + } catch (Exception e) { + throw new MalformedConfigurationException(e.getMessage()); + } + } + + private static void AttackOntologyWebsite(NodeList nl) throws MalformedConfigurationException { + try { + Element elt = (Element)(nl.item(0)); + AttackOntologyWebsite = elt.getAttribute("data"); + } catch (Exception e) { + throw new MalformedConfigurationException(e.getMessage()); + } + } private static void ExternalCommand1Host(NodeList nl) throws MalformedConfigurationException { try { diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index ba6134d6d453edfe7778740ca5a59ce8b6dd864b..70d66a8d5d04563e729fb0a1b5a965fe9f0d77ce 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -2154,6 +2154,29 @@ public class GTURTLEModeling { return str; } + + public String makeOneDiagramXMLFromGraphicalModel(TURTLEPanel tp, int indexOfDiagram) { + StringBuffer sb = new StringBuffer(); + //sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<TURTLEGMODELING>\n\n"); + sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<TURTLEGMODELING version=\"" + DefaultText.getVersion() + "\">\n\n"); + + StringBuffer s; + String str; + + + s = tp.saveInXML(indexOfDiagram); + + sb.append(s); + sb.append("\n\n"); + + + sb.append("</TURTLEGMODELING>"); + + str = new String(sb); + str = encodeString(str); + + return str; + } public String makeXMLFromTurtleModeling(int index) { StringBuffer sb = new StringBuffer(); diff --git a/src/ui/JMenuBarTurtle.java b/src/ui/JMenuBarTurtle.java index 3dbfbf743fcad0ae1a8798b69263fb265e2b6930..6debabba2f09353c27d578a7be0b5e15612c7bc2 100755 --- a/src/ui/JMenuBarTurtle.java +++ b/src/ui/JMenuBarTurtle.java @@ -55,7 +55,7 @@ public class JMenuBarTurtle extends JMenuBar { private JMenu menugraph; //Menu - private JMenu file, saveLastGraph, diagram, cd, ad, iod, ucd, sd, edit, vAndV, codeG, view, tool, capture, help; + private JMenu file, saveLastGraph, diagram, cd, ad, iod, ucd, sd, edit, vAndV, codeG, view, tool, capture, ontologies, help; public JMenuBarTurtle(MainGUI mgui) { super(); @@ -561,6 +561,16 @@ public class JMenuBarTurtle extends JMenuBar { menuItem.addMouseListener(mgui.mouseHandler); menuItem = capture.add(mgui.actions[TGUIAction.ACT_SELECTED_CAPTURE]); menuItem.addMouseListener(mgui.mouseHandler); + + + ontologies = new JMenu("Ontologies"); + tool.add(ontologies); + menuItem = ontologies.add(mgui.actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM]); + menuItem.addMouseListener(mgui.mouseHandler); + menuItem = ontologies.add(mgui.actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS]); + menuItem.addMouseListener(mgui.mouseHandler); + menuItem = ontologies.add(mgui.actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS]); + menuItem.addMouseListener(mgui.mouseHandler); menuItem = tool.add(mgui.actions[TGUIAction.ACT_GEN_DOC]); menuItem.addMouseListener(mgui.mouseHandler); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 91a01df800a54aa118a36bdc7723f75e92b445fe..d3420a45072bcfb20c07d5019375487e8528a8a6 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -580,6 +580,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { actions[TGUIAction.ACT_GEN_DOC_REQ].setEnabled(true); actions[TGUIAction.ACT_VIEW_JAVA].setEnabled(true); actions[TGUIAction.ACT_VIEW_BIRDEYES].setEnabled(true); + actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM].setEnabled(true); + actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS].setEnabled(true); + actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS].setEnabled(true); + break; case MODEL_OK: actions[TGUIAction.ACT_SAVE_TIF].setEnabled(true); @@ -5163,6 +5167,39 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { setPanelMode(); return true; } + + public void generateOntologyForCurrentDiagram() { + TraceManager.addDev("Ontology for current diagram"); + try { + TURTLEPanel tp = getCurrentTURTLEPanel(); + String modeling = gtm.makeOneDiagramXMLFromGraphicalModel(tp, tp.tabbedPane.getSelectedIndex()); + TraceManager.addDev("Model made: " + modeling); + } catch (Exception e) { + } + + } + + public void generateOntologyForCurrentSetOfDiagrams() { + TraceManager.addDev("Ontology for current set of diagrams"); + try { + String modeling = gtm.makeXMLFromTurtleModeling(mainTabbedPane.getSelectedIndex()); + TraceManager.addDev("Model made: " + modeling); + } catch (Exception e) { + } + + } + + public void generateOntologyForAllDiagrams() { + TraceManager.addDev("Ontology for all diagrams"); + try { + String modeling = gtm.makeXMLFromTurtleModeling(-1); + TraceManager.addDev("Model made"); + } catch (Exception e) { + } + + } + + public AvatarRDPanel getAvatarRDPanel(int index, int indexTab, String s) { TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(index)); @@ -7095,6 +7132,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } else if (command.equals(actions[TGUIAction.TOSAD_TIME_INTERVAL].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TOSAD_TIME_INTERVAL); + + // Ontologies + } else if (command.equals(actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM].getActionCommand())) { + generateOntologyForCurrentDiagram(); + } else if (command.equals(actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS].getActionCommand())) { + generateOntologyForCurrentSetOfDiagrams(); + } else if (command.equals(actions[TGUIAction.ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS].getActionCommand())) { + generateOntologyForAllDiagrams(); + // Requirement diagrams } else if (command.equals(actions[TGUIAction.TREQ_REQUIREMENT].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TREQ_REQUIREMENT); diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index 190596f9da8115eeb219847c1533606faa0bb31e..dcfc55fc382980448ae4b18289b498e1d0ebd10b 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -486,12 +486,16 @@ public class TGUIAction extends AbstractAction { public static final int ACT_AVATAR_FV_PROVERIF = 338; public static final int ACT_AVATAR_FV_STATICANALYSIS = 365; public static final int ACT_AVATAR_EXECUTABLE_GENERATION = 340; - + + // Ontologies + public static final int ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM = 367; + public static final int ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS = 369; + public static final int ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS = 368; //Action for the help button created by Solange public static final int PRUEBA_1 = 205; - public static final int NB_ACTION = 367; + public static final int NB_ACTION = 370; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -963,6 +967,12 @@ public class TGUIAction extends AbstractAction { actions[AAD_PARTITION] = new TAction("add-add-partition", "Partition", IconManager.imgic5052, IconManager.imgic5052, "Partition", "Add a partition to the currently opened avatar activity diagram", 0); actions[AAD_ALIGN_PARTITION] = new TAction("add-aad-align_partitions", "Align partitions", IconManager.imgic5054, IconManager.imgic5054, "Align partitions", "Align partitions of the currently opened avatar activity diagram", 0); + // Ontologies + actions[ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM] = new TAction("generate-ontology-current-diagram", "Generate ontology (current diagram)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (current diagram)", "Generate the ontology for the diagram under edition", 0); + actions[ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS] = new TAction("generate-ontology-current-set-of-diagrams", "Generate ontology (current set of diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (current set of diagrams)", "Generate the ontology for the current set of diagrams under edition", 0); + actions[ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS] = new TAction("generate-ontology-all-diagrams", "Generate ontology (all diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (all diagrams)", "Generate the ontology for the diagrams under edition", 0); + + } diff --git a/src/ui/TURTLEPanel.java b/src/ui/TURTLEPanel.java index 867c67bef5a9ef789d57315f77d4d5182b95ae35..3f9a132a572af1c519dde66e1ae22a4f302c3bf0 100755 --- a/src/ui/TURTLEPanel.java +++ b/src/ui/TURTLEPanel.java @@ -119,6 +119,26 @@ public abstract class TURTLEPanel implements GenericTree { return sb; } + public StringBuffer saveInXML(int indexOfDiagram) { + + TDiagramPanel tdp; + StringBuffer sb = new StringBuffer(); + sb.append(saveHeaderInXml()); + StringBuffer s; + + tdp = (TDiagramPanel)(panels.elementAt(indexOfDiagram)); + s = tdp.saveInXML(); + if (s == null) { + System.out.println("Null diagram"); + return null; + } + sb.append(s); + sb.append("\n\n"); + + sb.append(saveTailInXml()); + return sb; + } + public String toString() { return "TURTLE Modeling"; }