1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 14 import java.util.Map ; 15 16 import org.eclipse.osgi.util.TextProcessor; 17 18 public class CVSDecoratorConfiguration { 19 20 public static final String RESOURCE_NAME = "name"; public static final String RESOURCE_TAG = "tag"; public static final String FILE_REVISION = "revision"; public static final String FILE_KEYWORD = "keyword"; 26 public static final String REMOTELOCATION_METHOD = "method"; public static final String REMOTELOCATION_USER = "user"; public static final String REMOTELOCATION_HOST = "host"; public static final String REMOTELOCATION_ROOT = "root"; public static final String REMOTELOCATION_REPOSITORY = "repository"; public static final String REMOTELOCATION_LABEL = "label"; 34 public static final String NEW_DIRTY_FLAG = "outgoing_change_flag"; public static final String OLD_DIRTY_FLAG = "dirty_flag"; public static final String ADDED_FLAG = "added_flag"; public static final String DEFAULT_DIRTY_FLAG = CVSUIMessages.CVSDecoratorConfiguration_0; 40 public static final String DEFAULT_ADDED_FLAG = CVSUIMessages.CVSDecoratorConfiguration_1; 41 42 public static final String DEFAULT_FILETEXTFORMAT = CVSUIMessages.CVSDecoratorConfiguration_2; 44 public static final String DEFAULT_FOLDERTEXTFORMAT = CVSUIMessages.CVSDecoratorConfiguration_3; 45 public static final String DEFAULT_PROJECTTEXTFORMAT = CVSUIMessages.CVSDecoratorConfiguration_4; 46 47 private static final char KEYWORD_SEPCOLON = ':'; 49 private static final char KEYWORD_SEPAT = '@'; 50 51 public static final String OUTGOING_CHANGE_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_foreground_color"; public static final String OUTGOING_CHANGE_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_background_color"; public static final String OUTGOING_CHANGE_FONT = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_font"; public static final String IGNORED_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_foreground_color"; public static final String IGNORED_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_background_color"; public static final String IGNORED_FONT = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_font"; 59 public static void decorate(CVSDecoration decoration, String format, Map bindings) { 60 StringBuffer prefix = new StringBuffer (); 61 StringBuffer suffix = new StringBuffer (); 62 StringBuffer output = prefix; 63 64 int length = format.length(); 65 int start = -1; 66 int end = length; 67 while (true) { 68 if ((end = format.indexOf('{', start)) > -1) { 69 output.append(format.substring(start + 1, end)); 70 if ((start = format.indexOf('}', end)) > -1) { 71 String key = format.substring(end + 1, start); 72 String s; 73 74 if(key.equals(RESOURCE_NAME)) { 76 output = suffix; 77 s = null; 78 } else { 79 s = (String ) bindings.get(key); 80 } 81 82 if(s!=null) { 83 output.append(s); 84 } else { 85 int curLength = output.length(); 87 if(curLength>0) { 88 char c = output.charAt(curLength - 1); 89 if(c == KEYWORD_SEPCOLON || c == KEYWORD_SEPAT) { 90 output.deleteCharAt(curLength - 1); 91 } 92 } 93 } 94 } else { 95 output.append(format.substring(end, length)); 96 break; 97 } 98 } else { 99 output.append(format.substring(start + 1, length)); 100 break; 101 } 102 } 103 104 if (prefix.length() != 0) { 105 decoration.addPrefix(TextProcessor.process(prefix.toString(),"()[].")); } 107 if (suffix.length() != 0) { 108 decoration.addSuffix(TextProcessor.process(suffix.toString(),"()[].")); } 110 } 111 } 112 | Popular Tags |