Java 类com.intellij.openapi.actionSystem.Presentation 实例源码

项目:educational-plugin    文件:StudyCheckAction.java   
private static void updateDescription(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  final Project project = e.getProject();
  if (project != null) {
    final StudyEditor studyEditor = StudyUtils.getSelectedStudyEditor(project);
    if (studyEditor != null) {
      final Task task = studyEditor.getTaskFile().getTask();
      if (task instanceof TheoryTask) {
        presentation.setText(task.getLesson().getCourse().isAdaptive() ? "Get Next Recommendation" : "Mark as read");
      }
      else {
        presentation.setText(TEXT);
      }
    }
  }
}
项目:educational-plugin    文件:StudyRefreshAnswerPlaceholder.java   
@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);
}
项目:educational-plugin    文件:StudyUpdateRecommendationAction.java   
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();

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

  Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null || !course.isAdaptive()) {
    presentation.setEnabledAndVisible(false);
    return;
  }

  presentation.setEnabledAndVisible(true);
}
项目:educational-plugin    文件:StudyFillPlaceholdersAction.java   
@Override
public void update(AnActionEvent e) {
  StudyUtils.updateAction(e);
  final Project project = e.getProject();
  if (project != null) {

    Course course = StudyTaskManager.getInstance(project).getCourse();
    Presentation presentation = e.getPresentation();
    if (course != null && !EduNames.STUDY.equals(course.getCourseMode())) {
      presentation.setEnabled(false);
      presentation.setVisible(true);
      return;
    }
    StudyEditor studyEditor = StudyUtils.getSelectedStudyEditor(project);
    StudyState studyState = new StudyState(studyEditor);
    if (!studyState.isValid()) {
      presentation.setEnabledAndVisible(false);
      return;
    }
    TaskFile taskFile = studyState.getTaskFile();
    if (taskFile.getActivePlaceholders().isEmpty()) {
      presentation.setEnabledAndVisible(false);
    }
  }
}
项目:educational-plugin    文件:CCDeleteAllAnswerPlaceholdersAction.java   
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  presentation.setEnabledAndVisible(false);

  Project project = e.getProject();
  if (project == null) {
    return;
  }
  if (!CCUtils.isCourseCreator(project)) {
    return;
  }
  DataContext context = e.getDataContext();
  VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  if (file == null ) {
    return;
  }
  TaskFile taskFile = StudyUtils.getTaskFile(project, file);
  if (taskFile == null || taskFile.getAnswerPlaceholders().isEmpty()) {
    return;
  }
  presentation.setEnabledAndVisible(true);
}
项目:educational-plugin    文件:CCSubtaskPlaceholderAction.java   
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  presentation.setEnabledAndVisible(false);
  CCState state = getState(e);
  if (state == null) {
    return;
  }
  TaskFile taskFile = state.getTaskFile();
  if (taskFile.getTask() instanceof TaskWithSubtasks) {
    int offset = state.getEditor().getCaretModel().getOffset();
    if (isAvailable(taskFile, offset)) {
      presentation.setEnabledAndVisible(true);
    }
  }
}
项目:educational-plugin    文件:CCChangePlaceholderVisibility.java   
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  presentation.setEnabledAndVisible(false);
  CCState state = getState(e);
  if (state == null) {
    return;
  }
  AnswerPlaceholder placeholder = state.getAnswerPlaceholder();
  if (placeholder == null) {
    return;
  }
  Task task = state.getTaskFile().getTask();
  if ((task instanceof TaskWithSubtasks)) {
    Integer minSubtaskIndex = Collections.min(placeholder.getSubtaskInfos().keySet());
    if (canChangeState(placeholder, (TaskWithSubtasks)task, minSubtaskIndex)) {
      presentation.setEnabledAndVisible(true);
    }
  }
}
项目:educational-plugin    文件:CCChangeCourseInfo.java   
@Override
public void update(@NotNull AnActionEvent event) {
  final Project project = event.getProject();
  final Presentation presentation = event.getPresentation();
  if (project == null) {
    return;
  }
  presentation.setEnabledAndVisible(false);
  if (!CCUtils.isCourseCreator(project)) {
    return;
  }
  final IdeView view = event.getData(LangDataKeys.IDE_VIEW);
  if (view == null) {
    return;
  }
  final PsiDirectory[] directories = view.getDirectories();
  if (directories.length == 0) {
    return;
  }
  presentation.setEnabledAndVisible(true);
}
项目:educational-plugin    文件:CCShowPreview.java   
@Override
public void update(@NotNull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  presentation.setEnabledAndVisible(false);
  Project project = e.getProject();
  if (project == null) {
    return;
  }
  if (!CCUtils.isCourseCreator(project)) {
    return;
  }
  final PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
  if (file != null && StudyUtils.getTaskFile(project, file.getVirtualFile()) != null) {
    presentation.setEnabledAndVisible(true);
  }
}
项目:educational-plugin    文件:CCNewSubtaskAction.java   
@Override
public void update(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  Presentation presentation = e.getPresentation();
  presentation.setEnabledAndVisible(false);
  VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (virtualFile == null || project == null) {
    return;
  }
  if (!CCUtils.isCourseCreator(project)) {
    return;
  }
  if (StudyUtils.getTaskForFile(project, virtualFile) != null || StudyUtils.getTask(project, virtualFile) != null) {
    presentation.setEnabledAndVisible(true);
  }
}
项目:GitLink    文件:Action.java   
public void update(AnActionEvent event)
{
    super.update(event);

    if (event.getProject() == null) {
        event.getPresentation().setEnabled(false);
        return;
    }

    RemoteHost remoteHost = this.container().preferences(event.getProject()).getRemoteHost();

    Presentation presentation = event.getPresentation();

    presentation.setText(this.displayName(remoteHost));
    presentation.setIcon(remoteHost.icon());

    presentation.setEnabledAndVisible(this.shouldActionBeEnabled(event));
}
项目:intellij-ce-playground    文件:CreateLibraryFromFilesAction.java   
@Override
public void update(@NotNull AnActionEvent e) {
  final Project project = getEventProject(e);
  boolean visible = false;
  if (project != null && ModuleManager.getInstance(project).getModules().length > 0) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    for (VirtualFile root : getRoots(e)) {
      if (!root.isInLocalFileSystem() && FileUtilRt.extensionEquals(root.getName(), "jar") && !fileIndex.isInLibraryClasses(root)) {
        visible = true;
        break;
      }
    }
  }

  Presentation presentation = e.getPresentation();
  presentation.setVisible(visible);
  presentation.setEnabled(visible);
}
项目:livingdoc-intellij    文件:RepositoryViewUtils.java   
/**
 * Sets the enabled/disabled action property depending on the node type and whether the node is executable.
 *
 * @param selectedNodes       Selected nodes in the repository view tree.
 * @param presentation        {@link Presentation}       The specific place in the user interface of the action.
 * @param executableCondition True for nodes that can be executed. False otherwise.
 * @see NodeType
 * @see DefaultMutableTreeNode
 */

