com.intellij.ui.content.ContentManagerEvent Java Examples

The following examples show how to use com.intellij.ui.content.ContentManagerEvent. 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: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void listenForRenderTreeActivations(@NotNull ToolWindow toolWindow) {
  final ContentManager contentManager = toolWindow.getContentManager();
  contentManager.addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(@NotNull ContentManagerEvent event) {
      final ContentManagerEvent.ContentOperation operation = event.getOperation();
      if (operation == ContentManagerEvent.ContentOperation.add) {
        final String name = event.getContent().getTabName();
        if (Objects.equals(name, RENDER_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "renderTreeSelected");
        }
        else if (Objects.equals(name, WIDGET_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "widgetTreeSelected");
        }
      }
    }
  });
}
 
Example #2
Source File: VcsDockedComponent.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
private VcsDockedComponent(final Project project) {
    this.project = project;
    ApplicationManager.getApplication().invokeLater(() -> {
        if (project.isDisposed()) {
            return;
        }
        final ToolWindow toolWindow = getToolWindow();
        if (toolWindow == null) {
            // can happen if the project isn't fully initialized yet
            return;
        }
        final ContentManager contentManager = toolWindow.getContentManager();
        contentManager.addContentManagerListener(new ContentManagerAdapter() {
            @Override
            public void contentRemoved(ContentManagerEvent event) {
                final JComponent component = event.getContent().getComponent();
                if (component instanceof Disposable) {
                    Disposer.dispose((Disposable) component);
                }
            }
        });
        toolWindow.installWatcher(contentManager);
    });
}
 
Example #3
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void listenForRenderTreeActivations(@NotNull ToolWindow toolWindow) {
  final ContentManager contentManager = toolWindow.getContentManager();
  contentManager.addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(@NotNull ContentManagerEvent event) {
      final ContentManagerEvent.ContentOperation operation = event.getOperation();
      if (operation == ContentManagerEvent.ContentOperation.add) {
        final String name = event.getContent().getTabName();
        if (Objects.equals(name, RENDER_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "renderTreeSelected");
        }
        else if (Objects.equals(name, WIDGET_TAB_LABEL)) {
          FlutterInitializer.getAnalytics().sendEvent("inspector", "widgetTreeSelected");
        }
      }
    }
  });
}
 
Example #4
Source File: TabContentLayout.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void contentAdded(ContentManagerEvent event) {
  final Content content = event.getContent();
  final ContentTabLabel tab;
  if (content instanceof TabbedContent) {
    tab = new TabbedContentTabLabel((TabbedContent)content, this);
  }
  else {
    tab = new ContentTabLabel(content, this);
  }
  myTabs.add(event.getIndex(), tab);
  myContent2Tabs.put(content, tab);
  if (content instanceof DnDTarget) {
    DnDTarget target = (DnDTarget)content;
    DnDSupport.createBuilder(tab).setDropHandler(target).setTargetChecker(target).setCleanUpOnLeaveCallback(target::cleanUpOnLeave).install();
  }
}
 
Example #5
Source File: XDebugSessionTab.java    From consulo with Apache License 2.0 6 votes vote down vote up
private XDebugSessionTab(@Nonnull XDebugSessionImpl session, @Nullable Image icon, @Nullable ExecutionEnvironment environment) {
  super(session.getProject(), "Debug", session.getSessionName(), GlobalSearchScope.allScope(session.getProject()));

  setSession(session, environment, icon);

  myUi.addContent(createFramesContent(), 0, PlaceInGrid.left, false);
  addVariablesAndWatches(session);

  attachToSession(session);

  DefaultActionGroup focus = new DefaultActionGroup();
  focus.add(ActionManager.getInstance().getAction(XDebuggerActions.FOCUS_ON_BREAKPOINT));
  myUi.getOptions().setAdditionalFocusActions(focus);

  myUi.addListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      Content content = event.getContent();
      if (mySession != null && content.isSelected() && getWatchesContentId().equals(ViewImpl.ID.get(content))) {
        myRebuildWatchesRunnable.run();
      }
    }
  }, myRunContentDescriptor);

  rebuildViews();
}
 
