Skip to content

Commit

Permalink
Optimised Blackboard and MVC
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlano committed May 8, 2024
1 parent c946f8b commit 3e581d5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Compiler2.java
Original file line number Diff line number Diff line change
Expand Up @@ -5754,13 +5754,23 @@ public static String isKeywordOrPart(String st, String[] mess)
{ mess[0] = "usecase parameter, eg: parameter name : Type;";
return "parameter";
}

if ("oppositeOf".startsWith(st))
{ mess[0] = "oppositeOf clause in reference,\n" +
"e.g: reference children [*] ordered : Person oppositeOf parent;" +
"The matching declaration\n" +
" reference parent : Person;\n" +
"is also necessary.";
return "oppositeOf";
}

}

if (st.length() > 3)
{ if ("reference".startsWith(st))
{ mess[0] = "reference declaration, eg: reference name : Type;\nType is a class type or collection (of class element type)\nGeneral syntax is:\n" +
"reference role2 [cardinality] [stereotypes] : Entity2 [opp];\n" +
"Eg: reference children [*] ordered : Person oppositeOf parent;";
"E.g: reference children [*] ordered : Person oppositeOf parent;";
return "reference";
}

Expand Down Expand Up @@ -6236,7 +6246,14 @@ public static String isKeywordOrPart(String st, String[] mess)
}

if ("execute".startsWith(st))
{ mess[0] = "Execute expression as statement. Eg., execute (x->display())";
{ mess[0] = "Execute expression as statement. Eg., execute (x->display())\n" +
" execute (x->isDeleted())\n" +
"This also specifies direct updates of collections:\n" +
" execute (x : col)\n" +
" execute (x /: col)\n" +
" execute (x <: col)\n" +
" execute (x /<: col)\n" +
" execute col[i]->isDeleted()\n";
return "execute";
}
}
Expand Down
16 changes: 16 additions & 0 deletions UCDArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -15154,6 +15154,22 @@ public void observerPattern()
{ System.err.println("! Warning: no file libraries/observer.km3"); }
}

public void blackboardPattern()
{ File oclobserver = new File("libraries/blackboard.km3");
if (oclobserver.exists())
{ loadKM3FromFile(oclobserver); }
else
{ System.err.println("! Warning: no file libraries/blackboard.km3"); }
}

public void mvcPattern()
{ File oclobserver = new File("libraries/mvc.km3");
if (oclobserver.exists())
{ loadKM3FromFile(oclobserver); }
else
{ System.err.println("! Warning: no file libraries/mvc.km3"); }
}

public void java2python()
{ File ocltypes = new File("libraries/ocltype.km3");
if (ocltypes.exists())
Expand Down
12 changes: 12 additions & 0 deletions UmlTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,14 @@ public UmlTool()
observerMI.addActionListener(this);
patternsMenu.add(observerMI);

JMenuItem blackboardMI = new JMenuItem("Blackboard");
blackboardMI.addActionListener(this);
patternsMenu.add(blackboardMI);

JMenuItem mvcMI = new JMenuItem("MVC");
mvcMI.addActionListener(this);
patternsMenu.add(mvcMI);

JMenuItem facadeMI = new JMenuItem("Facade");
facadeMI.setToolTipText(
"Checks if 2+ classes all reference 2+ same other classes");
Expand Down Expand Up @@ -2750,6 +2758,10 @@ else if (label.equals("Singleton"))
{ makeSingletons(); }
else if (label.equals("Observer"))
{ ucdArea.observerPattern(); }
else if (label.equals("Blackboard"))
{ ucdArea.blackboardPattern(); }
else if (label.equals("MVC"))
{ ucdArea.mvcPattern(); }
else if (label.equals("Facade"))
{ checkForFacades(); }
else if (label.equals("Phased Construction"))
Expand Down

0 comments on commit 3e581d5

Please sign in to comment.