com.intellij.openapi.wm.ex.ToolWindowEx Java Examples

The following examples show how to use com.intellij.openapi.wm.ex.ToolWindowEx. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestfulWindowToolWindowFactory.java    From NutzCodeInsight with Apache License 2.0 6 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    final SimpleTree apiTree = new SimpleTree();
    apiTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.toolWindowEx = (ToolWindowEx) toolWindow;
    RefreshAction refreshAction = new RefreshAction("刷新", "重新加载URL", AllIcons.Actions.Refresh, toolWindowEx, apiTree);
    toolWindowEx.setTitleActions(refreshAction, actionManager.getAction("GoToRequestMapping"));
    apiTree.addMouseListener(new ApiTreeMouseAdapter(apiTree));
    ContentManager contentManager = toolWindow.getContentManager();
    Content content = contentManager.getFactory().createContent(new RestServicesNavigatorPanel(apiTree), null, false);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
    if (project.isInitialized()) {
        refreshAction.loadTree(project);
    }
}
 
Example #2
Source File: FavoritesTreeViewPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void setupToolWindow(ToolWindowEx window) {
  final CollapseAllAction collapseAction = new CollapseAllAction(myTree);
  collapseAction.getTemplatePresentation().setIcon(AllIcons.General.CollapseAll);
  collapseAction.getTemplatePresentation().setHoveredIcon(AllIcons.General.CollapseAllHover);
  window.setTitleActions(collapseAction);

  final DefaultActionGroup group = new DefaultActionGroup();

  group.add(new FavoritesFlattenPackagesAction(myProject, myBuilder));
  group.add(new FavoritesCompactEmptyMiddlePackagesAction(myProject, myBuilder));
  group.addAction(new FavoritesAbbreviatePackageNamesAction(myProject, myBuilder));

  group.add(new FavoritesShowMembersAction(myProject, myBuilder));

  final FavoritesAutoscrollFromSourceHandler handler = new FavoritesAutoscrollFromSourceHandler(myProject, myBuilder);
  handler.install();
  group.add(handler.createToggleAction());

  group.add(new FavoritesAutoScrollToSourceAction(myProject, myAutoScrollToSourceHandler, myBuilder));
  window.setAdditionalGearActions(group);
}
 
Example #3
Source File: ToggleWindowedModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void setSelected(AnActionEvent event, boolean flag) {
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  if (id == null) {
    return;
  }
  ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
  ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id);
  ToolWindowType type = toolWindow.getType();
  if (ToolWindowType.WINDOWED == type) {
    toolWindow.setType(toolWindow.getInternalType(), null);
  }
  else {
    toolWindow.setType(ToolWindowType.WINDOWED, null);
  }
}
 
Example #4
Source File: BaseToolWindowToggleAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public final void setSelected(AnActionEvent e, boolean state) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  if (id == null) {
    return;
  }

  ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
  ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id);

  setSelected(toolWindow, state);
}
 
Example #5
Source File: ToggleFloatingModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void setSelected(AnActionEvent event, boolean flag) {
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }
  String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
  if (id == null) {
    return;
  }
  ToolWindowManagerEx mgr = ToolWindowManagerEx.getInstanceEx(project);
  ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id);
  ToolWindowType type = toolWindow.getType();
  if (ToolWindowType.FLOATING == type) {
    toolWindow.setType(toolWindow.getInternalType(), null);
  }
  else {
    toolWindow.setType(ToolWindowType.FLOATING, null);
  }
}
 
Example #6
Source File: HideSideWindowsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  Project project = event.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    presentation.setEnabled(false);
    return;
  }

  ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
  String id = toolWindowManager.getActiveToolWindowId();
  if (id != null) {
    presentation.setEnabled(true);
    return;
  }

  id = toolWindowManager.getLastActiveToolWindowId();
  if (id == null) {
    presentation.setEnabled(false);
    return;
  }

  ToolWindowEx toolWindow = (ToolWindowEx)toolWindowManager.getToolWindow(id);
  presentation.setEnabled(toolWindow.isVisible());
}
 
Example #7
Source File: ToolWindowManagerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(final PropertyChangeEvent e) {
  ToolWindow toolWindow = (ToolWindow)e.getSource();
  if (ToolWindowEx.PROP_AVAILABLE.equals(e.getPropertyName())) {
    final WindowInfoImpl info = getInfo(toolWindow.getId());
    if (!toolWindow.isAvailable() && info.isVisible()) {
      hideToolWindow(toolWindow.getId(), false);
    }
  }
  ToolWindowStripeButton button = getStripeButton(toolWindow.getId());
  if (button != null) button.updatePresentation();
  ActivateToolWindowAction.updateToolWindowActionPresentation(toolWindow);
}
 
