Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 98771
Collapse All | Expand All

(-)src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java (-13 / +24 lines)
Lines 4-10 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
Lines 20-25 Link Here
20
import org.eclipse.swt.graphics.*;
20
import org.eclipse.swt.graphics.*;
21
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
21
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
22
import org.eclipse.team.internal.ccvs.core.util.Assert;
22
import org.eclipse.team.internal.ccvs.core.util.Assert;
23
import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager;
24
import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
23
import org.eclipse.team.internal.ui.TeamUIPlugin;
25
import org.eclipse.team.internal.ui.TeamUIPlugin;
24
import org.eclipse.team.ui.ISharedImages;
26
import org.eclipse.team.ui.ISharedImages;
25
import org.eclipse.ui.PlatformUI;
27
import org.eclipse.ui.PlatformUI;
Lines 35-47 Link Here
35
 * decoration APIs. As such a client can convert between them using helpers
37
 * decoration APIs. As such a client can convert between them using helpers
36
 * defined in this class.
38
 * defined in this class.
37
 * </p>
39
 * </p>
38
 * TODO: 
40
 * TODO:
39
 * profile
41
 * profile
40
 * add colors and fonts to preferences instead of being hard coded
42
 * add colors and fonts to preferences instead of being hard coded
41
 * what to do with CVSDecorationConfiguration class?
43
 * what to do with CVSDecorationConfiguration class?
42
 * preference page externalizations
44
 * preference page externalizations
43
 * preference page preview should update when theme changes
45
 * preference page preview should update when theme changes
44
 * 
46
 *
45
 * @since 3.1
47
 * @since 3.1
46
 */
48
 */
47
public class CVSDecoration {
49
public class CVSDecoration {
Lines 53-59 Link Here
53
	private Color bkgColor;
55
	private Color bkgColor;
54
	private Color fgColor;
56
	private Color fgColor;
55
	private Font font;
57
	private Font font;
56
	
58
57
	// Properties
59
	// Properties
58
	private int resourceType = IResource.FILE;
60
	private int resourceType = IResource.FILE;
59
	private boolean watchEditEnabled = false;
61
	private boolean watchEditEnabled = false;
Lines 78-84 Link Here
78
	private String dirtyTextIndicator;
80
	private String dirtyTextIndicator;
79
	private String addedTextIndicator;
81
	private String addedTextIndicator;
80
	private String resourceName;
82
	private String resourceName;
81
	
83
82
	//	Images cached for better performance
84
	//	Images cached for better performance
83
	private static ImageDescriptor dirty;
85
	private static ImageDescriptor dirty;
84
	private static ImageDescriptor checkedIn;
86
	private static ImageDescriptor checkedIn;
Lines 87-93 Link Here
87
	private static ImageDescriptor merged;
89
	private static ImageDescriptor merged;
88
	private static ImageDescriptor newResource;
90
	private static ImageDescriptor newResource;
89
	private static ImageDescriptor edited;
91
	private static ImageDescriptor edited;
90
	
92
91
	// List of preferences used to configure the decorations that
93
	// List of preferences used to configure the decorations that
92
	// are applied.
94
	// are applied.
93
	private Preferences preferences;
95
	private Preferences preferences;
Lines 131-137 Link Here
131
		// 	TODO: for efficiency don't look up a pref until its needed
133
		// 	TODO: for efficiency don't look up a pref until its needed
132
		IPreferenceStore store = getStore();
134
		IPreferenceStore store = getStore();
133
		Preferences prefs = new Preferences();
135
		Preferences prefs = new Preferences();
134
		
136
135
		prefs.setValue(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION));
137
		prefs.setValue(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION));
136
		prefs.setValue(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION));
138
		prefs.setValue(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION));
137
		prefs.setValue(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
139
		prefs.setValue(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, store.getBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
Lines 140-146 Link Here
140
		prefs.setValue(ICVSUIConstants.PREF_DIRTY_FLAG, store.getString(ICVSUIConstants.PREF_DIRTY_FLAG));
142
		prefs.setValue(ICVSUIConstants.PREF_DIRTY_FLAG, store.getString(ICVSUIConstants.PREF_DIRTY_FLAG));
141
		prefs.setValue(ICVSUIConstants.PREF_ADDED_FLAG, store.getString(ICVSUIConstants.PREF_ADDED_FLAG));
143
		prefs.setValue(ICVSUIConstants.PREF_ADDED_FLAG, store.getString(ICVSUIConstants.PREF_ADDED_FLAG));
142
		prefs.setValue(ICVSUIConstants.PREF_USE_FONT_DECORATORS, store.getString(ICVSUIConstants.PREF_USE_FONT_DECORATORS));
144
		prefs.setValue(ICVSUIConstants.PREF_USE_FONT_DECORATORS, store.getString(ICVSUIConstants.PREF_USE_FONT_DECORATORS));
143
		
145
144
		initialize(resourceName, prefs, store.getString(ICVSUIConstants.PREF_FILETEXT_DECORATION), store.getString(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION), store.getString(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION));
146
		initialize(resourceName, prefs, store.getString(ICVSUIConstants.PREF_FILETEXT_DECORATION), store.getString(ICVSUIConstants.PREF_FOLDERTEXT_DECORATION), store.getString(ICVSUIConstants.PREF_PROJECTTEXT_DECORATION));
145
	}
147
	}
146
148
Lines 203-209 Link Here
203
	public String getSuffix() {
205
	public String getSuffix() {
204
		return suffix;
206
		return suffix;
205
	}
207
	}
206
	
208
207
	public void setResourceType(int type) {
209
	public void setResourceType(int type) {
208
		this.resourceType = type;
210
		this.resourceType = type;
209
	}
211
	}
Lines 247-253 Link Here
247
		} else if(isHasRemote()){
249
		} else if(isHasRemote()){
248
			bindings.put(CVSDecoratorConfiguration.FILE_REVISION, getRevision());
250
			bindings.put(CVSDecoratorConfiguration.FILE_REVISION, getRevision());
249
			bindings.put(CVSDecoratorConfiguration.RESOURCE_TAG, getTag());
251
			bindings.put(CVSDecoratorConfiguration.RESOURCE_TAG, getTag());
250
		}	
252
		}
251
		bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, getResourceName());
253
		bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, getResourceName());
252
		bindings.put(CVSDecoratorConfiguration.FILE_KEYWORD, getKeywordSubstitution());
254
		bindings.put(CVSDecoratorConfiguration.FILE_KEYWORD, getKeywordSubstitution());
253
		if (resourceType != IResource.FILE && location != null) {
255
		if (resourceType != IResource.FILE && location != null) {
Lines 256-261 Link Here
256
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, location.getUsername());
258
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, location.getUsername());
257
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, location.getRootDirectory());
259
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, location.getRootDirectory());
258
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, repository);
260
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, repository);
261
262
            RepositoryManager repositoryManager = CVSUIPlugin.getPlugin().getRepositoryManager();
263
            RepositoryRoot root = repositoryManager.getRepositoryRootFor(location);
264
            CVSUIPlugin.getPlugin().getRepositoryManager();
265
            String label = root.getName();
266
            if (label == null) {
267
              label = location.getLocation(true);
268
            }
269
            bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, label);
