Java 类com.intellij.lang.ContextAwareActionHandler 实例源码

项目:intellij-ce-playground    文件:BaseGenerateAction.java   
@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));
  }
}
项目:intellij-ce-playground    文件:PresentableActionHandlerBasedAction.java   
@Override
protected void update(@NotNull Presentation presentation, @NotNull Project project,
                      @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext dataContext, @Nullable String actionPlace) {
  // avoid evaluating isValidFor several times unnecessary

  CodeInsightActionHandler handler = getValidHandler(editor, file);
  presentation.setEnabled(handler != null);
  if (handler instanceof ContextAwareActionHandler && !ActionPlaces.isMainMenuOrActionSearch(actionPlace)) {
    presentation.setVisible(((ContextAwareActionHandler)handler).isAvailableForQuickList(editor, file, dataContext));
  }

  if (presentation.isVisible() && handler instanceof PresentableCodeInsightActionHandler) {
    ((PresentableCodeInsightActionHandler)handler).update(editor, file, presentation);
  }
}
项目:intellij-ce-playground    文件:BaseRefactoringAction.java   
protected boolean hasAvailableHandler(@NotNull DataContext dataContext) {
  final RefactoringActionHandler handler = getHandler(dataContext);
  if (handler != null) {
    if (handler instanceof ContextAwareActionHandler) {
      final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
      final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
      if (editor != null && file != null && !((ContextAwareActionHandler)handler).isAvailableForQuickList(editor, file, dataContext)) {
        return false;
      }
    }
    return true;
  }
  return false;
}
项目:consulo    文件:BaseRefactoringAction.java   
protected boolean hasAvailableHandler(@Nonnull DataContext dataContext) {
  final RefactoringActionHandler handler = getHandler(dataContext);
  if (handler != null) {
    if (handler instanceof ContextAwareActionHandler) {
      final Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
      final PsiFile file = dataContext.getData(CommonDataKeys.PSI_FILE);
      if (editor != null && file != null && !((ContextAwareActionHandler)handler).isAvailableForQuickList(editor, file, dataContext)) {
        return false;
      }
    }
    return true;
  }
  return false;
}
项目:consulo-java    文件:BaseGenerateAction.java   
@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));
    }
}