[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Tag or branch name as label decoration

From: Matthias Kramer <simplex_99_at_gmx.de>
Date: 2004-12-05 14:00:54 CET

Hi Devs,

in the CVS plugin I liked very much that I could decorate projects,
folders and files with the currently checked out tag or branch name. In
Subclipse there is a similiar functionality that decorates with the
repository url. For its length that url can sometimes be unpractical.
Attached you'll find a patch for the ui-plugin project that makes a new
decoration {url_short} available showing only the part of the url above
the project name. For example if your url is something like
"http://svn.foo.org/foo/bar/myproject/src/mypackage/myfile.java" the
{url_short} decoration would resolve to "bar" for the project, the
package and the file, which is in most cases the current branch or tag name.

I thought some others could find the patch useful, so here it is.

Regards
Matthias

P.S. The patch was made against the 0.9.24 sources.

Index: ui/src/org/tigris/subversion/subclipse/ui/decorator/SVNDecoratorConfiguration.java
===================================================================
--- ui/src/org/tigris/subversion/subclipse/ui/decorator/SVNDecoratorConfiguration.java (revision 1130)
+++ ui/src/org/tigris/subversion/subclipse/ui/decorator/SVNDecoratorConfiguration.java (working copy)
@@ -63,6 +63,7 @@
     public static final String RESOURCE_AUTHOR = "author"; //$NON-NLS-1$
     public static final String RESOURCE_DATE = "date"; //$NON-NLS-1$
         public static final String RESOURCE_URL = "url"; //$NON-NLS-1$
+ public static final String RESOURCE_URL_SHORT = "url_short"; //$NON-NLS-1$
     
         // bindings for resource states
         public static final String DIRTY_FLAG = "dirty_flag"; //$NON-NLS-1$
Index: ui/src/org/tigris/subversion/subclipse/ui/decorator/SVNLightweightDecorator.java
===================================================================
--- ui/src/org/tigris/subversion/subclipse/ui/decorator/SVNLightweightDecorator.java (revision 1130)
+++ ui/src/org/tigris/subversion/subclipse/ui/decorator/SVNLightweightDecorator.java (working copy)
@@ -248,7 +248,7 @@
      */
         public void decorateTextLabel(IResource resource, IDecoration decoration, boolean isDirty) {
                 try {
- Map bindings = new HashMap(5);
+ Map bindings = new HashMap(6);
 
                         // if the resource does not have a location then return. This can happen if the resource
                         // has been deleted after we where asked to decorate it.
@@ -279,6 +279,11 @@
                                 bindings.put(
                                         SVNDecoratorConfiguration.RESOURCE_URL,
                                         status.getUrl().toString());
+ String shortUrl = status.getUrl().toString().substring(0, status.getUrl().toString().length() - resource.getFullPath().toString().length());
+ shortUrl = shortUrl.substring(shortUrl.lastIndexOf('/') + 1);
+ bindings.put(
+ SVNDecoratorConfiguration.RESOURCE_URL_SHORT,
+ shortUrl);
                         }
                         
                         if (status.isAdded()) {
Index: ui/src/org/tigris/subversion/subclipse/ui/preferences/SVNDecoratorPreferencesPage.java
===================================================================
--- ui/src/org/tigris/subversion/subclipse/ui/preferences/SVNDecoratorPreferencesPage.java (revision 1130)
+++ ui/src/org/tigris/subversion/subclipse/ui/preferences/SVNDecoratorPreferencesPage.java (working copy)
@@ -181,6 +181,7 @@
         bindings.put(SVNDecoratorConfiguration.RESOURCE_AUTHOR, "cchab"); //$NON-NLS-1$
         bindings.put(SVNDecoratorConfiguration.RESOURCE_DATE, DateFormat.getInstance().format(new Date())); //$NON-NLS-1$
         bindings.put(SVNDecoratorConfiguration.RESOURCE_URL, "http://localhost:8080/svn/repos/"); //$NON-NLS-1$
+ bindings.put(SVNDecoratorConfiguration.RESOURCE_URL_SHORT, "repos"); //$NON-NLS-1$
                 bindings.put(SVNDecoratorConfiguration.DIRTY_FLAG, dirtyFlag.getText());
                 bindings.put(SVNDecoratorConfiguration.ADDED_FLAG, addedFlag.getText());
         bindings.put(SVNDecoratorConfiguration.EXTERNAL_FLAG, externalFlag.getText());
@@ -499,6 +500,7 @@
         bindings.put(SVNDecoratorConfiguration.RESOURCE_NAME, Policy.bind("SVNDecoratorPreferencesPage.nameResourceVariable")); //$NON-NLS-1$
         bindings.put(SVNDecoratorConfiguration.DIRTY_FLAG, Policy.bind("SVNDecoratorPreferencesPage.flagDirtyVariable")); //$NON-NLS-1$
         bindings.put(SVNDecoratorConfiguration.RESOURCE_URL, Policy.bind("SVNDecoratorPreferencesPage.remoteLocationVariable")); //$NON-NLS-1$
+ bindings.put(SVNDecoratorConfiguration.RESOURCE_URL_SHORT, Policy.bind("SVNDecoratorPreferencesPage.remoteLocationVariableShort")); //$NON-NLS-1$
         return bindings;
     }
     
Index: ui/src/org/tigris/subversion/subclipse/ui/messages.properties
===================================================================
--- ui/src/org/tigris/subversion/subclipse/ui/messages.properties (revision 1130)
+++ ui/src/org/tigris/subversion/subclipse/ui/messages.properties (working copy)
@@ -535,6 +535,7 @@
 SVNDecoratorPreferencesPage.newResources=Indicate is &new resource
 SVNDecoratorPreferencesPage.projectFormat=&Project Format:
 SVNDecoratorPreferencesPage.remoteLocationVariable=url of remote repository
+SVNDecoratorPreferencesPage.remoteLocationVariableShort=last part of remote repository url (tag or branch name)
 SVNDecoratorPreferencesPage.revisionResourceVariable=last revision loaded into workspace
 SVNDecoratorPreferencesPage.selectFormats=Select the format for file, folders, and project text labels:
 SVNDecoratorPreferencesPage.selectVariablesToAdd=Select the &variables to add to the decoration format:
Received on Mon Dec 6 00:00:54 2004

This is an archived mail posted to the Subclipse Dev mailing list.