259
		}
270
		}
260
		CVSDecoratorConfiguration.decorate(this, getTextFormatter(), bindings);
271
		CVSDecoratorConfiguration.decorate(this, getTextFormatter(), bindings);
261
	}
272
	}
Lines 286-297 Link Here
286
		}
297
		}
287
		//nothing matched
298
		//nothing matched
288
		return null;
299
		return null;
289
	}	
300
	}
290
	
301
291
	private void computeColorsAndFonts() {
302
	private void computeColorsAndFonts() {
292
		if (!preferences.getBoolean(ICVSUIConstants.PREF_USE_FONT_DECORATORS))
303
		if (!preferences.getBoolean(ICVSUIConstants.PREF_USE_FONT_DECORATORS))
293
			return;
304
			return;
294
			
305
295
		ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
306
		ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
296
		if(isIgnored()) {
307
		if(isIgnored()) {
297
			setBackgroundColor(current.getColorRegistry().get(CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR));
308
			setBackgroundColor(current.getColorRegistry().get(CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR));
(-)src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorConfiguration.java (-11 / +12 lines)
Lines 4-10 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
Lines 15-39 Link Here
15
15
16
public class CVSDecoratorConfiguration {
16
public class CVSDecoratorConfiguration {
17
17
18
	// bindings for 
18
	// bindings for
19
	public static final String RESOURCE_NAME = "name"; //$NON-NLS-1$
19
	public static final String RESOURCE_NAME = "name"; //$NON-NLS-1$
20
	public static final String RESOURCE_TAG = "tag"; //$NON-NLS-1$
20
	public static final String RESOURCE_TAG = "tag"; //$NON-NLS-1$
21
	public static final String FILE_REVISION = "revision"; //$NON-NLS-1$
21
	public static final String FILE_REVISION = "revision"; //$NON-NLS-1$
22
	public static final String FILE_KEYWORD = "keyword"; //$NON-NLS-1$
22
	public static final String FILE_KEYWORD = "keyword"; //$NON-NLS-1$
23
	
23
24
	// bindings for repository location
24
	// bindings for repository location
25
	public static final String REMOTELOCATION_METHOD = "method"; //$NON-NLS-1$
25
	public static final String REMOTELOCATION_METHOD = "method"; //$NON-NLS-1$
26
	public static final String REMOTELOCATION_USER = "user"; //$NON-NLS-1$
26
	public static final String REMOTELOCATION_USER = "user"; //$NON-NLS-1$
27
	public static final String REMOTELOCATION_HOST = "host"; //$NON-NLS-1$
27
	public static final String REMOTELOCATION_HOST = "host"; //$NON-NLS-1$
28
	public static final String REMOTELOCATION_ROOT = "root"; //$NON-NLS-1$
28
	public static final String REMOTELOCATION_ROOT = "root"; //$NON-NLS-1$
29
	public static final String REMOTELOCATION_REPOSITORY = "repository"; //$NON-NLS-1$
29
	public static final String REMOTELOCATION_REPOSITORY = "repository"; //$NON-NLS-1$
30
	
30
	public static final String REMOTELOCATION_LABEL = "label"; //$NON-NLS-1$
31
31
	// bindings for resource states
32
	// bindings for resource states
32
	public static final String DIRTY_FLAG = "dirty_flag"; //$NON-NLS-1$
33
	public static final String DIRTY_FLAG = "dirty_flag"; //$NON-NLS-1$
33
	public static final String ADDED_FLAG = "added_flag"; //$NON-NLS-1$
34
	public static final String ADDED_FLAG = "added_flag"; //$NON-NLS-1$
34
	public static final String DEFAULT_DIRTY_FLAG = ">"; //$NON-NLS-1$
35
	public static final String DEFAULT_DIRTY_FLAG = ">"; //$NON-NLS-1$
35
	public static final String DEFAULT_ADDED_FLAG = "*"; //$NON-NLS-1$
36
	public static final String DEFAULT_ADDED_FLAG = "*"; //$NON-NLS-1$
36
	
37
37
	// default text decoration formats
38
	// default text decoration formats
38
	public static final String DEFAULT_FILETEXTFORMAT = "{dirty_flag}{name}  {revision} {tag} ({keyword})"; //$NON-NLS-1$
39
	public static final String DEFAULT_FILETEXTFORMAT = "{dirty_flag}{name}  {revision} {tag} ({keyword})"; //$NON-NLS-1$
39
	public static final String DEFAULT_FOLDERTEXTFORMAT = "{dirty_flag}{name}  {tag}"; //$NON-NLS-1$
40
	public static final String DEFAULT_FOLDERTEXTFORMAT = "{dirty_flag}{name}  {tag}"; //$NON-NLS-1$
Lines 42-48 Link Here
42
	// prefix characters that can be removed if the following binding is not found
43
	// prefix characters that can be removed if the following binding is not found
43
	private static final char KEYWORD_SEPCOLON = ':';
44
	private static final char KEYWORD_SEPCOLON = ':';
44
	private static final char KEYWORD_SEPAT = '@';
45
	private static final char KEYWORD_SEPAT = '@';
45
	
46
46
	// font and color definition ids
47
	// font and color definition ids
47
	public static final String OUTGOING_CHANGE_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_foreground_color"; //$NON-NLS-1$
48
	public static final String OUTGOING_CHANGE_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_foreground_color"; //$NON-NLS-1$
48
	public static final String OUTGOING_CHANGE_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_background_color"; //$NON-NLS-1$
49
	public static final String OUTGOING_CHANGE_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.outgoing_change_background_color"; //$NON-NLS-1$
Lines 50-61 Link Here
50
	public static final String IGNORED_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_foreground_color"; //$NON-NLS-1$
51
	public static final String IGNORED_FOREGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_foreground_color"; //$NON-NLS-1$
51
	public static final String IGNORED_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_background_color"; //$NON-NLS-1$
52
	public static final String IGNORED_BACKGROUND_COLOR = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_background_color"; //$NON-NLS-1$
52
	public static final String IGNORED_FONT = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_font"; //$NON-NLS-1$
53
	public static final String IGNORED_FONT = "org.eclipse.team.cvs.ui.fontsandcolors.ignored_resource_font"; //$NON-NLS-1$
53
	
54
54
	public static void decorate(CVSDecoration decoration, String format, Map bindings) {
55
	public static void decorate(CVSDecoration decoration, String format, Map bindings) {
55
		StringBuffer prefix = new StringBuffer(80);
56
		StringBuffer prefix = new StringBuffer(80);
56
		StringBuffer suffix = new StringBuffer(80);
57
		StringBuffer suffix = new StringBuffer(80);
57
		StringBuffer output = prefix;
58
		StringBuffer output = prefix;
58
		
59
59
		int length = format.length();
60
		int length = format.length();
60
		int start = -1;
61
		int start = -1;
61
		int end = length;
62
		int end = length;
Lines 66-72 Link Here
66
					String key = format.substring(end + 1, start);
67
					String key = format.substring(end + 1, start);
67
					String s;
68
					String s;
68
69
69
					//We use the RESOURCE_NAME key to determine if we are doing the prefix or suffix.  The name isn't actually part of either.					
70
					//We use the RESOURCE_NAME key to determine if we are doing the prefix or suffix.  The name isn't actually part of either.
70
					if(key.equals(RESOURCE_NAME)) {
71
					if(key.equals(RESOURCE_NAME)) {
71
						output = suffix;
72
						output = suffix;
72
						s = null;
73
						s = null;
Lines 82-88 Link Here
82
						if(curLength>0) {
83
						if(curLength>0) {
83
							char c = output.charAt(curLength - 1);
84
							char c = output.charAt(curLength - 1);
84
							if(c == KEYWORD_SEPCOLON || c == KEYWORD_SEPAT) {
85
							if(c == KEYWORD_SEPCOLON || c == KEYWORD_SEPAT) {
85
								output.deleteCharAt(curLength - 1);							
86
								output.deleteCharAt(curLength - 1);
86
							}
87
							}
87
						}
88
						}
88
					}
89
					}
Lines 95-101 Link Here
95
				break;
96
				break;
96
			}
97
			}
97
		}
98
		}
98
		
99
99
		if (prefix.length() != 0) {
100
		if (prefix.length() != 0) {
100
			decoration.addPrefix(prefix.toString());
101
			decoration.addPrefix(prefix.toString());
101
		}
102
		}
(-)src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java (-94 / +95 lines)
Lines 4-10 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
Lines 42-53 Link Here
42
public class CVSDecoratorPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage {
42
public class CVSDecoratorPreferencesPage extends PreferencePage implements IWorkbenchPreferencePage {
43
43
44
	private static class PreviewFile {
44
	private static class PreviewFile {
45
		
45
46
		public final String name, tag, mode;
46
		public final String name, tag, mode;
47
		public final int type;
47
		public final int type;
48
		public final boolean added, dirty, hasRemote, ignored, newResource;
48
		public final boolean added, dirty, hasRemote, ignored, newResource;
49
		public Collection children;
49
		public Collection children;
50
		
50
51
		public PreviewFile(String name, int type, boolean added, boolean newResource, boolean dirty, boolean ignored, boolean hasRemote, String mode, String tag)  {
51
		public PreviewFile(String name, int type, boolean added, boolean newResource, boolean dirty, boolean ignored, boolean hasRemote, String mode, String tag)  {
52
			this.name= name;
52
			this.name= name;
53
			this.type= type;
53
			this.type= type;
Lines 60-66 Link Here
60
			this.tag= tag != null ? tag : ""; //$NON-NLS-1$
60
			this.tag= tag != null ? tag : ""; //$NON-NLS-1$
61
			this.children= Collections.EMPTY_LIST;
61
			this.children= Collections.EMPTY_LIST;
62
		}
62
		}
63
		
63
64
		public void configureDecoration(CVSDecoration decoration) {
64
		public void configureDecoration(CVSDecoration decoration) {
65
			decoration.setResourceType(type);
65
			decoration.setResourceType(type);
66
			decoration.setAdded(added);
66
			decoration.setAdded(added);
Lines 72-100 Link Here
72
			decoration.setKeywordSubstitution(mode);
72
			decoration.setKeywordSubstitution(mode);
73
		}
73
		}
74
	}
74
	}
75
	
75
76
	private static class FormatEditor extends SelectionAdapter {
76
	private static class FormatEditor extends SelectionAdapter {
77
		private final Text fText;
77
		private final Text fText;
78
		private final Map fBindings;
78
		private final Map fBindings;
79
		private final String fKey;
79
		private final String fKey;
80
		
80
81
		public FormatEditor(Composite composite, String title, String buttonText, Map bindings, String key) {
81
		public FormatEditor(Composite composite, String title, String buttonText, Map bindings, String key) {
82
			
82
83
			fKey= key;
83
			fKey= key;
84
			fBindings= bindings;
84
			fBindings= bindings;
85
			
85
86
			final Label label= SWTUtils.createLabel(composite, title);
86
			final Label label= SWTUtils.createLabel(composite, title);
87
			label.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, false, false));
87
			label.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, false, false));
88
			
88
89
			fText= SWTUtils.createText(composite);
89
			fText= SWTUtils.createText(composite);
90
			
90
91
			final Button button = new Button(composite, SWT.NONE);
91
			final Button button = new Button(composite, SWT.NONE);
92
			button.setText(buttonText);
92
			button.setText(buttonText);
93
			button.setLayoutData(new GridData());
93
			button.setLayoutData(new GridData());
94
94
95
			button.addSelectionListener(this);
95
			button.addSelectionListener(this);
96
		}
96
		}
97
		
97
98
		public void addModifyListener(ModifyListener listener) {
98
		public void addModifyListener(ModifyListener listener) {
99
			fText.addModifyListener(listener);
99
			fText.addModifyListener(listener);
100
		}
100
		}
Lines 102-116 Link Here
102
		public String getText() {
102
		public String getText() {
103
			return fText.getText();
103
			return fText.getText();
104
		}
104
		}
105
		
105
106
		public void widgetSelected(SelectionEvent e) {
106
		public void widgetSelected(SelectionEvent e) {
107
		
107
108
			final ILabelProvider labelProvider = new LabelProvider() {
108
			final ILabelProvider labelProvider = new LabelProvider() {
109
				public String getText(Object element) {
109
				public String getText(Object element) {
110
					return ((Map.Entry)element).getKey() + " - " + ((Map.Entry)element).getValue(); //$NON-NLS-1$
110
					return ((Map.Entry)element).getKey() + " - " + ((Map.Entry)element).getValue(); //$NON-NLS-1$
111
				}
111
				}
112
			};
112
			};
113
			
113
114
			final IStructuredContentProvider contentsProvider = new IStructuredContentProvider() {
114
			final IStructuredContentProvider contentsProvider = new IStructuredContentProvider() {
115
				public Object[] getElements(Object inputElement) {
115
				public Object[] getElements(Object inputElement) {
116
					return ((Collection)inputElement).toArray();
116
					return ((Collection)inputElement).toArray();
Lines 118-124 Link Here
118
				public void dispose() {}
118
				public void dispose() {}
119
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
119
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
120
			};
120
			};
121
			
121
122
			final ListSelectionDialog dialog= new ListSelectionDialog(
122
			final ListSelectionDialog dialog= new ListSelectionDialog(
123
					fText.getShell(),
123
					fText.getShell(),
124
					fBindings.entrySet(),
124
					fBindings.entrySet(),
Lines 128-145 Link Here
128
			dialog.setTitle(CVSUIMessages.CVSDecoratorPreferencesPage_1);  //$NON-NLS-1$
128
			dialog.setTitle(CVSUIMessages.CVSDecoratorPreferencesPage_1);  //$NON-NLS-1$
129
			if (dialog.open() != Window.OK)
129
			if (dialog.open() != Window.OK)
130
				return;
130
				return;
131
		
131
132
			Object[] result = dialog.getResult();
132
			Object[] result = dialog.getResult();
133
			
133
134
			for (int i = 0; i < result.length; i++) {
134
			for (int i = 0; i < result.length; i++) {
135
				fText.insert("{"+((Map.Entry)result[i]).getKey() +"}");   //$NON-NLS-1$ //$NON-NLS-2$
135
				fText.insert("{"+((Map.Entry)result[i]).getKey() +"}");   //$NON-NLS-1$ //$NON-NLS-2$
136
			}		
136
			}
137
		}
137
		}
138
138
139
		public void performOk(IPreferenceStore store) {
139
		public void performOk(IPreferenceStore store) {
140
			store.setValue(fKey, fText.getText());
140
			store.setValue(fKey, fText.getText());
141
		}
141
		}
142
		
142
143
		public void performDefaults(IPreferenceStore store) {
143
		public void performDefaults(IPreferenceStore store) {
144
			store.setToDefault(fKey);
144
			store.setToDefault(fKey);
145
			fText.setText(store.getDefaultString(fKey));
145
			fText.setText(store.getDefaultString(fKey));
Lines 149-157 Link Here
149
			fText.setText(store.getString(fKey));
149
			fText.setText(store.getString(fKey));
150
		}
150
		}
151
	}
151
	}
152
	
152
153
	private abstract class Tab extends Observable {
153
	private abstract class Tab extends Observable {
154
		
154
155
		public abstract void initializeValues(IPreferenceStore store);
155
		public abstract void initializeValues(IPreferenceStore store);
156
		public abstract void performDefaults(IPreferenceStore store);
156
		public abstract void performDefaults(IPreferenceStore store);
157
		public abstract void performOk(IPreferenceStore store);
157
		public abstract void performOk(IPreferenceStore store);
Lines 160-215 Link Here
160
	}
160
	}
161
161
162
	private class IconDecoratorTab extends Tab implements SelectionListener {
162
	private class IconDecoratorTab extends Tab implements SelectionListener {
163
		
163
164
		private final Button fDirty, fHasRemote, fAdded, fNewResource;
164
		private final Button fDirty, fHasRemote, fAdded, fNewResource;
165
		
165
166
		public IconDecoratorTab(TabFolder parent) {
166
		public IconDecoratorTab(TabFolder parent) {
167
167
168
			final Composite composite= SWTUtils.createHFillComposite(parent, SWTUtils.MARGINS_DEFAULT);
168
			final Composite composite= SWTUtils.createHFillComposite(parent, SWTUtils.MARGINS_DEFAULT);
169
			
169
170
			fDirty= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_2); //$NON-NLS-1$
170
			fDirty= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_2); //$NON-NLS-1$
171
			fDirty.addSelectionListener(this);
171
			fDirty.addSelectionListener(this);
172
			
172
173
			fHasRemote= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_3); //$NON-NLS-1$
173
			fHasRemote= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_3); //$NON-NLS-1$
174
			fHasRemote.addSelectionListener(this);
174
			fHasRemote.addSelectionListener(this);
175
			
175
176
			fAdded= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_4); //$NON-NLS-1$
176
			fAdded= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_4); //$NON-NLS-1$
177
			fAdded.addSelectionListener(this);
177
			fAdded.addSelectionListener(this);
178
			
178
179
			fNewResource= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_5); //$NON-NLS-1$
179
			fNewResource= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_5); //$NON-NLS-1$
180
			fNewResource.addSelectionListener(this); 
180
			fNewResource.addSelectionListener(this);
181
			
181
182
			final TabItem item= new TabItem(parent, SWT.NONE);
182
			final TabItem item= new TabItem(parent, SWT.NONE);
183
			item.setText(CVSUIMessages.CVSDecoratorPreferencesPage_6);		 //$NON-NLS-1$
183
			item.setText(CVSUIMessages.CVSDecoratorPreferencesPage_6);		 //$NON-NLS-1$
184
			item.setControl(composite);	
184
			item.setControl(composite);
185
		}
185
		}
