本文整理汇总了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);
}
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}