1 /*******************************************************************************
2 * Copyright (c) 2010 Google, Inc and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sergey Prigogin (Google) - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.cdt.internal.ui.refactoring.rename;
13 import org.eclipse.jface.dialogs.IDialogSettings;
15 import org.eclipse.cdt.ui.CUIPlugin;
17 public class CRenameRefactoringPreferences {
18 private static final String DIALOG_SETTINGS_KEY = "CRenameRefactoringInputPage"; //$NON-NLS-1$
20 public static final String KEY_IGNORE_VIRTUAL = "ignoreVirtual"; //$NON-NLS-1$
21 public static final String KEY_REFERENCES_INV = "references_inv"; //$NON-NLS-1$
22 public static final String KEY_COMMENT = "comment"; //$NON-NLS-1$
23 public static final String KEY_STRING = "string"; //$NON-NLS-1$
24 public static final String KEY_INACTIVE = "inactive"; //$NON-NLS-1$
25 public static final String KEY_SCOPE = "scope"; //$NON-NLS-1$
26 public static final String KEY_WORKING_SET_NAME = "workingset"; //$NON-NLS-1$
28 public static final String KEY_INCLUDE = "include"; //$NON-NLS-1$
29 public static final String KEY_MACRO_DEFINITION = "macroDefinition"; //$NON-NLS-1$
30 public static final String KEY_PREPROCESSOR = "preprocessor"; //$NON-NLS-1$
31 public static final String KEY_EXHAUSTIVE_FILE_SEARCH = "exhausiveFileSearch"; //$NON-NLS-1$
33 private IDialogSettings fDialogSettings;
35 public CRenameRefactoringPreferences() {
37 IDialogSettings ds= CUIPlugin.getDefault().getDialogSettings();
38 fDialogSettings= ds.getSection(DIALOG_SETTINGS_KEY);
39 if (fDialogSettings == null) {
40 fDialogSettings= ds.addNewSection(DIALOG_SETTINGS_KEY);
44 public boolean getBoolean(String key) {
45 return fDialogSettings.getBoolean(key);
48 public void put(String key, int value) {
49 fDialogSettings.put(key, value);
52 public void put(String key, String value) {
53 fDialogSettings.put(key, value);
56 public void put(String key, boolean value) {
57 fDialogSettings.put(key, value);
60 public int getScope() {
62 return fDialogSettings.getInt(KEY_SCOPE);
63 } catch (Exception e) {
64 return TextSearchWrapper.SCOPE_RELATED_PROJECTS;
68 public String getWorkingSet() {
69 return fDialogSettings.get(KEY_WORKING_SET_NAME);
72 public int getOptions() {
74 if (!getBoolean(KEY_IGNORE_VIRTUAL))
75 options |= CRefactory.OPTION_DO_VIRTUAL;
76 if (!getBoolean(KEY_REFERENCES_INV))
77 options |= CRefactory.OPTION_IN_CODE;
78 if (getBoolean(KEY_COMMENT))
79 options |= CRefactory.OPTION_IN_COMMENT;
80 if (getBoolean(KEY_STRING))
81 options |= CRefactory.OPTION_IN_STRING_LITERAL;
82 if (getBoolean(KEY_INCLUDE))
83 options |= CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
84 if (getBoolean(KEY_MACRO_DEFINITION))
85 options |= CRefactory.OPTION_IN_MACRO_DEFINITION;
86 if (getBoolean(KEY_PREPROCESSOR))
87 options |= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
88 if (getBoolean(KEY_INACTIVE))
89 options |= CRefactory.OPTION_IN_INACTIVE_CODE;
90 if (getBoolean(KEY_EXHAUSTIVE_FILE_SEARCH))
91 options |= CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH;