com.intellij.ui.content.ContentManagerAdapter Java Examples

The following examples show how to use com.intellij.ui.content.ContentManagerAdapter. 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: 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 #3
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 #4
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 #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: 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 #7
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 #8
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);
}