Example #6
Source File: ToggleToolbarAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private ToggleToolbarAction(@Nonnull ToolWindow toolWindow, @Nonnull PropertiesComponent propertiesComponent) {
  super("Show Toolbar");
  myPropertiesComponent = propertiesComponent;
  myToolWindow = toolWindow;
  myToolWindow.getContentManager().addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void contentAdded(ContentManagerEvent event) {
      JComponent component = event.getContent().getComponent();
      setContentToolbarVisible(component, getVisibilityValue());

      // support nested content managers, e.g. RunnerLayoutUi as content component
      ContentManager contentManager =
              component instanceof DataProvider ? ((DataProvider)component).getDataUnchecked(PlatformDataKeys.CONTENT_MANAGER) : null;
      if (contentManager != null) contentManager.addContentManagerListener(this);
    }
  });
}
 
Example #7
Source File: TabContentLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void contentRemoved(ContentManagerEvent event) {
  final ContentTabLabel tab = myContent2Tabs.get(event.getContent());
  if (tab != null) {
    myTabs.remove(tab);
    myContent2Tabs.remove(event.getContent());
  }
}
 
Example #8
Source File: TabContentLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void init() {
  reset();

  myIdLabel = new BaseLabel(myUi, false);

  for (int i = 0; i < myUi.myManager.getContentCount(); i++) {
    contentAdded(new ContentManagerEvent(this, myUi.myManager.getContent(i), i));
  }
}
 
Example #9
Source File: LogConsoleManagerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void doAddLogConsole(@Nonnull final LogConsoleBase log, String id, Image icon, @Nullable RunProfile runProfile) {
  if (runProfile instanceof RunConfigurationBase) {
    ((RunConfigurationBase)runProfile).customizeLogConsole(log);
  }
  log.attachStopLogConsoleTrackingListener(getProcessHandler());
  addAdditionalTabComponent(log, id, icon);

  getUi().addListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(final ContentManagerEvent event) {
      log.activate();
    }
  }, log);
}
 
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: VcsLogTabsWatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void contentRemoved(ContentManagerEvent event) {
  Content content = event.getContent();
  if (content instanceof TabbedContent) {
    content.removePropertyChangeListener(this);
  }
}
 
Example #12
Source File: VcsLogTabsWatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void contentAdded(ContentManagerEvent event) {
  Content content = event.getContent();
  if (content instanceof TabbedContent) {
    content.addPropertyChangeListener(this);
  }
}
 
Example #13
Source File: ToolWindowHeadlessManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setSelectedContent(@Nonnull final Content content) {
  if (mySelected != null) {
    removeFromSelection(mySelected);
  }
  mySelected = content;
  ContentManagerEvent e = new ContentManagerEvent(this, content, myContents.indexOf(content), ContentManagerEvent.ContentOperation.add);
  myDispatcher.getMulticaster().selectionChanged(e);
}
 
Example #14
Source File: ToolWindowHeadlessManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean removeContent(@Nonnull final Content content, final boolean dispose) {
  boolean wasSelected = mySelected == content;
  int oldIndex = myContents.indexOf(content);
  if (wasSelected) {
    removeFromSelection(content);
  }
  boolean result = myContents.remove(content);
  if (dispose) Disposer.dispose(content);
  ContentManagerEvent e = new ContentManagerEvent(this, content, oldIndex, ContentManagerEvent.ContentOperation.remove);
  myDispatcher.getMulticaster().contentRemoved(e);
  Content item = ContainerUtil.getFirstItem(myContents);
  if (item != null) setSelectedContent(item);
  return result;
}
 
Example #15
Source File: ToolWindowHeadlessManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void addContent(@Nonnull Content content, int order) {
  myContents.add(order, content);
  Disposer.register(this, content);
  ContentManagerEvent e = new ContentManagerEvent(this, content, myContents.indexOf(content), ContentManagerEvent.ContentOperation.add);
  myDispatcher.getMulticaster().contentAdded(e);
  if (mySelected == null) setSelectedContent(content);
}
 
