use of com.intellij.ide.OccurenceNavigator in project intellij-community by JetBrains.
the class OccurenceNavigatorActionBase method getNavigator.
@Nullable
protected OccurenceNavigator getNavigator(DataContext dataContext) {
ContentManager contentManager = ContentManagerUtil.getContentManagerFromContext(dataContext, false);
if (contentManager != null) {
Content content = contentManager.getSelectedContent();
if (content == null)
return null;
JComponent component = content.getComponent();
return findNavigator(component);
}
return (OccurenceNavigator) getOccurenceNavigatorFromContext(dataContext);
}
use of com.intellij.ide.OccurenceNavigator in project intellij-community by JetBrains.
the class OccurenceNavigatorActionBase method actionPerformed.
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
if (project == null)
return;
OccurenceNavigator navigator = getNavigator(e.getDataContext());
if (navigator == null) {
return;
}
if (!hasOccurenceToGo(navigator)) {
return;
}
OccurenceNavigator.OccurenceInfo occurenceInfo = go(navigator);
if (occurenceInfo == null) {
return;
}
Navigatable descriptor = occurenceInfo.getNavigateable();
if (descriptor != null && descriptor.canNavigate()) {
descriptor.navigate(true);
}
if (occurenceInfo.getOccurenceNumber() == -1 || occurenceInfo.getOccurencesCount() == -1) {
return;
}
WindowManager.getInstance().getStatusBar(project).setInfo(IdeBundle.message("message.occurrence.N.of.M", occurenceInfo.getOccurenceNumber(), occurenceInfo.getOccurencesCount()));
}
use of com.intellij.ide.OccurenceNavigator in project intellij by bazelbuild.
the class BlazeConsoleView method createToolWindowContent.
void createToolWindowContent(ToolWindow toolWindow) {
// Create runner UI layout
RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(project);
RunnerLayoutUi layoutUi = factory.create("", "", "session", project);
Content console = layoutUi.createContent(BlazeConsoleToolWindowFactory.ID, consoleView.getComponent(), "", null, null);
console.setCloseable(false);
layoutUi.addContent(console, 0, PlaceInGrid.right, false);
// Adding actions
DefaultActionGroup group = new DefaultActionGroup();
layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);
// Initializing prev and next occurrences actions
OccurenceNavigator navigator = fromConsoleView(consoleView);
CommonActionsManager actionsManager = CommonActionsManager.getInstance();
AnAction prevAction = actionsManager.createPrevOccurenceAction(navigator);
prevAction.getTemplatePresentation().setText(navigator.getPreviousOccurenceActionName());
AnAction nextAction = actionsManager.createNextOccurenceAction(navigator);
nextAction.getTemplatePresentation().setText(navigator.getNextOccurenceActionName());
group.addAll(prevAction, nextAction);
AnAction[] consoleActions = consoleView.createConsoleActions();
for (AnAction action : consoleActions) {
if (!shouldIgnoreAction(action)) {
group.add(action);
}
}
group.add(new StopAction());
JComponent layoutComponent = layoutUi.getComponent();
// noinspection ConstantConditions
Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
content.setCloseable(false);
toolWindow.getContentManager().addContent(content);
}
use of com.intellij.ide.OccurenceNavigator in project intellij-community by JetBrains.
the class OccurenceNavigatorActionBase method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
Project project = event.getData(CommonDataKeys.PROJECT);
if (project == null) {
presentation.setEnabled(false);
// make it invisible only in main menu to avoid initial invisibility in toolbars
presentation.setVisible(!ActionPlaces.isMainMenuOrActionSearch(event.getPlace()));
return;
}
OccurenceNavigator navigator = getNavigator(event.getDataContext());
if (navigator == null) {
presentation.setEnabled(false);
// make it invisible only in main menu to avoid initial invisibility in toolbars
presentation.setVisible(!ActionPlaces.isMainMenuOrActionSearch(event.getPlace()));
return;
}
presentation.setVisible(true);
try {
presentation.setEnabled(hasOccurenceToGo(navigator));
presentation.setText(getDescription(navigator));
} catch (IndexNotReadyException e) {
presentation.setEnabled(false);
}
}
use of com.intellij.ide.OccurenceNavigator in project intellij-community by JetBrains.
the class OccurenceNavigatorActionBase method getOccurenceNavigatorFromContext.
@Nullable
private static Component getOccurenceNavigatorFromContext(DataContext dataContext) {
Window window = WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow();
if (window != null) {
Component component = window.getFocusOwner();
for (Component c = component; c != null; c = c.getParent()) {
if (c instanceof OccurenceNavigator) {
return c;
}
}
}
Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return null;
}
ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
String id = mgr.getLastActiveToolWindowId(component -> findNavigator(component) != null);
if (id == null) {
return null;
}
return (Component) findNavigator(mgr.getToolWindow(id).getComponent());
}
Aggregations