186
		
186
187
		public void widgetSelected(SelectionEvent e) {
187
		public void widgetSelected(SelectionEvent e) {
188
			setChanged();
188
			setChanged();
189
			notifyObservers();
189
			notifyObservers();
190
		}
190
		}
191
		
191
192
		public void initializeValues(IPreferenceStore store) {
192
		public void initializeValues(IPreferenceStore store) {
193
			fDirty.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION));
193
			fDirty.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION));
194
			fAdded.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION));
194
			fAdded.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION));
195
			fHasRemote.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
195
			fHasRemote.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
196
			fNewResource.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION));
196
			fNewResource.setSelection(store.getBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION));
197
		}
197
		}
198
		
198
199
		public void performOk(IPreferenceStore store) {
199
		public void performOk(IPreferenceStore store) {
200
			store.setValue(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, fDirty.getSelection());
200
			store.setValue(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, fDirty.getSelection());
201
			store.setValue(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, fAdded.getSelection());
201
			store.setValue(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, fAdded.getSelection());
202
			store.setValue(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, fHasRemote.getSelection());
202
			store.setValue(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION, fHasRemote.getSelection());
203
			store.setValue(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, fNewResource.getSelection());
203
			store.setValue(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION, fNewResource.getSelection());
204
		}
204
		}
