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.command.IdeCommandAdapter;
018: import com.togethersoft.openapi.ide.command.IdeCommandEvent;
019: import com.togethersoft.openapi.ide.window.IdeWindowManager;
020:
021: import de.uka.ilkd.key.casetool.together.keydebugclassloader.KeyDebugClassLoader;
022:
023: public class GlobalMenuIdeAdapter extends IdeCommandAdapter {
024:
025: public GlobalMenuIdeAdapter(KeyMenuExtension script,
026: IdeWindowManager aWinMan, int ind1, int ind2, int ind3,
027: String className) {
028: lnkKeyMenuExtension = script;
029: winMan = aWinMan;
030: typeI = ind1;
031: group = ind2;
032: groupItem = ind3;
033: globalMenuRootCN = className;
034: }
035:
036: private int typeI;
037: private int group;
038: private int groupItem;
039: private String globalMenuRootCN;
040: private IdeWindowManager winMan;
041: private KeyMenuExtension lnkKeyMenuExtension;
042:
043: public void actionPerformed(IdeCommandEvent event) {
044: // here we create an instance of classes like GlobalMenuePoint1_1
045: // by asking a classloader
046: Class cl;
047: ClassLoader classLoader = this .getClass().getClassLoader();
048: if ("on".equals(System.getProperty("KeyDebugClassLoader"))) {
049: // installing the keydebugclassloader instead
050: // see also de.uka.ilkd.tjext.keydebugclassloader.KeyScript
051: try {
052: classLoader = new KeyDebugClassLoader(classLoader);
053: ((KeyDebugClassLoader) classLoader)
054: .setClassAlwaysAskParent(GlobalMenu.class);
055: } catch (SecurityException se) {
056: System.err
057: .println("globalmenuideadapter: security manager exists and\n"
058: + "its checkPermission method doesn't allow access\n"
059: + "to the system class loader.");
060: System.err.println("KeYError: " + se);
061: se.printStackTrace();
062: }
063: }
064: try {
065: cl = classLoader.loadClass(globalMenuRootCN + "Point"
066: + group + "_" + groupItem);
067: // now creating an instance of the (re)loaded class and
068: // invoking the run-method
069: GlobalMenu instance = (GlobalMenu) cl.newInstance();
070: instance.run(winMan);
071: } catch (ClassNotFoundException cnfe) {
072: System.err
073: .println("classmenuideadapter: class cannot be located");
074: System.err.println("The exception was: " + cnfe);
075: cnfe.printStackTrace();
076: } catch (ExceptionInInitializerError ei) {
077: System.err
078: .println("globalmenuideadapter: the initialization provoked "
079: + "by this method fails.");
080: System.err.println("The exception was: " + ei);
081: ei.printStackTrace();
082: } catch (IllegalAccessException iae) {
083: System.err.println("globalmenuideadapter: class or "
084: + "initializer is not accessible.");
085: System.err.println("The exception was: " + iae);
086: iae.printStackTrace();
087: } catch (InstantiationException ie) {
088: System.err
089: .println("globalmenuideadapter: class tried to\n"
090: + "instantiate represents an abstract class, an interface,"
091: + "an array class, a primitive type, or void; or if the"
092: + "instantiation fails for some other reason.");
093: System.err.println("The exception was: " + ie);
094: ie.printStackTrace();
095: } catch (SecurityException se) {
096: System.err
097: .println("globalmenuideadapter: no permission to create"
098: + "a new instance");
099: System.err.println("The exception was: " + se);
100: se.printStackTrace();
101: }
102:
103: }
104:
105: public void checkStatus(IdeCommandEvent event) {
106: // here we create an instance of classes like GlobalMenueGroup1
107: // try{
108: // // ( lnkKeyMenuExtension.myGlobalMenuGroups[typeI][(group-1)]).setText(((GlobalMenu) Class.forName(globalMenuRootCN + "Group" + group).newInstance()).getMenuEntry());
109: // }catch(Exception e){
110: // System.err.println("KeYError: " + e);
111: // e.printStackTrace();
112: // }
113: }
114: }
|