[vcs-log] refactor hardcoded colors to color-keys

This commit is contained in:
Gregory.Shrago
2017-08-17 14:20:22 +03:00
parent 934a4de8cb
commit a0a39a154d
22 changed files with 292 additions and 111 deletions
@@ -41,7 +41,8 @@ public class EditorColorsUtil {
@Nullable
public static Color getGlobalOrDefaultColor(@NotNull ColorKey colorKey) {
return getColorSchemeForBackground(null).getColor(colorKey);
Color color = getColorSchemeForBackground(null).getColor(colorKey);
return color != null? color : colorKey.getDefaultColor();
}
/**
@@ -135,6 +135,12 @@ options.general.color.descriptor.indent.guide.selected=Code//Selected vertical i
options.general.color.descriptor.line.number=Code//Line number
options.general.color.descriptor.vcs.annotations=VCS Annotations//Foreground
options.general.color.descriptor.vcs.annotations.color.n=VCS Annotations//Background color #{0}
options.general.color.descriptor.vcs.log.merged.commit=VCS Log//Common//Merged commit
options.general.color.descriptor.vcs.log.refs.head=VCS Log//Common//Current
options.general.color.descriptor.vcs.log.refs.leaf=VCS Log//Common//Leaf
options.general.color.descriptor.vcs.log.refs.branch=VCS Log//Common//Branch
options.general.color.descriptor.vcs.log.refs.branch.tag=VCS Log//Common//Branch tag
options.general.color.descriptor.vcs.log.refs.tag=VCS Log//Common//Tag
options.general.color.descriptor.tearline=Editor//Tear line
options.general.color.descriptor.tearline.selected=Editor//Tear line selection
options.general.color.descriptor.separator.above=Editor//Separator line above
@@ -63,7 +63,9 @@
interface="com.intellij.openapi.vcs.actions.VcsQuickListContentProvider"/>
<extensionPoint name="patch.extension" interface="com.intellij.openapi.diff.impl.patch.PatchEP" area="IDEA_PROJECT"/>
<extensionPoint name="vcsChangesViewRefresher" interface="com.intellij.openapi.vcs.changes.ChangesViewRefresher" area="IDEA_PROJECT"/>
<extensionPoint name="vcsAnnotationGutterActionProvider" interface="com.intellij.openapi.vcs.annotate.AnnotationGutterActionProvider"/>
<extensionPoint name="vcsAnnotationGutterActionProvider"
interface="com.intellij.openapi.vcs.annotate.AnnotationGutterActionProvider"/>
<extensionPoint name="vcsColorsProvider" interface="com.intellij.vcs.VcsColorsProvider"/>
<extensionPoint name="vcs.taskHandler" interface="com.intellij.openapi.vcs.VcsTaskHandler" area="IDEA_PROJECT"/>
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2017 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.extensions.ExtensionPointName;
import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorDescriptor;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
/**
* @author gregsh
*/
public abstract class VcsColorsProvider {
public static final ExtensionPointName<VcsColorsProvider> EP_NAME = ExtensionPointName.create("com.intellij.vcsColorsProvider");
@NotNull
public List<AttributesDescriptor> getAttributeDescriptors() {
return Collections.emptyList();
}
@NotNull
public List<ColorDescriptor> getColorDescriptors() {
return Collections.emptyList();
}
}
+1
View File
@@ -8,6 +8,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="platform-api" exported="" />
<orderEntry type="module" module-name="lang-api" />
<orderEntry type="library" name="microba" level="project" />
<orderEntry type="module" module-name="vcs-api-core" exported="" />
<orderEntry type="module" module-name="diff-api" exported="" />
@@ -19,6 +19,7 @@ import com.intellij.application.options.colors.*;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.options.OptionsBundle;
import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider;
@@ -26,6 +27,8 @@ import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.psi.codeStyle.DisplayPriority;
import com.intellij.psi.codeStyle.DisplayPrioritySortable;
import com.intellij.util.ArrayUtil;
import com.intellij.vcs.VcsColorsProvider;
import com.intellij.vcs.log.VcsLogColors;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -55,7 +58,11 @@ public class VcsColorsPageFactory implements ColorAndFontPanelFactory, ColorAndF
@Override
@NotNull
public AttributesDescriptor[] getAttributeDescriptors() {
return new AttributesDescriptor[0];
List<AttributesDescriptor> descriptors = new ArrayList<>();
for (VcsColorsProvider provider : Extensions.getExtensions(VcsColorsProvider.EP_NAME)) {
descriptors.addAll(provider.getAttributeDescriptors());
}
return ArrayUtil.toObjectArray(descriptors, AttributesDescriptor.class);
}
@Override
@@ -76,6 +83,17 @@ public class VcsColorsPageFactory implements ColorAndFontPanelFactory, ColorAndF
descriptors.add(new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.vcs.annotations.color.n", i + 1), colorKeys.get(i), ColorDescriptor.Kind.BACKGROUND));
}
descriptors.add(new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.vcs.log.merged.commit"), VcsLogColors.MERGED_COMMIT, ColorDescriptor.Kind.FOREGROUND));
descriptors.add(new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.vcs.log.refs.head"), VcsLogColors.REFS_HEAD, ColorDescriptor.Kind.FOREGROUND));
descriptors.add(new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.vcs.log.refs.leaf"), VcsLogColors.REFS_LEAF, ColorDescriptor.Kind.FOREGROUND));
descriptors.add(new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.vcs.log.refs.branch"), VcsLogColors.REFS_BRANCH, ColorDescriptor.Kind.FOREGROUND));
descriptors.add(new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.vcs.log.refs.branch.tag"), VcsLogColors.REFS_BRANCH_REF, ColorDescriptor.Kind.FOREGROUND));
descriptors.add(new ColorDescriptor(OptionsBundle.message("options.general.color.descriptor.vcs.log.refs.tag"), VcsLogColors.REFS_TAG, ColorDescriptor.Kind.FOREGROUND));
for (VcsColorsProvider provider : Extensions.getExtensions(VcsColorsProvider.EP_NAME)) {
descriptors.addAll(provider.getColorDescriptors());
}
return ArrayUtil.toObjectArray(descriptors, ColorDescriptor.class);
}
@@ -0,0 +1,34 @@
/*
* Copyright 2000-2017 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;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import java.awt.*;
public interface VcsLogColors {
ColorKey MERGED_COMMIT = ColorKey.createColorKey("VCS_MERGED_COMMIT", new JBColor(Gray._128, Gray._96));
ColorKey REFS_HEAD = ColorKey.createColorKey("VCS_REFS_HEAD", new JBColor(new Color(0xffd100), new Color(0xe1c731)));
ColorKey REFS_LEAF = ColorKey.createColorKey("VCS_REFS_LEAF", new JBColor(new Color(0x8a2d6b), new Color(0xc31e8c)));
ColorKey REFS_BRANCH = ColorKey.createColorKey("VCS_REFS_BRANCH", new JBColor(new Color(0x3cb45c), new Color(0x3cb45c)));
ColorKey REFS_BRANCH_REF = ColorKey.createColorKey("VCS_REFS_BRANCH_REF", new JBColor(new Color(0x9f79b5), new Color(0x9f79b5)));
ColorKey REFS_TAG = ColorKey.createColorKey("VCS_REFS_TAG", new JBColor(new Color(0x7a7a7a), new Color(0x999999)));
}
@@ -1,9 +1,8 @@
package com.intellij.vcs.log;
import com.intellij.openapi.editor.colors.ColorKey;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
/**
* @author Kirill Likhodedov
*/
@@ -31,5 +30,5 @@ public interface VcsRefType {
* TODO maybe this is not the right place for color
*/
@NotNull
Color getBackgroundColor();
ColorKey getBgColorKey();
}
@@ -1,30 +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;
import com.intellij.ui.JBColor;
import java.awt.*;
public class VcsLogStandardColors {
public static class Refs {
public static final Color TIP = new JBColor(new Color(0xffd100), new Color(0xe1c731));
public static final Color LEAF = new JBColor(new Color(0x8a2d6b), new Color(0xc31e8c));
public static final Color BRANCH = new JBColor(new Color(0x3cb45c), new Color(0x3cb45c));
public static final Color BRANCH_REF = new JBColor(new Color(0x9f79b5), new Color(0x9f79b5));
public static final Color TAG = new JBColor(new Color(0x7a7a7a), new Color(0x999999));
}
}
@@ -15,6 +15,7 @@
*/
package com.intellij.vcs.log.impl;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
@@ -66,16 +67,17 @@ public class SimpleRefGroup implements RefGroup {
Map.Entry<VcsRefType, Collection<VcsRef>> firstItem =
ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(referencesByType.entrySet()));
boolean multiple = firstItem.getValue().size() > 1;
Color color = firstItem.getKey().getBackgroundColor();
Color color = EditorColorsUtil.getGlobalOrDefaultColor(firstItem.getKey().getBgColorKey());
return multiple ? Arrays.asList(color, color) : Collections.singletonList(color);
}
else {
List<Color> colorsList = ContainerUtil.newArrayList();
for (VcsRefType type : referencesByType.keySet()) {
Color color = EditorColorsUtil.getGlobalOrDefaultColor(type.getBgColorKey());
if (referencesByType.get(type).size() > 1) {
colorsList.add(type.getBackgroundColor());
colorsList.add(color);
}
colorsList.add(type.getBackgroundColor());
colorsList.add(color);
}
return colorsList;
}
@@ -15,6 +15,7 @@
*/
package com.intellij.vcs.log.impl;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.vcs.log.RefGroup;
import com.intellij.vcs.log.VcsRef;
import org.jetbrains.annotations.NotNull;
@@ -53,6 +54,7 @@ public class SingletonRefGroup implements RefGroup {
@NotNull
@Override
public List<Color> getColors() {
return Collections.singletonList(myRef.getType().getBackgroundColor());
Color color = EditorColorsUtil.getGlobalOrDefaultColor(myRef.getType().getBgColorKey());
return Collections.singletonList(color);
}
}
@@ -15,6 +15,7 @@
*/
package com.intellij.vcs.log.ui.frame;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.panels.Wrapper;
import com.intellij.util.ObjectUtils;
@@ -118,7 +119,7 @@ public class ReferencesPanel extends JPanel {
@NotNull Collection<VcsRef> refs,
int refIndex, int height) {
if (refIndex == 0) {
Color color = type.getBackgroundColor();
Color color = EditorColorsUtil.getGlobalOrDefaultColor(type.getBgColorKey());
return new LabelIcon(height, getBackground(),
refs.size() > 1 ? new Color[]{color, color} : new Color[]{color});
}
@@ -15,14 +15,15 @@
*/
package com.intellij.vcs.log.ui.highlighters;
import com.intellij.ui.Gray;
import com.intellij.ui.JBColor;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.VcsLogData;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
public class MergeCommitsHighlighter implements VcsLogHighlighter {
public static final JBColor MERGE_COMMIT_FOREGROUND = new JBColor(Gray._128, Gray._96);
@NotNull private final VcsLogUi myLogUi;
public MergeCommitsHighlighter(@NotNull VcsLogUi logUi) {
@@ -33,7 +34,10 @@ public class MergeCommitsHighlighter implements VcsLogHighlighter {
@Override
public VcsCommitStyle getStyle(@NotNull VcsShortCommitDetails details, boolean isSelected) {
if (isSelected || !myLogUi.isHighlighterEnabled(Factory.ID)) return VcsCommitStyle.DEFAULT;
if (details.getParents().size() >= 2) return VcsCommitStyleFactory.foreground(MERGE_COMMIT_FOREGROUND);
if (details.getParents().size() >= 2) {
Color color = EditorColorsUtil.getGlobalOrDefaultColor(VcsLogColors.MERGED_COMMIT);
return VcsCommitStyleFactory.foreground(color);
}
return VcsCommitStyle.DEFAULT;
}
@@ -15,6 +15,7 @@
*/
package com.intellij.vcs.log.ui.render;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ColorUtil;
@@ -71,7 +72,7 @@ class TooltipReferencesPanel extends ReferencesPanel {
@Override
protected Icon createIcon(@NotNull VcsRefType type, @NotNull Collection<VcsRef> refs, int refIndex, int height) {
if (refIndex == 0) {
Color color = type.getBackgroundColor();
Color color = EditorColorsUtil.getGlobalOrDefaultColor(type.getBgColorKey());
return new LabelIcon(height, getBackground(),
refs.size() > 1 ? new Color[]{color, color} : new Color[]{color}) {
@Override
@@ -17,10 +17,10 @@ package com.intellij.vcs.log.impl;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.vcs.VcsKey;
import com.intellij.openapi.vcs.changes.committed.MockAbstractVcs;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.JBColor;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
@@ -28,11 +28,9 @@ import com.intellij.vcs.log.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.io.DataInput;
import java.io.DataOutput;
import java.util.*;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
@@ -50,8 +48,8 @@ public class TestVcsLogProvider implements VcsLogProvider {
@NotNull
@Override
public Color getBackgroundColor() {
return JBColor.WHITE;
public ColorKey getBgColorKey() {
return VcsLogColors.REFS_BRANCH;
}
};
private static final String SAMPLE_SUBJECT = "Sample subject";
+1
View File
@@ -159,6 +159,7 @@
<cherryPicker implementation="git4idea.cherrypick.GitCherryPicker"/>
<vcsAnnotationGutterActionProvider implementation="git4idea.actions.GitShowCommitInLogAnnotationGutterActionProvider" />
<statistics.usagesCollector implementation="git4idea.GitStatisticsCollector" />
<vcsColorsProvider implementation="git4idea.GitColors"/>
<projectService serviceImplementation="git4idea.repo.GitRepositoryManager"/>
<projectService serviceImplementation="git4idea.ui.branch.GitBranchManager"/>
@@ -0,0 +1,49 @@
/*
* Copyright 2000-2017 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 git4idea;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.vcs.VcsColorsProvider;
import com.intellij.vcs.log.VcsLogColors;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* @author gregsh
*/
public class GitColors extends VcsColorsProvider {
public static final ColorKey REFS_HEAD = ColorKey.createColorKey("GIT_REFS_HEAD", VcsLogColors.REFS_HEAD);
public static final ColorKey REFS_LOCAL_BRANCH = ColorKey.createColorKey("GIT_REFS_BRANCH", VcsLogColors.REFS_BRANCH);
public static final ColorKey REFS_REMOTE_BRANCH = ColorKey.createColorKey("GIT_REFS_BRANCH_REF", VcsLogColors.REFS_BRANCH_REF);
public static final ColorKey REFS_TAG = ColorKey.createColorKey("GIT_REFS_TAG", VcsLogColors.REFS_TAG);
public static final ColorKey REFS_OTHER = ColorKey.createColorKey("GIT_REFS_OTHER", VcsLogColors.REFS_TAG);
@NotNull
@Override
public List<ColorDescriptor> getColorDescriptors() {
return Arrays.asList(
new ColorDescriptor("VCS Log//Git//Head", REFS_HEAD, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Git//Local branch", REFS_LOCAL_BRANCH, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Git//Remote branch", REFS_REMOTE_BRANCH, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Git//Tag", REFS_TAG, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Git//Other", REFS_OTHER, ColorDescriptor.Kind.FOREGROUND)
);
}
}
@@ -19,20 +19,18 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsNotifier;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.VcsLogData;
import com.intellij.vcs.log.impl.HashImpl;
import com.intellij.vcs.log.impl.VcsLogUtil;
import com.intellij.vcs.log.ui.highlighters.MergeCommitsHighlighter;
import com.intellij.vcs.log.ui.highlighters.VcsLogHighlighterFactory;
import git4idea.GitBranch;
import git4idea.commands.GitCommand;
@@ -128,9 +126,8 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
@Override
public VcsLogHighlighter.VcsCommitStyle getStyle(@NotNull VcsShortCommitDetails commitDetails, boolean isSelected) {
if (myNonPickedCommits == null) return VcsCommitStyle.DEFAULT;
return VcsCommitStyleFactory.foreground(!myNonPickedCommits.contains(new CommitId(commitDetails.getId(), commitDetails.getRoot()))
? MergeCommitsHighlighter.MERGE_COMMIT_FOREGROUND
: null);
boolean inNonPicked = myNonPickedCommits.contains(new CommitId(commitDetails.getId(), commitDetails.getRoot()));
return VcsCommitStyleFactory.foreground(inNonPicked ? null : EditorColorsUtil.getGlobalOrDefaultColor(VcsLogColors.MERGED_COMMIT));
}
@Override
@@ -199,7 +196,6 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
@NotNull private final String myComparedBranch;
@NotNull private final Set<CommitId> myCollectedNonPickedCommits = ContainerUtil.newHashSet();
@Nullable private VcsException myException;
private boolean myCancelled;
public MyTask(@NotNull Project project,
@@ -215,17 +211,11 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
for (Map.Entry<GitRepository, GitBranch> entry : myRepositoriesWithCurrentBranches.entrySet()) {
GitRepository repo = entry.getKey();
GitBranch currentBranch = entry.getValue();
myCollectedNonPickedCommits
.addAll(getNonPickedCommitsFromGit(myProject, repo.getRoot(), currentBranch.getName(), myComparedBranch));
}
}
catch (VcsException e) {
LOG.warn(e);
myException = e;
for (Map.Entry<GitRepository, GitBranch> entry : myRepositoriesWithCurrentBranches.entrySet()) {
GitRepository repo = entry.getKey();
GitBranch currentBranch = entry.getValue();
myCollectedNonPickedCommits
.addAll(getNonPickedCommitsFromGit(myProject, repo.getRoot(), currentBranch.getName(), myComparedBranch));
}
}
@@ -237,10 +227,6 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
removeHighlighting();
if (myException != null) {
VcsNotifier.getInstance(myProject).notifyError("Couldn't compare with branch " + myComparedBranch, myException.getMessage());
return;
}
myNonPickedCommits = myCollectedNonPickedCommits;
}
@@ -250,9 +236,9 @@ public class DeepComparator implements VcsLogHighlighter, Disposable {
@NotNull
private Set<CommitId> getNonPickedCommitsFromGit(@NotNull Project project,
@NotNull final VirtualFile root,
@NotNull VirtualFile root,
@NotNull String currentBranch,
@NotNull String comparedBranch) throws VcsException {
@NotNull String comparedBranch) {
GitLineHandler handler = new GitLineHandler(project, root, GitCommand.CHERRY);
handler.addParameters(currentBranch, comparedBranch); // upstream - current branch; head - compared branch
@@ -2,17 +2,23 @@ package git4idea.log;
import com.intellij.dvcs.repo.RepositoryManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.ObjectUtils;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.RefGroup;
import com.intellij.vcs.log.VcsLogRefManager;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.VcsRefType;
import com.intellij.vcs.log.impl.SimpleRefGroup;
import com.intellij.vcs.log.impl.SingletonRefGroup;
import com.intellij.vcs.log.impl.VcsLogUtil;
import git4idea.GitBranch;
import git4idea.GitColors;
import git4idea.GitRemoteBranch;
import git4idea.GitTag;
import git4idea.repo.GitBranchTrackInfo;
@@ -32,11 +38,11 @@ import java.util.List;
* @author Kirill Likhodedov
*/
public class GitRefManager implements VcsLogRefManager {
public static final VcsRefType HEAD = new SimpleRefType(true, VcsLogStandardColors.Refs.TIP, "HEAD");
public static final VcsRefType LOCAL_BRANCH = new SimpleRefType(true, VcsLogStandardColors.Refs.BRANCH, "LOCAL_BRANCH");
public static final VcsRefType REMOTE_BRANCH = new SimpleRefType(true, VcsLogStandardColors.Refs.BRANCH_REF, "REMOTE_BRANCH");
public static final VcsRefType TAG = new SimpleRefType(false, VcsLogStandardColors.Refs.TAG, "TAG");
public static final VcsRefType OTHER = new SimpleRefType(false, VcsLogStandardColors.Refs.TAG, "OTHER");
public static final VcsRefType HEAD = new SimpleRefType(true, GitColors.REFS_HEAD);
public static final VcsRefType LOCAL_BRANCH = new SimpleRefType(true, GitColors.REFS_LOCAL_BRANCH);
public static final VcsRefType REMOTE_BRANCH = new SimpleRefType(true, GitColors.REFS_REMOTE_BRANCH);
public static final VcsRefType TAG = new SimpleRefType(false, GitColors.REFS_TAG);
public static final VcsRefType OTHER = new SimpleRefType(false, GitColors.REFS_OTHER);
private static final List<VcsRefType> REF_TYPE_INDEX = Arrays.asList(HEAD, LOCAL_BRANCH, REMOTE_BRANCH, TAG, OTHER);
@@ -313,13 +319,11 @@ public class GitRefManager implements VcsLogRefManager {
private static class SimpleRefType implements VcsRefType {
private final boolean myIsBranch;
@NotNull private final Color myColor;
@NotNull private final String myName;
private final ColorKey myColorKey;
public SimpleRefType(boolean isBranch, @NotNull Color color, @NotNull String typeName) {
public SimpleRefType(boolean isBranch, @NotNull ColorKey colorKey) {
myIsBranch = isBranch;
myColor = color;
myName = typeName;
myColorKey = colorKey;
}
@Override
@@ -329,13 +333,13 @@ public class GitRefManager implements VcsLogRefManager {
@NotNull
@Override
public Color getBackgroundColor() {
return myColor;
public ColorKey getBgColorKey() {
return myColorKey;
}
@Override
public String toString() {
return myName;
return myColorKey.getExternalName();
}
@Override
@@ -343,12 +347,12 @@ public class GitRefManager implements VcsLogRefManager {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SimpleRefType type = (SimpleRefType)o;
return myIsBranch == type.myIsBranch && Objects.equals(myName, type.myName);
return myIsBranch == type.myIsBranch && myColorKey == type.myColorKey;
}
@Override
public int hashCode() {
return Objects.hash(myIsBranch, myName);
return Objects.hash(myIsBranch, myColorKey);
}
}
@@ -381,7 +385,8 @@ public class GitRefManager implements VcsLogRefManager {
@NotNull
@Override
public List<Color> getColors() {
return Collections.singletonList(VcsLogStandardColors.Refs.TIP);
Color color = EditorColorsUtil.getGlobalOrDefaultColor(GitColors.REFS_HEAD);
return Collections.singletonList(color);
}
}
@@ -414,7 +419,8 @@ public class GitRefManager implements VcsLogRefManager {
@NotNull
@Override
public List<Color> getColors() {
return Collections.singletonList(VcsLogStandardColors.Refs.BRANCH_REF);
Color color = EditorColorsUtil.getGlobalOrDefaultColor(GitColors.REFS_REMOTE_BRANCH);
return Collections.singletonList(color);
}
}
+1
View File
@@ -32,6 +32,7 @@
<logProvider implementation="org.zmlx.hg4idea.log.HgLogProvider"/>
<vcs.taskHandler implementation="org.zmlx.hg4idea.HgTaskHandler"/>
<vcs.ignoredFilesHolder implementation="org.zmlx.hg4idea.provider.HgIgnoredFileHolder$Provider"/>
<vcsColorsProvider implementation="org.zmlx.hg4idea.HgColors"/>
<applicationService serviceInterface="org.zmlx.hg4idea.HgGlobalSettings"
serviceImplementation="org.zmlx.hg4idea.HgGlobalSettings"/>
@@ -0,0 +1,58 @@
/*
* Copyright 2000-2017 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 org.zmlx.hg4idea;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.ui.JBColor;
import com.intellij.vcs.VcsColorsProvider;
import com.intellij.vcs.log.VcsLogColors;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.Arrays;
import java.util.List;
/**
* @author gregsh
*/
public class HgColors extends VcsColorsProvider {
public static final ColorKey REFS_TIP = ColorKey.createColorKey("HG_REFS_TIP", VcsLogColors.REFS_HEAD);
public static final ColorKey REFS_HEAD = ColorKey.createColorKey("HG_REFS_HEAD", VcsLogColors.REFS_LEAF);
public static final ColorKey REFS_BRANCH = ColorKey.createColorKey("HG_REFS_BRANCH", VcsLogColors.REFS_BRANCH);
public static final ColorKey REFS_BOOKMARK = ColorKey.createColorKey("HG_REFS_BOOKMARK", VcsLogColors.REFS_BRANCH_REF);
public static final ColorKey REFS_TAG = ColorKey.createColorKey("HG_REFS_TAG", VcsLogColors.REFS_TAG);
public static final ColorKey CLOSED_BRANCH = ColorKey.createColorKey("HG_CLOSED_BRANCH", new JBColor(new Color(0x823139), new Color(0xff5f6f)));
public static final ColorKey LOCAL_TAG = ColorKey.createColorKey("HG_LOCAL_TAG", new JBColor(new Color(0x009090), new Color(0x00f3f3)));
public static final ColorKey MQ_TAG = ColorKey.createColorKey("HG_MQ_TAG", new JBColor(new Color(0x002f90), new Color(0x0055ff)));
@NotNull
@Override
public List<ColorDescriptor> getColorDescriptors() {
return Arrays.asList(
new ColorDescriptor("VCS Log//Mercurial//Tip", REFS_TIP, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Mercurial//Head", REFS_HEAD, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Mercurial//Branch", REFS_BRANCH, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Mercurial//Bookmark", REFS_BOOKMARK, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Mercurial//Tag", REFS_TAG, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Mercurial//Closed branch", CLOSED_BRANCH, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Mercurial//Local tag", LOCAL_TAG, ColorDescriptor.Kind.FOREGROUND),
new ColorDescriptor("VCS Log//Mercurial//MQ tag", MQ_TAG, ColorDescriptor.Kind.FOREGROUND)
);
}
}
@@ -15,35 +15,34 @@
*/
package org.zmlx.hg4idea.log;
import com.intellij.ui.JBColor;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.RefGroup;
import com.intellij.vcs.log.VcsLogRefManager;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.VcsRefType;
import com.intellij.vcs.log.impl.SimpleRefGroup;
import com.intellij.vcs.log.impl.SingletonRefGroup;
import com.intellij.vcs.log.impl.VcsLogUtil;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.HgColors;
import java.awt.*;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.*;
import java.util.List;
public class HgRefManager implements VcsLogRefManager {
private static final Color CLOSED_BRANCH_COLOR = new JBColor(new Color(0x823139), new Color(0xff5f6f));
private static final Color LOCAL_TAG_COLOR = new JBColor(new Color(0x009090), new Color(0x00f3f3));
private static final Color MQ_TAG_COLOR = new JBColor(new Color(0x002f90), new Color(0x0055ff));
public static final VcsRefType TIP = new SimpleRefType("TIP", true, VcsLogStandardColors.Refs.TIP);
public static final VcsRefType HEAD = new SimpleRefType("HEAD", true, VcsLogStandardColors.Refs.LEAF);
public static final VcsRefType BRANCH = new SimpleRefType("BRANCH", true, VcsLogStandardColors.Refs.BRANCH);
public static final VcsRefType CLOSED_BRANCH = new SimpleRefType("CLOSED_BRANCH", false, CLOSED_BRANCH_COLOR);
public static final VcsRefType BOOKMARK = new SimpleRefType("BOOKMARK", true, VcsLogStandardColors.Refs.BRANCH_REF);
public static final VcsRefType TAG = new SimpleRefType("TAG", false, VcsLogStandardColors.Refs.TAG);
public static final VcsRefType LOCAL_TAG = new SimpleRefType("LOCAL_TAG", false, LOCAL_TAG_COLOR);
public static final VcsRefType MQ_APPLIED_TAG = new SimpleRefType("MQ_TAG", false, MQ_TAG_COLOR);
public static final VcsRefType TIP = new SimpleRefType("TIP", true, HgColors.REFS_TIP);
public static final VcsRefType HEAD = new SimpleRefType("HEAD", true, HgColors.REFS_HEAD);
public static final VcsRefType BRANCH = new SimpleRefType("BRANCH", true, HgColors.REFS_BRANCH);
public static final VcsRefType CLOSED_BRANCH = new SimpleRefType("CLOSED_BRANCH", false, HgColors.CLOSED_BRANCH);
public static final VcsRefType BOOKMARK = new SimpleRefType("BOOKMARK", true, HgColors.REFS_BOOKMARK);
public static final VcsRefType TAG = new SimpleRefType("TAG", false, HgColors.REFS_TAG);
public static final VcsRefType LOCAL_TAG = new SimpleRefType("LOCAL_TAG", false, HgColors.LOCAL_TAG);
public static final VcsRefType MQ_APPLIED_TAG = new SimpleRefType("MQ_TAG", false, HgColors.MQ_TAG);
// first has the highest priority
private static final List<VcsRefType> REF_TYPE_PRIORITIES = Arrays.asList(TIP, HEAD, BRANCH, BOOKMARK, TAG);
@@ -155,9 +154,9 @@ public class HgRefManager implements VcsLogRefManager {
private static class SimpleRefType implements VcsRefType {
@NotNull private final String myName;
private final boolean myIsBranch;
@NotNull private final Color myColor;
@NotNull private final ColorKey myColor;
public SimpleRefType(@NotNull String name, boolean isBranch, @NotNull Color color) {
public SimpleRefType(@NotNull String name, boolean isBranch, @NotNull ColorKey color) {
myName = name;
myIsBranch = isBranch;
myColor = color;
@@ -170,7 +169,7 @@ public class HgRefManager implements VcsLogRefManager {
@NotNull
@Override
public Color getBackgroundColor() {
public ColorKey getBgColorKey() {
return myColor;
}