205
		
205
206
		public void performDefaults(IPreferenceStore store) {
206
		public void performDefaults(IPreferenceStore store) {
207
			fDirty.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION));
207
			fDirty.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION));
208
			fAdded.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION));
208
			fAdded.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION));
209
			fHasRemote.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
209
			fHasRemote.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_HASREMOTE_DECORATION));
210
			fNewResource.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION));
210
			fNewResource.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION));
211
		}
211
		}
212
		
212
213
		public void setPreferences(Preferences prefs) {
213
		public void setPreferences(Preferences prefs) {
214
			prefs.setDefault(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, fDirty.getSelection());
214
			prefs.setDefault(ICVSUIConstants.PREF_SHOW_DIRTY_DECORATION, fDirty.getSelection());
215
			prefs.setDefault(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, fAdded.getSelection());
215
			prefs.setDefault(ICVSUIConstants.PREF_SHOW_ADDED_DECORATION, fAdded.getSelection());
Lines 219-257 Link Here
219
219
220
		public void widgetDefaultSelected(SelectionEvent e) {
220
		public void widgetDefaultSelected(SelectionEvent e) {
221
		}
221
		}
222
	}	
222
	}
223
	
223
224
	private class TextDecoratorTab extends Tab implements ModifyListener {
224
	private class TextDecoratorTab extends Tab implements ModifyListener {
225
		
225
226
		private final FormatEditor fFileDecoration;
226
		private final FormatEditor fFileDecoration;
227
		private final FormatEditor fFolderDecoration;	
227
		private final FormatEditor fFolderDecoration;
228
		private final FormatEditor fProjectDecoration;
228
		private final FormatEditor fProjectDecoration;
229
		
229
230
		private final Text dirtyFlag;
230
		private final Text dirtyFlag;
231
		private final Text addedFlag;
231
		private final Text addedFlag;
232
		
232
233
		public TextDecoratorTab(TabFolder parent) {
233
		public TextDecoratorTab(TabFolder parent) {
234
			
234
235
			final Composite composite= SWTUtils.createHFillComposite(parent, SWTUtils.MARGINS_DEFAULT, 3);
235
			final Composite composite= SWTUtils.createHFillComposite(parent, SWTUtils.MARGINS_DEFAULT, 3);
236
			Dialog.applyDialogFont(composite);
236
			Dialog.applyDialogFont(composite);
237
			
237
238
			fFileDecoration= new FormatEditor(composite, CVSUIMessages.CVSDecoratorPreferencesPage_7, CVSUIMessages.CVSDecoratorPreferencesPage_8, BINDINGS, ICVSUIConstants.PREF_FILETEXT_DECORATION);   //$NON-NLS-1$ //$NON-NLS-2$
238
			fFileDecoration= new FormatEditor(composite, CVSUIMessages.CVSDecoratorPreferencesPage_7, CVSUIMessages.CVSDecoratorPreferencesPage_8, BINDINGS, ICVSUIConstants.PREF_FILETEXT_DECORATION);   //$NON-NLS-1$ //$NON-NLS-2$
239
			fFolderDecoration= new FormatEditor(composite, CVSUIMessages.CVSDecoratorPreferencesPage_9, CVSUIMessages.CVSDecoratorPreferencesPage_10, FOLDER_BINDINGS, ICVSUIConstants.PREF_FOLDERTEXT_DECORATION);   //$NON-NLS-1$ //$NON-NLS-2$
239
			fFolderDecoration= new FormatEditor(composite, CVSUIMessages.CVSDecoratorPreferencesPage_9, CVSUIMessages.CVSDecoratorPreferencesPage_10, FOLDER_BINDINGS, ICVSUIConstants.PREF_FOLDERTEXT_DECORATION);   //$NON-NLS-1$ //$NON-NLS-2$
240
			fProjectDecoration= new FormatEditor(composite, CVSUIMessages.CVSDecoratorPreferencesPage_11, CVSUIMessages.CVSDecoratorPreferencesPage_12, FOLDER_BINDINGS, ICVSUIConstants.PREF_PROJECTTEXT_DECORATION); //$NON-NLS-1$ //$NON-NLS-2$
240
			fProjectDecoration= new FormatEditor(composite, CVSUIMessages.CVSDecoratorPreferencesPage_11, CVSUIMessages.CVSDecoratorPreferencesPage_12, FOLDER_BINDINGS, ICVSUIConstants.PREF_PROJECTTEXT_DECORATION); //$NON-NLS-1$ //$NON-NLS-2$
241
			
241
242
			fFileDecoration.addModifyListener(this);
242
			fFileDecoration.addModifyListener(this);
243
			fFolderDecoration.addModifyListener(this);
243
			fFolderDecoration.addModifyListener(this);
244
			fProjectDecoration.addModifyListener(this);
244
			fProjectDecoration.addModifyListener(this);
245
245
246
			SWTUtils.createPlaceholder(composite, 1, 3); 
246
			SWTUtils.createPlaceholder(composite, 1, 3);
247
			final Label dirtyLabel= SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_13, 1); //$NON-NLS-1$
247
			final Label dirtyLabel= SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_13, 1); //$NON-NLS-1$
248
			dirtyLabel.setLayoutData(new GridData());
248
			dirtyLabel.setLayoutData(new GridData());
249
			
249
250
			dirtyFlag = new Text(composite, SWT.BORDER);
250
			dirtyFlag = new Text(composite, SWT.BORDER);
251
			dirtyFlag.setLayoutData(SWTUtils.createHFillGridData(1));
251
			dirtyFlag.setLayoutData(SWTUtils.createHFillGridData(1));
252
			dirtyFlag.addModifyListener(this);
252
			dirtyFlag.addModifyListener(this);
253
			SWTUtils.createPlaceholder(composite, 1, 1);
253
			SWTUtils.createPlaceholder(composite, 1, 1);
254
			
254
255
255
256
			final Label addedLabel= SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_14, 1); //$NON-NLS-1$
256
			final Label addedLabel= SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_14, 1); //$NON-NLS-1$
