mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] no more branches panel
This commit is contained in:
@@ -270,8 +270,6 @@ vcs.log.bek.sort.disabled=false
|
||||
vcs.log.bek.sort.disabled.description=Disable IntelliSort
|
||||
vcs.log.linear.bek.sort=false
|
||||
vcs.log.linear.bek.sort.description=Third kind of IntelliSort that simplifies merges and tries to show history as linear
|
||||
vcs.log.square.labels=false
|
||||
vcs.log.square.labels.description=Square shape of labels for branches and tags
|
||||
vcs.log.recent.commits.count=1000
|
||||
vcs.log.recent.commits.count.description=Before full log is loaded (which can take some time), a number of recent commits is loaded to show quickly
|
||||
vcs.log.open.another.log.visible=false
|
||||
|
||||
@@ -30,10 +30,6 @@ public interface VcsLogUi {
|
||||
|
||||
void removeLogListener(@NotNull VcsLogListener listener);
|
||||
|
||||
void setBranchesPanelVisible(boolean visible);
|
||||
|
||||
boolean isBranchesPanelVisible();
|
||||
|
||||
boolean areGraphActionsEnabled();
|
||||
|
||||
boolean isMultipleRoots();
|
||||
|
||||
@@ -49,8 +49,4 @@ public interface VcsLogUiProperties {
|
||||
boolean isHighlighterEnabled(@NotNull String id);
|
||||
|
||||
void enableHighlighter(@NotNull String id, boolean value);
|
||||
|
||||
boolean isShowBranchesPanel();
|
||||
|
||||
void setShowBranchesPanel(boolean show);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public abstract class VcsLogUiPropertiesImpl implements PersistentStateComponent
|
||||
|
||||
public static class State {
|
||||
public boolean SHOW_DETAILS = true;
|
||||
public boolean SHOW_BRANCHES_PANEL = false;
|
||||
public boolean LONG_EDGES_VISIBLE = false;
|
||||
public int BEK_SORT_TYPE = 0;
|
||||
public boolean SHOW_ROOT_NAMES = false;
|
||||
@@ -136,16 +135,6 @@ public abstract class VcsLogUiPropertiesImpl implements PersistentStateComponent
|
||||
getState().HIGHLIGHTERS.put(id, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowBranchesPanel() {
|
||||
return getState().SHOW_BRANCHES_PANEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShowBranchesPanel(boolean show) {
|
||||
getState().SHOW_BRANCHES_PANEL = show;
|
||||
}
|
||||
|
||||
public static class UserGroup {
|
||||
public List<String> users = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ public class VcsLogFeaturesCollector extends AbstractApplicationUsagesCollector
|
||||
VcsLogUiImpl ui = projectLog.getMainLogUi();
|
||||
if (ui != null) {
|
||||
Set<UsageDescriptor> usages = ContainerUtil.newHashSet();
|
||||
usages.add(StatisticsUtilKt.getBooleanUsage("ui.branches.panel", ui.isBranchesPanelVisible()));
|
||||
usages.add(StatisticsUtilKt.getBooleanUsage("ui.details", ui.isShowDetails()));
|
||||
usages.add(StatisticsUtilKt.getBooleanUsage("ui.long.edges", ui.areLongEdgesVisible()));
|
||||
|
||||
|
||||
@@ -258,7 +258,6 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
public void applyFiltersAndUpdateUi() {
|
||||
VcsLogFilterCollection filters = myMainFrame.getFilterUi().getFilters();
|
||||
myFilterer.onFiltersChange(filters);
|
||||
myMainFrame.onFiltersChange(filters);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -276,17 +275,6 @@ public class VcsLogUiImpl implements VcsLogUi, Disposable {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBranchesPanelVisible(boolean visible) {
|
||||
myMainFrame.setBranchesPanelVisible(visible);
|
||||
myUiProperties.setShowBranchesPanel(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBranchesPanelVisible() {
|
||||
return myUiProperties.isShowBranchesPanel();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent getToolbar() {
|
||||
return myMainFrame.getToolbar();
|
||||
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.vcs.log.VcsLogDataKeys;
|
||||
import com.intellij.vcs.log.VcsLogUi;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ShowBranchesPanelAction extends ToggleAction implements DumbAware {
|
||||
|
||||
public ShowBranchesPanelAction() {
|
||||
super("Show Branches Panel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
|
||||
e.getPresentation().setEnabledAndVisible(ui != null);
|
||||
super.update(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(@NotNull AnActionEvent e) {
|
||||
VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
|
||||
return ui != null && ui.isBranchesPanelVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(@NotNull AnActionEvent e, boolean state) {
|
||||
VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
|
||||
if (ui != null) {
|
||||
ui.setBranchesPanelVisible(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.RefGroup;
|
||||
import com.intellij.vcs.log.VcsLogFilterCollection;
|
||||
import com.intellij.vcs.log.VcsLogRefs;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import com.intellij.vcs.log.data.VcsLogData;
|
||||
import com.intellij.vcs.log.data.VisiblePack;
|
||||
import com.intellij.vcs.log.impl.SingletonRefGroup;
|
||||
import com.intellij.vcs.log.impl.VcsLogUtil;
|
||||
import com.intellij.vcs.log.ui.VcsLogColorManagerImpl;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiImpl;
|
||||
import com.intellij.vcs.log.ui.render.VcsRefPainter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Panel with branch labels, above the graph.
|
||||
*/
|
||||
public class BranchesPanel extends JPanel {
|
||||
private static final int SMALL_ROOTS_GAP = 3;
|
||||
private static final int BIG_ROOTS_GAP = 7;
|
||||
private static final int TOP = 2;
|
||||
private static final int BOTTOM = 3;
|
||||
@NotNull private final VcsLogData myLogData;
|
||||
@NotNull private final VcsLogUiImpl myUi;
|
||||
@NotNull private final VcsRefPainter myReferencePainter;
|
||||
@NotNull private final JBScrollPane myScrollPane;
|
||||
|
||||
@NotNull private LinkedHashMap<VirtualFile, List<RefGroup>> myRefGroups;
|
||||
@Nullable private Collection<VirtualFile> myRoots = null;
|
||||
|
||||
public BranchesPanel(@NotNull VcsLogData logData, @NotNull VcsLogUiImpl ui, @NotNull VcsLogRefs initialRefsModel) {
|
||||
super(new FlowLayout(FlowLayout.LEADING, BIG_ROOTS_GAP - 2 * SMALL_ROOTS_GAP, 0));
|
||||
setBorder(new EmptyBorder(TOP, SMALL_ROOTS_GAP, BOTTOM, SMALL_ROOTS_GAP));
|
||||
|
||||
myLogData = logData;
|
||||
myUi = ui;
|
||||
myRefGroups = getRefsToDisplayOnPanel(initialRefsModel);
|
||||
myReferencePainter = new VcsRefPainter(myUi.getColorManager(), true);
|
||||
myScrollPane =
|
||||
new JBScrollPane(this, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
myScrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0, 0));
|
||||
myScrollPane.getHorizontalScrollBar().setUnitIncrement(10);
|
||||
myScrollPane.setBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
recreateComponents();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent getMainComponent() {
|
||||
return myScrollPane;
|
||||
}
|
||||
|
||||
private void recreateComponents() {
|
||||
for (Map.Entry<VirtualFile, List<RefGroup>> entry : myRefGroups.entrySet()) {
|
||||
if (myRoots == null || myRoots.contains(entry.getKey())) {
|
||||
add(new RootGroupComponent(entry.getValue(), entry.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuild(@NotNull VcsLogRefs refsModel) {
|
||||
myRefGroups = getRefsToDisplayOnPanel(refsModel);
|
||||
removeAll();
|
||||
recreateComponents();
|
||||
getParent().validate();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private LinkedHashMap<VirtualFile, List<RefGroup>> getRefsToDisplayOnPanel(@NotNull VcsLogRefs refsModel) {
|
||||
Collection<VcsRef> allRefs = refsModel.getBranches();
|
||||
|
||||
LinkedHashMap<VirtualFile, List<RefGroup>> groups = ContainerUtil.newLinkedHashMap();
|
||||
for (Map.Entry<VirtualFile, Set<VcsRef>> entry : VcsLogUtil.groupRefsByRoot(allRefs).entrySet()) {
|
||||
groups.put(entry.getKey(),
|
||||
expandExpandableGroups(myLogData.getLogProvider(entry.getKey()).getReferenceManager().group(entry.getValue())));
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<RefGroup> expandExpandableGroups(@NotNull List<RefGroup> refGroups) {
|
||||
List<RefGroup> groups = ContainerUtil.newArrayList();
|
||||
for (RefGroup group : refGroups) {
|
||||
if (group.isExpanded() || group.getRefs().size() == 1) {
|
||||
groups.addAll(ContainerUtil.map(group.getRefs(), (Function<VcsRef, RefGroup>)ref -> new SingletonRefGroup(ref)));
|
||||
}
|
||||
else {
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void onFiltersChange(@NotNull VcsLogFilterCollection filters) {
|
||||
myRoots = VcsLogUtil.getAllVisibleRoots(myLogData.getRoots(), filters.getRootFilter(), filters.getStructureFilter());
|
||||
removeAll();
|
||||
recreateComponents();
|
||||
getParent().validate();
|
||||
}
|
||||
|
||||
public void updateDataPack(@NotNull VisiblePack dataPack, boolean permGraphChanged) {
|
||||
if (permGraphChanged) {
|
||||
rebuild(dataPack.getRefs());
|
||||
}
|
||||
}
|
||||
|
||||
public void setBranchPanelVisible(boolean visible) {
|
||||
myScrollPane.setVisible(visible);
|
||||
}
|
||||
|
||||
private class RootGroupComponent extends JPanel {
|
||||
@NotNull private final List<RefGroup> myGroups;
|
||||
|
||||
private RootGroupComponent(@NotNull List<RefGroup> groups, @NotNull VirtualFile root) {
|
||||
super(new FlowLayout(FlowLayout.LEADING, SMALL_ROOTS_GAP, 0));
|
||||
myGroups = groups;
|
||||
|
||||
for (RefGroup group : myGroups) {
|
||||
add(new ReferenceGroupComponent(group, myReferencePainter, myUi, root));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReferenceGroupComponent extends JPanel {
|
||||
@NotNull private final RefGroup myGroup;
|
||||
@NotNull private final VcsRefPainter myReferencePainter;
|
||||
@NotNull private final VcsLogUiImpl myUi;
|
||||
@NotNull private final VirtualFile myRoot;
|
||||
|
||||
private ReferenceGroupComponent(@NotNull RefGroup group,
|
||||
@NotNull VcsRefPainter referencePainter,
|
||||
@NotNull VcsLogUiImpl ui,
|
||||
@NotNull VirtualFile root) {
|
||||
myGroup = group;
|
||||
myReferencePainter = referencePainter;
|
||||
myUi = ui;
|
||||
myRoot = root;
|
||||
addMouseListener(new MyMouseAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
Color rootIndicatorColor = VcsLogColorManagerImpl.getIndicatorColor(myUi.getColorManager().getRootColor(myRoot));
|
||||
myReferencePainter
|
||||
.paint(myGroup.getName(), g, 0, (getHeight() - myReferencePainter.getHeight(this)) / 2, myGroup.getBgColor(), rootIndicatorColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return myReferencePainter.getSize(myGroup.getName(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
private class MyMouseAdapter extends MouseAdapter {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (!myUi.areGraphActionsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myGroup.getRefs().size() == 1) {
|
||||
VcsLogUtil.triggerUsage("BranchPanelGoToRef");
|
||||
|
||||
VcsRef ref = myGroup.getRefs().iterator().next();
|
||||
myUi.jumpToCommit(ref.getCommitHash(), ref.getRoot());
|
||||
}
|
||||
else {
|
||||
VcsLogUtil.triggerUsage("BranchPanelPopup");
|
||||
|
||||
ReferencePopupBuilder popupBuilder = new ReferencePopupBuilder(myGroup, myUi);
|
||||
popupBuilder.getPopup().showUnderneathOf(ReferenceGroupComponent.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,7 +542,7 @@ class CommitPanel extends JBPanel {
|
||||
@NotNull private Color myColor = getCommitDetailsBackground();
|
||||
|
||||
RootPanel() {
|
||||
myLabelPainter = new TextLabelPainter(true) {
|
||||
myLabelPainter = new TextLabelPainter() {
|
||||
@Override
|
||||
protected Font getLabelFont() {
|
||||
return RootPanel.getLabelFont();
|
||||
|
||||
@@ -56,7 +56,6 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
|
||||
@NotNull private final JBLoadingPanel myChangesLoadingPane;
|
||||
@NotNull private final VcsLogGraphTable myGraphTable;
|
||||
@NotNull private final BranchesPanel myBranchesPanel;
|
||||
@NotNull private final DetailsPanel myDetailsPanel;
|
||||
@NotNull private final Splitter myDetailsSplitter;
|
||||
@NotNull private final JComponent myToolbar;
|
||||
@@ -81,8 +80,6 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
|
||||
// initialize components
|
||||
myGraphTable = new VcsLogGraphTable(ui, logData, initialDataPack);
|
||||
myBranchesPanel = new BranchesPanel(logData, ui, initialDataPack.getRefs());
|
||||
setBranchesPanelVisible(uiProperties.isShowBranchesPanel());
|
||||
myDetailsPanel = new DetailsPanel(logData, ui.getColorManager(), this);
|
||||
|
||||
myChangesBrowser = new RepositoryChangesBrowser(project, null, Collections.emptyList(), null) {
|
||||
@@ -133,7 +130,6 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
|
||||
JComponent toolbars = new JPanel(new BorderLayout());
|
||||
toolbars.add(myToolbar, BorderLayout.NORTH);
|
||||
toolbars.add(myBranchesPanel.getMainComponent(), BorderLayout.CENTER);
|
||||
JComponent toolbarsAndTable = new JPanel(new BorderLayout());
|
||||
toolbarsAndTable.add(toolbars, BorderLayout.NORTH);
|
||||
toolbarsAndTable.add(progressStripe, BorderLayout.CENTER);
|
||||
@@ -161,7 +157,6 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
public void updateDataPack(@NotNull VisiblePack dataPack, boolean permGraphChanged) {
|
||||
myFilterUi.updateDataPack(dataPack);
|
||||
myGraphTable.updateDataPack(dataPack, permGraphChanged);
|
||||
myBranchesPanel.updateDataPack(dataPack, permGraphChanged);
|
||||
}
|
||||
|
||||
private void updateWhenDetailsAreLoaded() {
|
||||
@@ -246,10 +241,6 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setBranchesPanelVisible(boolean visible) {
|
||||
myBranchesPanel.setBranchPanelVisible(visible);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
@@ -311,10 +302,6 @@ public class MainFrame extends JPanel implements DataProvider, Disposable {
|
||||
return myGraphTable.getRowCount() > 0;
|
||||
}
|
||||
|
||||
public void onFiltersChange(@NotNull VcsLogFilterCollection filters) {
|
||||
myBranchesPanel.onFiltersChange(filters);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static TextRevisionNumber convertToRevisionNumber(@NotNull Hash hash) {
|
||||
return new TextRevisionNumber(hash.asString(), hash.toShortString());
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* 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.frame;
|
||||
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.ui.ListUtil;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.speedSearch.ListWithFilter;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcs.log.RefGroup;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiImpl;
|
||||
import com.intellij.vcs.log.ui.render.VcsRefPainter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
class ReferencePopupBuilder {
|
||||
@NotNull private final JBPopup myPopup;
|
||||
@NotNull private final JBList myList;
|
||||
@NotNull private final VcsLogUiImpl myUi;
|
||||
@NotNull private final SingleReferenceComponent myRendererComponent;
|
||||
@NotNull private final ListCellRenderer myCellRenderer;
|
||||
|
||||
ReferencePopupBuilder(@NotNull RefGroup group, @NotNull VcsLogUiImpl ui) {
|
||||
myUi = ui;
|
||||
|
||||
myRendererComponent = new SingleReferenceComponent(new VcsRefPainter(ui.getColorManager(), false));
|
||||
myCellRenderer = (list, value, index, isSelected, cellHasFocus) -> {
|
||||
myRendererComponent.setReference((VcsRef)value);
|
||||
myRendererComponent.setSelected(isSelected);
|
||||
return myRendererComponent;
|
||||
};
|
||||
|
||||
myList = createList(group);
|
||||
myPopup = createPopup();
|
||||
}
|
||||
|
||||
private JBList createList(RefGroup group) {
|
||||
JBList list = new JBList(createListModel(group));
|
||||
list.setCellRenderer(myCellRenderer);
|
||||
ListUtil.installAutoSelectOnMouseMove(list);
|
||||
list.setSelectedIndex(0);
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
jumpOnMouseClick(list);
|
||||
jumpOnEnter(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void jumpOnMouseClick(JBList list) {
|
||||
list.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
jumpToSelectedRef();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void jumpOnEnter(JBList list) {
|
||||
list.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
jumpToSelectedRef();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private JBPopup createPopup() {
|
||||
return JBPopupFactory.getInstance()
|
||||
.createComponentPopupBuilder(ListWithFilter.wrap(myList, ScrollPaneFactory.createScrollPane(myList), new Function<VcsRef, String>() {
|
||||
@Override
|
||||
public String fun(VcsRef vcsRef) {
|
||||
return vcsRef.getName();
|
||||
}
|
||||
}), myList).
|
||||
setCancelOnClickOutside(true).
|
||||
setCancelOnWindowDeactivation(true).
|
||||
setFocusable(true).
|
||||
setRequestFocus(true).
|
||||
setResizable(true).
|
||||
setDimensionServiceKey(myUi.getProject(), "Vcs.Log.Branch.Panel.RefGroup.Popup", false).
|
||||
createPopup();
|
||||
}
|
||||
|
||||
private static DefaultListModel createListModel(RefGroup group) {
|
||||
DefaultListModel model = new DefaultListModel();
|
||||
for (final VcsRef vcsRef : group.getRefs()) {
|
||||
model.addElement(vcsRef);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
JBPopup getPopup() {
|
||||
return myPopup;
|
||||
}
|
||||
|
||||
private void jumpToSelectedRef() {
|
||||
myPopup.cancel(); // close the popup immediately not to stay at the front if jumping to a commits takes long time.
|
||||
VcsRef selectedRef = (VcsRef)myList.getSelectedValue();
|
||||
if (selectedRef != null) {
|
||||
myUi.jumpToCommit(selectedRef.getCommitHash(), selectedRef.getRoot());
|
||||
}
|
||||
}
|
||||
|
||||
private static class SingleReferenceComponent extends JPanel {
|
||||
private static final int PADDING_Y = 2;
|
||||
private static final int PADDING_X = 5;
|
||||
@NotNull private final VcsRefPainter myReferencePainter;
|
||||
|
||||
@Nullable private VcsRef myReference;
|
||||
public boolean mySelected;
|
||||
|
||||
public SingleReferenceComponent(@NotNull VcsRefPainter referencePainter) {
|
||||
myReferencePainter = referencePainter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
g.setColor(mySelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
if (myReference != null) {
|
||||
myReferencePainter.paint(myReference, g, PADDING_X, PADDING_Y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (myReference == null) return super.getPreferredSize();
|
||||
Dimension size = myReferencePainter.getSize(myReference, this);
|
||||
return new Dimension(size.width + 2 * PADDING_X, size.height + 2 * PADDING_Y);
|
||||
}
|
||||
|
||||
public void setReference(@NotNull VcsRef reference) {
|
||||
myReference = reference;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
mySelected = selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,11 +142,7 @@ public class TagLabelPainter {
|
||||
}
|
||||
|
||||
protected Font getReferenceFont() {
|
||||
return getFont();
|
||||
}
|
||||
|
||||
public static Font getFont() {
|
||||
return UIUtil.getLabelFont();
|
||||
return TextLabelPainter.getFont();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.vcs.log.ui.render;
|
||||
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
@@ -24,81 +23,38 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
public class TextLabelPainter {
|
||||
protected static final int TEXT_PADDING_X = 5;
|
||||
public static final int TOP_TEXT_PADDING = 2;
|
||||
public static final int BOTTOM_TEXT_PADDING = 1;
|
||||
|
||||
private static final int LABEL_ARC = 5;
|
||||
|
||||
private final boolean mySquare;
|
||||
|
||||
public TextLabelPainter(boolean square) {
|
||||
mySquare = square;
|
||||
}
|
||||
|
||||
public static TextLabelPainter createPainter(boolean paintFlag) {
|
||||
boolean square = Registry.is("vcs.log.square.labels");
|
||||
if (paintFlag) {
|
||||
return square ? new UnderlinedLabelPainter() : new FlagLabelPainter();
|
||||
}
|
||||
else {
|
||||
return new TextLabelPainter(square);
|
||||
}
|
||||
}
|
||||
|
||||
public static Font getFont() {
|
||||
return UIUtil.getLabelFont();
|
||||
}
|
||||
|
||||
protected Rectangle paint(@NotNull Graphics2D g2,
|
||||
@NotNull String text,
|
||||
int paddingX,
|
||||
int paddingY,
|
||||
int textPadding,
|
||||
@NotNull Color color) {
|
||||
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
|
||||
g2.setFont(getLabelFont());
|
||||
g2.setStroke(new BasicStroke(1.5f));
|
||||
|
||||
FontMetrics fontMetrics = g2.getFontMetrics();
|
||||
int width = fontMetrics.stringWidth(text) + 2 * TEXT_PADDING_X + textPadding;
|
||||
int height = fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING;
|
||||
|
||||
g2.setColor(color);
|
||||
if (mySquare) {
|
||||
g2.fillRect(paddingX, paddingY, width, height);
|
||||
}
|
||||
else {
|
||||
g2.fill(new RoundRectangle2D.Double(paddingX, paddingY, width, height, LABEL_ARC, LABEL_ARC));
|
||||
}
|
||||
|
||||
g2.setColor(JBColor.BLACK);
|
||||
int x = paddingX + textPadding + TEXT_PADDING_X;
|
||||
int y = paddingY + SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
|
||||
g2.drawString(text, x, y);
|
||||
|
||||
config.restore();
|
||||
return new Rectangle(x, y, width, height);
|
||||
}
|
||||
|
||||
protected Font getLabelFont() {
|
||||
return getFont();
|
||||
}
|
||||
|
||||
public Rectangle paint(@NotNull Graphics2D g2, @NotNull String text, int paddingX, int paddingY, @NotNull Color color) {
|
||||
return paint(g2, text, paddingX, paddingY, 0, color);
|
||||
}
|
||||
public void paint(@NotNull Graphics2D g2, @NotNull String text, int paddingX, int paddingY, @NotNull Color color) {
|
||||
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
|
||||
g2.setFont(getLabelFont());
|
||||
g2.setStroke(new BasicStroke(1.5f));
|
||||
|
||||
public Rectangle paint(@NotNull Graphics2D g2,
|
||||
@NotNull String text,
|
||||
int paddingX,
|
||||
int paddingY,
|
||||
@NotNull Color labelColor,
|
||||
@NotNull Color flagColor) {
|
||||
return paint(g2, text, paddingX, paddingY, 0, labelColor);
|
||||
FontMetrics fontMetrics = g2.getFontMetrics();
|
||||
int width = fontMetrics.stringWidth(text) + 2 * TEXT_PADDING_X;
|
||||
int height = fontMetrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING;
|
||||
|
||||
g2.setColor(color);
|
||||
g2.fillRect(paddingX, paddingY, width, height);
|
||||
|
||||
g2.setColor(JBColor.BLACK);
|
||||
int x = paddingX + TEXT_PADDING_X;
|
||||
int y = paddingY + SimpleColoredComponent.getTextBaseLine(fontMetrics, height);
|
||||
g2.drawString(text, x, y);
|
||||
|
||||
config.restore();
|
||||
}
|
||||
|
||||
public Dimension calculateSize(@NotNull String text, @NotNull FontMetrics metrics) {
|
||||
@@ -106,83 +62,4 @@ public class TextLabelPainter {
|
||||
int height = metrics.getHeight() + TOP_TEXT_PADDING + BOTTOM_TEXT_PADDING;
|
||||
return new Dimension(width, height);
|
||||
}
|
||||
|
||||
private static class FlagLabelPainter extends TextLabelPainter {
|
||||
private static final int FLAG_WIDTH = 8;
|
||||
private static final int FLAG_PADDING = 6;
|
||||
private static final int FLAG_TOP_INDENT = 2;
|
||||
|
||||
public FlagLabelPainter() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle paint(@NotNull Graphics2D g2,
|
||||
@NotNull String text,
|
||||
int paddingX,
|
||||
int paddingY,
|
||||
@NotNull Color labelColor,
|
||||
@NotNull Color flagColor) {
|
||||
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
|
||||
|
||||
Rectangle rectangle =
|
||||
super.paint(g2, text, paddingX, paddingY + FLAG_TOP_INDENT, FLAG_WIDTH + 2 * FLAG_PADDING - TEXT_PADDING_X, labelColor);
|
||||
|
||||
g2.setColor(flagColor);
|
||||
int x0 = paddingX + FLAG_PADDING;
|
||||
int xMid = x0 + FLAG_WIDTH / 2;
|
||||
int xRight = x0 + FLAG_WIDTH;
|
||||
|
||||
int y0 = paddingY;
|
||||
int yMid = y0 + 2 * rectangle.height / 3 - 2;
|
||||
int yBottom = y0 + rectangle.height - 4;
|
||||
|
||||
// something like a knight flag
|
||||
Polygon polygon = new Polygon(new int[]{x0, xRight, xRight, xMid, x0}, new int[]{y0, y0, yMid, yBottom, yMid}, 5);
|
||||
g2.fillPolygon(polygon);
|
||||
|
||||
config.restore();
|
||||
return new Rectangle(paddingX, paddingY, rectangle.width, rectangle.height + FLAG_TOP_INDENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension calculateSize(@NotNull String text, @NotNull FontMetrics metrics) {
|
||||
Dimension size = super.calculateSize(text, metrics);
|
||||
return new Dimension(size.width + FLAG_WIDTH + 2 * FLAG_PADDING - TEXT_PADDING_X, size.height + FLAG_TOP_INDENT);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnderlinedLabelPainter extends TextLabelPainter {
|
||||
|
||||
private static final int LINE_GAP = 1;
|
||||
private static final int LINE_HEIGHT = 4;
|
||||
|
||||
public UnderlinedLabelPainter() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle paint(@NotNull Graphics2D g2,
|
||||
@NotNull String text,
|
||||
int paddingX,
|
||||
int paddingY,
|
||||
@NotNull Color labelColor,
|
||||
@NotNull Color flagColor) {
|
||||
GraphicsConfig config = GraphicsUtil.setupAAPainting(g2);
|
||||
|
||||
Rectangle rectangle = super.paint(g2, text, paddingX, paddingY, 0, labelColor);
|
||||
|
||||
g2.setColor(flagColor);
|
||||
g2.fillRect(paddingX, paddingY + rectangle.height + LINE_GAP, rectangle.width, LINE_HEIGHT);
|
||||
|
||||
config.restore();
|
||||
return new Rectangle(paddingX, paddingY, rectangle.width, rectangle.height + LINE_GAP + LINE_HEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension calculateSize(@NotNull String text, @NotNull FontMetrics metrics) {
|
||||
Dimension size = super.calculateSize(text, metrics);
|
||||
return new Dimension(size.width, size.height + LINE_GAP + LINE_HEIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* 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.render;
|
||||
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import com.intellij.vcs.log.ui.VcsLogColorManager;
|
||||
import com.intellij.vcs.log.ui.VcsLogColorManagerImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class VcsRefPainter {
|
||||
@NotNull private final VcsLogColorManager myColorManager;
|
||||
@NotNull private final TextLabelPainter myTextLabelPainter;
|
||||
|
||||
public VcsRefPainter(@NotNull VcsLogColorManager colorManager, boolean paintRoot) {
|
||||
myColorManager = colorManager;
|
||||
myTextLabelPainter = TextLabelPainter.createPainter(paintRoot && colorManager.isMultipleRoots());
|
||||
}
|
||||
|
||||
public void paint(@NotNull VcsRef reference, @NotNull Graphics g, int paddingX, int paddingY) {
|
||||
myTextLabelPainter.paint((Graphics2D)g, reference.getName(), paddingX, paddingY, reference.getType().getBackgroundColor(),
|
||||
VcsLogColorManagerImpl.getIndicatorColor(myColorManager.getRootColor(reference.getRoot())));
|
||||
}
|
||||
|
||||
public Rectangle paint(@NotNull String text,
|
||||
@NotNull Graphics g,
|
||||
int paddingX,
|
||||
int paddingY,
|
||||
@NotNull Color color,
|
||||
@NotNull Color flagColor) {
|
||||
return myTextLabelPainter.paint((Graphics2D)g, text, paddingX, paddingY, color, flagColor);
|
||||
}
|
||||
|
||||
public Dimension getSize(@NotNull VcsRef reference, @NotNull JComponent component) {
|
||||
return getSize(reference.getName(), component);
|
||||
}
|
||||
|
||||
public Dimension getSize(@NotNull String referenceName, @NotNull JComponent component) {
|
||||
return myTextLabelPainter.calculateSize(referenceName, component.getFontMetrics(TextLabelPainter.getFont()));
|
||||
}
|
||||
|
||||
public int getHeight(@NotNull JComponent component) {
|
||||
return myTextLabelPainter.calculateSize("", component.getFontMetrics(TextLabelPainter.getFont())).height;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user