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 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 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); }
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()); }