public static void renameProject(Project p, Object caller) { if (p == null) { return; } ContextAwareAction action = (ContextAwareAction) CommonProjectActions.renameProjectAction(); Lookup ctx = Lookups.singleton(p); Action ctxAction = action.createContextAwareInstance(ctx); ctxAction.actionPerformed(new ActionEvent(caller, 0, "")); // NOI18N }
@Override public Action createContextAwareInstance(Lookup actionContext) { try { Method getDelegateMethod = action.getClass().getDeclaredMethod("getDelegate"); getDelegateMethod.setAccessible(true); Action act = (Action) getDelegateMethod.invoke(action); String iconBase = (String) action.getValue("iconBase"); if (iconBase != null) { act.putValue(SMALL_ICON, ImageUtilities.loadImageIcon(iconBase, true)); } return act; } catch (Exception ex) { return action.createContextAwareInstance(actionContext); } }