private static void setEnabledForNode(final DefaultMutableTreeNode[] selectedNodes, final Presentation presentation,
                                      final boolean executableCondition) {

    if (ArrayUtils.isEmpty(selectedNodes)) {
        presentation.setEnabled(false);
        return;
    }

    boolean currentEnabled = presentation.isEnabled();

    for (DefaultMutableTreeNode selectedNode : selectedNodes) {

        Object userObject = selectedNode.getUserObject();

        currentEnabled = ((Node) userObject).getType() == NodeType.SPECIFICATION;

        if (!currentEnabled || (executableCondition && !((SpecificationNode) userObject).isExecutable())) {
            currentEnabled = false;
            break;
        }
    }

    presentation.setEnabled(currentEnabled);
}
项目:livingdoc-intellij    文件:RepositoryViewUtilsTest.java   
@Test
public void setEnabledForNodeVersion() {

    DefaultMutableTreeNode defaultMutableTreeNode = new DefaultMutableTreeNode(specificationNode);

    DefaultMutableTreeNode[] selectedNodes = new DefaultMutableTreeNode[]{defaultMutableTreeNode};
    DefaultMutableTreeNode[] selectedNodesEmpty = new DefaultMutableTreeNode[]{};

    Presentation presentation = new Presentation("Presentation text");
    boolean toCurrentVersion = true;

    presentation.setEnabled(true);
    specificationNode.setExecutable(true);
    specificationNode.setCanBeImplemented(true);

    RepositoryViewUtils.setEnabledForNodeVersion(selectedNodes, presentation, toCurrentVersion);
    Assert.assertTrue(presentation.isEnabled());

    RepositoryViewUtils.setEnabledForNodeVersion(selectedNodesEmpty, presentation, toCurrentVersion);
    Assert.assertFalse(presentation.isEnabled());

    // Coverage another similar method without boolean parameter
    RepositoryViewUtils.setEnabledForSpecificationNode(selectedNodes, presentation);
    Assert.assertTrue(presentation.isEnabled());
}
项目:intellij-ce-playground    文件:PutSourceItemIntoDefaultLocationAction.java   
@Override
public void update(AnActionEvent e) {
  final List<PackagingSourceItem> items = mySourceItemsTree.getSelectedItems();
  boolean enabled = false;
  final Presentation presentation = e.getPresentation();
  if (!items.isEmpty()) {
    enabled = true;
    Set<String> paths = new HashSet<String>();
    for (PackagingSourceItem item : items) {
      final String path = getDefaultPath(item);
      if (path == null) {
        enabled = false;
        break;
      }
      paths.add(StringUtil.trimStart(StringUtil.trimEnd(path, "/"), "/"));
    }
    presentation.setText("Put into " + getTargetLocationText(paths));
  }
  presentation.setVisible(enabled);
  presentation.setEnabled(enabled);
}
项目:intellij-ce-playground    文件:BaseToolWindowToggleAction.java   
@Override
public final void update(AnActionEvent e) {
  super.update(e);
  Presentation presentation = e.getPresentation();
  Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }
  ToolWindowManager mgr=ToolWindowManager.getInstance(project);
  String id=mgr.getActiveToolWindowId();

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

  ToolWindow window = mgr.getToolWindow(id);

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

  update(window, presentation);
}
项目:intellij-ce-playground    文件:ServersTreeAction.java   
@Override
public void update(@NotNull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  List<T> targetNodes = getTargetNodes(e);

  boolean visible;
  boolean enabled;

  if (targetNodes == null) {
    visible = false;
    enabled = false;
  }
  else {
    visible = true;
    enabled = true;
    for (T targetNode : targetNodes) {
      visible &= isVisible4(targetNode);
      enabled &= visible && isEnabled4(targetNode);
    }
  }

  presentation.setVisible(visible);
  presentation.setEnabled(enabled);
  updatePresentation(presentation, ContainerUtil.getFirstItem(targetNodes));
}
项目:intellij-ce-playground    文件:LocaleMenuAction.java   
private void updatePresentation(Presentation presentation) {
  Configuration configuration = myRenderContext.getConfiguration();
  boolean visible = configuration != null;
  if (visible) {
    // TEMPORARY WORKAROUND:
    // We don't properly sync the project locale to layouts yet, so in the mean time
    // show the actual locale being used rather than the intended locale, so as not
    // to be totally confusing:
    //Locale locale = configuration.isLocaleSpecificLayout()
    //                ? configuration.getLocale() : configuration.getConfigurationManager().getLocale();
    Locale locale = configuration.getLocale();
    if (locale == Locale.ANY) {
      presentation.setIcon(AndroidIcons.Globe);
    } else {
      presentation.setIcon(locale.getFlagImage());
    }
    String brief = getLocaleLabel(locale, true);
    presentation.setText(brief);
  } else {
    presentation.setIcon(AndroidIcons.Globe);
  }
  if (visible != presentation.isVisible()) {
    presentation.setVisible(visible);
  }
}
项目:intellij-ce-playground    文件:RestPythonUtil.java   
public static Presentation updateSphinxQuickStartRequiredAction(final AnActionEvent e) {
  final Presentation presentation = e.getPresentation();

  final Project project = e.getData(CommonDataKeys.PROJECT);
  if (project != null) {
    Module module = e.getData(LangDataKeys.MODULE);
    if (module == null) {
      Module[] modules = ModuleManager.getInstance(project).getModules();
      module = modules.length == 0 ? null : modules [0];
    }
    if (module != null) {
      Sdk sdk = PythonSdkType.findPythonSdk(module);
      if (sdk != null) {
        PyPackageManager manager = PyPackageManager.getInstance(sdk);
        try {
          final PyPackage sphinx = manager.findPackage("Sphinx", false);
          presentation.setEnabled(sphinx != null);
        }
        catch (ExecutionException ignored) {
        }
      }
    }
  }
  return presentation;
}
项目:intellij-ce-playground    文件:ToggleDockModeAction.java   
public void update(AnActionEvent event){
  super.update(event);
  Presentation presentation = event.getPresentation();
  Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }
  ToolWindowManager mgr=ToolWindowManager.getInstance(project);
  String id=mgr.getActiveToolWindowId();
  if(id==null){
    presentation.setEnabled(false);
    return;
  }
  ToolWindow toolWindow=mgr.getToolWindow(id);
  presentation.setEnabled(toolWindow.isAvailable()
    && toolWindow.getType() != ToolWindowType.FLOATING
    && toolWindow.getType() != ToolWindowType.WINDOWED);
}
项目:intellij-ce-playground    文件:ConfigurationMenuAction.java   
public PreviewAction(@NotNull RenderContext renderContext, @NotNull String title, int action,
                     @Nullable RenderPreviewMode mode, boolean enabled) {
  super(title, null, null);
  myRenderContext = renderContext;
  myAction = action;
  myMode = mode;

  if (mode != null && mode == RenderPreviewMode.getCurrent()) {
    // Select
    Presentation templatePresentation = getTemplatePresentation();
    templatePresentation.setIcon(AllIcons.Actions.Checked);
    templatePresentation.setEnabled(false);
  }

  if (!enabled) {
    getTemplatePresentation().setEnabled(false);
  }
}
项目:intellij-ce-playground    文件:DockableEditorTabbedContainer.java   
@Override
public Image processDropOver(@NotNull DockableContent content, RelativePoint point) {
  JBTabs current = getTabsAt(content, point);

  if (myCurrentOver != null && myCurrentOver != current) {
    resetDropOver(content);
  }

  if (myCurrentOver == null && current != null) {
    myCurrentOver = current;
    Presentation presentation = content.getPresentation();
    myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon());
    myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point);
  }

  if (myCurrentOver != null) {
    myCurrentOver.processDropOver(myCurrentOverInfo, point);
  }

  return myCurrentOverImg;
}
项目:intellij-ce-playground    文件:PresentationFactory.java   
@NotNull
public final Presentation getPresentation(@NotNull AnAction action){
  Presentation presentation = myAction2Presentation.get(action);
  if (presentation == null || !action.isDefaultIcon()){
    Presentation templatePresentation = action.getTemplatePresentation();
    if (presentation == null) {
      presentation = templatePresentation.clone();
      myAction2Presentation.put(action, presentation);
    }
    if (!action.isDefaultIcon()) {
      presentation.setIcon(templatePresentation.getIcon());
      presentation.setDisabledIcon(templatePresentation.getDisabledIcon());
    }
    processPresentation(presentation);
  }
  return presentation;
}
项目:intellij-ce-playground    文件:CreateChangelistAction.java   
@Override
public void update(AnActionEvent event) {
  super.update(event);
  if (event.getPresentation().isEnabled()) {
    TaskManager manager = getTaskManager(event);
    Presentation presentation = event.getPresentation();

    if (manager == null || !manager.isVcsEnabled()) {
      presentation.setText(getTemplatePresentation().getText());
      presentation.setEnabled(false);
    }
    else {
      presentation.setEnabled(true);
      if (manager.getActiveTask().getChangeLists().size() == 0) {
        presentation.setText("Create changelist for '" + TaskUtil.getTrimmedSummary(manager.getActiveTask()) + "'");
      }
      else {
        presentation.setText("Add changelist for '" + TaskUtil.getTrimmedSummary(manager.getActiveTask()) + "'");
      }
    }
  }
}
项目:intellij-ce-playground    文件:ContentEntryEditingAction.java   
@Override
public void update(AnActionEvent e) {
  super.update(e);
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(true);
  final VirtualFile[] files = getSelectedFiles();
  if (files.length == 0) {
    presentation.setEnabled(false);
    return;
  }
  for (VirtualFile file : files) {
    if (file == null || !file.isDirectory()) {
      presentation.setEnabled(false);
      break;
    }
  }
}
项目:intellij-ce-playground    文件:XDebuggerActionBase.java   
@Override
public void update(final AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  boolean hidden = isHidden(event);
  if (hidden) {
    presentation.setEnabledAndVisible(false);
    return;
  }

  boolean enabled = isEnabled(event);
  if (myHideDisabledInPopup && ActionPlaces.isPopupPlace(event.getPlace())) {
    presentation.setVisible(enabled);
  }
  else {
    presentation.setVisible(true);
  }
  presentation.setEnabled(enabled);
}
项目:epigraph    文件:AddRetroAction.java   
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
  if (element.getNode().getElementType() == TokenType.WHITE_SPACE) element = PsiTreeUtil.prevVisibleLeaf(element);

  SchemaValueTypeRef valueTypeRef = PsiTreeUtil.getParentOfType(element, SchemaValueTypeRef.class);
  if (valueTypeRef != null) {
    int endOffset = valueTypeRef.getNode().getTextRange().getEndOffset();
    editor.getCaretModel().moveToOffset(endOffset);
    EditorModificationUtil.insertStringAtCaret(editor, " default ");

    ApplicationManager.getApplication().invokeLater(() -> {
      AnActionEvent event = AnActionEvent.createFromDataContext("AddDefaultAction",
          new Presentation(), ((EditorEx) editor).getDataContext());

      new CodeCompletionAction().actionPerformed(event);
    });
  }
}
项目:intellij-ce-playground    文件:CCAddAsTaskFile.java   
@Override
public void update(AnActionEvent e) {
  Project project = e.getProject();
  Presentation presentation = e.getPresentation();
  if (project == null) {
    presentation.setEnabledAndVisible(false);
    return;
  }
  VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
  if (file == null || file.isDirectory() || CCProjectService.getInstance(project).isAnswerFile(file)) {
    presentation.setEnabledAndVisible(false);
    return;
  }
  Task task = CCProjectService.getInstance(project).getTask(file);
  if (task == null) {
    presentation.setEnabledAndVisible(false);
  }
}
项目:intellij-ce-playground    文件:ImportModuleFromImlFileAction.java   
@Override
public void update(AnActionEvent e) {
  final List<VirtualFile> modules = getModuleNames(e);
  final Presentation presentation = e.getPresentation();
  final boolean visible = !modules.isEmpty();
  presentation.setVisible(visible);
  presentation.setEnabled(visible);
  String text;
  if (modules.size() > 1) {
    text = "Import " + modules.size() + " Modules";
  }
  else if (modules.size() == 1) {
    text = "Import '" + modules.get(0).getNameWithoutExtension() + "' Module";
  }
  else {
    text = getTemplatePresentation().getText();
  }
  presentation.setText(text);
}
项目:mybatis-log-plugin    文件:GoogleTranslateAction.java   
public void update(AnActionEvent var1) {
    Presentation var2 = var1.getPresentation();
    DataContext var3 = var1.getDataContext();
    CopyProvider var4 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var3);
    boolean var5 = var4 != null && var4.isCopyEnabled(var3) && var4.isCopyVisible(var3);
    var2.setEnabled(var5);
    var2.setVisible(var5);
}
项目:mybatis-log-plugin    文件:BaiduSearchAction.java   
public void update(AnActionEvent var1) {
    Presentation var2 = var1.getPresentation();
    DataContext var3 = var1.getDataContext();
    CopyProvider var4 = (CopyProvider) PlatformDataKeys.COPY_PROVIDER.getData(var3);
    boolean var5 = var4 != null && var4.isCopyEnabled(var3) && var4.isCopyVisible(var3);
    var2.setEnabled(var5);
    var2.setVisible(var5);
}
项目:nullability-annotations-inspection    文件:AddPackageInfoWithNullabilityDefaultsFix.java   
@Nullable
private PsiJavaFile createPackageInfoFile(PsiFile file, PsiPackage target) {
    DataManager.getInstance().getDataContextFromFocus().doWhenDone((Consumer<DataContext>) context -> {
        AnActionEvent event =
                new AnActionEvent(null, context, "", new Presentation(), ActionManager.getInstance(), 0);
        new CreatePackageInfoAction().actionPerformed(event);
    });
    return packageInfoFile(target, file.getContainingDirectory());
}
项目:greycat-idea-plugin    文件:GCM2EcoreAction.java   
@Override
public void update(AnActionEvent e) {
    super.update(e);
    VirtualFile currentFile = DataKeys.VIRTUAL_FILE.getData(e.getDataContext());
    final Presentation presentation = e.getPresentation();
    if (currentFile != null && currentFile.getName().endsWith(".ecore")) {
        presentation.setEnabledAndVisible(true);
    } else {
        presentation.setEnabledAndVisible(false);
    }
}
项目:intellij-randomness    文件:DataInsertAction.java   
/**
 * Disables this action if no editor is currently opened.
 *
 * @param event the performed action
 */