257
			addedLabel.setLayoutData(new GridData());
257
			addedLabel.setLayoutData(new GridData());
Lines 260-273 Link Here
260
			addedFlag.setLayoutData(SWTUtils.createHFillGridData(1));
260
			addedFlag.setLayoutData(SWTUtils.createHFillGridData(1));
261
			addedFlag.addModifyListener(this);
261
			addedFlag.addModifyListener(this);
262
			SWTUtils.createPlaceholder(composite, 1, 1);
262
			SWTUtils.createPlaceholder(composite, 1, 1);
263
			
263
264
			SWTUtils.createPlaceholder(composite, 1, 3);
264
			SWTUtils.createPlaceholder(composite, 1, 3);
265
265
266
			final TabItem item= new TabItem(parent, SWT.NONE);
266
			final TabItem item= new TabItem(parent, SWT.NONE);
267
			item.setText(CVSUIMessages.CVSDecoratorPreferencesPage_15);		 //$NON-NLS-1$
267
			item.setText(CVSUIMessages.CVSDecoratorPreferencesPage_15);		 //$NON-NLS-1$
268
			item.setControl(composite);	
268
			item.setControl(composite);
269
		}
269
		}
270
		
270
271
		public void initializeValues(IPreferenceStore store) {
271
		public void initializeValues(IPreferenceStore store) {
272
			fFileDecoration.initializeValue(store);
272
			fFileDecoration.initializeValue(store);
273
			fFolderDecoration.initializeValue(store);
273
			fFolderDecoration.initializeValue(store);
Lines 275-281 Link Here
275
			addedFlag.setText(store.getString(ICVSUIConstants.PREF_ADDED_FLAG));
275
			addedFlag.setText(store.getString(ICVSUIConstants.PREF_ADDED_FLAG));
276
			dirtyFlag.setText(store.getString(ICVSUIConstants.PREF_DIRTY_FLAG));
276
			dirtyFlag.setText(store.getString(ICVSUIConstants.PREF_DIRTY_FLAG));
277
		}
277
		}
278
		
278
279
		public void performOk(IPreferenceStore store) {
279
		public void performOk(IPreferenceStore store) {
280
			fFileDecoration.performOk(store);
280
			fFileDecoration.performOk(store);
281
			fFolderDecoration.performOk(store);
281
			fFolderDecoration.performOk(store);
Lines 283-294 Link Here
283
			store.setValue(ICVSUIConstants.PREF_ADDED_FLAG, addedFlag.getText());
283
			store.setValue(ICVSUIConstants.PREF_ADDED_FLAG, addedFlag.getText());
284
			store.setValue(ICVSUIConstants.PREF_DIRTY_FLAG, dirtyFlag.getText());
284
			store.setValue(ICVSUIConstants.PREF_DIRTY_FLAG, dirtyFlag.getText());
285
		}
285
		}
286
		
286
287
		public void performDefaults(IPreferenceStore store) {
287
		public void performDefaults(IPreferenceStore store) {
288
			fFileDecoration.performDefaults(store);
288
			fFileDecoration.performDefaults(store);
289
			fFolderDecoration.performDefaults(store);
289
			fFolderDecoration.performDefaults(store);
290
			fProjectDecoration.performDefaults(store);
290
			fProjectDecoration.performDefaults(store);
291
			
291
292
			addedFlag.setText(store.getDefaultString(ICVSUIConstants.PREF_ADDED_FLAG));
292
			addedFlag.setText(store.getDefaultString(ICVSUIConstants.PREF_ADDED_FLAG));
293
			dirtyFlag.setText(store.getDefaultString(ICVSUIConstants.PREF_DIRTY_FLAG));
293
			dirtyFlag.setText(store.getDefaultString(ICVSUIConstants.PREF_DIRTY_FLAG));
294
		}
294
		}
