| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
package com.bonevich.eclipse.cvsgrapher; |
| 59 |
|
|
| 60 |
|
import org.eclipse.core.resources.IWorkspace; |
| 61 |
|
import org.eclipse.core.resources.ResourcesPlugin; |
| 62 |
|
import org.eclipse.core.runtime.IPluginDescriptor; |
| 63 |
|
import org.eclipse.jface.preference.IPreferenceStore; |
| 64 |
|
import org.eclipse.swt.graphics.Color; |
| 65 |
|
import org.eclipse.ui.plugin.AbstractUIPlugin; |
| 66 |
|
|
| 67 |
|
import java.util.ResourceBundle; |
| 68 |
|
import java.util.regex.Pattern; |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
public final class CvsGraphPlugin |
| 74 |
|
extends AbstractUIPlugin |
| 75 |
|
implements CvsGraphPluginResources |
| 76 |
|
{ |
| 77 |
|
public static final String PREFERENCE_COLOR_VERSION = "cvsgrapher.prefs.color.version"; |
| 78 |
|
public static final String PREFERENCE_COLOR_BRANCH = "cvsgrapher.prefs.color.branch"; |
| 79 |
|
public static final String PREFERENCE_MERGETAG_SOURCE = "cvsgrapher.prefs.mergetag.pattern.source"; |
| 80 |
|
public static final String PREFERENCE_MERGETAG_DEST = "cvsgrapher.prefs.mergetag.pattern.dest"; |
| 81 |
|
public static final String PREFERENCE_SHOW_AUTHOR = "cvsgrapher.prefs.show.author"; |
| 82 |
|
public static final String PREFERENCE_SHOW_TIMESTAMP = "cvsgrapher.prefs.show.timestamp"; |
| 83 |
|
public static final String PREFERENCE_SHOW_TAGS = "cvsgrapher.prefs.show.tags"; |
| 84 |
|
|
| 85 |
|
public static final String DEFAULT_COLOR_VERSION = "211,211,211"; |
| 86 |
|
public static final String DEFAULT_COLOR_BRANCH = "255,255,0"; |
| 87 |
|
|
| 88 |
|
public static final String DEFAULT_MERGETAG_SOURCE = "source_(.*)"; |
| 89 |
|
public static final String DEFAULT_MERGETAG_DEST = "merge_(.*)"; |
| 90 |
|
|
| 91 |
|
public static final boolean DEFAULT_SHOW_AUTHOR = true; |
| 92 |
|
public static final boolean DEFAULT_SHOW_TIMESTAMP = true; |
| 93 |
|
public static final boolean DEFAULT_SHOW_TAGS = true; |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
private static CvsGraphPlugin _currentInstance; |
| 97 |
|
private ColorConverter _converter; |
| 98 |
|
private Pattern _sourcePattern; |
| 99 |
|
private Pattern _destPattern; |
| 100 |
|
|
| 101 |
|
public CvsGraphPlugin(IPluginDescriptor descriptor) |
| 102 |
|
{ |
| 103 |
0 |
super(descriptor); |
| 104 |
0 |
_currentInstance = this; |
| 105 |
0 |
_converter = new ColorConverter(); |
| 106 |
0 |
} |
| 107 |
|
|
| 108 |
|
public static CvsGraphPlugin getPlugin() |
| 109 |
|
{ |
| 110 |
0 |
return _currentInstance; |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
public static IWorkspace getWorkspace() |
| 114 |
|
{ |
| 115 |
0 |
return ResourcesPlugin.getWorkspace(); |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
public static String getResourceString(String key) |
| 123 |
|
{ |
| 124 |
0 |
return CvsGraphPluginMessages.bind(key); |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
public ResourceBundle getResourceBundle() |
| 128 |
|
{ |
| 129 |
0 |
return CvsGraphPluginMessages.getResourceBundle(); |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
protected void initializeDefaultPreferences(IPreferenceStore store) |
| 133 |
|
{ |
| 134 |
0 |
store.setDefault(PREFERENCE_COLOR_VERSION, DEFAULT_COLOR_VERSION); |
| 135 |
0 |
store.setDefault(PREFERENCE_COLOR_BRANCH, DEFAULT_COLOR_BRANCH); |
| 136 |
0 |
store.setDefault(PREFERENCE_MERGETAG_SOURCE, DEFAULT_MERGETAG_SOURCE); |
| 137 |
0 |
store.setDefault(PREFERENCE_MERGETAG_DEST, DEFAULT_MERGETAG_DEST); |
| 138 |
0 |
store.setDefault(PREFERENCE_SHOW_AUTHOR, DEFAULT_SHOW_AUTHOR); |
| 139 |
0 |
store.setDefault(PREFERENCE_SHOW_TIMESTAMP, DEFAULT_SHOW_TIMESTAMP); |
| 140 |
0 |
store.setDefault(PREFERENCE_SHOW_TAGS, DEFAULT_SHOW_TAGS); |
| 141 |
0 |
} |
| 142 |
|
|
| 143 |
|
public Color getVersionNodeColorPreference() |
| 144 |
|
{ |
| 145 |
0 |
return _converter.getColor(getPreferenceStore().getString(PREFERENCE_COLOR_VERSION)); |
| 146 |
|
} |
| 147 |
|
|
| 148 |
|
public Color getBranchNodeColorPreference() |
| 149 |
|
{ |
| 150 |
0 |
return _converter.getColor(getPreferenceStore().getString(PREFERENCE_COLOR_BRANCH)); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
public Pattern getMergeTagSourcePreference() |
| 154 |
|
{ |
| 155 |
0 |
String patternString = getPreferenceStore().getString(PREFERENCE_MERGETAG_SOURCE); |
| 156 |
0 |
if (_sourcePattern == null || !_sourcePattern.pattern().equals(patternString)) |
| 157 |
|
{ |
| 158 |
0 |
_sourcePattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE); |
| 159 |
|
} |
| 160 |
0 |
return _sourcePattern; |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
public Pattern getMergeTagDestPreference() |
| 164 |
|
{ |
| 165 |
0 |
String patternString = getPreferenceStore().getString(PREFERENCE_MERGETAG_DEST); |
| 166 |
0 |
if (_destPattern == null || !_destPattern.pattern().equals(patternString)) |
| 167 |
|
{ |
| 168 |
0 |
_destPattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE); |
| 169 |
|
} |
| 170 |
0 |
return _destPattern; |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
public boolean showAuthorPreference() |
| 174 |
|
{ |
| 175 |
0 |
return getPreferenceStore().getBoolean(PREFERENCE_SHOW_AUTHOR); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
public boolean showTimestampPreference() |
| 179 |
|
{ |
| 180 |
0 |
return getPreferenceStore().getBoolean(PREFERENCE_SHOW_TIMESTAMP); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
public boolean showTagsPreference() |
| 184 |
|
{ |
| 185 |
0 |
return getPreferenceStore().getBoolean(PREFERENCE_SHOW_TAGS); |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
} |