Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a0c41cad0a7efc7d6ae7a8852873679fbb7a3654 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*******************************************************************************
 * Copyright (c) 2000, 2011 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ccvs.ui;

import org.eclipse.compare.CompareUI;
import org.eclipse.jface.preference.*;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Event;
import org.eclipse.team.internal.ui.SWTUtils;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;

/**
 * Preference page for configuring CVS comparisons
 */
public class ComparePreferencePage extends CVSFieldEditorPreferencePage {
	private BooleanFieldEditor contents;
	private StringFieldEditor regex;

    /* (non-Javadoc)
     * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageHelpContextId()
     */
    protected String getPageHelpContextId() {
        return IHelpContextIds.COMPARE_PREFERENCE_PAGE;
    }

    /* (non-Javadoc)
     * @see org.eclipse.team.internal.ccvs.ui.CVSFieldEditorPreferencePage#getPageDescription()
     */
    protected String getPageDescription() {
        return CVSUIMessages.ComparePreferencePage_0;
    }

    /* (non-Javadoc)
     * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
     */
    protected void createFieldEditors() {
		IPreferenceStore store = getPreferenceStore();

		contents = new BooleanFieldEditor(ICVSUIConstants.PREF_CONSIDER_CONTENTS,
				CVSUIMessages.ComparePreferencePage_4,
				BooleanFieldEditor.DEFAULT, getFieldEditorParent()) {
			private Event selectionEvent = createSelectionEvent();
			private Event createSelectionEvent() {
				Event event = new Event();
				event.type = SWT.Selection;
				return event;
			}
			// invert the UI
			protected void doLoad() {
				super.doLoad();
				getChangeControl(getFieldEditorParent()).setSelection(!getBooleanValue());
				getChangeControl(getFieldEditorParent()).notifyListeners(SWT.Selection,
						selectionEvent);
			}
			protected void doLoadDefault() {
				super.doLoadDefault();
				getChangeControl(getFieldEditorParent()).setSelection(!getBooleanValue());
				getChangeControl(getFieldEditorParent()).notifyListeners(SWT.Selection,
						selectionEvent);
			}
			protected void doStore() {
				getPreferenceStore().setValue(getPreferenceName(), !getBooleanValue());
			}
		};
		addField(contents);
		regex = new StringFieldEditor(ICVSUIConstants.PREF_SYNCVIEW_REGEX_FILTER_PATTERN,
				CVSUIMessages.ComparePreferencePage_5,
				getFieldEditorParent());
		addField(regex);
		GridData data = new GridData();
		data.horizontalIndent = 20;
		regex.getLabelControl(getFieldEditorParent()).setLayoutData(data);
		regex.setEnabled(store.getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS), getFieldEditorParent());
		addField(new BooleanFieldEditor(
				ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG,
				CVSUIMessages.ComparePreferencePage_3,
				BooleanFieldEditor.DEFAULT,
				getFieldEditorParent()));
		addField(new BooleanFieldEditor(
				ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT,
				CVSUIMessages.ComparePreferencePage_2,
				BooleanFieldEditor.DEFAULT,
				getFieldEditorParent()));
		addField(new BooleanFieldEditor(
				ICVSUIConstants.PREF_ENABLE_MODEL_SYNC,
				CVSUIMessages.ComparePreferencePage_7,
				BooleanFieldEditor.DEFAULT,
				getFieldEditorParent()));
		addField(new BooleanFieldEditor(
				ICVSUIConstants.PREF_OPEN_COMPARE_EDITOR_FOR_SINGLE_FILE,
				CVSUIMessages.ComparePreferencePage_8,
				BooleanFieldEditor.DEFAULT,
				getFieldEditorParent()));

		IPreferencePageContainer container = getContainer();
		if (container instanceof IWorkbenchPreferenceContainer) {
			IWorkbenchPreferenceContainer workbenchContainer = (IWorkbenchPreferenceContainer) container;
			SWTUtils.createPreferenceLink(workbenchContainer, getFieldEditorParent(),
					CompareUI.PREFERENCE_PAGE_ID, CVSUIMessages.ComparePreferencePage_6);
		}
	}

	public void propertyChange(PropertyChangeEvent event) {
		super.propertyChange(event);
		regex.setEnabled(!contents.getBooleanValue(), getFieldEditorParent());
	}
}

Back to the top