001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: //
010:
011: /* Generated by Together */
012:
013: // Auxiliary class to cover behavior what was
014: // covered by an innerclass before.
015: package de.uka.ilkd.key.casetool.together.scripts.menuextension;
016:
017: import com.togethersoft.openapi.ide.IdeContext;
018: import com.togethersoft.openapi.ide.command.IdeCommandAdapter;
019: import com.togethersoft.openapi.ide.command.IdeCommandEvent;
020: import com.togethersoft.openapi.ide.diagram.IdeDiagramManagerAccess;
021: import com.togethersoft.openapi.ide.window.IdeWindowManager;
022: import com.togethersoft.openapi.rwi.RwiDiagram;
023: import com.togethersoft.openapi.rwi.RwiModel;
024: import com.togethersoft.openapi.rwi.RwiModelAccess;
025:
026: import de.uka.ilkd.key.casetool.together.keydebugclassloader.KeyDebugClassLoader;
027:
028: public class OpMenuIdeAdapter extends IdeCommandAdapter {
029:
030: public OpMenuIdeAdapter(KeyMenuExtension script,
031: IdeWindowManager aWinMan, int ind1, String className) {
032: lnkKeyMenuExtension = script;
033: winMan = aWinMan;
034: groupElementNo = ind1;
035: opMenuRootCN = className;
036: }
037:
038: private int groupElementNo;
039: private String opMenuRootCN;
040: private IdeWindowManager winMan;
041: private KeyMenuExtension lnkKeyMenuExtension;
042:
043: public void checkStatus(IdeCommandEvent event) {
044: try {
045: lnkKeyMenuExtension.myOpItem[groupElementNo - 1]
046: .setText(((OpMenu) Class.forName(
047: opMenuRootCN + "Point" + groupElementNo)
048: .newInstance()).getMenuEntry());
049: } catch (ExceptionInInitializerError ei) {
050: System.err
051: .println("opmenuideadapter: the initialization provoked "
052: + "by this method fails.");
053: System.err.println("The exception was: " + ei);
054: ei.printStackTrace();
055: } catch (ClassNotFoundException cnfe) {
056: System.err
057: .println("opmenuideadapter: class cannot be located");
058: System.err.println("The exception was: " + cnfe);
059: cnfe.printStackTrace();
060: } catch (IllegalAccessException iae) {
061: System.err.println("opmenuideadapter: class or "
062: + "initializer is not accessible.");
063: System.err.println("The exception was: " + iae);
064: iae.printStackTrace();
065: } catch (InstantiationException ie) {
066: System.err
067: .println("opmenuideadapter: class tried to\n"
068: + "instantiate represents an abstract class, an interface,"
069: + "an array class, a primitive type, or void; or if the"
070: + "instantiation fails for some other reason.");
071: System.err.println("The exception was: " + ie);
072: ie.printStackTrace();
073: } catch (SecurityException se) {
074: System.err
075: .println("opmenuideadapter: no permission to create"
076: + "a new instance");
077: System.err.println("The exception was: " + se);
078: se.printStackTrace();
079: } catch (LinkageError le) {
080: System.err.println("opmenuideadapter: linkage failed");
081: System.err.println("The exception was: " + le);
082: le.printStackTrace();
083: }
084: lnkKeyMenuExtension.myOpItem[groupElementNo - 1]
085: .setEnabled(true);
086: lnkKeyMenuExtension.myOpItem[groupElementNo - 1]
087: .setVisible(true);
088: }
089:
090: public void actionPerformed(IdeCommandEvent event) {
091: // what should be done be selecting this context menu
092: IdeContext context = event.getElementContext(); //getting the element(s) under the cursor
093: RwiDiagram activeRwiDiagram = IdeDiagramManagerAccess
094: .getDiagramManager().getActiveDiagram().getRwiDiagram();
095: RwiModel currentRwiModel = RwiModelAccess.getModel();
096:
097: Class cl;
098: ClassLoader classLoader = this .getClass().getClassLoader();
099: if ("on".equals(System.getProperty("KeyDebugClassLoader"))) {
100: // installing the keydebugclassloader instead
101: // see also de.uka.ilkd.tjext.keydebugclassloader.KeyScript
102: try {
103: classLoader = new KeyDebugClassLoader(classLoader);
104: ((KeyDebugClassLoader) classLoader)
105: .setClassAlwaysAskParent(OpMenu.class);
106:
107: } catch (SecurityException se) {
108: System.err
109: .println("opmenuideadapter: no permission to create"
110: + "a new instance");
111: System.err.println("The exception was: " + se);
112: se.printStackTrace();
113: }
114: }
115: try {
116: cl = classLoader.loadClass(opMenuRootCN + "Point"
117: + groupElementNo);
118: // now creating an instance of the (re)loaded class and
119: // invoking the run-method
120: OpMenu instance = (OpMenu) cl.newInstance();
121: instance.run(winMan, context, currentRwiModel,
122: activeRwiDiagram);
123: } catch (ClassNotFoundException cnfe) {
124: System.err
125: .println("opmenuideadapter: class cannot be located");
126: System.err.println("The exception was: " + cnfe);
127: cnfe.printStackTrace();
128: } catch (ExceptionInInitializerError ei) {
129: System.err
130: .println("opmenuideadapter: the initialization provoked "
131: + "by this method fails.");
132: System.err.println("The exception was: " + ei);
133: ei.printStackTrace();
134: } catch (IllegalAccessException iae) {
135: System.err.println("opmenuideadapter: class or "
136: + "initializer is not accessible.");
137: System.err.println("The exception was: " + iae);
138: iae.printStackTrace();
139: } catch (InstantiationException ie) {
140: System.err
141: .println("opmenuideadapter: class tried to\n"
142: + "instantiate represents an abstract class, an interface,"
143: + "an array class, a primitive type, or void; or if the"
144: + "instantiation fails for some other reason.");
145: System.err.println("The exception was: " + ie);
146: ie.printStackTrace();
147: } catch (SecurityException se) {
148: System.err
149: .println("opmenuideadapter: no permission to create"
150: + "a new instance");
151: System.err.println("The exception was: " + se);
152: se.printStackTrace();
153: }
154:
155: }
156:
157: }
|