mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] Hide the Branches Panel by default, introduce log quick settings
Motivation: The panel with branch labels and ability to navigate to the selected branch by clicking on it seems to be not designed well enough, especially when there are many local branches, and in the multi-repo case. Introduce "Quick Settings" button at the log toolbar. Add "Show Branches Panel" action there.
This commit is contained in:
@@ -18,4 +18,11 @@ public interface VcsLogSettings {
|
||||
*/
|
||||
int getRecentCommitsCount();
|
||||
|
||||
/**
|
||||
* Checks if the branches panel should be displayed or hidden.
|
||||
*/
|
||||
boolean isShowBranchesPanel();
|
||||
|
||||
void setShowBranchesPanel(boolean show);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,12 @@
|
||||
<actions>
|
||||
<action class="com.intellij.vcs.log.ui.VcsLogCopyHashAction" id="Vcs.Log.CopyHash"
|
||||
icon="AllIcons.Actions.Copy" text="Copy Hash" description="Copy hash value of the selected commit to clipboard" />
|
||||
|
||||
<action class="com.intellij.vcs.log.ui.VcsLogQuickSettingsActions" id="Vcs.Log.QuickSettings"
|
||||
icon="AllIcons.General.Gear" text="Quick Settings" description="Quick Settings" />
|
||||
|
||||
<group id="Vcs.Log.Toolbar">
|
||||
<reference id="Vcs.Log.CopyHash"/>
|
||||
<reference id="Vcs.Log.QuickSettings" />
|
||||
</group>
|
||||
<group id="Vcs.Log.ContextMenu">
|
||||
<reference id="Vcs.Log.CopyHash"/>
|
||||
|
||||
@@ -17,6 +17,7 @@ public class VcsLogSettingsImpl implements VcsLogSettings, PersistentStateCompon
|
||||
|
||||
public static class State {
|
||||
public int RECENT_COMMITS_COUNT = 1000;
|
||||
public boolean SHOW_BRANCHES_PANEL = false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -35,6 +36,16 @@ public class VcsLogSettingsImpl implements VcsLogSettings, PersistentStateCompon
|
||||
return myState.RECENT_COMMITS_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowBranchesPanel() {
|
||||
return myState.SHOW_BRANCHES_PANEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowBranchesPanel(boolean show) {
|
||||
myState.SHOW_BRANCHES_PANEL = show;
|
||||
}
|
||||
|
||||
public void setRecentCommitsBlockSize(int commitCount) {
|
||||
myState.RECENT_COMMITS_COUNT = commitCount;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.*;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.impl.content.ToolWindowContentUi;
|
||||
import com.intellij.vcs.log.VcsLogSettings;
|
||||
import com.intellij.vcs.log.impl.VcsLogManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class VcsLogQuickSettingsActions extends DumbAwareAction {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
VcsLogSettings settings = ServiceManager.getService(project, VcsLogSettings.class);
|
||||
VcsLogManager logManager = ServiceManager.getService(project, VcsLogManager.class);
|
||||
if (settings == null || logManager == null) {
|
||||
return;
|
||||
}
|
||||
VcsLogUI logUi = logManager.getLogUi();
|
||||
|
||||
ActionGroup settingsGroup = new MySettingsActionGroup(settings, logUi);
|
||||
ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ToolWindowContentUi.POPUP_PLACE, settingsGroup);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
InputEvent inputEvent = e.getInputEvent();
|
||||
if (inputEvent instanceof MouseEvent) {
|
||||
x = ((MouseEvent)inputEvent).getX();
|
||||
y = ((MouseEvent)inputEvent).getY();
|
||||
}
|
||||
popupMenu.getComponent().show(inputEvent.getComponent(), x, y);
|
||||
}
|
||||
|
||||
private static class MySettingsActionGroup extends ActionGroup {
|
||||
|
||||
private final VcsLogSettings mySettings;
|
||||
private final VcsLogUI myUi;
|
||||
|
||||
public MySettingsActionGroup(VcsLogSettings settings, VcsLogUI ui) {
|
||||
mySettings = settings;
|
||||
myUi = ui;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
return new AnAction[] {
|
||||
new ToggleAction("Show Branches Panel") {
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return mySettings.isShowBranchesPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
mySettings.setShowBranchesPanel(state);
|
||||
myUi.setBranchesPanelVisible(state);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class VcsLogUI {
|
||||
myColorManager = manager;
|
||||
myUiProperties = uiProperties;
|
||||
myFilterer = new VcsLogFilterer(logDataHolder, this);
|
||||
myMainFrame = new MainFrame(myLogDataHolder, this, project, uiProperties);
|
||||
myMainFrame = new MainFrame(myLogDataHolder, this, project, settings, uiProperties);
|
||||
project.getMessageBus().connect(project).subscribe(VcsLogDataHolder.REFRESH_COMPLETED, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -247,4 +247,8 @@ public class VcsLogUI {
|
||||
ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, task, false, null, this.getMainFrame().getMainComponent());
|
||||
}
|
||||
|
||||
public void setBranchesPanelVisible(boolean visible) {
|
||||
myMainFrame.setBranchesPanelVisible(visible);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBLoadingPanel;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.vcs.log.VcsLogSettings;
|
||||
import com.intellij.vcs.log.data.VcsLogDataHolder;
|
||||
import com.intellij.vcs.log.ui.VcsLogUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,10 +39,16 @@ public class ActiveSurface extends JPanel implements TypeSafeDataProvider {
|
||||
@NotNull private final Splitter myDetailsSplitter;
|
||||
@NotNull private final JBLoadingPanel myChangesLoadingPane;
|
||||
|
||||
ActiveSurface(@NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUI vcsLogUI, @NotNull Project project) {
|
||||
ActiveSurface(@NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUI vcsLogUI,
|
||||
@NotNull VcsLogSettings settings, @NotNull Project project) {
|
||||
myLogDataHolder = logDataHolder;
|
||||
myGraphTable = new VcsLogGraphTable(vcsLogUI, logDataHolder);
|
||||
myBranchesPanel = new BranchesPanel(logDataHolder, vcsLogUI);
|
||||
|
||||
if (!settings.isShowBranchesPanel()) {
|
||||
myBranchesPanel.setVisible(false);
|
||||
}
|
||||
|
||||
myDetailsPanel = new DetailsPanel(logDataHolder, myGraphTable, vcsLogUI.getColorManager());
|
||||
|
||||
final ChangesBrowser changesBrowser = new ChangesBrowser(project, null, Collections.<Change>emptyList(), null, false, false, null,
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.SeparatorComponent;
|
||||
import com.intellij.ui.SeparatorOrientation;
|
||||
import com.intellij.vcs.log.VcsLogSettings;
|
||||
import com.intellij.vcs.log.data.VcsLogDataHolder;
|
||||
import com.intellij.vcs.log.data.VcsLogUiProperties;
|
||||
import com.intellij.vcs.log.ui.VcsLogUI;
|
||||
@@ -33,13 +34,13 @@ public class MainFrame {
|
||||
@NotNull private final VcsLogFilterUi myFilterUi;
|
||||
|
||||
public MainFrame(@NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUI vcsLogUI, @NotNull Project project,
|
||||
@NotNull VcsLogUiProperties uiProperties) {
|
||||
@NotNull VcsLogSettings settings, @NotNull VcsLogUiProperties uiProperties) {
|
||||
myLogDataHolder = logDataHolder;
|
||||
myUI = vcsLogUI;
|
||||
myProject = project;
|
||||
myUiProperties = uiProperties;
|
||||
|
||||
myActiveSurface = new ActiveSurface(logDataHolder, vcsLogUI, project);
|
||||
myActiveSurface = new ActiveSurface(logDataHolder, vcsLogUI, settings, project);
|
||||
myActiveSurface.setupDetailsSplitter(myUiProperties.isShowDetails());
|
||||
|
||||
JComponent toolbar = Box.createHorizontalBox();
|
||||
@@ -135,4 +136,8 @@ public class MainFrame {
|
||||
myActiveSurface.getBranchesPanel().rebuild();
|
||||
}
|
||||
|
||||
public void setBranchesPanelVisible(boolean visible) {
|
||||
myActiveSurface.getBranchesPanel().setVisible(visible);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user