diff --git a/platform/platform-resources/src/idea/VcsActions.xml b/platform/platform-resources/src/idea/VcsActions.xml
index 23f7a4143a55..0a1bab4b9d14 100644
--- a/platform/platform-resources/src/idea/VcsActions.xml
+++ b/platform/platform-resources/src/idea/VcsActions.xml
@@ -379,5 +379,11 @@
+
+
+
+
+
+
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java
index 7d4d84648486..fbde51eb3117 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesViewContentManager.java
@@ -228,14 +228,20 @@ public class ChangesViewContentManager extends AbstractProjectComponent implemen
return null;
}
- public boolean isContentSelected(final Content content) {
- return Comparing.equal(content, myContentManager.getSelectedContent());
+ public boolean isContentSelected(@NotNull String contentName) {
+ Content selectedContent = myContentManager.getSelectedContent();
+ if (selectedContent == null) return false;
+ return Comparing.equal(contentName, selectedContent.getTabName());
}
- public void selectContent(final String tabName) {
+ public void selectContent(@NotNull String tabName) {
+ selectContent(tabName, false);
+ }
+
+ public void selectContent(@NotNull String tabName, boolean requestFocus) {
for(Content content: myContentManager.getContents()) {
if (content.getDisplayName().equals(tabName)) {
- myContentManager.setSelectedContent(content);
+ myContentManager.setSelectedContent(content, requestFocus);
break;
}
}
diff --git a/platform/vcs-impl/src/com/intellij/vcs/VcsShowLocalChangesAction.java b/platform/vcs-impl/src/com/intellij/vcs/VcsShowLocalChangesAction.java
new file mode 100644
index 000000000000..d8573dc3356d
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/vcs/VcsShowLocalChangesAction.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs;
+
+import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
+import org.jetbrains.annotations.NotNull;
+
+public class VcsShowLocalChangesAction extends VcsShowToolWindowTabAction {
+ @NotNull
+ @Override
+ protected String getTabName() {
+ return ChangesViewContentManager.LOCAL_CHANGES;
+ }
+}
diff --git a/platform/vcs-impl/src/com/intellij/vcs/VcsShowShelfAction.java b/platform/vcs-impl/src/com/intellij/vcs/VcsShowShelfAction.java
new file mode 100644
index 000000000000..4e33fbea7dcd
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/vcs/VcsShowShelfAction.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs;
+
+import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
+import org.jetbrains.annotations.NotNull;
+
+public class VcsShowShelfAction extends VcsShowToolWindowTabAction {
+ @NotNull
+ @Override
+ protected String getTabName() {
+ return ChangesViewContentManager.SHELF;
+ }
+}
+
diff --git a/platform/vcs-impl/src/com/intellij/vcs/VcsShowToolWindowTabAction.java b/platform/vcs-impl/src/com/intellij/vcs/VcsShowToolWindowTabAction.java
new file mode 100644
index 000000000000..0dd8059a08b8
--- /dev/null
+++ b/platform/vcs-impl/src/com/intellij/vcs/VcsShowToolWindowTabAction.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs;
+
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.project.DumbAwareAction;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
+import com.intellij.openapi.wm.IdeFocusManager;
+import com.intellij.openapi.wm.ToolWindow;
+import com.intellij.openapi.wm.ToolWindowManager;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static com.intellij.util.ObjectUtils.assertNotNull;
+
+public abstract class VcsShowToolWindowTabAction extends DumbAwareAction {
+
+ @Override
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
+ ToolWindow toolWindow = assertNotNull(getToolWindow(project));
+ final ChangesViewContentManager changesViewContentManager = (ChangesViewContentManager)ChangesViewContentManager.getInstance(project);
+ final String tabName = getTabName();
+
+ if (toolWindow.isActive() && changesViewContentManager.isContentSelected(tabName)) {
+ toolWindow.hide(null);
+ }
+ else {
+ toolWindow.activate(new Runnable() {
+ @Override
+ public void run() {
+ IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(new Runnable() {
+ @Override
+ public void run() {
+ changesViewContentManager.selectContent(tabName, true);
+ }
+ });
+ }
+ }, true, true);
+ }
+ }
+
+ @Nullable
+ private static ToolWindow getToolWindow(@Nullable Project project) {
+ if (project == null) return null;
+ return ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
+ }
+
+ @Override
+ public void update(@NotNull AnActionEvent e) {
+ super.update(e);
+ e.getPresentation().setEnabledAndVisible(getToolWindow(e.getProject()) != null);
+ }
+
+ @NotNull
+ protected abstract String getTabName();
+}
diff --git a/platform/vcs-log/impl/src/META-INF/vcs-log.xml b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
index 0911d8aeb864..dd403347f8ac 100644
--- a/platform/vcs-log/impl/src/META-INF/vcs-log.xml
+++ b/platform/vcs-log/impl/src/META-INF/vcs-log.xml
@@ -28,6 +28,9 @@
+
+
+
diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/VcsShowLogAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/VcsShowLogAction.java
new file mode 100644
index 000000000000..46b9f5911680
--- /dev/null
+++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/VcsShowLogAction.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.vcs.log.ui.actions;
+
+import com.intellij.vcs.VcsShowToolWindowTabAction;
+import com.intellij.vcs.log.impl.VcsLogContentProvider;
+import org.jetbrains.annotations.NotNull;
+
+public class VcsShowLogAction extends VcsShowToolWindowTabAction {
+ @NotNull
+ @Override
+ protected String getTabName() {
+ return VcsLogContentProvider.TAB_NAME;
+ }
+}
+