mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] refresh and open another log tab actions work for correct log manager instance
This commit is contained in:
@@ -33,6 +33,7 @@ import com.intellij.util.ContentsUtil;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.vcs.log.ui.VcsLogPanel;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -85,8 +86,7 @@ public class VcsLogContentProvider implements ChangesViewContentProvider {
|
||||
myLogManager.disposeLog();
|
||||
}
|
||||
|
||||
public static void openAnotherLogTab(@NotNull Project project) {
|
||||
VcsLogProjectManager logManager = VcsLogProjectManager.getInstance(project);
|
||||
public static void openAnotherLogTab(@NotNull VcsLogManager logManager, @NotNull Project project) {
|
||||
ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.VCS);
|
||||
|
||||
String shortName = generateShortName(toolWindow);
|
||||
@@ -111,14 +111,14 @@ public class VcsLogContentProvider implements ChangesViewContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addLogTab(@NotNull VcsLogProjectManager logManager,
|
||||
private static void addLogTab(@NotNull VcsLogManager logManager,
|
||||
@NotNull ToolWindow toolWindow,
|
||||
@NotNull VcsLogUiImpl logUi,
|
||||
@NotNull String shortName) {
|
||||
logManager.watchTab(ContentUtilEx.getFullName(TAB_NAME, shortName), logUi);
|
||||
logUi.requestFocus();
|
||||
ContentUtilEx
|
||||
.addTabbedContent(toolWindow.getContentManager(), logUi.getMainFrame().getMainComponent(), TAB_NAME, shortName, true, logUi);
|
||||
.addTabbedContent(toolWindow.getContentManager(), new VcsLogPanel(logManager, logUi), TAB_NAME, shortName, true, logUi);
|
||||
toolWindow.activate(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.VcsRoot;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -40,12 +39,12 @@ import com.intellij.vcs.log.data.VcsLogTabsProperties;
|
||||
import com.intellij.vcs.log.data.VcsLogUiProperties;
|
||||
import com.intellij.vcs.log.graph.PermanentGraph;
|
||||
import com.intellij.vcs.log.ui.VcsLogColorManagerImpl;
|
||||
import com.intellij.vcs.log.ui.VcsLogPanel;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -105,7 +104,7 @@ public class VcsLogManager implements Disposable {
|
||||
watch(myUi);
|
||||
}
|
||||
myUi.requestFocus();
|
||||
return myUi.getMainFrame().getMainComponent();
|
||||
return new VcsLogPanel(this, myUi);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -51,22 +51,12 @@ public class VcsLogProjectManager {
|
||||
return Arrays.asList(ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots());
|
||||
}
|
||||
|
||||
public void watchTab(@NotNull String contentTabName, @NotNull VcsLogUiImpl logUi) {
|
||||
myLogManager.watchTab(contentTabName, logUi);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent initMainLog(@NotNull String contentTabName) {
|
||||
initData();
|
||||
return myLogManager.initMainLog(contentTabName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public VcsLogUiImpl createLog(@NotNull String logId) {
|
||||
initData();
|
||||
return myLogManager.createLog(logId);
|
||||
}
|
||||
|
||||
public boolean initData() {
|
||||
if (myLogManager != null) return true;
|
||||
myLogManager = new VcsLogManager(myProject, myUiProperties, getVcsRoots());
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.vcs.log.impl.VcsLogManager;
|
||||
|
||||
public class VcsLogDataKeys {
|
||||
public static final DataKey<VcsLogManager> LOG_MANAGER = DataKey.create("Vcs.Log.Manager");
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.ui.components.JBPanel;
|
||||
import com.intellij.vcs.log.impl.VcsLogManager;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class VcsLogPanel extends JBPanel implements DataProvider {
|
||||
@NotNull private final VcsLogManager myManager;
|
||||
|
||||
public VcsLogPanel(@NotNull VcsLogManager manager, @NotNull VcsLogUiImpl logUi) {
|
||||
super(new BorderLayout());
|
||||
myManager = manager;
|
||||
add(logUi.getMainFrame().getMainComponent(), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (VcsLogDataKeys.LOG_MANAGER.is(dataId)) {
|
||||
return myManager;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+11
-10
@@ -17,11 +17,14 @@ package com.intellij.vcs.log.ui.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
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.util.registry.Registry;
|
||||
import com.intellij.vcs.log.impl.VcsLogContentProvider;
|
||||
import com.intellij.vcs.log.impl.VcsLogManager;
|
||||
import com.intellij.vcs.log.impl.VcsLogProjectManager;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiImpl;
|
||||
import com.intellij.vcs.log.ui.VcsLogDataKeys;
|
||||
|
||||
public class OpenAnotherLogTabAction extends DumbAwareAction {
|
||||
protected OpenAnotherLogTabAction() {
|
||||
@@ -30,21 +33,19 @@ public class OpenAnotherLogTabAction extends DumbAwareAction {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
if (e.getProject() == null || !Registry.is("vcs.log.open.another.log.visible")) {
|
||||
Project project = e.getProject();
|
||||
if (project == null || !Registry.is("vcs.log.open.another.log.visible")) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
VcsLogUiImpl mainLogUi = VcsLogProjectManager.getInstance(e.getProject()).getMainLogUi();
|
||||
if (mainLogUi == null) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
e.getPresentation().setEnabledAndVisible(true);
|
||||
VcsLogProjectManager logProjectManager = VcsLogProjectManager.getInstance(project);
|
||||
VcsLogManager logManager = e.getData(VcsLogDataKeys.LOG_MANAGER);
|
||||
e.getPresentation()
|
||||
.setEnabledAndVisible(logManager != null && logProjectManager.getLogManager() == logManager); // only for main log (it is a question, how and where we want to open tabs for external logs)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
VcsLogContentProvider.openAnotherLogTab(e.getProject());
|
||||
VcsLogContentProvider.openAnotherLogTab(e.getRequiredData(VcsLogDataKeys.LOG_MANAGER), e.getRequiredData(CommonDataKeys.PROJECT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@ package com.intellij.vcs.log.ui.actions;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.actions.RefreshAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.vcs.log.VcsLogDataKeys;
|
||||
import com.intellij.vcs.log.data.VcsLogDataManager;
|
||||
import com.intellij.vcs.log.impl.VcsLogProjectManager;
|
||||
import com.intellij.vcs.log.impl.VcsLogManager;
|
||||
import com.intellij.vcs.log.ui.VcsLogDataKeys;
|
||||
|
||||
public class RefreshLogAction extends RefreshAction {
|
||||
public RefreshLogAction() {
|
||||
@@ -31,20 +28,13 @@ public class RefreshLogAction extends RefreshAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
|
||||
VcsLogProjectManager.getInstance(project).getDataManager().refreshCompletely();
|
||||
VcsLogManager logManager = e.getRequiredData(VcsLogDataKeys.LOG_MANAGER);
|
||||
logManager.getDataManager().refreshCompletely();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (project == null) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
}
|
||||
else {
|
||||
VcsLogProjectManager projectManager = VcsLogProjectManager.getInstance(project);
|
||||
VcsLogDataManager dataManager = projectManager.getDataManager();
|
||||
e.getPresentation().setEnabledAndVisible(dataManager != null && e.getData(VcsLogDataKeys.VCS_LOG_UI) != null);
|
||||
}
|
||||
VcsLogManager logManager = e.getData(VcsLogDataKeys.LOG_MANAGER);
|
||||
e.getPresentation().setEnabledAndVisible(logManager != null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user