@Override
public final void update(final AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    final Editor editor = event.getData(CommonDataKeys.EDITOR);

    presentation.setText(getName());
    presentation.setEnabled(editor != null);
}
项目:intellij-randomness    文件:DataInsertActionTest.java   
/**
 * Tests that the action's presentation is disabled when the editor is null.
 */
@Test
public void testUpdateDisabled() {
    final AnActionEvent event = mock(AnActionEvent.class);
    final Presentation presentation = spy(Presentation.class);
    when(event.getData(CommonDataKeys.EDITOR)).thenReturn(null);
    when(event.getPresentation()).thenReturn(presentation);

    dataInsertAction.update(event);

    assertThat(presentation.isEnabled()).isFalse();
}
项目:intellij-randomness    文件:DataInsertActionTest.java   
/**
 * Tests that the action's presentation is enabled when the editor is not null.
 */
@Test
public void testUpdateEnabled() {
    final AnActionEvent event = mock(AnActionEvent.class);
    final Presentation presentation = spy(Presentation.class);
    when(event.getData(CommonDataKeys.EDITOR)).thenReturn(mock(Editor.class));
    when(event.getPresentation()).thenReturn(presentation);

    dataInsertAction.update(event);

    assertThat(presentation.isEnabled()).isTrue();
}
项目:hybris-integration-intellij-idea-plugin    文件:ProjectRefreshAction.java   
@Override
public void update(AnActionEvent event) {
    final Project project = event.getData(PlatformDataKeys.PROJECT);
    final Presentation presentation = event.getPresentation();
    if (project == null) {
        presentation.setVisible(false);
        return;
    }
    presentation.setIcon(HybrisIcons.HYBRIS_ICON);
    presentation.setVisible(CommonIdeaService.getInstance().isHybrisProject(project));
}
项目:hybris-integration-intellij-idea-plugin    文件:AbstractImpexTableFormatAction.java   
@Override
public void update(
    final Editor editor, final Presentation presentation, final DataContext dataContext
) {
    super.update(editor, presentation, dataContext);
    final VirtualFile file = dataContext.getData(CommonDataKeys.VIRTUAL_FILE);
    final boolean enabled = file != null && file.getName().endsWith(".impex");
    presentation.setEnabledAndVisible(enabled);
}
项目:educational-plugin    文件:StudyUtils.java   
public static void updateAction(@NotNull final AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(false);
  final Project project = e.getProject();
  if (project != null) {
    final StudyEditor studyEditor = getSelectedStudyEditor(project);
    if (studyEditor != null) {
      presentation.setEnabledAndVisible(true);
    }
  }
}
项目:educational-plugin    文件:StudyCheckAction.java   
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  StudyUtils.updateAction(e);
  if (presentation.isEnabled()) {
    updateDescription(e);
    presentation.setEnabled(!myCheckInProgress.get());
  }
}