Java Code Examples for com.intellij.openapi.actionSystem.Presentation#setVisible()

The following examples show how to use com.intellij.openapi.actionSystem.Presentation#setVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenXCodeAction.java    From robovm-idea with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void update(AnActionEvent e) {
    Presentation presentation = getTemplatePresentation();
    VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
    for(Module module: ModuleManager.getInstance(e.getProject()).getModules()) {
        if(ModuleRootManager.getInstance(module).getFileIndex().isInContent(file)) {
            this.module = module;
        }
    }
    if(module == null || !RoboVmPlugin.isRoboVmModule(module)) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
    } else {
        presentation.setEnabled(true);
        presentation.setVisible(true);
    }
}
 
Example 2
Source File: CommonCheckinProjectAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void update(VcsContext vcsContext, Presentation presentation) {
  Project project = vcsContext.getProject();
  if (project == null) {
    presentation.setEnabled(false);
    presentation.setVisible(false);
    return;
  }
  final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project);
  if (! plVcsManager.hasActiveVcss()) {
    presentation.setEnabled(false);
    presentation.setVisible(false);
    return;
  }

  String actionName = getActionName(vcsContext) + "...";
  presentation.setText(actionName);

  presentation.setEnabled(! plVcsManager.isBackgroundVcsOperationRunning());
  presentation.setVisible(true);
}
 
Example 3
Source File: BaseShowDiffAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  boolean canShow = isAvailable(e);
  presentation.setEnabled(canShow);
  if (ActionPlaces.isPopupPlace(e.getPlace())) {
    presentation.setVisible(canShow);
  }
}
 
Example 4
Source File: CreateFromTemplateAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent e){
  super.update(e);
  Presentation presentation = e.getPresentation();
  boolean isEnabled = CreateFromTemplateGroup.canCreateFromTemplate(e, myTemplate);
  presentation.setEnabled(isEnabled);
  presentation.setVisible(isEnabled);
}
 
Example 5
Source File: FlutterExternalIdeActionGroup.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void update(AnActionEvent event) {
  final Presentation presentation = event.getPresentation();
  final boolean enabled = isExternalIdeFile(event);
  presentation.setEnabled(enabled);
  presentation.setVisible(enabled);
}
 
Example 6
Source File: DeleteAlreadyUnshelvedAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(final AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final Presentation presentation = e.getPresentation();
  if (project == null) {
    presentation.setEnabled(false);
    presentation.setVisible(false);
  }
  presentation.setEnabled(true);
  presentation.setVisible(true);
  presentation.setText(myText);
}
 
Example 7
Source File: FlutterBuildActionGroup.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void update(AnActionEvent event) {
  final Presentation presentation = event.getPresentation();
  final boolean enabled = isInFlutterModule(event);
  presentation.setEnabled(enabled);
  presentation.setVisible(enabled);
}
 
Example 8
Source File: VirtualFileUnderSvnActionBase.java    From SVNToolBox with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
    super.update(e);

    final Presentation presentation = e.getPresentation();
    final DataContext dataContext = e.getDataContext();

    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
    }

    VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
    if (vFile == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
    }
    SvnVcs vcs = SvnVcs.getInstance(project);
    if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, new VirtualFile[]{vFile})) {
        presentation.setEnabled(false);
        presentation.setVisible(true);
        return;
    }
    presentation.setEnabled(true);
    presentation.setVisible(true);
}
 
Example 9
Source File: CreateSwarmReviewAction.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Override
protected void update(@NotNull final VcsContext event, @NotNull final Presentation presentation) {
    Project project = event.getProject();
    if (project == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
    }
    ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project);
    if (registry == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
    }
    List<ChangeList> changeLists = getSelectedChangeLists(event);
    if (changeLists.isEmpty()) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
    }
    // Restrict to just 1 changelist to create a review.
    if (changeLists.size() != 1) {
        presentation.setEnabled(false);
        presentation.setVisible(true);
        return;
    }
    boolean hasChanges = false;
    for (ChangeList changeList : changeLists) {
        if (!changeList.getChanges().isEmpty()) {
            hasChanges = true;
            break;
        }
    }
    presentation.setEnabled(hasChanges);
    presentation.setVisible(true);
}
 
