當前位置: 首頁>>代碼示例>>Java>>正文


Java Presentation.isEnabled方法代碼示例

本文整理匯總了Java中com.intellij.openapi.actionSystem.Presentation.isEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Presentation.isEnabled方法的具體用法?Java Presentation.isEnabled怎麽用?Java Presentation.isEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.actionSystem.Presentation的用法示例。


在下文中一共展示了Presentation.isEnabled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
@Override
public void update(final AnActionEvent e) {
    super.update(e);

    Presentation presentation = e.getPresentation();
    boolean enabled = presentation.isEnabled();
    boolean selected = false;

    if (enabled) {
        final EditorEx editor = (EditorEx) CommonDataKeys.EDITOR.getData(e.getDataContext());
        if (editor != null) {
            LineSelectionManager manager = LineSelectionManager.getInstance(editor);
            RangeLimitedCaretSpawningHandler spawningHandler = manager.getCaretSpawningHandler();
            if (spawningHandler != null && !spawningHandler.isBackwards()) {
                selected = true;
            }
        }
    }

    presentation.putClientProperty(Toggleable.SELECTED_PROPERTY, selected);

    e.getPresentation().setVisible(!ApplicationSettings.getInstance().isHideDisabledButtons() || e.getPresentation().isEnabled());
}
 
開發者ID:vsch,項目名稱:MissingInActions,代碼行數:24,代碼來源:ForwardSearchCaretSpawningAction.java

示例2: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
@Override
public void update(final AnActionEvent e) {
    super.update(e);

    Presentation presentation = e.getPresentation();
    boolean enabled = presentation.isEnabled();
    boolean selected = false;

    if (enabled) {
        final EditorEx editor = (EditorEx) CommonDataKeys.EDITOR.getData(e.getDataContext());
        if (editor != null) {
            LineSelectionManager manager = LineSelectionManager.getInstance(editor);
            RangeLimitedCaretSpawningHandler spawningHandler = manager.getCaretSpawningHandler();
            if (spawningHandler != null && spawningHandler.isBackwards()) {
                selected = true;
            }
        }
    }

    presentation.putClientProperty(Toggleable.SELECTED_PROPERTY, selected);

    e.getPresentation().setVisible(!ApplicationSettings.getInstance().isHideDisabledButtons() || e.getPresentation().isEnabled());
}
 
開發者ID:vsch,項目名稱:MissingInActions,代碼行數:24,代碼來源:BackwardSearchCaretSpawningAction.java

示例3: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
@Override
public void update(AnActionEvent e) {
    super.update(e);
    final Presentation presentation = e.getPresentation();
    if(presentation.isEnabled()) {
        final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
        final Project project = e.getProject();
        if (view != null && project != null) {
            ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
            PsiDirectory[] dirs = view.getDirectories();
            for (PsiDirectory dir : dirs) {
                if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) &&
                        JavaDirectoryService.getInstance().getPackage(dir) != null && isValidForClass(project,dir)) {
                    return;
                }
            }
        }
        presentation.setEnabled(false);
        presentation.setVisible(false);
    }
}
 
開發者ID:wangtotang,項目名稱:DaggerHelper,代碼行數:22,代碼來源:BaseAction.java

示例4: setEnabledForNode

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:testIT-LivingDoc,項目名稱:livingdoc-intellij,代碼行數:35,代碼來源:RepositoryViewUtils.java