Example #8
Source File: ContentManagerUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * This is utility method. It returns <code>ContentManager</code> from the current context.
 */
public static ContentManager getContentManagerFromContext(DataContext dataContext, boolean requiresVisibleToolWindow){
  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return null;
  }

  ToolWindowManagerEx mgr=ToolWindowManagerEx.getInstanceEx(project);

  String id = mgr.getActiveToolWindowId();
  if (id == null) {
    if(mgr.isEditorComponentActive()){
      id = mgr.getLastActiveToolWindowId();
    }
  }
  if(id == null){
    return null;
  }

  ToolWindowEx toolWindow = (ToolWindowEx)mgr.getToolWindow(id);
  if (requiresVisibleToolWindow && !toolWindow.isVisible()) {
    return null;
  }

  final ContentManager fromContext = dataContext.getData(PlatformDataKeys.CONTENT_MANAGER);
  if (fromContext != null) return fromContext;

  return toolWindow != null ? toolWindow.getContentManager() : null;
}
 
Example #9
Source File: LightToolWindow.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setSelected(AnActionEvent e, boolean state) {
  ToolWindow window = myManager.getToolWindow();
  ToolWindowType type = window.getType();
  if (type == ToolWindowType.FLOATING) {
    window.setType(((ToolWindowEx)window).getInternalType(), null);
  }
  else {
    window.setType(ToolWindowType.FLOATING, null);
  }
  myManager.setEditorMode(null);
}
 
Example #10
Source File: ProjectViewImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void setupToolWindow(@Nonnull ToolWindow toolWindow, final boolean loadPaneExtensions) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  myActionGroup = new DefaultActionGroup();

  myAutoScrollFromSourceHandler.install();

  myContentManager = toolWindow.getContentManager();
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    toolWindow.setDefaultContentUiType(ToolWindowContentUiType.COMBO);
    ((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
    toolWindow.getComponent().putClientProperty(ToolWindowContentUI.HIDE_ID_LABEL, "true");
  }

  GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
  SwingUtilities.invokeLater(() -> splitterProportions.restoreSplitterProportions(myPanel));

  if (loadPaneExtensions) {
    ensurePanesLoaded();
  }
  isInitialized = true;
  doAddUninitializedPanes();

  getContentManager().addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
        viewSelectionChanged();
      }
    }
  });
  viewSelectionChanged();
}
 
Example #11
Source File: FavoritesViewToolWindowFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
  if (toolWindow != null) {
    final ContentManager contentManager = toolWindow.getContentManager();
    final FavoritesTreeViewPanel panel = new FavoritesPanel(project).getPanel();
    panel.setupToolWindow((ToolWindowEx)toolWindow);
    final Content content = contentManager.getFactory().createContent(panel, null, false);
    contentManager.addContent(content);
  }
}
 
Example #12
Source File: RestfulWindowToolWindowFactory.java    From NutzCodeInsight with Apache License 2.0 5 votes vote down vote up
@Override
public void init(@NotNull ToolWindow toolWindow) {
    this.toolWindowEx = (ToolWindowEx) toolWindow;
    toolWindowEx.setStripeTitle(TITLE);
    toolWindowEx.setIcon(NutzCons.NUTZ);
    toolWindowEx.setTitle(TITLE);
}
 
Example #13
Source File: StructureViewFactoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void initToolWindow(ToolWindowEx toolWindow) {
  myStructureViewWrapperImpl = new StructureViewWrapperImpl(myProject, toolWindow);
  if (myRunWhenInitialized != null) {
    myRunWhenInitialized.run();
    myRunWhenInitialized = null;
  }
}
 
Example #14
Source File: DocumentationManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void installComponentActions(ToolWindow toolWindow, DocumentationComponent component) {
  ((ToolWindowEx)toolWindow).setTitleActions(component.getActions());
  DefaultActionGroup group = new DefaultActionGroup(createActions());
  group.add(component.getFontSizeAction());
  ((ToolWindowEx)toolWindow).setAdditionalGearActions(group);
  component.removeCornerMenu();
}
 
