コード例 #1
0
ファイル: GitProjectUtils.java プロジェクト: jonas/nbgit
 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
 }
コード例 #2
0
  @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);
    }
  }