@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);
           }
         }
       }
     }
   }
 }
  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    final DataContext dataContext = e.getDataContext();

    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if ((project == null)
        || (ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning())) {
      presentation.setEnabled(false);
      presentation.setVisible(false);
      return;
    }

    VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
    if (files == null || files.length == 0) {
      presentation.setEnabled(false);
      presentation.setVisible(false);
      return;
    }
    boolean enabled = false;
    boolean visible = false;
    if (files.length == 1 && files[0].isDirectory()) {
      visible = true;
      if (!SvnStatusUtil.isUnderControl(project, files[0])) {
        enabled = true;
      }
    }
    presentation.setEnabled(enabled);
    presentation.setVisible(visible);
  }
  @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);
  }
  @Override
  public void update(@NotNull AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    final Project project = event.getData(CommonDataKeys.PROJECT);
    if (project == null) {
      presentation.setVisible(false);
      presentation.setEnabled(false);
      return;
    }

    final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
    if (view == null) {
      presentation.setVisible(false);
      presentation.setEnabled(false);
      return;
    }

    final PsiDirectory[] directories = view.getDirectories();
    if (directories.length == 0) {
      presentation.setVisible(false);
      presentation.setEnabled(false);
      return;
    }
    final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view);
    final CCProjectService service = CCProjectService.getInstance(project);
    final Course course = service.getCourse();
    if (course != null && directory != null && course.getLesson(directory.getName()) == null) {
      presentation.setVisible(false);
      presentation.setEnabled(false);
      return;
    }

    presentation.setVisible(true);
    presentation.setEnabled(true);
  }
  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 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);
      }
    }
 @Override
 public void update(AnActionEvent e) {
   Presentation presentation = e.getPresentation();
   String filePath = getActionFile(e);
   if (filePath == null) {
     presentation.setVisible(false);
   } else {
     File f = new File(filePath);
     presentation.setVisible(true);
     presentation.setText(String.format("Load \"%s\" in Haskell REPL", f.getName()));
   }
 }
  @Override
  public void update(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();

    OpenInBrowserRequest result = BaseOpenInBrowserAction.doUpdate(e);
    if (result == null) {
      return;
    }

    String description = getTemplatePresentation().getDescription();
    if (HtmlUtil.isHtmlFile(result.getFile())) {
      description += " (hold Shift to open URL of local file)";
    }

    presentation.setText(getTemplatePresentation().getText());
    presentation.setDescription(description);

    WebBrowser browser = findUsingBrowser();
    if (browser != null) {
      presentation.setIcon(browser.getIcon());
    }

    if (ActionPlaces.isPopupPlace(e.getPlace())) {
      presentation.setVisible(presentation.isEnabled());
    }
  }
 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);
 }
 public void update(AnActionEvent e) {
   super.update(e);
   Presentation presentation = e.getPresentation();
   boolean isEnabled = CreateFromTemplateGroup.canCreateFromTemplate(e, myTemplate);
   presentation.setEnabled(isEnabled);
   presentation.setVisible(isEnabled);
 }
Esempio n. 11
0
 public void update(
     final Presentation presentation,
     final ConfigurationContext context,
     final String actionText) {
   super.update(presentation, context, actionText);
   presentation.setVisible(false);
 }
Esempio n. 12
0
 @Override
 public void update(AnActionEvent event) {
   super.update(event);
   boolean available = isAvailable(event);
   Presentation p = event.getPresentation();
   p.setEnabled(available);
   p.setVisible(available);
 }
  @Override
  public void update(@NotNull AnActionEvent e) {
    Presentation p = e.getPresentation();

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

    p.setVisible(visible);
  }
 @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());
 }
Esempio n. 15
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
  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(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);
  }
  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(AnActionEvent e) {
    super.update(e);

    boolean visible = isActionAvailable(e);

    final Presentation presentation = e.getPresentation();
    presentation.setVisible(visible);
    presentation.setEnabled(visible);
  }
  @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));
  }
Esempio n. 21
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(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);
  }
Esempio n. 23
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);
  }
  public void update(final AnActionEvent event) {
    log.debug("update");
    super.update(event);

    final Presentation presentation = event.getPresentation();
    final DataContext context = event.getDataContext();
    Module module = (Module) context.getData(LangDataKeys.MODULE.getName());

    log.debug("update: module: " + module);

    final boolean hasModule = module != null;
    presentation.setEnabled(hasModule);
    presentation.setVisible(hasModule);
  }
  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);
   }
 }
  public void update(AnActionEvent e) {
    DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext());

    boolean visible = false;
    boolean enabled = false;
    String text = DebuggerBundle.message("action.resume.thread.text.resume");

    if (selectedNodes != null && selectedNodes.length > 0) {
      visible = true;
      enabled = true;
      for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
        final NodeDescriptorImpl threadDescriptor = selectedNode.getDescriptor();
        if (!(threadDescriptor instanceof ThreadDescriptorImpl)
            || !((ThreadDescriptorImpl) threadDescriptor).isSuspended()) {
          visible = false;
          break;
        }
      }
    }
    final Presentation presentation = e.getPresentation();
    presentation.setText(text);
    presentation.setVisible(visible);
    presentation.setEnabled(enabled);
  }
  @Override
  public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    presentation.setEnabledAndVisible(false);
    Project project = e.getProject();
    if (project == null) {
      return;
    }
    Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
      return;
    }

    if (!EduNames.STUDY.equals(course.getCourseMode())) {
      presentation.setVisible(true);
      return;
    }

    if (getAnswerPlaceholder(e) == null) {
      presentation.setEnabledAndVisible(false);
      return;
    }
    presentation.setEnabledAndVisible(true);
  }
Esempio n. 30
0
 @Patch
 protected void update(VcsContext context, Presentation presentation) {
   presentation.setEnabled(isActive(context));
   // MPS patch: hide "Go to next/prev change" actions for non-text editors
   presentation.setVisible(context.getEditor() != null);
 }