Example #15
Source File: ResizeToolWindowAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void incWidth(ToolWindow wnd, int value, boolean isPositive) {
  ((ToolWindowEx)wnd).stretchWidth(isPositive ? value : -value);
}
 
Example #16
Source File: DesktopToolWindowManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected ToolWindowInternalDecorator createInternalDecorator(Project project, @Nonnull WindowInfoImpl info, ToolWindowEx toolWindow, boolean dumbAware) {
  return new DesktopInternalDecorator(project, info, (DesktopToolWindowImpl)toolWindow, dumbAware);
}
 
Example #17
Source File: DesktopToolWindowManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected ToolWindowEx createToolWindow(String id, LocalizeValue displayName, boolean canCloseContent, @Nullable Object component, boolean shouldBeAvailable) {
  return new DesktopToolWindowImpl(this, id, displayName, canCloseContent, (JComponent)component, shouldBeAvailable);
}
 
Example #18
Source File: WebToolWindowManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected ToolWindowInternalDecorator createInternalDecorator(Project project, @Nonnull WindowInfoImpl info, ToolWindowEx toolWindow, boolean dumbAware) {
  return new WebToolWindowInternalDecorator(project, info, (UnifiedToolWindowImpl)toolWindow, dumbAware);
}
 
Example #19
Source File: WebToolWindowManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
protected ToolWindowEx createToolWindow(String id, LocalizeValue displayName, boolean canCloseContent, @Nullable Object component, boolean shouldBeAvailable) {
  return new UnifiedToolWindowImpl(this, id, displayName, canCloseContent, component, shouldBeAvailable);
}
 
Example #20
Source File: StructureViewWrapperImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public StructureViewWrapperImpl(Project project, ToolWindowEx toolWindow) {
  myProject = project;
  myToolWindow = toolWindow;

  myUpdateQueue = new MergingUpdateQueue("StructureView", Registry.intValue("structureView.coalesceTime"), false, myToolWindow.getComponent(), this, myToolWindow.getComponent(), true);
  myUpdateQueue.setRestartTimerOnAdd(true);

  final TimerListener timerListener = new TimerListener() {
    @Override
    public ModalityState getModalityState() {
      return ModalityState.stateForComponent(myToolWindow.getComponent());
    }

    @Override
    public void run() {
      checkUpdate();
    }
  };
  ActionManager.getInstance().addTimerListener(500, timerListener);
  Disposer.register(this, new Disposable() {
    @Override
    public void dispose() {
      ActionManager.getInstance().removeTimerListener(timerListener);
    }
  });

  myToolWindow.getComponent().addHierarchyListener(new HierarchyListener() {
    @Override
    public void hierarchyChanged(HierarchyEvent e) {
      if (BitUtil.isSet(e.getChangeFlags(), HierarchyEvent.DISPLAYABILITY_CHANGED)) {
        scheduleRebuild();
      }
    }
  });
  myToolWindow.getContentManager().addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      if (myStructureView instanceof StructureViewComposite) {
        StructureViewComposite.StructureViewDescriptor[] views = ((StructureViewComposite)myStructureView).getStructureViews();
        for (StructureViewComposite.StructureViewDescriptor view : views) {
          if (view.title.equals(event.getContent().getTabName())) {
            updateHeaderActions(view.structureView);
            break;
          }
        }
      }
    }
  });
  Disposer.register(myToolWindow.getContentManager(), this);
}
 
Example #21
Source File: RefreshAction.java    From NutzCodeInsight with Apache License 2.0 4 votes vote down vote up
public RefreshAction(String text, String description, Icon icon, ToolWindowEx toolWindowEx, JTree apiTree) {
    super(text, description, icon);
    this.toolWindowEx = toolWindowEx;
    this.apiTree = apiTree;
}
 
Example #22
Source File: StructureViewToolWindowFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
  StructureViewFactoryImpl factory = (StructureViewFactoryImpl)StructureViewFactory.getInstance(project);
  factory.initToolWindow((ToolWindowEx)toolWindow);
}
 
Example #23
Source File: DockablePopupManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void installComponentActions(ToolWindow toolWindow, T component) {
  ((ToolWindowEx)myToolWindow).setAdditionalGearActions(new DefaultActionGroup(createActions()));
}
 
Example #24
Source File: ResizeToolWindowAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void incHeight(ToolWindow wnd, int value, boolean isPositive) {
  ((ToolWindowEx)wnd).stretchHeight(isPositive ? value : -value);
}
 
