当前位置: 首页>>代码示例>>Java>>正文


Java Presentation类代码示例

本文整理汇总了Java中com.intellij.openapi.actionSystem.Presentation的典型用法代码示例。如果您正苦于以下问题:Java Presentation类的具体用法?Java Presentation怎么用?Java Presentation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Presentation类属于com.intellij.openapi.actionSystem包,在下文中一共展示了Presentation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateDescription

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
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);
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyCheckAction.java

示例2: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:25,代码来源:StudyRefreshAnswerPlaceholder.java

示例3: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:19,代码来源:StudyUpdateRecommendationAction.java

示例4: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:26,代码来源:StudyFillPlaceholdersAction.java

示例5: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:24,代码来源:CCDeleteAllAnswerPlaceholdersAction.java

示例6: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:CCSubtaskPlaceholderAction.java

示例7: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:CCChangePlaceholderVisibility.java

示例8: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:22,代码来源:CCChangeCourseInfo.java

示例9: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:CCShowPreview.java

示例10: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:18,代码来源:CCNewSubtaskAction.java

示例11: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
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));
}
 
开发者ID:ben-gibson,项目名称:GitLink,代码行数:19,代码来源:Action.java

示例12: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:CreateLibraryFromFilesAction.java

示例13: 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

示例14: setEnabledForNodeVersion

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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());
}
 
开发者ID:testIT-LivingDoc,项目名称:livingdoc-intellij,代码行数:26,代码来源:RepositoryViewUtilsTest.java

示例15: update

import com.intellij.openapi.actionSystem.Presentation; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PutSourceItemIntoDefaultLocationAction.java


注:本文中的com.intellij.openapi.actionSystem.Presentation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。