/** * Calls the extension to get the right menu item. This is already wrapped for errors in the * caller. It is right for it to create a new wrapped object each time. We do not want extensions * to share objects. It is here since it can access all constructors directly. * * @param attachedObject Description of the Parameter * @return The menuItem value */ JMenuItem getMenuItem(Object attachedObject) { if (currentMenuGen == null) return null; if (attachedObject == null) { JMenuItem anItem = currentMenuGen.getToolsMenuItem(null); if (anItem != null) return anItem; // Try to use the old deprecated method. return currentMenuGen.getMenuItem(); } if (attachedObject instanceof Package) { Package attachedPkg = (Package) attachedObject; Identifier anId = new Identifier(attachedPkg.getProject(), attachedPkg); return currentMenuGen.getToolsMenuItem(new BPackage(anId)); } if (attachedObject instanceof ClassTarget) { ClassTarget aTarget = (ClassTarget) attachedObject; String qualifiedClassName = aTarget.getQualifiedName(); Package attachedPkg = aTarget.getPackage(); Identifier anId = new Identifier(attachedPkg.getProject(), attachedPkg, qualifiedClassName); return currentMenuGen.getClassMenuItem(new BClass(anId)); } if (attachedObject instanceof ObjectWrapper) { ObjectWrapper aWrapper = (ObjectWrapper) attachedObject; return currentMenuGen.getObjectMenuItem(new BObject(aWrapper)); } return null; }