public static Action findAction(String key) { FileObject fo = FileUtil.getConfigFile(key); if (fo != null && fo.isValid()) { try { DataObject dob = DataObject.find(fo); InstanceCookie ic = dob.getCookie(InstanceCookie.class); if (ic != null) { Object instance = ic.instanceCreate(); if (instance instanceof Action) { Action a = (Action) instance; return a; } } } catch (Exception e) { ErrorManager.getDefault().notify(ErrorManager.WARNING, e); return null; } } return null; }
/** * Accepts only cookies that can provide <code>Toolbar</code>. * * @param cookie an <code>InstanceCookie</code> to test * @return true if the cookie can provide accepted instances */ protected InstanceCookie acceptCookie(InstanceCookie cookie) throws java.io.IOException, ClassNotFoundException { Class c = cookie.instanceClass(); if (Toolbar.class.isAssignableFrom(c)) { return cookie; } if (Presenter.Toolbar.class.isAssignableFrom(c)) { return cookie; } if (separatorClass.isAssignableFrom(c)) { return cookie; } return null; }