diff --git a/src/main/java/ui/AvatarDesignPanelTranslator.java b/src/main/java/ui/AvatarDesignPanelTranslator.java index 9c8ba8bbefd81541900f4b3537495ee264b83f74..fff47053c0011bf2d0393877293038dc5c43b08b 100644 --- a/src/main/java/ui/AvatarDesignPanelTranslator.java +++ b/src/main/java/ui/AvatarDesignPanelTranslator.java @@ -241,7 +241,7 @@ public class AvatarDesignPanelTranslator { } public AvatarPragmaLatency checkPerformancePragma(String _pragma, List<AvatarBDBlock> _blocks, AvatarSpecification as, TGComponent tgc){ - if (_pragma.contains("=") || (!_pragma.contains(">") && !_pragma.contains("<") && !_pragma.contains("?")) || !_pragma.contains("Latency")){ + if (_pragma.contains("=") || (!_pragma.contains(">") && !_pragma.contains("<") && !_pragma.contains("?")) || !_pragma.contains("Latency(")){ UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "No latency expression found in pragma "+ _pragma); ce.setTDiagramPanel(adp.getAvatarBDPanel()); ce.setTGComponent(tgc); @@ -256,7 +256,6 @@ public class AvatarDesignPanelTranslator { String p1 = pragma.split(",")[0]; - //Throw error if lack of '.' in block.signal if (!p1.contains(".")){ UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Invalid block.signal format in pragma " + _pragma); @@ -266,9 +265,8 @@ public class AvatarDesignPanelTranslator { TraceManager.addDev("Invalid block.signal format in pragma " + _pragma); return null; } - String block1 = p1.split("\\.")[0]; - String state1 = p1.split("\\.")[1]; + String state1 = p1.split("\\.",-1)[1]; AvatarBlock bl1; AvatarStateMachineElement st1=null; List<String> id1= new ArrayList<String>(); @@ -323,7 +321,7 @@ public class AvatarDesignPanelTranslator { } String block2 = p2.split("\\.")[0]; - String state2 = p2.split("\\.")[1]; + String state2 = p2.split("\\.",-1)[1]; diff --git a/src/main/java/ui/avatarbd/AvatarBDToolBar.java b/src/main/java/ui/avatarbd/AvatarBDToolBar.java index 8c2ea662fb5cb44425af9a02b2504ea16e35b788..4177b34d9d5f3ee05f1a7f51ec440b03cac174e6 100644 --- a/src/main/java/ui/avatarbd/AvatarBDToolBar.java +++ b/src/main/java/ui/avatarbd/AvatarBDToolBar.java @@ -131,10 +131,10 @@ public class AvatarBDToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.ABD_CRYPTOBLOCK]); button.addMouseListener(mgui.mouseHandler); - - button = this.add(mgui.actions[TGUIAction.AVATAR_FIREWALL]); - button.addMouseListener(mgui.mouseHandler); - + if (MainGUI.experimentalOn) { + button = this.add(mgui.actions[TGUIAction.AVATAR_FIREWALL]); + button.addMouseListener(mgui.mouseHandler); + } this.addSeparator(); button = this.add(mgui.actions[TGUIAction.ABD_DATATYPE]); diff --git a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java index dc69393be87a67cfd2853aaa12e62f5c46d2649b..e694a6113a1b062d3a3f152fe7c32915f1784716 100755 --- a/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java +++ b/src/main/java/ui/tmldd/TMLArchiDiagramToolBar.java @@ -153,15 +153,16 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener button = this.add(mgui.actions[TGUIAction.TMLARCHI_CPNODE]); button.addMouseListener(mgui.mouseHandler); button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]); - button.addMouseListener(mgui.mouseHandler); + button.addMouseListener(mgui.mouseHandler); + button = this.add(mgui.actions[TGUIAction.TMLARCHI_FIREWALL]); + button.addMouseListener(mgui.mouseHandler); } this.addSeparator(); button = this.add(mgui.actions[TGUIAction.TMLARCHI_KEY]); button.addMouseListener(mgui.mouseHandler); - button = this.add(mgui.actions[TGUIAction.TMLARCHI_FIREWALL]); - button.addMouseListener(mgui.mouseHandler); + this.addSeparator(); diff --git a/ttool/src/test/java/avatartranslator/AvatarSafetyTests.java b/ttool/src/test/java/avatartranslator/AvatarSafetyTests.java index 172fb14e5531c84a132a47da14c1c896a2f838c3..81489cb4c883337be9ab903fc9353d7c4c38e9ad 100644 --- a/ttool/src/test/java/avatartranslator/AvatarSafetyTests.java +++ b/ttool/src/test/java/avatartranslator/AvatarSafetyTests.java @@ -129,9 +129,19 @@ public class AvatarSafetyTests { //Fail if does not contain 'Latency()' pragma = adpt.checkPerformancePragma("Lat(b,s)<1", blocks, as, null); assertNull(pragma); + //Fail if missing comma + pragma = adpt.checkPerformancePragma("Latency(bs)<1", blocks, as, null); + assertNull(pragma); //Fail if unmatched ')' pragma = adpt.checkPerformancePragma("Latency(b,s<1", blocks, as, null); assertNull(pragma); + //Fail if invalid comparison sign + pragma = adpt.checkPerformancePragma("Latency(b,s)-1", blocks, as, null); + assertNull(pragma); + pragma = adpt.checkPerformancePragma("Latency(b,s)*1", blocks, as, null); + assertNull(pragma); + pragma = adpt.checkPerformancePragma("Latency(b<s),1", blocks, as, null); + assertNull(pragma); } @Test @@ -217,6 +227,18 @@ public class AvatarSafetyTests { assertEquals(pragma.getId2().size(),2); } + + @Test + public void testFailInvalidStateFormatPerformancePragma(){ + pragma = adpt.checkPerformancePragma("Latency(A,C.c1)<1", blocks, as, null); + assertTrue(pragma ==null); + pragma = adpt.checkPerformancePragma("Latency(A.,C.c1)<1", blocks, as, null); + assertTrue(pragma ==null); + pragma = adpt.checkPerformancePragma("Latency(B.sig2,C)<1", blocks, as, null); + assertTrue(pragma ==null); + pragma = adpt.checkPerformancePragma("Latency(B.sig2,C.)<1", blocks, as, null); + assertTrue(pragma ==null); + } @Test public void testFormAvatarStatePragma(){