Lines 316-322 Link Here
316
			prefs.setDefault(ICVSUIConstants.PREF_ADDED_FLAG, addedFlag.getText());
316
			prefs.setDefault(ICVSUIConstants.PREF_ADDED_FLAG, addedFlag.getText());
317
		}
317
		}
318
	}
318
	}
319
	
319
320
	private class GeneralTab extends Tab implements SelectionListener {
320
	private class GeneralTab extends Tab implements SelectionListener {
321
		private final Button fShowDirty;
321
		private final Button fShowDirty;
322
		private final Button fUseFontDecorations;
322
		private final Button fUseFontDecorations;
Lines 324-335 Link Here
324
		public GeneralTab(TabFolder parent) {
324
		public GeneralTab(TabFolder parent) {
325
			final Composite composite= SWTUtils.createHFillComposite(parent, SWTUtils.MARGINS_DEFAULT);
325
			final Composite composite= SWTUtils.createHFillComposite(parent, SWTUtils.MARGINS_DEFAULT);
326
			Dialog.applyDialogFont(composite);
326
			Dialog.applyDialogFont(composite);
327
			
327
328
            SWTUtils.createPreferenceLink((IWorkbenchPreferenceContainer) getContainer(), composite, CVSUIMessages.CVSDecoratorPreferencesPage_36, CVSUIMessages.CVSDecoratorPreferencesPage_37); //$NON-NLS-1$ //$NON-NLS-2$
328
            SWTUtils.createPreferenceLink((IWorkbenchPreferenceContainer) getContainer(), composite, CVSUIMessages.CVSDecoratorPreferencesPage_36, CVSUIMessages.CVSDecoratorPreferencesPage_37); //$NON-NLS-1$ //$NON-NLS-2$
329
            
329
330
			fShowDirty= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_16); //$NON-NLS-1$
330
			fShowDirty= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_16); //$NON-NLS-1$
331
			SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_17); //$NON-NLS-1$
331
			SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_17); //$NON-NLS-1$
332
			
332
333
			fUseFontDecorations= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_18); //$NON-NLS-1$
333
			fUseFontDecorations= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_18); //$NON-NLS-1$
334
334
335
			SWTUtils.createPreferenceLink((IWorkbenchPreferenceContainer) getContainer(), composite, CVSUIMessages.CVSDecoratorPreferencesPage_19, CVSUIMessages.CVSDecoratorPreferencesPage_20); //$NON-NLS-1$ //$NON-NLS-2$
335
			SWTUtils.createPreferenceLink((IWorkbenchPreferenceContainer) getContainer(), composite, CVSUIMessages.CVSDecoratorPreferencesPage_19, CVSUIMessages.CVSDecoratorPreferencesPage_20); //$NON-NLS-1$ //$NON-NLS-2$
Lines 339-352 Link Here
339
339
340
			final TabItem item= new TabItem(parent, SWT.NONE);
340
			final TabItem item= new TabItem(parent, SWT.NONE);
341
			item.setText(CVSUIMessages.CVSDecoratorPreferencesPage_21);		 //$NON-NLS-1$
341
			item.setText(CVSUIMessages.CVSDecoratorPreferencesPage_21);		 //$NON-NLS-1$
342
			item.setControl(composite);	
342
			item.setControl(composite);
343
		}
343
		}
344
344
345
		public void widgetSelected(SelectionEvent e) {
345
		public void widgetSelected(SelectionEvent e) {
346
			setChanged();
346
			setChanged();
347
			notifyObservers();
347
			notifyObservers();
348
		}
348
		}
349
		
349
350
		public void widgetDefaultSelected(SelectionEvent e) {
350
		public void widgetDefaultSelected(SelectionEvent e) {
351
		}
351
		}
352
352
Lines 359-380 Link Here
359
			fShowDirty.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY));
359
			fShowDirty.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY));
360
			fUseFontDecorations.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_USE_FONT_DECORATORS));
360
			fUseFontDecorations.setSelection(store.getDefaultBoolean(ICVSUIConstants.PREF_USE_FONT_DECORATORS));
361
		}
361
		}
362
		
362
363
		public void performOk(IPreferenceStore store) {
363
		public void performOk(IPreferenceStore store) {
364
			store.setValue(ICVSUIConstants.PREF_CALCULATE_DIRTY, fShowDirty.getSelection());
364
			store.setValue(ICVSUIConstants.PREF_CALCULATE_DIRTY, fShowDirty.getSelection());
365
			store.setValue(ICVSUIConstants.PREF_USE_FONT_DECORATORS, fUseFontDecorations.getSelection());
365
			store.setValue(ICVSUIConstants.PREF_USE_FONT_DECORATORS, fUseFontDecorations.getSelection());
366
		}
366
		}
367
		
367
368
		public void setPreferences(Preferences preferences) {
368
		public void setPreferences(Preferences preferences) {
369
			preferences.setValue(ICVSUIConstants.PREF_CALCULATE_DIRTY, fShowDirty.getSelection());
369
			preferences.setValue(ICVSUIConstants.PREF_CALCULATE_DIRTY, fShowDirty.getSelection());
370
			preferences.setValue(ICVSUIConstants.PREF_USE_FONT_DECORATORS, fUseFontDecorations.getSelection());
370
			preferences.setValue(ICVSUIConstants.PREF_USE_FONT_DECORATORS, fUseFontDecorations.getSelection());
371
		}
371
		}
372
	}
372
	}
373
	
