Java 类com.intellij.ui.content.ContentManagerAdapter 实例源码

项目:intellij-ce-playground    文件:ToggleToolbarAction.java   
private ToggleToolbarAction(@NotNull ToolWindow toolWindow, @NotNull 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 ? PlatformDataKeys.CONTENT_MANAGER.getData((DataProvider)component) : null;
      if (contentManager != null) contentManager.addContentManagerListener(this);
    }
  });
}
项目:intellij-ocaml    文件:OCamlToolWindowComponent.java   
private void registerToolWindowIfNeeded() {
    if (myToolWindowWasRegistered || !toolWindowShouldBeRegistered()) return;

    final ToolWindow toolWindow = myToolWindowManager.registerToolWindow(TOOL_WINDOW_ID, true, ToolWindowAnchor.BOTTOM, false);
    toolWindow.setIcon(OCamlIconUtil.getSmallOCamlIcon());
    toolWindow.setTitle(TOOL_WINDOW_ID);

    myToolWindowWasRegistered = true;

    final ContentManager contentManager = toolWindow.getContentManager();
    contentManager.addContentManagerListener(new ContentManagerAdapter() {
        @Override
        public void contentRemoved(@NotNull final ContentManagerEvent event) {
            if (contentManager.getContentCount() == 0) {
                OCamlToolWindowUtil.addAndSelectStartContent(myProject, contentManager);
            }
        }
    });

    OCamlToolWindowUtil.addAndSelectStartContent(myProject, contentManager);
}
项目:tools-idea    文件:PanelWithActionsAndCloseButton.java   
public PanelWithActionsAndCloseButton(ContentManager contentManager, @NonNls String helpId, final boolean verticalToolbar) {
  super(new BorderLayout());
  myContentManager = contentManager;
  myHelpId = helpId;
  myVerticalToolbar = verticalToolbar;
  myCloseEnabled = true;

  if (myContentManager != null) {
    myContentManager.addContentManagerListener(new ContentManagerAdapter(){
      public void contentRemoved(ContentManagerEvent event) {
        if (event.getContent().getComponent() == PanelWithActionsAndCloseButton.this) {
          dispose();
          myContentManager.removeContentManagerListener(this);
        }
      }
    });
  }

}
项目:tools-idea    文件:LogConsoleManagerBase.java   
private void doAddLogConsole(final LogConsoleBase log,
                             final String id,
                             Icon icon) {
  if (myEnvironment != null && myEnvironment.getRunProfile() instanceof RunConfigurationBase) {
    ((RunConfigurationBase)myEnvironment.getRunProfile()).customizeLogConsole(log);
  }
  log.attachStopLogConsoleTrackingListener(getProcessHandler());
  addAdditionalTabComponent(log, id, icon);

  getUi().addListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(final ContentManagerEvent event) {
      log.activate();
    }
  }, log);
}
项目:consulo    文件:ToggleToolbarAction.java   
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);
    }
  });
}
项目:consulo    文件:XDebugSessionTab.java   
private XDebugSessionTab(@Nonnull XDebugSessionImpl session, @Nullable Icon 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();
}
项目:intellij-ce-playground    文件:ProjectViewImpl.java   
public synchronized void setupImpl(@NotNull 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(new Runnable() {
    @Override
    public void run() {
      splitterProportions.restoreSplitterProportions(myPanel);
    }
  });

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

  myContentManager.addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
        viewSelectionChanged();
      }
    }
  });
  viewSelectionChanged();
}
项目:intellij-ce-playground    文件:LogConsoleManagerBase.java   
private void doAddLogConsole(@NotNull final LogConsoleBase log, String id,  Icon 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);
}
项目:intellij-ce-playground    文件:CvsTabbedWindow.java   
public CvsTabbedWindow(Project project) {
  myProject = project;
  Disposer.register(project, this);
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      final ToolWindow toolWindow = getToolWindow();
      final ContentManager contentManager = toolWindow.getContentManager();
      contentManager.addContentManagerListener(new ContentManagerAdapter() {
        public void contentRemoved(ContentManagerEvent event) {
          final JComponent component = event.getContent().getComponent();
          final JComponent removedComponent = component instanceof CvsTabbedWindowComponent ?
                                              ((CvsTabbedWindowComponent)component).getComponent() : component;
          if (removedComponent == myErrorsView) {
            myErrorsView.dispose();
            myErrorsView = null;
          }
          else if (myOutput != null && removedComponent == myOutput.getComponent()) {
            EditorFactory.getInstance().releaseEditor(myOutput);
            myOutput = null;
          }
        }
      });
      toolWindow.installWatcher(contentManager);
    }
  });
}
项目:consulo    文件:ProjectViewImpl.java   
@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();
}
项目:consulo    文件:LogConsoleManagerBase.java   
private void doAddLogConsole(@Nonnull final LogConsoleBase log, String id, Icon 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);
}
项目:intellij-ce-playground    文件:PreviewManagerImpl.java   
protected void checkGlobalState() {
  ToolWindowManagerImpl toolWindowManager = (ToolWindowManagerImpl)ToolWindowManager.getInstance(myProject);
  if (!isAvailable() && toolWindowManager.getToolWindow(ToolWindowId.PREVIEW) != null) {
    myHistory.clear();
    myContentManager.removeAllContents(true);
    toolWindowManager.unregisterToolWindow(ToolWindowId.PREVIEW);
    return;
  }
  if (isAvailable() && toolWindowManager.getToolWindow(ToolWindowId.PREVIEW) == null) {
    myToolWindow = (ToolWindowImpl)toolWindowManager
      .registerToolWindow(ToolWindowId.PREVIEW, myEmptyStatePanel, ToolWindowAnchor.RIGHT, myProject, false);
    myContentManager = myToolWindow.getContentManager();
    myToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowPreview);
    myToolWindow.setContentUiType(ToolWindowContentUiType.COMBO, null);
    myToolWindow.setAutoHide(true);
    myEmptyStateContent = myContentManager.getContent(0);
    final MoveToStandardViewAction moveToStandardViewAction = new MoveToStandardViewAction();
    myContentManager.addContentManagerListener(new ContentManagerAdapter() {
      @Override
      public void selectionChanged(ContentManagerEvent event) {
        if (myInnerSelectionChange || event.getOperation() != ContentManagerEvent.ContentOperation.add) return;
        PreviewInfo previewInfo = event.getContent().getUserData(INFO_KEY);
        if (previewInfo != null) {
          preview(previewInfo, false);
          myToolWindow.setTitleActions(previewInfo.supportsStandardPlace() ? moveToStandardViewAction : null);
        }
      }
    });

    moveToStandardViewAction.registerCustomShortcutSet(new ShortcutSet() {
      @NotNull
      @Override
      public Shortcut[] getShortcuts() {
        Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
        return keymap.getShortcuts("ShowContent");
      }
    }, myToolWindow.getComponent());

    myToolWindow.setTitleActions(moveToStandardViewAction);
    ArrayList<AnAction> myGearActions = new ArrayList<AnAction>();
    for (PreviewPanelProvider provider : myProviders) {
      myGearActions.add(new ContentTypeToggleAction(provider));
    }
    myToolWindow.setAdditionalGearActions(new DefaultActionGroup("Preview", myGearActions));
    myToolWindow.activate(new Runnable() {
      @Override
      public void run() {
        myToolWindow.activate(null);
      }
    });
  }
}
项目:railways    文件:RoutesView.java   
/**
 * 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(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);


    ToolWindowManagerEx toolManager = ToolWindowManagerEx.getInstanceEx(myProject);
    toolManager.addToolWindowManagerListener(new ToolWindowManagerAdapter() {

        /**
         * 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);
}