@Override
 public void update(AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   presentation.setVisible(false);
   final DataContext dataContext = e.getDataContext();
   final Project project = CommonDataKeys.PROJECT.getData(dataContext);
   if (project != null) {
     final RunConfiguration configuration = RunConfiguration.DATA_KEY.getData(dataContext);
     if (isPatternBasedConfiguration(configuration)) {
       final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext);
       if (testProxy != null) {
         final Location location =
             testProxy.getLocation(
                 project, ((T) configuration).getConfigurationModule().getSearchScope());
         if (location != null) {
           final PsiElement psiElement = location.getPsiElement();
           if (psiElement instanceof PsiClass
               && getPattern((T) configuration)
                   .contains(((PsiClass) psiElement).getQualifiedName())) {
             presentation.setVisible(true);
           }
         }
       }
     }
   }
 }
      private AnAction patch(final AnAction child) {
        if (child instanceof ActionGroup) {
          return new IconsFreeActionGroup((ActionGroup) child);
        }

        Presentation presentation = child.getTemplatePresentation();
        return new AnAction(presentation.getText(), presentation.getDescription(), null) {
          @Override
          public void actionPerformed(@NotNull AnActionEvent e) {
            child.actionPerformed(e);
            UsageTrigger.trigger("welcome.screen." + e.getActionManager().getId(child));
          }

          @Override
          public void update(@NotNull AnActionEvent e) {
            child.update(e);
            e.getPresentation().setIcon(null);
          }

          @Override
          public boolean isDumbAware() {
            return child.isDumbAware();
          }
        };
      }
  @Override
  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();

    Project project = e.getProject();
    if (project == null) {
      presentation.setEnabled(false);
      return;
    }

    final DataContext dataContext = e.getDataContext();
    Editor editor = getEditor(dataContext, project, true);
    if (editor == null) {
      presentation.setEnabled(false);
      return;
    }

    final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
    if (file == null) {
      presentation.setEnabled(false);
      return;
    }

    update(presentation, project, editor, file, dataContext, e.getPlace());
  }
Exemplo n.º 4
0
 protected Color defaultActionForeground(boolean isSelected, Presentation presentation) {
   return isSelected
       ? UIUtil.getListSelectionForeground()
       : presentation.isEnabled() && presentation.isVisible()
           ? UIUtil.getListForeground()
           : UIUtil.getInactiveTextColor();
 }