示例5: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
@Override
protected void update(final VcsContext vcsContext, final Presentation presentation) {
  super.update(vcsContext, presentation);
  if (presentation.isVisible() && presentation.isEnabled()) {
    final ChangeList[] selectedChangeLists = vcsContext.getSelectedChangeLists();
    final Change[] selectedChanges = vcsContext.getSelectedChanges();
    if (vcsContext.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) {
      if (selectedChangeLists != null && selectedChangeLists.length > 0) {
        presentation.setEnabled(selectedChangeLists.length == 1 && !ContainerUtil.isEmpty(selectedChangeLists[0].getChanges()));
      }
      else {
        presentation.setEnabled (selectedChanges != null && selectedChanges.length > 0);
      }
    }
    if (presentation.isEnabled() && selectedChanges != null) {
      final ChangeListManager changeListManager = ChangeListManager.getInstance(vcsContext.getProject());
      for(Change c: selectedChanges) {
        if (c.getFileStatus() == FileStatus.HIJACKED && changeListManager.getChangeList(c) == null) {
          presentation.setEnabled(false);
          break;
        }
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:AbstractCommitChangesAction.java

示例6: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
public void update(final AnActionEvent e) {
  super.update(e);
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final Presentation presentation = e.getPresentation();
  if (presentation.isEnabled()) {
    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    if (view != null) {
      final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
      final PsiDirectory[] dirs = view.getDirectories();
      for (final PsiDirectory dir : dirs) {
        if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
          return;
        }
      }
    }

    presentation.setEnabled(false);
    presentation.setVisible(false);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:AbstractCreateFormAction.java

示例7: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  StudyUtils.updateAction(e);
  if (presentation.isEnabled()) {
    updateDescription(e);
    presentation.setEnabled(!myCheckInProgress.get());
  }
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:10,代碼來源:StudyCheckAction.java

示例8: executeAction

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
public static void executeAction(String actionId, InputEvent e) {
    ActionManager actionManager = ActionManager.getInstance();
    AnAction action = actionManager.getAction(actionId);
    if (action != null) {
        Presentation presentation = new Presentation();
        AnActionEvent event = new AnActionEvent(e, DataManager.getInstance().getDataContext(e.getComponent()), "", presentation, actionManager, 0);
        action.update(event);
        if (presentation.isEnabled()) {
            action.actionPerformed(event);
        }
    }
}
 
開發者ID:seedstack,項目名稱:intellij-plugin,代碼行數:13,代碼來源:NavigatorUtil.java

示例9: setEnabledForNodeVersion

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
/**
 * Sets the enabled/disabled action property for the executable nodes that can change their version.
 *
 * @param selectedNodes    Selected nodes in the repository view tree.
 * @param presentation     The specific place in the user interface of the action.
 * @param toCurrentVersion True whether the action changes to current version. False for implemented version.
 */
public static void setEnabledForNodeVersion(final DefaultMutableTreeNode[] selectedNodes,
                                            final Presentation presentation, final boolean toCurrentVersion) {

    setEnabledForExecutableNode(selectedNodes, presentation);

    boolean currentEnabled = presentation.isEnabled();

    if (!currentEnabled) {
        return;
    }

    for (DefaultMutableTreeNode selectedNode : selectedNodes) {

        Object userObject = selectedNode.getUserObject();

        if (userObject instanceof SpecificationNode) {
            SpecificationNode specificationNode = (SpecificationNode) userObject;

            if (!(specificationNode.isCanBeImplemented()
                    && (specificationNode.isUsingCurrentVersion() ^ toCurrentVersion))) {

                currentEnabled = false;
                break;
            }
        }
    }
    presentation.setEnabled(currentEnabled);
}
 
開發者ID:testIT-LivingDoc,項目名稱:livingdoc-intellij,代碼行數:36,代碼來源:RepositoryViewUtils.java

示例10: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
@Override
protected void update(@NotNull Presentation presentation,
                      @NotNull Project project,
                      @NotNull Editor editor,
                      @NotNull PsiFile file,
                      @NotNull DataContext dataContext,
                      @Nullable String actionPlace) {
  super.update(presentation, project, editor, file, dataContext, actionPlace);
  if (myHandler instanceof ContextAwareActionHandler && presentation.isEnabled()) {
    presentation.setEnabled(((ContextAwareActionHandler)myHandler).isAvailableForQuickList(editor, file, dataContext));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:BaseGenerateAction.java

示例11: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
public void update(AnActionEvent event){
  super.update(event);
  Presentation presentation = event.getPresentation();
  if (!presentation.isEnabled()) {
    return;
  }
  presentation.setEnabled(CommonDataKeys.PROJECT.getData(event.getDataContext()) != null);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:CompileDirtyAction.java

示例12: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
public void update(AnActionEvent event) {
  super.update(event);
  Presentation presentation = event.getPresentation();
  if (!presentation.isEnabled()) {
    return;
  }
  Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
  presentation.setEnabled(project != null);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:CompileProjectAction.java

示例13: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
protected void update(final FileSystemTree fileSystemTree, final AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  if (!presentation.isEnabled()) return;

  final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
  presentation.setEnabled(userHomeDir != null && fileSystemTree.isUnderRoots(userHomeDir));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:GotoHomeAction.java

示例14: update

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  StudyUtils.updateAction(e);
  if (presentation.isEnabled()) {
    presentation.setEnabled(!checkInProgress);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:StudyCheckAction.java

示例15: setEnabled

import com.intellij.openapi.actionSystem.Presentation; //導入方法依賴的package包/類
/**
 * Enable or disable current action from event.
 *
 * @param e Action event
 * @return Enabled value
 */
public static boolean setEnabled(AnActionEvent e) {
    ThumbnailView thumbnailView = getVisibleThumbnailView(e);
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(thumbnailView != null);
    return presentation.isEnabled();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:ThumbnailViewActionUtil.java


注:本文中的com.intellij.openapi.actionSystem.Presentation.isEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。