@Override public void update(@NotNull AnActionEvent e) { super.update(e); Presentation presentation = e.getPresentation(); DataContext context = e.getDataContext(); EditorWindow window = getEditorWindow(context); if (window == null || window.getOwner().isPreview()) { presentation.setEnabledAndVisible(false); } else { if (getFile(context) != null) { presentation.setEnabledAndVisible(true); } else { Content content = getContent(context); presentation.setEnabledAndVisible(content != null && content.isPinnable()); } } if (ActionPlaces.EDITOR_TAB_POPUP.equals(e.getPlace()) || ViewContext.CELL_POPUP_PLACE.equals(e.getPlace())) { presentation.setText( isSelected(e) ? IdeBundle.message("action.unpin.tab") : IdeBundle.message("action.pin.tab")); } else { presentation.setText( isSelected(e) ? IdeBundle.message("action.unpin.active.tab") : IdeBundle.message("action.pin.active.tab")); } }
public void update(AnActionEvent e) { super.update(e); final Project project = e.getData(DataKeys.PROJECT); final VirtualFile file = e.getData(DataKeys.VIRTUAL_FILE); boolean visible = project != null && file != null && !file.isDirectory() && file.getFileType() == CppSupportLoader.CPP_FILETYPE && !Communicator.isHeaderFile(file); boolean enabled = visible; if (!visible) { visible = ActionPlaces.MAIN_MENU.equals(e.getPlace()); } e.getPresentation().setEnabled(enabled); e.getPresentation().setVisible(visible); if (visible) { final String s = "Do c&ompile for " + (file != null ? file.getName() : "selected c/c++ fileToCompile"); e.getPresentation().setText(s); e.getPresentation().setDescription(s); } }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); Project project = e.getProject(); if (project == null) { presentation.setEnabled(false); return; } final DataContext dataContext = e.getDataContext(); Editor editor = getEditor(dataContext, project, true); if (editor == null) { presentation.setEnabled(false); return; } final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); if (file == null) { presentation.setEnabled(false); return; } update(presentation, project, editor, file, dataContext, e.getPlace()); }
public static void updateFindUsagesAction(AnActionEvent event) { Presentation presentation = event.getPresentation(); DataContext dataContext = event.getDataContext(); boolean enabled = isEnabled(dataContext); presentation.setVisible(enabled || !ActionPlaces.isPopupPlace(event.getPlace())); presentation.setEnabled(enabled); }
@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); } }
public void update(AnActionEvent e) { boolean active = getHandler(e) != null; if (ActionPlaces.isPopupPlace(e.getPlace())) { e.getPresentation().setVisible(active); } else { e.getPresentation().setEnabled(active); } }
public void update(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); boolean enabled = (editor != null && FileDocumentManager.getInstance().getFile(editor.getDocument()) != null) || getElementToCopy(editor, dataContext) != null; e.getPresentation().setEnabled(enabled); if (ActionPlaces.isPopupPlace(e.getPlace())) { e.getPresentation().setVisible(enabled); } else { e.getPresentation().setVisible(true); } }
private static void showPopupInBestPosition( @NotNull ListPopup popup, @NotNull AnActionEvent event, @NotNull DataContext dataContext) { if (event.getInputEvent() instanceof MouseEvent) { if (!event.getPlace().equals(ActionPlaces.UPDATE_POPUP)) { popup.show(new RelativePoint((MouseEvent) event.getInputEvent())); } else { // quick fix for invoking from the context menu: coordinates are calculated // incorrectly there. popup.showInBestPositionFor(dataContext); } } else { popup.showInBestPositionFor(dataContext); } }
@Override public void update(@NotNull AnActionEvent e) { if (!ActionPlaces.DIFF_TOOLBAR.equals(e.getPlace())) { e.getPresentation().setEnabled(true); return; } PrevNextDifferenceIterable iterable = DiffDataKeys.PREV_NEXT_DIFFERENCE_ITERABLE.getData(e.getDataContext()); if (iterable != null && iterable.canGoPrev()) { e.getPresentation().setEnabled(true); return; } e.getPresentation().setEnabled(false); }
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; }
public void actionPerformed(final AnActionEvent e) { final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject); EditorWindow window; final VirtualFile file = (VirtualFile) myTabInfo.getObject(); if (ActionPlaces.EDITOR_TAB.equals(e.getPlace())) { window = myWindow; } else { window = mgr.getCurrentWindow(); } if (window != null) { if ((e.getModifiers() & InputEvent.ALT_MASK) != 0) { window.closeAllExcept(file); } else { if (window.findFileComposite(file) != null) { mgr.closeFile(file, window); } } } }
@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); } }
public static boolean isContextView(AnActionEvent e) { return DebuggerActions.EVALUATION_DIALOG_POPUP.equals(e.getPlace()) || DebuggerActions.FRAME_PANEL_POPUP.equals(e.getPlace()) || DebuggerActions.WATCH_PANEL_POPUP.equals(e.getPlace()) || DebuggerActions.INSPECT_PANEL_POPUP.equals(e.getPlace()); }