Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 69c3555b22abed9a1f9307e474d1c7432ecfec08 (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
/*******************************************************************************
 * Copyright (c) 2010, 2011 Google, Inc 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:
 * 	   Sergey Prigogin (Google) - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;

import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.dialogs.IDialogSettings;

public class CRenameRefactoringPreferences {
	private static final String DIALOG_SETTINGS_KEY = "CRenameRefactoringInputPage"; //$NON-NLS-1$

	public static final String KEY_IGNORE_VIRTUAL = "ignoreVirtual"; //$NON-NLS-1$
	public static final String KEY_REFERENCES_INV = "references_inv"; //$NON-NLS-1$
	public static final String KEY_COMMENT = "comment"; //$NON-NLS-1$
	public static final String KEY_STRING = "string"; //$NON-NLS-1$
	public static final String KEY_INACTIVE = "inactive"; //$NON-NLS-1$
	public static final String KEY_SCOPE = "scope"; //$NON-NLS-1$
	public static final String KEY_WORKING_SET_NAME = "workingset"; //$NON-NLS-1$

	public static final String KEY_INCLUDE = "include"; //$NON-NLS-1$
	public static final String KEY_MACRO_DEFINITION = "macroDefinition"; //$NON-NLS-1$
	public static final String KEY_PREPROCESSOR = "preprocessor"; //$NON-NLS-1$
	public static final String KEY_EXHAUSTIVE_FILE_SEARCH = "exhausiveFileSearch"; //$NON-NLS-1$

	private IDialogSettings fDialogSettings;

	public CRenameRefactoringPreferences() {
		super();
		IDialogSettings ds = CUIPlugin.getDefault().getDialogSettings();
		fDialogSettings = ds.getSection(DIALOG_SETTINGS_KEY);
		if (fDialogSettings == null) {
			fDialogSettings = ds.addNewSection(DIALOG_SETTINGS_KEY);
		}
	}

	public boolean getBoolean(String key) {
		return fDialogSettings.getBoolean(key);
	}

	public boolean getBoolean(String key, boolean defaultValue) {
		String value = fDialogSettings.get(key);
		return value != null ? Boolean.parseBoolean(value) : defaultValue;
	}

	public void put(String key, int value) {
		fDialogSettings.put(key, value);
	}

	public void put(String key, String value) {
		fDialogSettings.put(key, value);
	}

	public void put(String key, boolean value) {
		fDialogSettings.put(key, value);
	}

	public int getScope() {
		try {
			return fDialogSettings.getInt(KEY_SCOPE);
		} catch (Exception e) {
			return TextSearchWrapper.SCOPE_RELATED_PROJECTS;
		}
	}

	public String getWorkingSet() {
		return fDialogSettings.get(KEY_WORKING_SET_NAME);
	}

	public int getOptions() {
		int options = 0;
		if (!getBoolean(KEY_IGNORE_VIRTUAL))
			options |= CRefactory.OPTION_DO_VIRTUAL;
		if (!getBoolean(KEY_REFERENCES_INV))
			options |= CRefactory.OPTION_IN_CODE_REFERENCES;
		if (getBoolean(KEY_INACTIVE))
			options |= CRefactory.OPTION_IN_INACTIVE_CODE;
		if (getBoolean(KEY_COMMENT))
			options |= CRefactory.OPTION_IN_COMMENT;
		if (getBoolean(KEY_STRING))
			options |= CRefactory.OPTION_IN_STRING_LITERAL;
		if (getBoolean(KEY_INCLUDE))
			options |= CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
		if (getBoolean(KEY_MACRO_DEFINITION))
			options |= CRefactory.OPTION_IN_MACRO_DEFINITION;
		if (getBoolean(KEY_PREPROCESSOR))
			options |= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
		if (getBoolean(KEY_EXHAUSTIVE_FILE_SEARCH))
			options |= CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH;
		return options;
	}
}

Back to the top