upload tizen1.0 source
[sdk/ide/product.git] / org.eclipse.cdt.ui / src / org / eclipse / cdt / internal / ui / refactoring / rename / CRenameRefactoringPreferences.java
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
7  *
8  * Contributors:
9  *         Sergey Prigogin (Google) - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.cdt.internal.ui.refactoring.rename;
12
13 import org.eclipse.jface.dialogs.IDialogSettings;
14
15 import org.eclipse.cdt.ui.CUIPlugin;
16
17 public class CRenameRefactoringPreferences {
18         private static final String DIALOG_SETTINGS_KEY = "CRenameRefactoringInputPage"; //$NON-NLS-1$
19
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$
27
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$
32
33     private IDialogSettings fDialogSettings;
34
35     public CRenameRefactoringPreferences() {
36                 super();
37         IDialogSettings ds= CUIPlugin.getDefault().getDialogSettings();
38         fDialogSettings= ds.getSection(DIALOG_SETTINGS_KEY);
39         if (fDialogSettings == null) {
40             fDialogSettings= ds.addNewSection(DIALOG_SETTINGS_KEY);
41         }
42         }
43
44         public boolean getBoolean(String key) {
45                 return fDialogSettings.getBoolean(key);
46         }
47
48         public void put(String key, int value) {
49                 fDialogSettings.put(key, value);
50         }
51
52         public void put(String key, String value) {
53                 fDialogSettings.put(key, value);
54         }
55
56         public void put(String key, boolean value) {
57                 fDialogSettings.put(key, value);
58         }
59
60         public int getScope() {
61             try {
62                 return fDialogSettings.getInt(KEY_SCOPE);
63             } catch (Exception e) {
64                 return TextSearchWrapper.SCOPE_RELATED_PROJECTS;
65             }
66         }
67
68         public String getWorkingSet() {
69                 return fDialogSettings.get(KEY_WORKING_SET_NAME);
70         }
71
72         public int getOptions() {
73         int options= 0;
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;
92         return options;
93     }
94 }