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: /* Generated by Together */
12:
13: // All implementing classes should have a name of
14: // "OpMenu" + ...
15: package de.uka.ilkd.key.casetool.together.scripts.menuextension;
16:
17: import com.togethersoft.openapi.ide.IdeContext;
18: import com.togethersoft.openapi.ide.window.IdeDialogType;
19: import com.togethersoft.openapi.ide.window.IdeWindowManager;
20: import com.togethersoft.openapi.rwi.*;
21:
22: import de.uka.ilkd.key.casetool.ModelMethod;
23: import de.uka.ilkd.key.casetool.together.TogetherModelMethod;
24:
25: import javax.swing.ProgressMonitor;
26:
27: public abstract class OpMenu {
28:
29: protected ProgressMonitor pm;
30:
31: public abstract String getMenuEntry();
32:
33: public abstract String getSubMenuName();
34:
35: public void run(IdeWindowManager winMan, IdeContext context,
36: RwiModel rwiModel, RwiDiagram rwiDiagram) {
37: RwiElement[] selectedRwiElements = context.getRwiElements();
38: RwiElement selectedRwiElement = selectedRwiElements[0];
39: RwiReference selectedRef = rwiDiagram
40: .findReference(selectedRwiElement);
41: // if a operation is selected it is always a member (so the cast
42: // shouldn't be dangerous
43: RwiMember selectedMember = ((RwiMemberReference) selectedRef)
44: .getMember();
45: TogetherModelMethod modelMethod = new TogetherModelMethod(
46: selectedMember, rwiModel, rwiDiagram);
47:
48: String result = runCore(modelMethod);
49:
50: if (!result.equals("")) {
51: if (pm != null)
52: pm.close();
53: winMan.showMessageDialog("Result",
54: IdeDialogType.INFORMATION, result);
55: }
56: }
57:
58: protected abstract String runCore(ModelMethod aReprModelMethod);
59: }
|