01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.casetool.together;
12:
13: import com.togethersoft.openapi.ide.IdeAccess;
14: import com.togethersoft.openapi.ide.diagram.IdeDiagram;
15: import com.togethersoft.openapi.ide.diagram.IdeDiagramElement;
16: import com.togethersoft.openapi.ide.diagram.IdeDiagramManager;
17: import com.togethersoft.openapi.rwi.RwiDiagram;
18: import com.togethersoft.openapi.rwi.RwiElement;
19: import com.togethersoft.openapi.rwi.RwiModel;
20: import com.togethersoft.openapi.rwi.RwiModelAccess;
21: import com.togethersoft.openapi.sci.*;
22:
23: import de.uka.ilkd.key.java.abstraction.Type;
24: import de.uka.ilkd.key.logic.op.ProgramMethod;
25:
26: class ModelUtilImpl {
27:
28: private ModelUtilImpl() {
29: }
30:
31: /**
32: * Get the method signature in Together format
33: * e.g.: callM#(#SuperA#C#)#
34: * @author VK
35: */
36: static String togetherSignature(ProgramMethod pm) {
37: String s = pm.name().toString() + "#(#";
38: for (int i = 0; i < pm.arity() - 1; i++) {
39: if (i > 0)
40: s = s + "#";
41: s = s
42: + pm.getMethodDeclaration()
43: .getParameterDeclarationAt(i)
44: .getVariableSpecification().getType()
45: .getFullName();
46: }
47: s = s + "#)#";
48: return s;
49: }
50:
51: static void hiliteMethod(Type t, ProgramMethod pm) {
52: SciModel sciModel = SciModelAccess.getModel();
53: RwiModel rwiModel = RwiModelAccess.getModel();
54:
55: SciClass cl = sciModel.findClass(SciLanguage.JAVA, t
56: .getFullName());
57: SciMember op = SciUtil.findMemberBySignature(cl,
58: togetherSignature(pm), true);
59:
60: // SciOperationEnumeration openum = cl.operations();
61: // while (openum.hasMoreElements())
62: // System.out.println(openum.nextSciOperation().getSignature());
63: // System.out.println("op="+op);
64:
65: RwiElement rwiOp = rwiModel.findMember(op);
66:
67: IdeDiagramManager diaMan = IdeAccess.getDiagramManager();
68: RwiDiagram rwiDiagram2 = rwiModel.findDiagramFor(rwiOp);
69: IdeDiagram dia = diaMan.openDiagram(rwiDiagram2, true);
70: diaMan.setActiveDiagram(dia);
71: IdeDiagramElement idx = dia.findElement(rwiOp);
72: // System.out.println(idx);
73: dia.unselectAll();
74: dia.select(idx);
75: }
76:
77: }
|