373
374
	public class Preview extends LabelProvider implements Observer, ITreeContentProvider {
374
	public class Preview extends LabelProvider implements Observer, ITreeContentProvider {
375
		
375
376
		private final ResourceManager fImageCache;
376
		private final ResourceManager fImageCache;
377
		private final TreeViewer fViewer; 
377
		private final TreeViewer fViewer;
378
378
379
		public Preview(Composite composite) {
379
		public Preview(Composite composite) {
380
            SWTUtils.createLabel(composite, "Previe&w:");
380
            SWTUtils.createLabel(composite, "Previe&w:");
Lines 386-400 Link Here
386
			fViewer.setInput(ROOT);
386
			fViewer.setInput(ROOT);
387
			fViewer.expandAll();
387
			fViewer.expandAll();
388
		}
388
		}
389
		
389
390
		public void refresh() {
390
		public void refresh() {
391
			fViewer.refresh(true);
391
			fViewer.refresh(true);
392
		}
392
		}
393
		
393
394
		public void update(Observable o, Object arg) {
394
		public void update(Observable o, Object arg) {
395
			refresh();
395
			refresh();
396
		}
396
		}
397
		
397
398
		public Object[] getChildren(Object parentElement) {
398
		public Object[] getChildren(Object parentElement) {
399
			return ((PreviewFile)parentElement).children.toArray();
399
			return ((PreviewFile)parentElement).children.toArray();
400
		}
400
		}
Lines 421-435 Link Here
421
		public Color getBackground(Object element) {
421
		public Color getBackground(Object element) {
422
			return getDecoration(element).getBackgroundColor();
422
			return getDecoration(element).getBackgroundColor();
423
		}
423
		}
424
		
424
425
		public Color getForeground(Object element) {
425
		public Color getForeground(Object element) {
426
			return getDecoration(element).getForegroundColor();
426
			return getDecoration(element).getForegroundColor();
427
		}
427
		}
428
			
428
429
		public Font getFont(Object element) {
429
		public Font getFont(Object element) {
430
			return getDecoration(element).getFont();
430
			return getDecoration(element).getFont();
431
		}
431
		}
432
		
432
433
		public String getText(Object element) {
433
		public String getText(Object element) {
434
			final CVSDecoration decoration = getDecoration(element);
434
			final CVSDecoration decoration = getDecoration(element);
435
			final StringBuffer buffer = new StringBuffer();
435
			final StringBuffer buffer = new StringBuffer();
Lines 442-455 Link Here
442
				buffer.append(suffix);
442
				buffer.append(suffix);
443
			return buffer.toString();
443
			return buffer.toString();
444
		}
444
		}
445
		
445
446
		public CVSDecoration getDecoration(Object element) {
446
		public CVSDecoration getDecoration(Object element) {
447
			final CVSDecoration decoration = buildDecoration((PreviewFile)element);
447
			final CVSDecoration decoration = buildDecoration((PreviewFile)element);
448
			((PreviewFile)element).configureDecoration(decoration);
448
			((PreviewFile)element).configureDecoration(decoration);
449
			decoration.compute();
449
			decoration.compute();
450
			return decoration;
450
			return decoration;
451
		}
451
		}
452
		
452
453
		public Image getImage(Object element) {
453
		public Image getImage(Object element) {
454
			final String s;
454
			final String s;
455
			switch (((PreviewFile)element).type) {
455
			switch (((PreviewFile)element).type) {
Lines 472-482 Link Here
472
            return null;
472
            return null;
473
		}
473
		}
474
	}
474
	}
475
	
475
476
	private static class ThemeListener implements IPropertyChangeListener {
476
	private static class ThemeListener implements IPropertyChangeListener {
477
477
478
		private final Preview fPreview;
478
		private final Preview fPreview;
479
		
479
480
		ThemeListener(Preview preview) {
480
		ThemeListener(Preview preview) {
481
			fPreview= preview;
481
			fPreview= preview;
482
		}
482
		}
Lines 484-490 Link Here
484
			fPreview.refresh();
484
			fPreview.refresh();
485
		}
485
		}
486
	}
486
	}
487
	
487
488
	protected static final Collection ROOT;
488
	protected static final Collection ROOT;
489
	protected static final Map BINDINGS;
489
	protected static final Map BINDINGS;
490
	protected static final Map FOLDER_BINDINGS;
490
	protected static final Map FOLDER_BINDINGS;
Lines 497-503 Link Here
497
		BINDINGS.put(CVSDecoratorConfiguration.FILE_REVISION, CVSUIMessages.CVSDecoratorPreferencesPage_25);  //$NON-NLS-1$
497
		BINDINGS.put(CVSDecoratorConfiguration.FILE_REVISION, CVSUIMessages.CVSDecoratorPreferencesPage_25);  //$NON-NLS-1$
498
		BINDINGS.put(CVSDecoratorConfiguration.DIRTY_FLAG, CVSUIMessages.CVSDecoratorPreferencesPage_26);  //$NON-NLS-1$
498
		BINDINGS.put(CVSDecoratorConfiguration.DIRTY_FLAG, CVSUIMessages.CVSDecoratorPreferencesPage_26);  //$NON-NLS-1$
499
		BINDINGS.put(CVSDecoratorConfiguration.ADDED_FLAG, CVSUIMessages.CVSDecoratorPreferencesPage_27); //$NON-NLS-1$
499
		BINDINGS.put(CVSDecoratorConfiguration.ADDED_FLAG, CVSUIMessages.CVSDecoratorPreferencesPage_27); //$NON-NLS-1$
500
		
500
501
		FOLDER_BINDINGS= new HashMap();
501
		FOLDER_BINDINGS= new HashMap();
502
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.RESOURCE_NAME, CVSUIMessages.CVSDecoratorPreferencesPage_28);  //$NON-NLS-1$
502
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.RESOURCE_NAME, CVSUIMessages.CVSDecoratorPreferencesPage_28);  //$NON-NLS-1$
503
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.RESOURCE_TAG, CVSUIMessages.CVSDecoratorPreferencesPage_29);  //$NON-NLS-1$
503
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.RESOURCE_TAG, CVSUIMessages.CVSDecoratorPreferencesPage_29);  //$NON-NLS-1$
Lines 506-513 Link Here
506
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, CVSUIMessages.CVSDecoratorPreferencesPage_32);  //$NON-NLS-1$
506
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, CVSUIMessages.CVSDecoratorPreferencesPage_32);  //$NON-NLS-1$
507
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, CVSUIMessages.CVSDecoratorPreferencesPage_33);  //$NON-NLS-1$
507
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, CVSUIMessages.CVSDecoratorPreferencesPage_33);  //$NON-NLS-1$
508
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, CVSUIMessages.CVSDecoratorPreferencesPage_34);  //$NON-NLS-1$
508
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, CVSUIMessages.CVSDecoratorPreferencesPage_34);  //$NON-NLS-1$
509
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, CVSUIMessages.CVSDecoratorPreferencesPage_38);  //$NON-NLS-1$
509
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.DIRTY_FLAG, CVSUIMessages.CVSDecoratorPreferencesPage_35); //$NON-NLS-1$
510
		FOLDER_BINDINGS.put(CVSDecoratorConfiguration.DIRTY_FLAG, CVSUIMessages.CVSDecoratorPreferencesPage_35); //$NON-NLS-1$
510
		
511
511
		final PreviewFile project= new PreviewFile("Project", IResource.PROJECT, false, false, false, false, true, null, "v1_0"); //$NON-NLS-1$ //$NON-NLS-2$
512
		final PreviewFile project= new PreviewFile("Project", IResource.PROJECT, false, false, false, false, true, null, "v1_0"); //$NON-NLS-1$ //$NON-NLS-2$
512
		final ArrayList children= new ArrayList();
513
		final ArrayList children= new ArrayList();
513
		children.add(new PreviewFile("Folder", IResource.FOLDER, false, false, false, false, true, null, null)); //$NON-NLS-1$
514
		children.add(new PreviewFile("Folder", IResource.FOLDER, false, false, false, false, true, null, null)); //$NON-NLS-1$
Lines 521-552 Link Here
521
		ROOT= Collections.singleton(project);
522
		ROOT= Collections.singleton(project);
522
	}
523
	}
523
524
524
		
525
525
	private TextDecoratorTab fTextTab;
526
	private TextDecoratorTab fTextTab;
526
	private IconDecoratorTab fIconTab;
527
	private IconDecoratorTab fIconTab;
527
	private GeneralTab fGeneralTab;
528
	private GeneralTab fGeneralTab;
528
529
529
	private Preview fPreview;
530
	private Preview fPreview;
530
	private ThemeListener fThemeListener;
531
	private ThemeListener fThemeListener;
531
	
