diff options
| author | Mathias Kinzler | 2010-03-18 16:28:50 +0000 |
|---|---|---|
| committer | Matthias Sohn | 2010-03-25 23:55:49 +0000 |
| commit | 14ac3efaab9305704a864903de54c76e33dd4043 (patch) | |
| tree | 6d317bc0741f6c51561153a89adeddb9394629ce | |
| parent | 83c26754272bc930eff2b07edcb19c892657ae01 (diff) | |
| download | egit-14ac3efaab9305704a864903de54c76e33dd4043.tar.gz egit-14ac3efaab9305704a864903de54c76e33dd4043.tar.xz egit-14ac3efaab9305704a864903de54c76e33dd4043.zip | |
Allow to use the repository name in Git Label Decorations
Currently, the Git (text-) label decorations include variables for dirty,
staged, and branch. Since there are many repositories with the same "master"
branch, we should have a "repository name" variable. This should be the name
of the repository's directory. While not necessarily unique, this helps in
identifying the repository in the project explorer.
Bug: 306397
Change-Id: I08f8bc2681fc2440ca684bd1735a4a0d7468cea6
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
6 files changed, 50 insertions, 13 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java index 6d1546461b..6926529bdb 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java @@ -124,6 +124,9 @@ public class UIText extends NLS { public static String GitCloneWizard_errorCannotCreate; /** */ + public static String GitDecoratorPreferencePage_bindingRepositoryNameFlag; + + /** */ public static String GitHistoryPage_CompareVersions; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java index f83134c363..2cf5b8bd81 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java @@ -61,6 +61,8 @@ class DecoratableResourceAdapter implements IDecoratableResource { private String branch = ""; //$NON-NLS-1$ + private final String repositoryName; + private boolean tracked = false; private boolean ignored = false; @@ -89,6 +91,12 @@ class DecoratableResourceAdapter implements IDecoratableResource { store = Activator.getDefault().getPreferenceStore(); + File gitDir = repository.getDirectory(); + if (gitDir != null) + repositoryName = repository.getDirectory().getParentFile() + .getName(); + else + repositoryName = ""; //$NON-NLS-1$ // TODO: Add option to shorten branch name to 6 chars if it's a SHA branch = repository.getBranch(); @@ -379,6 +387,10 @@ class DecoratableResourceAdapter implements IDecoratableResource { return resource.getType(); } + public String getRepositoryName() { + return repositoryName; + } + public String getBranch() { return branch; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java index 8e9083c226..446fe6b501 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java @@ -231,6 +231,9 @@ public class GitLightweightDecorator extends LabelProvider implements public static final String BINDING_BRANCH_NAME = "branch"; //$NON-NLS-1$ /** */ + public static final String BINDING_REPOSITORY_NAME = "repository"; //$NON-NLS-1$ + + /** */ public static final String BINDING_DIRTY_FLAG = "dirty"; //$NON-NLS-1$ /** */ @@ -355,6 +358,7 @@ public class GitLightweightDecorator extends LabelProvider implements Map<String, String> bindings = new HashMap<String, String>(); bindings.put(BINDING_RESOURCE_NAME, resource.getName()); + bindings.put(BINDING_REPOSITORY_NAME, resource.getRepositoryName()); bindings.put(BINDING_BRANCH_NAME, resource.getBranch()); bindings.put(BINDING_DIRTY_FLAG, resource.isDirty() ? ">" : null); //$NON-NLS-1$ bindings.put(BINDING_STAGED_FLAG, diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java index b45a13c9dc..6ab99a14d1 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java @@ -47,6 +47,14 @@ public interface IDecoratableResource { String getName(); /** + * Gets the name of the repository of the resource + * + * @return the name of the current branch, or <code>null</code> if not + * applicable + */ + String getRepositoryName(); + + /** * Gets the current branch of the resource if applicable * * @return the name of the current branch, or <code>null</code> if not diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java index fb1462eb1f..908cd25499 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitDecoratorPreferencePage.java @@ -102,42 +102,42 @@ public class GitDecoratorPreferencePage extends PreferencePage implements static { final PreviewResource project = new PreviewResource( - "Project", IResource.PROJECT, "master", true, false, true, Staged.NOT_STAGED, false, false); //$NON-NLS-1$ //$NON-NLS-2$1 + "Project", IResource.PROJECT, "repository", "master", true, false, true, Staged.NOT_STAGED, false, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ final ArrayList<PreviewResource> children = new ArrayList<PreviewResource>(); children .add(new PreviewResource( - "folder", IResource.FOLDER, null, true, false, true, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ + "folder", IResource.FOLDER, "repository", null, true, false, true, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "tracked.txt", IResource.FILE, null, true, false, false, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ + "tracked.txt", IResource.FILE, "repository", null, true, false, false, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "untracked.txt", IResource.FILE, null, false, false, false, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ + "untracked.txt", IResource.FILE, "repository", null, false, false, false, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "ignored.txt", IResource.FILE, null, false, true, false, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ + "ignored.txt", IResource.FILE, "repository", null, false, true, false, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "dirty.txt", IResource.FILE, null, true, false, true, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ + "dirty.txt", IResource.FILE, "repository", null, true, false, true, Staged.NOT_STAGED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "staged.txt", IResource.FILE, null, true, false, false, Staged.MODIFIED, false, false)); //$NON-NLS-1$ + "staged.txt", IResource.FILE, "repository", null, true, false, false, Staged.MODIFIED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "partially-staged.txt", IResource.FILE, null, true, false, true, Staged.MODIFIED, false, false)); //$NON-NLS-1$ + "partially-staged.txt", IResource.FILE, "repository", null, true, false, true, Staged.MODIFIED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "added.txt", IResource.FILE, null, true, false, false, Staged.ADDED, false, false)); //$NON-NLS-1$ + "added.txt", IResource.FILE, "repository", null, true, false, false, Staged.ADDED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "removed.txt", IResource.FILE, null, true, false, false, Staged.REMOVED, false, false)); //$NON-NLS-1$ + "removed.txt", IResource.FILE, "repository", null, true, false, false, Staged.REMOVED, false, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "conflict.txt", IResource.FILE, null, true, false, true, Staged.NOT_STAGED, true, false)); //$NON-NLS-1$ + "conflict.txt", IResource.FILE, "repository", null, true, false, true, Staged.NOT_STAGED, true, false)); //$NON-NLS-1$ //$NON-NLS-2$ children .add(new PreviewResource( - "assume-valid.txt", IResource.FILE, null, true, false, false, Staged.NOT_STAGED, false, true)); //$NON-NLS-1$ + "assume-valid.txt", IResource.FILE, "repository", null, true, false, false, Staged.NOT_STAGED, false, true)); //$NON-NLS-1$ //$NON-NLS-2$ project.children = children; PREVIEW_FILESYSTEM_ROOT = Collections.singleton(project); @@ -156,6 +156,8 @@ public class GitDecoratorPreferencePage extends PreferencePage implements UIText.DecoratorPreferencesPage_bindingDirtyFlag); PROJECT_BINDINGS.put(DecorationHelper.BINDING_STAGED_FLAG, UIText.DecoratorPreferencesPage_bindingStagedFlag); + PROJECT_BINDINGS.put(DecorationHelper.BINDING_REPOSITORY_NAME, + UIText.GitDecoratorPreferencePage_bindingRepositoryNameFlag); PROJECT_BINDINGS.put(DecorationHelper.BINDING_BRANCH_NAME, UIText.DecoratorPreferencesPage_bindingBranchName); } @@ -800,6 +802,8 @@ public class GitDecoratorPreferencePage extends PreferencePage implements private static class PreviewResource implements IDecoratableResource { private final String name; + private final String repositoryName; + private final String branch; private final int type; @@ -818,11 +822,12 @@ public class GitDecoratorPreferencePage extends PreferencePage implements private boolean assumeValid; - public PreviewResource(String name, int type, String branch, + public PreviewResource(String name, int type, String repositoryName, String branch, boolean tracked, boolean ignored, boolean dirty, Staged staged, boolean conflicts, boolean assumeValid) { this.name = name; + this.repositoryName = repositoryName; this.branch = branch; this.type = type; this.children = Collections.EMPTY_LIST; @@ -838,6 +843,10 @@ public class GitDecoratorPreferencePage extends PreferencePage implements return name; } + public String getRepositoryName() { + return repositoryName; + } + public int getType() { return type; } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties index 01e95f29f0..b2aca2a7ea 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties @@ -46,6 +46,7 @@ GitCloneWizard_title=Import Git Repository GitCloneWizard_jobName=Cloning from {0} GitCloneWizard_failed=Git repository clone failed. GitCloneWizard_errorCannotCreate=Cannot create directory {0}. +GitDecoratorPreferencePage_bindingRepositoryNameFlag=name of the repository GitHistoryPage_CompareVersions=Compare with each other GitHistoryPage_CompareWithWorking=Compare with working tree GitHistoryPage_FileNotInCommit={0} not in {1} |