Exemplo n.º 5
0
 private static Presentation wrapIcon(Presentation presentation) {
   Icon original = presentation.getIcon();
   CenteredIcon centered =
       new CenteredIcon(original != null ? original : DEFAULT_ICON, 40, 40, false);
   presentation.setIcon(centered);
   return presentation;
 }
  @Override
  public void update(final AnActionEvent event) {
    if (event.getProject() == null
        || event.getData(EditorGutter.KEY) != null
        || Boolean.TRUE.equals(event.getData(CommonDataKeys.EDITOR_VIRTUAL_SPACE))) {
      event.getPresentation().setEnabled(false);
      return;
    }

    for (GotoDeclarationHandler handler :
        Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {
      try {
        String text = handler.getActionText(event.getDataContext());
        if (text != null) {
          Presentation presentation = event.getPresentation();
          presentation.setText(text);
          break;
        }
      } catch (AbstractMethodError e) {
        LOG.error(handler.toString(), e);
      }
    }

    super.update(event);
  }
 public void update(AnActionEvent e) {
   super.update(e);
   Presentation presentation = e.getPresentation();
   boolean isEnabled = CreateFromTemplateGroup.canCreateFromTemplate(e, myTemplate);
   presentation.setEnabled(isEnabled);
   presentation.setVisible(isEnabled);
 }
  @Override
  public void actionPerformed(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (project == null || editor == null) {
      presentation.setEnabled(false);
      return;
    }

    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (file == null || file.getVirtualFile() == null) {
      presentation.setEnabled(false);
      return;
    }

    boolean hasSelection = editor.getSelectionModel().hasSelection();
    LayoutCodeDialog dialog = new LayoutCodeDialog(project, file, hasSelection, HELP_ID);
    dialog.show();

    if (dialog.isOK()) {
      new FileInEditorProcessor(file, editor, dialog.getRunOptions()).processCode();
    }
  }
 private void initButton() {
   setIcon(myPresentation.getIcon());
   setEnabled(myPresentation.isEnabled());
   setText(myPresentation.getText());
   updateTooltipText(myPresentation.getDescription());
   updateButtonSize();
 }
 public static void updateFindUsagesAction(AnActionEvent event) {
   Presentation presentation = event.getPresentation();
   DataContext dataContext = event.getDataContext();
   boolean enabled = isEnabled(dataContext);
   presentation.setVisible(enabled || !ActionPlaces.isPopupPlace(event.getPlace()));
   presentation.setEnabled(enabled);
 }
 @Override
 public final void update(final AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   final Project project = e.getProject();
   if (project == null) return;
   presentation.setEnabled(isEnabled());
   presentation.setText(getCurrentScopeType());
 }
  @Override
  protected void update(@NotNull VcsContext context, @NotNull Presentation presentation) {
    Project project = context.getProject();

    presentation.setEnabled(isEnabled(context));
    presentation.setVisible(
        project != null && ProjectLevelVcsManager.getInstance(project).hasActiveVcss());
  }
  @Override
  public void update(@NotNull AnActionEvent e) {
    Presentation p = e.getPresentation();

    boolean visible = findPomXml(e.getDataContext()) != null;

    p.setVisible(visible);
  }
Exemplo n.º 14
0
  @Override
  public void update(AnActionEvent event) {
    Presentation p = event.getPresentation();
    boolean hasProject = event.getData(CommonDataKeys.PROJECT) != null;

    p.setVisible(hasProject);
    p.setEnabled(hasProject);
  }
 @Override
 public void update(AnActionEvent event) {
   final Presentation presentation = event.getPresentation();
   final Project project = event.getData(CommonDataKeys.PROJECT);
   presentation.setEnabled(project != null);
   presentation.setVisible(
       ActionPlaces.isMainMenuOrActionSearch(event.getPlace()) && !PlatformUtils.isCidr());
 }
Exemplo n.º 16
0
 @Override
 public void update(AnActionEvent event) {
   super.update(event);
   boolean available = isAvailable(event);
   Presentation p = event.getPresentation();
   p.setEnabled(available);
   p.setVisible(available);
 }
    public ExternalSystemTaskAction(Project project, String group, TaskData taskData) {
      myGroup = group;
      myTaskData = taskData;
      myId = getActionPrefix(project, taskData.getLinkedExternalProjectPath()) + taskData.getName();

      Presentation template = getTemplatePresentation();
      template.setText(myTaskData.getName() + " (" + group + ")", false);
      template.setIcon(ExternalSystemIcons.Task);
    }
  @Override
  public void update(AnActionEvent e) {
    final DataContext dc = e.getDataContext();

    final Presentation presentation = e.getPresentation();

    // presentation.setVisible(isVisible(dc));
    presentation.setEnabled(isVisible(dc) && isEnabled(dc));
  }
  @Override
  public void update(final AnActionEvent e) {
    final Presentation presentation = e.getPresentation();

    // visible only in SMTRunnerTestTreeView
    presentation.setVisible(e.getData(SMTRunnerTestTreeView.SM_TEST_RUNNER_VIEW) != null);
    // enabled if some proxy is selected
    presentation.setEnabled(getSelectedTestProxy(e) != null);
  }
 @Override
 public void update(final AnActionEvent e) {
   super.update(e);
   final Presentation presentation = e.getPresentation();
   presentation.setIcon(SvnIcons.ShowIntegratedFrom);
   presentation.setText(SvnBundle.message("committed.changes.action.enable.merge.highlighting"));
   presentation.setDescription(
       SvnBundle.message("committed.changes.action.enable.merge.highlighting.description.text"));
 }
  public void update(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();

    final boolean enabled = isAvailable(dataContext);

    presentation.setVisible(enabled);
    presentation.setEnabled(enabled);
  }
 @Override
 public void update(final AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   if (myFocusDrawer == null) {
     presentation.setText("Start Focus Debugger");
   } else {
     presentation.setText("Stop Focus Debugger");
   }
 }
  public boolean processAction(final InputEvent e, ActionProcessor processor) {
    ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    final Project project = PlatformDataKeys.PROJECT.getData(myContext.getDataContext());
    final boolean dumb = project != null && DumbService.getInstance(project).isDumb();
    List<AnActionEvent> nonDumbAwareAction = new ArrayList<AnActionEvent>();
    for (final AnAction action : myContext.getActions()) {
      final Presentation presentation = myPresentationFactory.getPresentation(action);

      // Mouse modifiers are 0 because they have no any sense when action is invoked via keyboard
      final AnActionEvent actionEvent =
          processor.createEvent(
              e,
              myContext.getDataContext(),
              ActionPlaces.MAIN_MENU,
              presentation,
              ActionManager.getInstance());

      ActionUtil.performDumbAwareUpdate(action, actionEvent, true);

      if (dumb && !action.isDumbAware()) {
        if (Boolean.FALSE.equals(
            presentation.getClientProperty(ActionUtil.WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) {
          continue;
        }

        nonDumbAwareAction.add(actionEvent);
        continue;
      }

      if (!presentation.isEnabled()) {
        continue;
      }

      processor.onUpdatePassed(e, action, actionEvent);

      ((DataManagerImpl.MyDataContext) myContext.getDataContext())
          .setEventCount(IdeEventQueue.getInstance().getEventCount(), this);
      actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent);
      Component component =
          PlatformDataKeys.CONTEXT_COMPONENT.getData(actionEvent.getDataContext());
      if (component != null && !component.isShowing()) {
        return true;
      }

      processor.performAction(e, action, actionEvent);
      actionManager.fireAfterActionPerformed(action, actionEvent.getDataContext(), actionEvent);
      return true;
    }

    if (!nonDumbAwareAction.isEmpty()) {
      showDumbModeWarningLaterIfNobodyConsumesEvent(
          e, nonDumbAwareAction.toArray(new AnActionEvent[nonDumbAwareAction.size()]));
    }

    return false;
  }
  @Override
  public void update(AnActionEvent e) {
    super.update(e);

    boolean visible = isActionAvailable(e);

    final Presentation presentation = e.getPresentation();
    presentation.setVisible(visible);
    presentation.setEnabled(visible);
  }
 @Override
 public void actionPerformed(AnActionEvent e) {
   Presentation presentation = e.getPresentation();
   JComponent button = (JComponent) presentation.getClientProperty("button");
   DefaultActionGroup group =
       createPopupActionGroup(myProject, myToDoSettings, myTodoFilterConsumer);
   ActionPopupMenu popupMenu =
       ActionManager.getInstance().createActionPopupMenu(ActionPlaces.TODO_VIEW_TOOLBAR, group);
   popupMenu.getComponent().show(button, button.getWidth(), 0);
 }
 @Override
 public void update(final AnActionEvent e) {
   super.update(e);
   final Presentation presentation = e.getPresentation();
   presentation.setText(
       ProjectBundle.message(
           myEditTestSources
               ? "module.toggle.test.sources.action"
               : "module.toggle.sources.action"));
 }
Exemplo n.º 27
0
  @Override
  public void update(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();

    final boolean enabled = LangDataKeys.PSI_FILE.getData(dataContext) instanceof DartFile;

    presentation.setVisible(enabled);
    presentation.setEnabled(enabled);
  }
  @Override
  public void update(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    final Change[] changes = e.getData(getChangesKey());

    final Presentation presentation = e.getPresentation();
    presentation.setVisible(VcsDataKeys.CHANGES.getData(dataContext) != null);
    presentation.setEnabled(enabled(project, changes));
  }
  @Override
  public void update(AnActionEvent e) {
    super.update(e);
    Presentation presentation = e.getPresentation();
    Project project = e.getProject();
    if (project == null) {
      presentation.setEnabled(false);
      presentation.setVisible(false);
      return;
    }

    VirtualFile[] vFiles = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    if (vFiles == null || vFiles.length != 1 || vFiles[0] == null) { // only 1 file for now
      presentation.setEnabled(false);
      presentation.setVisible(true);
      return;
    }

    GitRepositoryManager manager = GitUtil.getRepositoryManager(project);

    GitRepository repository = manager.getRepositoryForFile(vFiles[0]);
    if (repository == null || repository.isFresh() || noBranchesToCompare(repository)) {
      presentation.setEnabled(false);
      presentation.setVisible(true);
      return;
    }

    presentation.setEnabled(true);
    presentation.setVisible(true);
  }
Exemplo n.º 30
0
 public void update(AnActionEvent event) {
   Presentation presentation = event.getPresentation();
   Project project = PlatformDataKeys.PROJECT.getData(event.getDataContext());
   if (project == null) {
     presentation.setEnabled(false);
     return;
   }
   DebuggerSession debuggerSession =
       (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession();
   presentation.setEnabled(debuggerSession != null);
 }