532
532
	protected Control createContents(Composite parent) {
533
	protected Control createContents(Composite parent) {
533
		
534
534
		final Composite composite= SWTUtils.createHVFillComposite(parent, SWTUtils.MARGINS_NONE);
535
		final Composite composite= SWTUtils.createHVFillComposite(parent, SWTUtils.MARGINS_NONE);
535
		
536
536
		final Composite folderComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE);
537
		final Composite folderComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE);
537
				
538
538
		// create a tab folder for the page
539
		// create a tab folder for the page
539
		final TabFolder tabFolder = new TabFolder(folderComposite, SWT.NONE);
540
		final TabFolder tabFolder = new TabFolder(folderComposite, SWT.NONE);
540
		tabFolder.setLayout(new TabFolderLayout());
541
		tabFolder.setLayout(new TabFolderLayout());
541
		tabFolder.setLayoutData(SWTUtils.createHFillGridData());
542
		tabFolder.setLayoutData(SWTUtils.createHFillGridData());
542
		
543
543
		// text decoration options
544
		// text decoration options
544
		fGeneralTab= new GeneralTab(tabFolder);
545
		fGeneralTab= new GeneralTab(tabFolder);
545
		fTextTab= new TextDecoratorTab(tabFolder);
546
		fTextTab= new TextDecoratorTab(tabFolder);
546
		fIconTab= new IconDecoratorTab(tabFolder);
547
		fIconTab= new IconDecoratorTab(tabFolder);
547
548
548
		fPreview= new Preview(composite);
549
		fPreview= new Preview(composite);
549
		
550
550
		fTextTab.addObserver(fPreview);
551
		fTextTab.addObserver(fPreview);
551
		fIconTab.addObserver(fPreview);
552
		fIconTab.addObserver(fPreview);
552
		fGeneralTab.addObserver(fPreview);
553
		fGeneralTab.addObserver(fPreview);
Lines 554-572 Link Here
554
		initializeValues();
555
		initializeValues();
555
        PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.DECORATORS_PREFERENCE_PAGE);
556
        PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.DECORATORS_PREFERENCE_PAGE);
556
		Dialog.applyDialogFont(parent);
557
		Dialog.applyDialogFont(parent);
557
		
558
558
		PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener= new ThemeListener(fPreview));
559
		PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener= new ThemeListener(fPreview));
559
		
560
560
		return tabFolder;
561
		return tabFolder;
561
	}
562
	}
562
	
563
563
	public void dispose() {
564
	public void dispose() {
564
		if (fThemeListener != null)
565
		if (fThemeListener != null)
565
			PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(fThemeListener);
566
			PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(fThemeListener);
566
        if (fPreview != null)
567
        if (fPreview != null)
567
            fPreview.dispose();
568
            fPreview.dispose();
568
	}
569
	}
569
	
570
570
	/**
571
	/**
571
	 * Initializes states of the controls from the preference store.
572
	 * Initializes states of the controls from the preference store.
572
	 */
573
	 */
Lines 608-614 Link Here
608
	 */
609
	 */
609
	protected void performDefaults() {
610
	protected void performDefaults() {
610
		final IPreferenceStore store = getPreferenceStore();
611
		final IPreferenceStore store = getPreferenceStore();
611
		
612
612
		fTextTab.performDefaults(store);
613
		fTextTab.performDefaults(store);
613
		fIconTab.performDefaults(store);
614
		fIconTab.performDefaults(store);
614
		fGeneralTab.performDefaults(store);
615
		fGeneralTab.performDefaults(store);
Lines 626-642 Link Here
626
	protected IPreferenceStore doGetPreferenceStore() {
627
	protected IPreferenceStore doGetPreferenceStore() {
627
		return CVSUIPlugin.getPlugin().getPreferenceStore();
628
		return CVSUIPlugin.getPlugin().getPreferenceStore();
628
	}
629
	}
629
	
630
630
	
631
631
	public CVSDecoration buildDecoration(PreviewFile file) {
632
	public CVSDecoration buildDecoration(PreviewFile file) {
632
		final Preferences prefs = new Preferences();
633
		final Preferences prefs = new Preferences();
633
		
634
634
		fIconTab.setPreferences(prefs);
635
		fIconTab.setPreferences(prefs);
635
		fTextTab.setPreferences(prefs);
636
		fTextTab.setPreferences(prefs);
636
		fGeneralTab.setPreferences(prefs);
637
		fGeneralTab.setPreferences(prefs);
637
		
638
638
		final CVSDecoration decoration= new CVSDecoration(file.name, prefs, fTextTab.getFileTextFormat(), fTextTab.getFolderTextFormat(), fTextTab.getProjectTextFormat());
639
		final CVSDecoration decoration= new CVSDecoration(file.name, prefs, fTextTab.getFileTextFormat(), fTextTab.getFolderTextFormat(), fTextTab.getProjectTextFormat());
639
		
640
640
		decoration.setKeywordSubstitution(Command.KSUBST_TEXT.getShortDisplayText());
641
		decoration.setKeywordSubstitution(Command.KSUBST_TEXT.getShortDisplayText());
641
		decoration.setRevision("1.45");  //$NON-NLS-1$
642
		decoration.setRevision("1.45");  //$NON-NLS-1$
642
		try {
643
		try {
(-)src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java (-2 / +3 lines)
Lines 3-10 Link Here
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
6
 *
7
 * Contributors: 
7
 * Contributors:
8
 * IBM - Initial API and implementation
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
9
 **********************************************************************/
10
package org.eclipse.team.internal.ccvs.ui;
10
package org.eclipse.team.internal.ccvs.ui;
Lines 146-151 Link Here
146
	public static String CVSDecoratorPreferencesPage_35;
146
	public static String CVSDecoratorPreferencesPage_35;
147
    public static String CVSDecoratorPreferencesPage_36;
147
    public static String CVSDecoratorPreferencesPage_36;
148
    public static String CVSDecoratorPreferencesPage_37;
148
    public static String CVSDecoratorPreferencesPage_37;
149
    public static String CVSDecoratorPreferencesPage_38;  // repository label
149
150
150
	public static String CVSFilePropertiesPage_ignored;
151
	public static String CVSFilePropertiesPage_ignored;
151
	public static String CVSFilePropertiesPage_notManaged;
152
	public static String CVSFilePropertiesPage_notManaged;
(-)src/org/eclipse/team/internal/ccvs/ui/messages.properties (+1 lines)
Lines 137-142 Link Here
137
CVSDecoratorPreferencesPage_35=flag indicating that the folder has a child resource with outgoing changes
137
CVSDecoratorPreferencesPage_35=flag indicating that the folder has a child resource with outgoing changes
138
CVSDecoratorPreferencesPage_36=org.eclipse.ui.preferencePages.Decorators
138
CVSDecoratorPreferencesPage_36=org.eclipse.ui.preferencePages.Decorators
139
CVSDecoratorPreferencesPage_37=See <a>''{0}''</a> to enable CVS decorations.
139
CVSDecoratorPreferencesPage_37=See <a>''{0}''</a> to enable CVS decorations.
140
CVSDecoratorPreferencesPage_38=the repository label
140
141
141
142
142
CVSFilePropertiesPage_ignored=The file is ignored by CVS.
143
CVSFilePropertiesPage_ignored=The file is ignored by CVS.

Return to bug 98771