Example #25
Source File: SymfonyWebProfilerWindowFactory.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
private static void setUpContent(ToolWindowEx toolWindow, SymfonyWebProfilerPane symfony2SearchPane) {
    symfony2SearchPane.setup(toolWindow);
}
 
Example #26
Source File: PreviewView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initToolWindow(@NotNull ToolWindow toolWindow) {
  final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
  final ContentManager contentManager = toolWindow.getContentManager();

  final Content content = contentFactory.createContent(null, null, false);
  content.setCloseable(false);

  windowPanel = new OutlineComponent(this);
  content.setComponent(windowPanel);

  windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent());

  final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();

  tree = new OutlineTree(rootNode);
  tree.setCellRenderer(new OutlineTreeCellRenderer());
  tree.expandAll();

  initTreePopup();

  // Add collapse all, expand all, and show only widgets buttons.
  if (toolWindow instanceof ToolWindowEx) {
    final ToolWindowEx toolWindowEx = (ToolWindowEx)toolWindow;

    final CommonActionsManager actions = CommonActionsManager.getInstance();
    final TreeExpander expander = new DefaultTreeExpander(tree);

    final AnAction expandAllAction = actions.createExpandAllAction(expander, tree);
    expandAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Expandall);

    final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree);
    collapseAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall);

    final ShowOnlyWidgetsAction showOnlyWidgetsAction = new ShowOnlyWidgetsAction();

    toolWindowEx.setTitleActions(expandAllAction, collapseAllAction, showOnlyWidgetsAction);
  }

  new TreeSpeedSearch(tree) {
    @Override
    protected String getElementText(Object element) {
      final TreePath path = (TreePath)element;
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
      final Object object = node.getUserObject();
      if (object instanceof OutlineObject) {
        return ((OutlineObject)object).getSpeedSearchString();
      }
      return null;
    }
  };

  tree.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() > 1) {
        final TreePath selectionPath = tree.getSelectionPath();
        if (selectionPath != null) {
          selectPath(selectionPath, true);
        }
      }
    }
  });

  tree.addTreeSelectionListener(treeSelectionListener);

  scrollPane = ScrollPaneFactory.createScrollPane(tree);
  content.setPreferredFocusableComponent(tree);

  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  splitter = new Splitter(true);
  setSplitterProportion(getState().getSplitterProportion());
  getState().addListener(e -> {
    final float newProportion = getState().getSplitterProportion();
    if (splitter.getProportion() != newProportion) {
      setSplitterProportion(newProportion);
    }
  });
  //noinspection Convert2Lambda
  splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if (!isSettingSplitterProportion) {
        getState().setSplitterProportion(splitter.getProportion());
      }
    }
  });
  scrollPane.setMinimumSize(new Dimension(1, 1));
  splitter.setFirstComponent(scrollPane);
  windowPanel.setContent(splitter);
}
 
Example #27
Source File: PreviewView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initToolWindow(@NotNull ToolWindow toolWindow) {
  final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
  final ContentManager contentManager = toolWindow.getContentManager();

  final Content content = contentFactory.createContent(null, null, false);
  content.setCloseable(false);

  windowPanel = new OutlineComponent(this);
  content.setComponent(windowPanel);

  windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent());

  final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();

  tree = new OutlineTree(rootNode);
  tree.setCellRenderer(new OutlineTreeCellRenderer());
  tree.expandAll();

  initTreePopup();

  // Add collapse all, expand all, and show only widgets buttons.
  if (toolWindow instanceof ToolWindowEx) {
    final ToolWindowEx toolWindowEx = (ToolWindowEx)toolWindow;

    final CommonActionsManager actions = CommonActionsManager.getInstance();
    final TreeExpander expander = new DefaultTreeExpander(tree);

    final AnAction expandAllAction = actions.createExpandAllAction(expander, tree);
    expandAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Expandall);

    final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree);
    collapseAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall);

    final ShowOnlyWidgetsAction showOnlyWidgetsAction = new ShowOnlyWidgetsAction();

    toolWindowEx.setTitleActions(expandAllAction, collapseAllAction, showOnlyWidgetsAction);
  }

  new TreeSpeedSearch(tree) {
    @Override
    protected String getElementText(Object element) {
      final TreePath path = (TreePath)element;
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
      final Object object = node.getUserObject();
      if (object instanceof OutlineObject) {
        return ((OutlineObject)object).getSpeedSearchString();
      }
      return null;
    }
  };

  tree.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() > 1) {
        final TreePath selectionPath = tree.getSelectionPath();
        if (selectionPath != null) {
          selectPath(selectionPath, true);
        }
      }
    }
  });

  tree.addTreeSelectionListener(treeSelectionListener);

  scrollPane = ScrollPaneFactory.createScrollPane(tree);
  content.setPreferredFocusableComponent(tree);

  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  splitter = new Splitter(true);
  setSplitterProportion(getState().getSplitterProportion());
  getState().addListener(e -> {
    final float newProportion = getState().getSplitterProportion();
    if (splitter.getProportion() != newProportion) {
      setSplitterProportion(newProportion);
    }
  });
  //noinspection Convert2Lambda
  splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if (!isSettingSplitterProportion) {
        getState().setSplitterProportion(splitter.getProportion());
      }
    }
  });
  scrollPane.setMinimumSize(new Dimension(1, 1));
  splitter.setFirstComponent(scrollPane);
  windowPanel.setContent(splitter);
}
 
