import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.GraphicsConfig;
-import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkRenderer;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.ui.ColorUtil;
import com.intellij.ui.ColoredTableCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.ui.TableCell;
-import com.intellij.ui.components.JBLabel;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.VcsRef;
-import com.intellij.vcs.log.VcsRefType;
import com.intellij.vcs.log.data.VcsLogData;
import com.intellij.vcs.log.graph.EdgePrintElement;
import com.intellij.vcs.log.graph.PrintElement;
import com.intellij.vcs.log.paint.GraphCellPainter;
import com.intellij.vcs.log.paint.PaintParameters;
-import com.intellij.vcs.log.ui.frame.ReferencesPanel;
import com.intellij.vcs.log.ui.frame.VcsLogGraphTable;
import com.intellij.vcs.log.ui.tables.GraphTableModel;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Collection;
-import java.util.Map;
public class GraphCommitCellRenderer extends ColoredTableCellRenderer {
private static final Logger LOG = Logger.getInstance(GraphCommitCellRenderer.class);
if (!refs.isEmpty()) {
customizeRefsPainter(myReferencePainter, refs, getForeground());
if (myReferencePainter.getSize().getWidth() - LabelPainter.GRADIENT_WIDTH >= width - point.getX()) {
- return new TooltipReferencesPanel(refs);
+ return new TooltipReferencesPanel(myLogData, myReferencePainter, refs);
}
}
return null;
return myWidth;
}
}
-
- private class TooltipReferencesPanel extends ReferencesPanel {
- private static final int REFS_LIMIT = 10;
- private boolean myHasGroupWithMultipleRefs;
-
- public TooltipReferencesPanel(@NotNull Collection<VcsRef> refs) {
- super(new VerticalFlowLayout(JBUI.scale(H_GAP), JBUI.scale(V_GAP)), REFS_LIMIT);
- VirtualFile root = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(refs)).getRoot();
- setReferences(
- ContainerUtil.sorted(refs, myLogData.getLogProvider(root).getReferenceManager().getLabelsOrderComparator()));
- }
-
- @Override
- public void update() {
- super.update();
- myHasGroupWithMultipleRefs = false;
- for (Map.Entry<VcsRefType, Collection<VcsRef>> typeAndRefs : myGroupedVisibleReferences.entrySet()) {
- if (typeAndRefs.getValue().size() > 1) {
- myHasGroupWithMultipleRefs = true;
- }
- }
- }
-
- @NotNull
- @Override
- protected Font getLabelsFont() {
- return myReferencePainter.getReferenceFont();
- }
-
- @Nullable
- @Override
- protected Icon createIcon(@NotNull VcsRefType type, @NotNull Collection<VcsRef> refs, int refIndex, int height) {
- if (refIndex == 0) {
- Color color = type.getBackgroundColor();
- return new LabelIcon(height, getBackground(),
- refs.size() > 1 ? new Color[]{color, color} : new Color[]{color}) {
- @Override
- public int getIconWidth() {
- return getWidth(myHasGroupWithMultipleRefs ? 2 : 1);
- }
- };
- }
- return createEmptyIcon(height);
- }
-
- @NotNull
- private Icon createEmptyIcon(int height) {
- return EmptyIcon.create(LabelIcon.getWidth(height, 2), height);
- }
-
- @NotNull
- @Override
- protected JBLabel createRestLabel(int restSize) {
- String gray = ColorUtil.toHex(UIManager.getColor("Button.disabledText"));
- return createLabel("<html><font color=\"#" + gray + "\">... " + restSize + " more in details pane</font></html>",
- createEmptyIcon(getIconHeight()));
- }
- }
}
--- /dev/null
+/*
+ * 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.render;
+
+import com.intellij.openapi.ui.VerticalFlowLayout;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.ui.ColorUtil;
+import com.intellij.ui.components.JBLabel;
+import com.intellij.util.ObjectUtils;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.ui.EmptyIcon;
+import com.intellij.util.ui.JBUI;
+import com.intellij.vcs.log.VcsRef;
+import com.intellij.vcs.log.VcsRefType;
+import com.intellij.vcs.log.data.VcsLogData;
+import com.intellij.vcs.log.ui.frame.ReferencesPanel;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.Collection;
+import java.util.Map;
+
+class TooltipReferencesPanel extends ReferencesPanel {
+ private static final int REFS_LIMIT = 10;
+ @NotNull private final ReferencePainter myReferencePainter;
+ private boolean myHasGroupWithMultipleRefs;
+
+ public TooltipReferencesPanel(@NotNull VcsLogData logData,
+ @NotNull ReferencePainter referencePainter,
+ @NotNull Collection<VcsRef> refs) {
+ super(new VerticalFlowLayout(JBUI.scale(H_GAP), JBUI.scale(V_GAP)), REFS_LIMIT);
+ myReferencePainter = referencePainter;
+
+ VirtualFile root = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(refs)).getRoot();
+ setReferences(ContainerUtil.sorted(refs, logData.getLogProvider(root).getReferenceManager().getLabelsOrderComparator()));
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ myHasGroupWithMultipleRefs = false;
+ for (Map.Entry<VcsRefType, Collection<VcsRef>> typeAndRefs : myGroupedVisibleReferences.entrySet()) {
+ if (typeAndRefs.getValue().size() > 1) {
+ myHasGroupWithMultipleRefs = true;
+ }
+ }
+ }
+
+ @NotNull
+ @Override
+ protected Font getLabelsFont() {
+ return myReferencePainter.getReferenceFont();
+ }
+
+ @Nullable
+ @Override
+ protected Icon createIcon(@NotNull VcsRefType type, @NotNull Collection<VcsRef> refs, int refIndex, int height) {
+ if (refIndex == 0) {
+ Color color = type.getBackgroundColor();
+ return new LabelIcon(height, getBackground(),
+ refs.size() > 1 ? new Color[]{color, color} : new Color[]{color}) {
+ @Override
+ public int getIconWidth() {
+ return getWidth(myHasGroupWithMultipleRefs ? 2 : 1);
+ }
+ };
+ }
+ return createEmptyIcon(height);
+ }
+
+ @NotNull
+ private static Icon createEmptyIcon(int height) {
+ return EmptyIcon.create(LabelIcon.getWidth(height, 2), height);
+ }
+
+ @NotNull
+ @Override
+ protected JBLabel createRestLabel(int restSize) {
+ String gray = ColorUtil.toHex(UIManager.getColor("Button.disabledText"));
+ return createLabel("<html><font color=\"#" + gray + "\">... " + restSize + " more in details pane</font></html>",
+ createEmptyIcon(getIconHeight()));
+ }
+}