@Override public final void update(final AnActionEvent event) { final Presentation presentation = event.getPresentation(); final DataContext dataContext = event.getDataContext(); final HierarchyBrowserBaseEx browser = (HierarchyBrowserBaseEx) dataContext.getData(myBrowserDataKey); if (browser == null) { presentation.setVisible(false); presentation.setEnabled(false); return; } presentation.setVisible(true); final PsiElement selectedElement = browser.getSelectedElement(); if (selectedElement == null || !browser.isApplicableElement(selectedElement)) { presentation.setEnabled(false); presentation.setVisible(false); return; } presentation.setEnabled(isEnabled(browser, selectedElement)); String nonDefaultText = getNonDefaultText(browser, selectedElement); if (nonDefaultText != null) { presentation.setText(nonDefaultText); } }
public void update(final AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setEnabled(false); final PackageDependenciesNode leftNode = myLeftTree.getSelectedNode(); final PackageDependenciesNode rightNode = myRightTree.getSelectedNode(); if (leftNode != null && rightNode != null) { final PatternDialectProvider provider = PatternDialectProvider.getInstance(mySettings.SCOPE_TYPE); presentation.setEnabled( (provider.createPackageSet(leftNode, true) != null || provider.createPackageSet(leftNode, false) != null) && (provider.createPackageSet(rightNode, true) != null || provider.createPackageSet(rightNode, false) != null)); } }
// Async update @Override public final void update(AnActionEvent e) { final T data = prepareDataFromContext(e); final Presentation originalPresentation = e.getPresentation(); if (!forceSyncUpdate(e) && isDumbAware()) { final Presentation realPresentation = (Presentation) originalPresentation.clone(); ourUpdaterService.submit( new Runnable() { @Override public void run() { performUpdate(realPresentation, data); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { if (originalPresentation.isVisible() != realPresentation.isVisible()) { LOG.error( "Async update is not supported for actions that change their visibility." + "Either stop extending AsyncUpdateAction or override forceSyncUpdate() to return true." + "Action class is: " + AsyncUpdateAction.this.getClass().getName()); } originalPresentation.copyFrom(realPresentation); } }); } }); originalPresentation.setVisible(true); originalPresentation.setEnabled(false); } else { performUpdate(originalPresentation, data); } }
@Override public void update(AnActionEvent event) { final Presentation presentation = event.getPresentation(); final Project project = event.getData(CommonDataKeys.PROJECT); presentation.setEnabled(project != null); presentation.setVisible( ActionPlaces.isMainMenuOrActionSearch(event.getPlace()) && !PlatformUtils.isCidr()); }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); if (ActionPlaces.PROJECT_VIEW_POPUP.equals(e.getPlace()) || ActionPlaces.COMMANDER_POPUP.equals(e.getPlace())) { presentation.setText(IdeBundle.message("action.delete.ellipsis")); } else { presentation.setText(IdeBundle.message("action.delete")); } if (e.getProject() == null) { presentation.setEnabled(false); return; } DataContext dataContext = e.getDataContext(); DeleteProvider provider = getDeleteProvider(dataContext); if (e.getInputEvent() instanceof KeyEvent) { KeyEvent keyEvent = (KeyEvent) e.getInputEvent(); Object component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext); if (component instanceof JTextComponent) provider = null; // Do not override text deletion if (keyEvent.getKeyCode() == KeyEvent.VK_BACK_SPACE) { // Do not override text deletion in speed search if (component instanceof JComponent) { SpeedSearchSupply searchSupply = SpeedSearchSupply.getSupply((JComponent) component); if (searchSupply != null) provider = null; } String activeSpeedSearchFilter = SpeedSearchSupply.SPEED_SEARCH_CURRENT_QUERY.getData(dataContext); if (!StringUtil.isEmpty(activeSpeedSearchFilter)) { provider = null; } } } if (provider instanceof TitledHandler) { presentation.setText(((TitledHandler) provider).getActionTitle()); } boolean canDelete = provider != null && provider.canDeleteElement(dataContext); if (ActionPlaces.isPopupPlace(e.getPlace())) { presentation.setVisible(canDelete); } else { presentation.setEnabled(canDelete); } }
@Override public final void update(final AnActionEvent e) { final Presentation presentation = e.getPresentation(); final Project project = e.getProject(); if (project == null) return; presentation.setEnabled(isEnabled()); presentation.setText(getCurrentScopeType()); }
public void update(final AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Presentation presentation = e.getPresentation(); final boolean enabled = isAvailable(dataContext); presentation.setVisible(enabled); presentation.setEnabled(enabled); }
public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setEnabled(false); if (myElement != null) { final PsiElement element = myElement.getElement(); final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element); final PsiElement originalElement = DocumentationManager.getOriginalElement(element); if (provider instanceof ExternalDocumentationProvider) { presentation.setEnabled( element != null && ((ExternalDocumentationProvider) provider) .hasDocumentationFor(element, originalElement)); } else { final List<String> urls = provider.getUrlFor(element, originalElement); presentation.setEnabled(element != null && urls != null && !urls.isEmpty()); } } }
public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setEnabled(false); final TreePath[] selectionPath = myTree.getSelectionPaths(); if (selectionPath != null) { Object[] nodes = ContainerUtil.map2Array( selectionPath, new Function<TreePath, Object>() { @Override public Object fun(TreePath treePath) { return treePath.getLastPathComponent(); } }); if (!myCondition.value(nodes)) return; presentation.setEnabled(true); } }
@Override public void update(final AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = PlatformDataKeys.PROJECT.getData(dataContext); final Change[] changes = e.getData(getChangesKey()); final Presentation presentation = e.getPresentation(); presentation.setVisible(VcsDataKeys.CHANGES.getData(dataContext) != null); presentation.setEnabled(enabled(project, changes)); }
@Override public void update(final AnActionEvent event) { final Presentation presentation = event.getPresentation(); String name = myEnvironment.getRunProfile().getName(); ProcessHandler processHandler = myDescriptor.getProcessHandler(); final boolean isRunning = processHandler != null && !processHandler.isProcessTerminated(); presentation.setText(ExecutionBundle.message("rerun.configuration.action.name", name)); presentation.setIcon(isRunning ? AllIcons.Actions.Restart : myExecutor.getIcon()); presentation.setEnabled(isEnabled()); }
@Override public void update(final AnActionEvent e) { if (!e.getPresentation().isVisible()) { return; } final DataContext dataContext = e.getDataContext(); final Presentation presentation = e.getPresentation(); final boolean enabled = isAvailable(dataContext); presentation.setVisible(enabled); presentation.setEnabled(enabled); }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); Project project = e.getData(CommonDataKeys.PROJECT); if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) { presentation.setDescription( ExecutionBundle.message("choose.run.configuration.action.description")); } try { if (project == null || project.isDisposed() || !project.isInitialized()) { updatePresentation(null, null, null, presentation); presentation.setEnabled(false); } else { updatePresentation( ExecutionTargetManager.getActiveTarget(project), RunManagerEx.getInstanceEx(project).getSelectedConfiguration(), project, presentation); presentation.setEnabled(true); } } catch (IndexNotReadyException e1) { presentation.setEnabled(false); } }
@Override public void update(final AnActionEvent e) { final Presentation presentation = e.getPresentation(); final Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) { disable(presentation); return; } RunnerAndConfigurationSettings settings = chooseTempSettings(project); if (settings == null) { disable(presentation); } else { presentation.setText( ExecutionBundle.message( "save.temporary.run.configuration.action.name", settings.getName())); presentation.setDescription(presentation.getText()); presentation.setVisible(true); presentation.setEnabled(true); } }
@Override public final void update(@NotNull final AnActionEvent event) { final Presentation presentation = event.getPresentation(); presentation.setEnabled(myInfo.isVisible()); }
private static void disable(final Presentation presentation) { presentation.setEnabled(false); presentation.setVisible(false); }
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); presentation.setEnabled(getTreeSelection() != null); }
public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setEnabled(!myBackStack.isEmpty()); }
@Override public final void update(@NotNull final AnActionEvent event) { super.update(event); final Presentation presentation = event.getPresentation(); presentation.setEnabled(isValidBase()); }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setEnabled(myElements != null && myIndex < myElements.length - 1); }
@Override public void update(AnActionEvent e) { super.update(e); Presentation presentation = e.getPresentation(); presentation.setEnabled(myContainerNodes.size() > 1); }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setEnabled(myIndex > 0); }
@Override public final void update(final AnActionEvent event) { final Presentation presentation = event.getPresentation(); presentation.setEnabled(true); }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); presentation.setEnabled(!myForwardStack.isEmpty()); }
@Override public void update(AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); presentation.setEnabled(allTargetsAreValid()); }