@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); } }
@Override public final void actionPerformed(final AnActionEvent event) { final DataContext dataContext = event.getDataContext(); final HierarchyBrowserBaseEx browser = (HierarchyBrowserBaseEx) dataContext.getData(myBrowserDataKey); if (browser == null) return; final PsiElement selectedElement = browser.getSelectedElement(); if (selectedElement == null || !browser.isApplicableElement(selectedElement)) return; final String currentViewType = browser.myCurrentViewType; Disposer.dispose(browser); final HierarchyProvider provider = BrowseHierarchyActionBase.findProvider( myProviderLanguageExtension, selectedElement, selectedElement.getContainingFile(), event.getDataContext()); final HierarchyBrowser newBrowser = BrowseHierarchyActionBase.createAndAddToPanel( selectedElement.getProject(), provider, selectedElement); ApplicationManager.getApplication() .invokeLater( () -> ((HierarchyBrowserBaseEx) newBrowser) .changeView(correctViewType(browser, currentViewType))); }
public static void showPopup(AnActionEvent e, JBPopup popup) { final InputEvent event = e.getInputEvent(); if (event instanceof MouseEvent) { popup.showUnderneathOf(event.getComponent()); } else { popup.showInBestPositionFor(e.getDataContext()); } }
@Override public void update(AnActionEvent e) { if (mySession != null) { e.getPresentation().setEnabled(false); } else { e.getPresentation().setEnabled(true); } }
@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(AnActionEvent e) { if (!running) { e.getPresentation().setEnabled(true); e.getPresentation().setIcon(RESOLVEIcons.CHECKMARK); } else { e.getPresentation().setEnabled(false); } }
public boolean processAction(final InputEvent e, ActionProcessor processor) { ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); final Project project = PlatformDataKeys.PROJECT.getData(myContext.getDataContext()); final boolean dumb = project != null && DumbService.getInstance(project).isDumb(); List<AnActionEvent> nonDumbAwareAction = new ArrayList<AnActionEvent>(); for (final AnAction action : myContext.getActions()) { final Presentation presentation = myPresentationFactory.getPresentation(action); // Mouse modifiers are 0 because they have no any sense when action is invoked via keyboard final AnActionEvent actionEvent = processor.createEvent( e, myContext.getDataContext(), ActionPlaces.MAIN_MENU, presentation, ActionManager.getInstance()); ActionUtil.performDumbAwareUpdate(action, actionEvent, true); if (dumb && !action.isDumbAware()) { if (Boolean.FALSE.equals( presentation.getClientProperty(ActionUtil.WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) { continue; } nonDumbAwareAction.add(actionEvent); continue; } if (!presentation.isEnabled()) { continue; } processor.onUpdatePassed(e, action, actionEvent); ((DataManagerImpl.MyDataContext) myContext.getDataContext()) .setEventCount(IdeEventQueue.getInstance().getEventCount(), this); actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent); Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(actionEvent.getDataContext()); if (component != null && !component.isShowing()) { return true; } processor.performAction(e, action, actionEvent); actionManager.fireAfterActionPerformed(action, actionEvent.getDataContext(), actionEvent); return true; } if (!nonDumbAwareAction.isEmpty()) { showDumbModeWarningLaterIfNobodyConsumesEvent( e, nonDumbAwareAction.toArray(new AnActionEvent[nonDumbAwareAction.size()])); } return false; }
@Override public void update(AnActionEvent e) { // e.getPresentation() if (pl.vcIsProved.containsKey(vcNum) && pl.vcIsProved.get(vcNum)) { e.getPresentation().setIcon(RESOLVEIcons.PROVED); isProved = true; } else { e.getPresentation().setIcon(RESOLVEIcons.NOT_PROVED); } }
@Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(!myTable.isEditing() && myTable.getSelectedRow() >= 0); e.getPresentation().setText("Revert to Default"); e.getPresentation().setIcon(IconLoader.getIcon("/general/remove.png")); if (e.getPresentation().isEnabled()) { final RegistryValue rv = myModel.getRegistryValue(myTable.getSelectedRow()); e.getPresentation().setEnabled(rv.isChangedFromDefault()); } }
@Override public void actionPerformed(AnActionEvent e) { JPanel result = new JPanel(new BorderLayout()); JLabel label = new JLabel("Lines around:"); label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0)); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(label, BorderLayout.NORTH); result.add(wrapper, BorderLayout.WEST); final JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 5, 1); slider.setMinorTickSpacing(1); slider.setPaintTicks(true); slider.setPaintTrack(true); slider.setSnapToTicks(true); UIUtil.setSliderIsFilled(slider, true); slider.setPaintLabels(true); slider.setLabelTable(LABELS); result.add(slider, BorderLayout.CENTER); final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); for (int i = 0; i < ourMarks.length; i++) { int mark = ourMarks[i]; if (mark == configuration.SHORT_DIFF_EXTRA_LINES) { slider.setValue(i + 1); } } JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider).createPopup(); popup.setFinalRunnable( new Runnable() { @Override public void run() { int value = slider.getModel().getValue(); if (configuration.SHORT_DIFF_EXTRA_LINES != ourMarks[value - 1]) { configuration.SHORT_DIFF_EXTRA_LINES = ourMarks[value - 1]; myFragmentedContent.recalculate(); refreshData(myFragmentedContent); } } }); InputEvent inputEvent = e.getInputEvent(); if (inputEvent instanceof MouseEvent) { int width = result.getPreferredSize().width; MouseEvent inputEvent1 = (MouseEvent) inputEvent; Point point1 = new Point(inputEvent1.getX() - width / 2, inputEvent1.getY()); RelativePoint point = new RelativePoint(inputEvent1.getComponent(), point1); popup.show(point); } else { popup.showInBestPositionFor(e.getDataContext()); } }
@Override public void actionPerformed(AnActionEvent e) { if (e.getProject() == null) return; RESOLVEPluginController controller = RESOLVEPluginController.getInstance(e.getProject()); controller.getVerifierWindow().show(null); // open the verifier window VerificationConditionSelectorPanel vcselector = controller.getVerifierPanel().getVcSelectorPanel(); if (vcselector == null) return; vcselector.vcTabs.get(Integer.parseInt(vcNum)); VerifierPanel verifierPanel = controller.getVerifierPanel(); if (verifierPanel.getVcSelectorPanel() == null) return; VerificationConditionSelectorPanel selector = verifierPanel.getVcSelectorPanel(); ConditionCollapsiblePanel details = selector.vcTabs.get(Integer.parseInt(vcNum)); details.setExpanded(true); }
public void update(AnActionEvent e) { boolean enabled = true; for (DependenciesBuilder builder : myBuilders) { enabled &= builder.getScope().isValid(); } e.getPresentation().setEnabled(enabled); }
public void update(final AnActionEvent e) { super.update(e); final PatternDialectProvider provider = PatternDialectProvider.getInstance(mySettings.SCOPE_TYPE); e.getPresentation().setText(provider.getDisplayName()); e.getPresentation().setIcon(provider.getIcon()); }
@Override public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setEnabled(false); if (getSelectedProfile() == null) return; final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) return; final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null); if (selectedNodes == null) return; final List<Descriptor> descriptors = new ArrayList<Descriptor>(); for (InspectionConfigTreeNode node : selectedNodes) { collect(descriptors, new ArrayList<InspectionConfigTreeNode>(), node); } presentation.setEnabled(!getAvailableScopes(project, descriptors).isEmpty()); }
@Override public void update(final AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); presentation.setIcon(SvnIcons.ShowIntegratedFrom); presentation.setText(SvnBundle.message("committed.changes.action.enable.merge.highlighting")); presentation.setDescription( SvnBundle.message("committed.changes.action.enable.merge.highlighting.description.text")); }
@Override public void update(@NotNull AnActionEvent e) { final OrderEntry entry = getSelectedEntry(); e.getPresentation() .setVisible( entry instanceof ModuleOrderEntry && ((ModuleOrderEntry) entry).getModule() != null || entry instanceof LibraryOrderEntry && ((LibraryOrderEntry) entry).getLibrary() != null); }
public void setSelected(AnActionEvent e, boolean state) { T change = ObjectUtils.tryCast(e.getData(VcsDataKeys.CURRENT_CHANGE), myClass); if (change == null) return; if (state) { myViewer.includeChange(change); } else { myViewer.excludeChange(change); } }
@Override public void actionPerformed(AnActionEvent e) { final List<Descriptor> descriptors = new ArrayList<Descriptor>(); final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null); LOG.assertTrue(selectedNodes != null); final List<InspectionConfigTreeNode> nodes = new ArrayList<InspectionConfigTreeNode>(Arrays.asList(selectedNodes)); for (InspectionConfigTreeNode node : selectedNodes) { collect(descriptors, nodes, node); } final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); final List<String> availableScopes = getAvailableScopes(project, descriptors); final int idx = Messages.showChooseDialog( myTree, "Scope:", "Choose Scope", ArrayUtil.toStringArray(availableScopes), availableScopes.get(0), Messages.getQuestionIcon()); if (idx == -1) return; final NamedScope chosenScope = NamedScopesHolder.getScope(project, availableScopes.get(idx)); for (InspectionConfigTreeNode node : nodes) { final Descriptor descriptor = node.getDesriptor(); if (node.getScopeName() != null || descriptor == null) continue; final InspectionProfileEntry tool = descriptor.getTool(); // copy final ScopeToolState scopeToolState = getSelectedProfile() .addScope( tool, chosenScope, getSelectedProfile().getErrorLevel(descriptor.getKey(), chosenScope), getSelectedProfile().isToolEnabled(descriptor.getKey())); final Descriptor addedDescriptor = new Descriptor(scopeToolState, getSelectedProfile()); if (node.getChildCount() == 0) { node.add( new InspectionConfigTreeNode( descriptor, getSelectedProfile().getToolDefaultState(descriptor.getKey().toString()), true, true, false)); } node.insert(new InspectionConfigTreeNode(addedDescriptor, scopeToolState, false, false), 0); node.setInspectionNode(false); node.dropCache(); ((DefaultTreeModel) myTree.getModel()).reload(node); myTree.expandPath(new TreePath(node.getPath())); } myTree.revalidate(); }
static boolean canCreateFromTemplate(AnActionEvent e, FileTemplate template) { if (e == null) return false; DataContext dataContext = e.getDataContext(); IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext); if (view == null) return false; PsiDirectory[] dirs = view.getDirectories(); if (dirs.length == 0) return false; return FileTemplateUtil.canCreateFromTemplate(dirs, template); }
@Override public void actionPerformed(AnActionEvent e) { final Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) return; Runnable searchEverywhere = mySearchEverywhereRunnable; mySearchEverywhereRunnable = null; hideHints(); if (searchEverywhere != null) { searchEverywhere.run(); return; } final RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext()); PsiDocumentManager.getInstance(project).commitAllDocuments(); FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.usages"); UsageTarget[] usageTargets = e.getData(UsageView.USAGE_TARGETS_KEY); final Editor editor = e.getData(PlatformDataKeys.EDITOR); if (usageTargets == null) { chooseAmbiguousTargetAndPerform( project, editor, new PsiElementProcessor<PsiElement>() { @Override public boolean execute(@NotNull final PsiElement element) { startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE); return false; } }); } else { PsiElement element = ((PsiElementUsageTarget) usageTargets[0]).getElement(); if (element != null) { startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE); } } }
public void update(final AnActionEvent e) { final boolean[] direct = new boolean[] {true}; processDependencies( getSelectedScope(myLeftTree), getSelectedScope(myRightTree), new Processor<List<PsiFile>>() { public boolean process(final List<PsiFile> path) { direct[0] = false; return false; } }); e.getPresentation().setEnabled(!direct[0]); }
@Override public void update(AnActionEvent event) { super.update(event); Presentation presentation = event.getPresentation(); FileTemplate[] allTemplates = FileTemplateManager.getInstance().getAllTemplates(); for (FileTemplate template : allTemplates) { if (canCreateFromTemplate(event, template)) { presentation.setEnabled(true); return; } } presentation.setEnabled(false); }
@Override public void actionPerformed(AnActionEvent e) { final DefaultActionGroup dag = new DefaultActionGroup(); dag.add(myUsual); dag.add(myNumbered); dag.add(mySoftWrapsAction); final ListPopup popup = JBPopupFactory.getInstance() .createActionGroupPopup( null, dag, e.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); if (e.getInputEvent() instanceof MouseEvent) { popup.show(new RelativePoint((MouseEvent) e.getInputEvent())); } else { // todo correct /*final Dimension dimension = popup.getContent().getPreferredSize(); final Point at = new Point(-dimension.width / 2, 0); popup.show(new RelativePoint(myParent, at));*/ popup.showInBestPositionFor(e.getDataContext()); } }
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)); } }
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 actionPerformed(AnActionEvent e) { DataContext context = e.getDataContext(); Editor editor = PlatformDataKeys.EDITOR.getData(context); PsiFile psiFile = LangDataKeys.PSI_FILE.getData(context); if (psiFile == null) return; List<GotoRelatedItem> items = getItems(psiFile, editor, context); if (items.isEmpty()) return; if (items.size() == 1 && items.get(0).getElement() != null) { items.get(0).navigate(); return; } if (ApplicationManager.getApplication().isUnitTestMode()) { System.out.println(items); } createPopup(items, "Go to Related Files").showInBestPositionFor(context); }
public void actionPerformed(AnActionEvent e) { final JBPopupFactory popupFactory = JBPopupFactory.getInstance(); final ListPopupStep step = popupFactory.createActionsStep( myActionGroup, e.getDataContext(), false, false, myActionGroup.getTemplatePresentation().getText(), myTree, true, myPreselection != null ? myPreselection.getDefaultIndex() : 0, true); final ListPopup listPopup = popupFactory.createListPopup(step); listPopup.setHandleAutoSelectionBeforeShow(true); if (e instanceof AnActionButton.AnActionEventWrapper) { ((AnActionButton.AnActionEventWrapper) e).showPopup(listPopup); } else { listPopup.showUnderneathOf(myNorthPanel); } }
public void actionPerformed(final AnActionEvent e) { @NonNls final String delim = " -> "; final StringBuffer buf = new StringBuffer(); processDependencies( getSelectedScope(myLeftTree), getSelectedScope(myRightTree), new Processor<List<PsiFile>>() { public boolean process(final List<PsiFile> path) { if (buf.length() > 0) buf.append("<br>"); buf.append( StringUtil.join( path, new Function<PsiFile, String>() { public String fun(final PsiFile psiFile) { return psiFile.getName(); } }, delim)); return true; } }); final JEditorPane pane = new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString() + "</html>"); pane.setForeground(Color.black); pane.setBackground(HintUtil.INFORMATION_COLOR); pane.setOpaque(true); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane); final Dimension dimension = pane.getPreferredSize(); scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20)); scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20)); JBPopupFactory.getInstance() .createComponentPopupBuilder(scrollPane, pane) .setTitle("Dependencies") .setMovable(true) .createPopup() .showInBestPositionFor(e.getDataContext()); }
private AnActionEvent stopConsole(AnActionEvent e) { if (myPydevConsoleCommunication != null) { e = new AnActionEvent( e.getInputEvent(), e.getDataContext(), e.getPlace(), e.getPresentation(), e.getActionManager(), e.getModifiers()); try { closeCommunication(); // waiting for REPL communication before destroying process handler Thread.sleep(300); } catch (Exception ignored) { // Ignore } } return e; }
@Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(!myTable.isEditing() && myTable.getSelectedRow() >= 0); e.getPresentation().setText("Edit"); e.getPresentation().setIcon(IconLoader.getIcon("/actions/editSource.png")); }