Example #28
Source File: SymfonyWebProfilerWindowFactory.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    SymfonyWebProfilerPane symfony2SearchPane = new SymfonyWebProfilerPane(project);
    setUpContent((ToolWindowEx)toolWindow, symfony2SearchPane);
    toolWindow.setIcon(TOOLWINDOW_ICON);
}
 
Example #29
Source File: LightToolWindowManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected final void initGearActions() {
  ToolWindowEx toolWindow = (ToolWindowEx)myToolWindow;
  toolWindow.setAdditionalGearActions(new DefaultActionGroup(createGearActions()));
}
 
Example #30
Source File: ToolWindowManagerBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@RequiredUIAccess
protected ToolWindow registerToolWindow(@Nonnull final String id,
                                        @Nullable LocalizeValue displayName,
                                        @Nullable final Object component,
                                        @Nonnull final ToolWindowAnchor anchor,
                                        boolean sideTool,
                                        boolean canCloseContent,
                                        final boolean canWorkInDumbMode,
                                        boolean shouldBeAvailable) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("enter: installToolWindow(" + id + "," + component + "," + anchor + "\")");
  }
  UIAccess.assertIsUIThread();
  if (myLayout.isToolWindowRegistered(id)) {
    throw new IllegalArgumentException("window with id=\"" + id + "\" is already registered");
  }

  final WindowInfoImpl info = myLayout.register(id, anchor, sideTool);
  final boolean wasActive = info.isActive();
  final boolean wasVisible = info.isVisible();
  info.setActive(false);
  info.setVisible(false);

  LocalizeValue displayNameNonnull = ObjectUtil.notNull(displayName, LocalizeValue.of(id));

  // Create decorator
  ToolWindowEx toolWindow = createToolWindow(id, displayNameNonnull, canCloseContent, component, shouldBeAvailable);

  ToolWindowInternalDecorator decorator = createInternalDecorator(myProject, info.copy(), toolWindow, canWorkInDumbMode);
  ActivateToolWindowAction.ensureToolWindowActionRegistered(toolWindow);
  myId2InternalDecorator.put(id, decorator);
  decorator.addInternalDecoratorListener(myInternalDecoratorListener);
  toolWindow.addPropertyChangeListener(myToolWindowPropertyChangeListener);

  installFocusWatcher(id, toolWindow);

  // Create and show tool button

  final ToolWindowStripeButton button = createStripeButton(decorator);
  myId2StripeButton.put(id, button);
  List<FinalizableCommand> commandsList = new ArrayList<>();
  appendAddButtonCmd(button, info, commandsList);

  // If preloaded info is visible or active then we have to show/activate the installed
  // tool window. This step has sense only for windows which are not in the auto hide
  // mode. But if tool window was active but its mode doesn't allow to activate it again
  // (for example, tool window is in auto hide mode) then we just activate editor component.

  if (!info.isAutoHide() && (info.isDocked() || info.isFloating())) {
    if (wasActive) {
      activateToolWindowImpl(info.getId(), commandsList, true, true);
    }
    else if (wasVisible) {
      showToolWindowImpl(info.getId(), false, commandsList);
    }
  }

  execute(commandsList);
  fireToolWindowRegistered(id);
  return toolWindow;
}