ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / platform / lang-impl / src / com / intellij / ide / hierarchy / HierarchyBrowserManager.java
blobd62524975598b3d8a56aad59bca27e328434193a
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.intellij.ide.hierarchy;
19 import com.intellij.ide.impl.ContentManagerWatcher;
20 import com.intellij.openapi.components.PersistentStateComponent;
21 import com.intellij.openapi.components.ServiceManager;
22 import com.intellij.openapi.components.State;
23 import com.intellij.openapi.components.Storage;
24 import com.intellij.openapi.project.Project;
25 import com.intellij.openapi.util.IconLoader;
26 import com.intellij.openapi.wm.*;
27 import com.intellij.ui.content.ContentManager;
29 @State(
30 name="HierarchyBrowserManager",
31 storages= {
32 @Storage(
33 id="other",
34 file = "$WORKSPACE_FILE$"
37 public final class HierarchyBrowserManager implements PersistentStateComponent<HierarchyBrowserManager.State> {
38 public static class State {
39 public boolean IS_AUTOSCROLL_TO_SOURCE;
40 public boolean SORT_ALPHABETICALLY;
41 public boolean HIDE_CLASSES_WHERE_METHOD_NOT_IMPLEMENTED;
44 private State myState = new State();
46 private final ContentManager myContentManager;
48 public HierarchyBrowserManager(final Project project) {
49 final ToolWindowManager toolWindowManager=ToolWindowManager.getInstance(project);
50 final ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.HIERARCHY, true, ToolWindowAnchor.RIGHT, project);
51 myContentManager = toolWindow.getContentManager();
52 toolWindow.setIcon(IconLoader.getIcon("/general/toolWindowHierarchy.png"));
53 new ContentManagerWatcher(toolWindow,myContentManager);
56 public final ContentManager getContentManager() {
57 return myContentManager;
60 public State getState() {
61 return myState;
64 public void loadState(final State state) {
65 myState = state;
68 public static HierarchyBrowserManager getInstance(final Project project) {
69 return ServiceManager.getService(project, HierarchyBrowserManager.class);