Java Code Examples for com.intellij.openapi.actionSystem.Presentation#isEnabled()
The following examples show how to use
com.intellij.openapi.actionSystem.Presentation#isEnabled() .
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: AbstractCommitChangesAction.java From consulo with Apache License 2.0 | 6 votes |
@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); } 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; } } } } }
Example 2
Source File: GotoHomeAction.java From consulo with Apache License 2.0 | 5 votes |
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)); }
Example 3
Source File: AbstractCommonUpdateAction.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void update(@Nonnull VcsContext vcsContext, @Nonnull Presentation presentation) { Project project = vcsContext.getProject(); if (project != null) { final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); final boolean underVcs = vcsManager.hasActiveVcss(); if (! underVcs) { presentation.setVisible(false); return; } String actionName = getCompleteActionName(vcsContext); if (myActionInfo.showOptions(project) || OptionsDialog.shiftIsPressed(vcsContext.getModifiers())) { actionName += "..."; } presentation.setText(actionName); presentation.setVisible(true); presentation.setEnabled(true); if (supportingVcsesAreEmpty(vcsManager, myActionInfo)) { presentation.setVisible(myAlwaysVisible); presentation.setEnabled(false); return; } if (filterRootsBeforeAction()) { FilePath[] roots = filterRoots(myScopeInfo.getRoots(vcsContext, myActionInfo), vcsContext); if (roots.length == 0) { presentation.setVisible(myAlwaysVisible); presentation.setEnabled(false); return; } } if (presentation.isVisible() && presentation.isEnabled() && vcsManager.isBackgroundVcsOperationRunning()) { presentation.setEnabled(false); } } else { presentation.setVisible(false); presentation.setEnabled(false); } }