Example 10
Source File: FlutterPackagesExplorerActionGroup.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void update(@NotNull AnActionEvent e) {
  final boolean enabled = isFlutterPubspec(e);
  final Presentation presentation = e.getPresentation();
  presentation.setEnabled(enabled);
  presentation.setVisible(enabled);
}
 
Example 11
Source File: FlutterExternalIdeActionGroup.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void update(AnActionEvent event) {
  final Presentation presentation = event.getPresentation();
  final boolean enabled = isExternalIdeFile(event);
  presentation.setEnabled(enabled);
  presentation.setVisible(enabled);
}
 
Example 12
Source File: PsiViewerAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  final Project project = e.getDataContext().getData(CommonDataKeys.PROJECT);
  final Presentation p = e.getPresentation();
  if (project == null) {
    p.setVisible(false);
    p.setEnabled(false);
    return;
  }

  p.setEnabledAndVisible(Application.get().isInternal());
}
 
Example 13
Source File: CloneElementAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateForToolWindow(String id, DataContext dataContext,Presentation presentation) {
  // work only with single selection
  PsiElement[] elements = dataContext.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
  presentation.setEnabled(elements != null && elements.length == 1 && CopyHandler.canClone(elements));
  presentation.setVisible(true);
  if (!ToolWindowId.COMMANDER.equals(id)) {
    presentation.setVisible(false);
  }
}
 
Example 14
Source File: Unity3dShowMetaFileProjectViewPaneOptionProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredUIAccess
public void update(AnActionEvent e)
{
	super.update(e);
	final Presentation presentation = e.getPresentation();
	final ProjectView projectView = ProjectView.getInstance(e.getProject());
	presentation.setVisible(projectView.getCurrentProjectViewPane() == myPane && Unity3dModuleExtensionUtil.getRootModuleExtension(myPane.getProject()) != null);
}
 
Example 15
Source File: IgnoreFileGroupAction.java    From idea-gitignore with MIT License 5 votes vote down vote up
/**
 * Presents a list of suitable Gitignore files that can cover currently selected {@link VirtualFile}.
 * Shows a subgroup with available files or one option if only one Gitignore file is available.
 *
 * @param e action event
 */
@Override
public void update(@NotNull AnActionEvent e) {
    final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final Presentation presentation = e.getPresentation();
    files.clear();

    if (project != null && file != null) {
        try {
            presentation.setVisible(true);
            baseDir = Utils.getModuleRootForFile(file, project);

            for (IgnoreLanguage language : IgnoreBundle.LANGUAGES) {
                //skip already bundled languages for ignore action
                if (!(this instanceof UnignoreFileGroupAction)
                        && (language instanceof GitLanguage || language instanceof MercurialLanguage)) {
                    continue;
                }

                final IgnoreFileType fileType = language.getFileType();
                List<VirtualFile> list = Utils.getSuitableIgnoreFiles(project, fileType, file);
                Collections.reverse(list);
                files.put(fileType, list);
            }
        } catch (ExternalFileException e1) {
            presentation.setVisible(false);
        }
    }

    setPopup(countFiles() > 1);
}
 
Example 16
Source File: ShowChangesViewAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void update(VcsContext vcsContext, Presentation presentation) {
  presentation.setVisible(getActiveVcses(vcsContext).size() > 0);
}
 
Example 17
Source File: ShowChangeMarkerAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected void update(VcsContext context, Presentation presentation) {
  boolean active = isActive(context);
  presentation.setEnabled(active);
  presentation.setVisible(context.getEditor() != null || ActionPlaces.isToolbarPlace(context.getPlace()));
}
 
Example 18
Source File: AbstractShowDiffAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected static void updateDiffAction(final Presentation presentation, final VcsContext vcsContext,
                                       final VcsBackgroundableActions actionKey) {
  presentation.setEnabled(isEnabled(vcsContext, actionKey) != null);
  presentation.setVisible(isVisible(vcsContext));
}
 
Example 19
Source File: MarkFileGroup.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setVisible(EnforcedPlainTextFileTypeManager.getInstance() != null);
}
 
Example 20
Source File: ExcludeFromCompileAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  final boolean isApplicable = getSelectedFile() != null;
  presentation.setEnabled(isApplicable);
  presentation.setVisible(isApplicable);
}