@Override
    public final void update(final AnActionEvent event) {
      final Presentation presentation = event.getPresentation();

      final DataContext dataContext = event.getDataContext();
      final HierarchyBrowserBaseEx browser =
          (HierarchyBrowserBaseEx) dataContext.getData(myBrowserDataKey);
      if (browser == null) {
        presentation.setVisible(false);
        presentation.setEnabled(false);
        return;
      }

      presentation.setVisible(true);

      final PsiElement selectedElement = browser.getSelectedElement();
      if (selectedElement == null || !browser.isApplicableElement(selectedElement)) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
      }

      presentation.setEnabled(isEnabled(browser, selectedElement));
      String nonDefaultText = getNonDefaultText(browser, selectedElement);
      if (nonDefaultText != null) {
        presentation.setText(nonDefaultText);
      }
    }
  public void update(final AnActionEvent event) {
    super.update(event);

    final Presentation presentation = event.getPresentation();
    final DataContext context = event.getDataContext();
    Module module = (Module) context.getData(LangDataKeys.MODULE.getName());
    PsiFile currentFile = (PsiFile) context.getData(LangDataKeys.PSI_FILE.getName());
    Editor editor = (Editor) context.getData(PlatformDataKeys.EDITOR.getName());
    // VirtualFile currentFile = (VirtualFile)
    // context.getData(PlatformDataKeys.VIRTUAL_FILE.getName());
    if (currentFile != null && editor != null) {
      boolean isSSFile =
          currentFile
              .getFileType()
              .getDefaultExtension()
              .equals(SilverStripeFileType.DEFAULT_EXTENSION);
      SelectionModel selectionModel = editor.getSelectionModel();
      String selectedText = selectionModel.getSelectedText();
      this.selectedText = selectedText;
      this.selectonModel = selectionModel;
      this.editor = editor;
      this.currentFile = currentFile;
      if (selectedText == null) {
        presentation.setEnabled(false);
      }
      if (!isSSFile) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
      }
    } else {
      presentation.setEnabled(false);
      presentation.setVisible(false);
    }
  }
 @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);
           }
         }
       }
     }
   }
 }
예제 #4
0
  // Async update
  @Override
  public final void update(AnActionEvent e) {
    final T data = prepareDataFromContext(e);
    final Presentation originalPresentation = e.getPresentation();
    if (!forceSyncUpdate(e) && isDumbAware()) {
      final Presentation realPresentation = (Presentation) originalPresentation.clone();
      ourUpdaterService.submit(
          new Runnable() {
            @Override
            public void run() {
              performUpdate(realPresentation, data);
              SwingUtilities.invokeLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      if (originalPresentation.isVisible() != realPresentation.isVisible()) {
                        LOG.error(
                            "Async update is not supported for actions that change their visibility."
                                + "Either stop extending AsyncUpdateAction or override forceSyncUpdate() to return true."
                                + "Action class is: "
                                + AsyncUpdateAction.this.getClass().getName());
                      }
                      originalPresentation.copyFrom(realPresentation);
                    }
                  });
            }
          });

      originalPresentation.setVisible(true);
      originalPresentation.setEnabled(false);
    } else {
      performUpdate(originalPresentation, data);
    }
  }
 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 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());
 }
  @Override
  public void update(@NotNull AnActionEvent e) {
    Presentation p = e.getPresentation();

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

    p.setVisible(visible);
  }
  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);
  }
예제 #9
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) {
    final Presentation presentation = e.getPresentation();
    final Project project = e.getData(CommonDataKeys.PROJECT);

    presentation.setEnabled(true);
    if (project == null || project.isDisposed()) {
      presentation.setEnabled(false);
      presentation.setVisible(false);
      return;
    }

    if (null == getDefaultExecutor()) {
      presentation.setEnabled(false);
      presentation.setVisible(false);
      return;
    }

    presentation.setEnabled(true);
    presentation.setVisible(true);
  }
예제 #12
0
  @Override
  public void update(final AnActionEvent e) {
    if (!e.getPresentation().isVisible()) {
      return;
    }
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();

    final boolean enabled = isAvailable(dataContext);

    presentation.setVisible(enabled);
    presentation.setEnabled(enabled);
  }
예제 #13
0
  protected void updateForEditor(DataContext dataContext, Presentation presentation) {
    Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
    if (editor == null) {
      presentation.setVisible(false);
      return;
    }

    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
      return;
    }
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());

    PsiElement element = getTargetElement(editor, project);
    boolean result = element != null && CopyHandler.canCopy(new PsiElement[] {element});

    if (!result && file != null) {
      result = CopyHandler.canCopy(new PsiElement[] {file});
    }

    presentation.setEnabled(result);
    presentation.setVisible(true);
  }
  @Override
  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();

    if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace())
        || ActionPlaces.COMMANDER_POPUP.equals(e.getPlace())) {
      presentation.setText(IdeBundle.message("action.delete.ellipsis"));
    } else {
      presentation.setText(IdeBundle.message("action.delete"));
    }

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

    DataContext dataContext = e.getDataContext();
    DeleteProvider provider = getDeleteProvider(dataContext);
    if (e.getInputEvent() instanceof KeyEvent) {
      KeyEvent keyEvent = (KeyEvent) e.getInputEvent();
      Object component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
      if (component instanceof JTextComponent) provider = null; // Do not override text deletion
      if (keyEvent.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
        // Do not override text deletion in speed search
        if (component instanceof JComponent) {
          SpeedSearchSupply searchSupply = SpeedSearchSupply.getSupply((JComponent) component);
          if (searchSupply != null) provider = null;
        }

        String activeSpeedSearchFilter =
            SpeedSearchSupply.SPEED_SEARCH_CURRENT_QUERY.getData(dataContext);
        if (!StringUtil.isEmpty(activeSpeedSearchFilter)) {
          provider = null;
        }
      }
    }
    if (provider instanceof TitledHandler) {
      presentation.setText(((TitledHandler) provider).getActionTitle());
    }
    boolean canDelete = provider != null && provider.canDeleteElement(dataContext);
    if (ActionPlaces.isPopupPlace(e.getPlace())) {
      presentation.setVisible(canDelete);
    } else {
      presentation.setEnabled(canDelete);
    }
  }
 @Override
 public void update(final AnActionEvent e) {
   final Presentation presentation = e.getPresentation();
   final Project project = e.getData(CommonDataKeys.PROJECT);
   if (project == null) {
     disable(presentation);
     return;
   }
   RunnerAndConfigurationSettings settings = chooseTempSettings(project);
   if (settings == null) {
     disable(presentation);
   } else {
     presentation.setText(
         ExecutionBundle.message(
             "save.temporary.run.configuration.action.name", settings.getName()));
     presentation.setDescription(presentation.getText());
     presentation.setVisible(true);
     presentation.setEnabled(true);
   }
 }
 private static void disable(final Presentation presentation) {
   presentation.setEnabled(false);
   presentation.setVisible(false);
 }
예제 #17
0
 protected void disable(Presentation p) {
   p.setEnabled(false);
   p.setVisible(myIsAlwaysVisible);
 }
예제 #18
0
 protected void enable(final Presentation p) {
   p.setEnabled(true);
   p.setVisible(true);
 }