Example #16
Source File: ToolWindowHeadlessManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void addContent(@Nonnull final Content content) {
  myContents.add(content);
  Disposer.register(this, content);
  ContentManagerEvent e = new ContentManagerEvent(this, content, myContents.indexOf(content), ContentManagerEvent.ContentOperation.add);
  myDispatcher.getMulticaster().contentAdded(e);
  if (mySelected == null) setSelectedContent(content);
}
 
Example #17
Source File: VcsLogTabsWatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void selectionChanged(ContentManagerEvent event) {
  if (ContentManagerEvent.ContentOperation.add.equals(event.getOperation())) {
    selectionChanged(event.getContent().getTabName());
  }
}
 
Example #18
Source File: ToolWindowHeadlessManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void removeFromSelection(@Nonnull final Content content) {
  ContentManagerEvent e = new ContentManagerEvent(this, content, myContents.indexOf(mySelected), ContentManagerEvent.ContentOperation.remove);
  myDispatcher.getMulticaster().selectionChanged(e);
}
 
Example #19
Source File: ComboContentLayout.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void contentAdded(ContentManagerEvent event) {
}
 
Example #20
Source File: ComboContentLayout.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void contentRemoved(ContentManagerEvent event) {
}
 
Example #21
Source File: RoutesView.java    From railways with MIT License 4 votes vote down vote up
/**
 * Initializes tool window.
 *
 * @param toolWindow Tool window to initialize.
 */
synchronized void initToolWindow(final ToolWindow toolWindow) {
    myToolWindow = toolWindow;
    myContentManager = toolWindow.getContentManager();

    if (!ApplicationManager.getApplication().isUnitTestMode()) {
        toolWindow.setContentUiType(ToolWindowContentUiType.getInstance("combo"), null);
        toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
    }

    // Add all modules that are already added till this moment.
    Module[] modules = ModuleManager.getInstance(myProject).getModules();
    for (Module m : modules)
        addModulePane(m);

    // Add listener to update mainPanel when a module is selected from
    // tool window header.
    myContentManager.addContentManagerListener(new ContentManagerAdapter() {
        @Override
        public void selectionChanged(@NotNull ContentManagerEvent event) {
            // When user selects a module from tool window combo,
            // selectionChanges is called twice:
            // 1. With 'remove' operation -  for previously selected item,
            // 2. With 'add' operation - for newly selected item.
            if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
                viewSelectionChanged();
                refreshRouteActionsStatus();
            }
        }
    });


    // Open tab that was active in previous IDE session
    Content savedContent = myContentManager.getContent(myState.selectedTabId);
    if (savedContent != null)
        myContentManager.setSelectedContent(savedContent);

    mainPanel.getRouteFilter().setMountedRoutesVisible(!myState.hideMountedRoutes);

    myConnection.subscribe(ToolWindowManagerListener.TOPIC, new ToolWindowManagerListener() {

        /**
         * This method is called when ToolWindow changes its state, i.e.
         * expanded/collapsed, docked to another panel, etc.
         */
        @Override
        public void stateChanged() {
            // We have to check if our tool window is still registered, as
            // otherwise it will raise an exception when project is closed.
            if (ToolWindowManagerEx.getInstanceEx(myProject).getToolWindow("Routes") == null)
                return;

            updateToolWindowOrientation(toolWindow);

            if (toolWindow.isVisible())
                if (currentPane != null && currentPane.isRoutesInvalidated())
                    currentPane.updateRoutes();

            refreshRouteActionsStatus();
        }
    });

    updateToolWindowOrientation(toolWindow);
}
 
Example #22
Source File: UnifiedContentLayout.java    From consulo with Apache License 2.0 2 votes vote down vote up
public void contentAdded(ContentManagerEvent event) {

  }
 
Example #23
Source File: UnifiedContentLayout.java    From consulo with Apache License 2.0 2 votes vote down vote up
public void contentRemoved(ContentManagerEvent event) {

  }
 
Example #24
Source File: ContentLayout.java    From consulo with Apache License 2.0 votes vote down vote up
public abstract void contentAdded(ContentManagerEvent event); 
Example #25
Source File: ContentLayout.java    From consulo with Apache License 2.0 votes vote down vote up
public abstract void contentRemoved(ContentManagerEvent event);