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.
16 package org
.jetbrains
.idea
.svn
.actions
;
18 import com
.intellij
.CommonBundle
;
19 import com
.intellij
.openapi
.Disposable
;
20 import com
.intellij
.openapi
.actionSystem
.AnAction
;
21 import com
.intellij
.openapi
.actionSystem
.AnActionEvent
;
22 import com
.intellij
.openapi
.actionSystem
.PlatformDataKeys
;
23 import com
.intellij
.openapi
.help
.HelpManager
;
24 import com
.intellij
.openapi
.project
.Project
;
25 import com
.intellij
.openapi
.project
.ProjectManager
;
26 import com
.intellij
.openapi
.util
.IconLoader
;
27 import com
.intellij
.openapi
.wm
.ToolWindow
;
28 import com
.intellij
.openapi
.wm
.ToolWindowAnchor
;
29 import com
.intellij
.openapi
.wm
.ToolWindowManager
;
30 import com
.intellij
.ui
.content
.Content
;
31 import com
.intellij
.ui
.content
.ContentFactory
;
32 import org
.jetbrains
.idea
.svn
.dialogs
.RepositoryBrowserDialog
;
37 public class BrowseRepositoryAction
extends AnAction
{
38 public static final String REPOSITORY_BROWSER_TOOLWINDOW
= "SVN Repositories";
40 public void actionPerformed(AnActionEvent e
) {
41 Project project
= e
.getData(PlatformDataKeys
.PROJECT
);
42 if (project
== null) {
43 RepositoryBrowserDialog dialog
= new RepositoryBrowserDialog(ProjectManager
.getInstance().getDefaultProject());
47 ToolWindowManager manager
= ToolWindowManager
.getInstance(project
);
48 ToolWindow w
= manager
.getToolWindow(REPOSITORY_BROWSER_TOOLWINDOW
);
50 RepositoryToolWindowPanel component
= new RepositoryToolWindowPanel(project
);
51 w
= manager
.registerToolWindow(REPOSITORY_BROWSER_TOOLWINDOW
, true, ToolWindowAnchor
.BOTTOM
);
52 final Content content
= ContentFactory
.SERVICE
.getInstance().createContent(component
, "", false);
53 content
.setDisposer(component
);
54 w
.getContentManager().addContent(content
);
61 private static class RepositoryToolWindowPanel
extends JPanel
implements Disposable
{
62 private final RepositoryBrowserDialog myDialog
;
63 private final Project myProject
;
65 private RepositoryToolWindowPanel(final Project project
) {
66 super(new BorderLayout());
69 myDialog
= new RepositoryBrowserDialog(project
);
70 JComponent component
= myDialog
.createBrowserComponent(true);
72 add(component
, BorderLayout
.CENTER
);
73 add(myDialog
.createToolbar(false, new HelpAction()), BorderLayout
.WEST
);
76 public void dispose() {
77 myDialog
.disposeRepositoryBrowser();
78 ToolWindowManager
.getInstance(myProject
).unregisterToolWindow(BrowseRepositoryAction
.REPOSITORY_BROWSER_TOOLWINDOW
);
81 private class HelpAction
extends AnAction
{
83 super(CommonBundle
.getHelpButtonText(), null, IconLoader
.getIcon("/actions/help.png"));
86 public void actionPerformed(AnActionEvent e
) {
87 HelpManager
.getInstance().invokeHelp("reference.svn.repository");