--- a/cnd.editor/nbproject/project.properties
+++ a/cnd.editor/nbproject/project.properties
@@ -1,6 +1,15 @@
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
+auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
+auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeMethodCallParen=true
+auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeMethodDeclParen=true
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.6
-spec.version.base=1.22.0
+spec.version.base=1.23
test.config.stableBTD.includes=**/*Test.class
test.config.stableBTD.excludes=\
--- a/cnd.editor/nbproject/project.xml
+++ a/cnd.editor/nbproject/project.xml
@@ -112,6 +112,15 @@
+ org.netbeans.modules.editor.settings.storage
+
+
+
+ 1
+ 1.38
+
+
+
org.netbeans.modules.editor.util
--- a/cnd.editor/src/org/netbeans/modules/cnd/editor/api/CodeStyle.java
+++ a/cnd.editor/src/org/netbeans/modules/cnd/editor/api/CodeStyle.java
@@ -58,41 +58,32 @@
EditorOptions.codeStyleFactory = new FactoryImpl();
}
- private static CodeStyle INSTANCE_C;
- private static CodeStyle INSTANCE_H;
- private static CodeStyle INSTANCE_CPP;
- private Language language;
+ private final Language language;
private Preferences preferences;
+ private String styleID;
private final boolean useOverrideOptions;
- private CodeStyle(Language language, Preferences preferences, boolean useOverrideOptions) {
+ private CodeStyle(Language language, Preferences preferences, String styleID, boolean useOverrideOptions) {
+ assert language != null;
this.language = language;
+ assert preferences != null;
this.preferences = preferences;
+ assert styleID != null;
+ this.styleID = styleID;
this.useOverrideOptions = useOverrideOptions;
}
- public synchronized static CodeStyle getDefault(Language language) {
- switch(language) {
- case C:
- if (INSTANCE_C == null) {
- INSTANCE_C = create(language);
- setSimplePreferences(language, INSTANCE_C);
- }
- return INSTANCE_C;
- case HEADER:
- if (INSTANCE_H == null) {
- INSTANCE_H = create(language);
- setSimplePreferences(language, INSTANCE_H);
- }
- return INSTANCE_H;
- case CPP:
- default:
- if (INSTANCE_CPP == null) {
- INSTANCE_CPP = create(language);
- setSimplePreferences(language, INSTANCE_CPP);
- }
- return INSTANCE_CPP;
- }
+ public synchronized static CodeStyle getDefault(Language language, Document doc) {
+ assert doc != null;
+ CodeStyle aCodeStyle = create(language, doc);
+ setSimplePreferences(language, aCodeStyle);
+ return aCodeStyle;
+ }
+
+ public synchronized static CodeStyle getDefault(Language language, Preferences pref) {
+ CodeStyle aCodeStyle = create(language, pref);
+ setSimplePreferences(language, aCodeStyle);
+ return aCodeStyle;
}
private static void setSimplePreferences(Language language, CodeStyle codeStyle){
@@ -110,18 +101,24 @@
//}
} else {
if (mimeType.equals(MIMENames.C_MIME_TYPE)) {
- return getDefault(Language.C);
+ return getDefault(Language.C, doc);
} else if (mimeType.equals(MIMENames.HEADER_MIME_TYPE)) {
- return getDefault(Language.HEADER);
+ return getDefault(Language.HEADER, doc);
}
}
- return getDefault(Language.CPP);
+ return getDefault(Language.CPP, doc);
}
- private static CodeStyle create(Language language) {
- return new CodeStyle(language, EditorOptions.getPreferences(language, EditorOptions.getCurrentProfileId(language)), true);
+ private static CodeStyle create(Language language, Document doc) {
+ final String currentProfileId = EditorOptions.getCurrentProfileId(language, doc);
+ return new CodeStyle(language, EditorOptions.getPreferences(language, currentProfileId, doc), currentProfileId, true);
}
+ private static CodeStyle create(Language language, Preferences pref) {
+ final String currentProfileId = EditorOptions.getCurrentProfileId(language, pref);
+ return new CodeStyle(language, pref, currentProfileId, true);
+ }
+
// General indents ------------------------------------------------
private boolean isOverideTabIndents(){
@@ -522,26 +519,31 @@
// }
private boolean getOption(String key, boolean defaultValue) {
- defaultValue = (Boolean)EditorOptions.getDefault(language, EditorOptions.getCurrentProfileId(language), key);
- return getPreferences().getBoolean(key, defaultValue);
+ defaultValue = (Boolean)EditorOptions.getDefault(language, styleID, key);
+ return getPreferences().getBoolean(styleID+'.'+key, defaultValue);
}
private int getOption(String key, int defaultValue) {
- defaultValue = (Integer)EditorOptions.getDefault(language, EditorOptions.getCurrentProfileId(language), key);
- return getPreferences().getInt(key, defaultValue);
+ defaultValue = (Integer)EditorOptions.getDefault(language, styleID, key);
+ return getPreferences().getInt(styleID+'.'+key, defaultValue);
}
private String getOption(String key, String defaultValue) {
- defaultValue = (String)EditorOptions.getDefault(language, EditorOptions.getCurrentProfileId(language), key);
- return getPreferences().get(key, defaultValue);
+ defaultValue = (String)EditorOptions.getDefault(language, styleID, key);
+ return getPreferences().get(styleID+'.'+key, defaultValue);
}
private Preferences getPreferences(){
return preferences;
}
- private void setPreferences(Preferences preferences){
+ private String getStyleID(){
+ return styleID;
+ }
+
+ private void setPreferences(Preferences preferences, String styleID){
this.preferences = preferences;
+ this.styleID = styleID;
}
@Override
@@ -597,16 +599,21 @@
// Communication with non public packages ----------------------------------
private static class FactoryImpl implements EditorOptions.CodeStyleFactory {
@Override
- public CodeStyle create(Language language, Preferences preferences, boolean useOverrideOptions) {
- return new CodeStyle(language, preferences, useOverrideOptions);
+ public CodeStyle create(Language language, Preferences preferences, String styleID, boolean useOverrideOption) {
+ return new CodeStyle(language, preferences, styleID, useOverrideOption);
}
@Override
public Preferences getPreferences(CodeStyle codeStyle) {
return codeStyle.getPreferences();
}
@Override
- public void setPreferences(CodeStyle codeStyle, Preferences preferences) {
- codeStyle.setPreferences(preferences);
+ public void setPreferences(CodeStyle codeStyle, Preferences preferences, String styleID) {
+ codeStyle.setPreferences(preferences, styleID);
}
- }
+
+ @Override
+ public String getStyleID(CodeStyle codeStyle) {
+ return codeStyle.getStyleID();
+ }
+ }
}
--- a/cnd.editor/src/org/netbeans/modules/cnd/editor/layer.xml
+++ a/cnd.editor/src/org/netbeans/modules/cnd/editor/layer.xml
@@ -21,97 +21,115 @@
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
--- a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/CodeStylePreferencesProvider.java
+++ a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/CodeStylePreferencesProvider.java
@@ -0,0 +1,90 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.cnd.editor.options;
+
+import java.util.prefs.Preferences;
+import javax.swing.text.Document;
+import org.netbeans.api.editor.mimelookup.MimeLookup;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.lib.editor.util.swing.DocumentUtilities;
+import org.netbeans.modules.cnd.utils.MIMENames;
+import org.netbeans.modules.cnd.utils.MIMESupport;
+import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
+import org.openide.filesystems.FileObject;
+
+/**
+ *
+ * @author alsimon
+ */
+public class CodeStylePreferencesProvider implements CodeStylePreferences.Provider {
+
+ @Override
+ public Preferences forFile(FileObject file, String mimeType) {
+ if (mimeType == null) {
+ mimeType = MIMESupport.getSourceFileMIMEType(file);
+ }
+ if (MIMENames.C_MIME_TYPE.equals(mimeType)) {
+ return MimeLookup.getLookup(MimePath.parse(MIMENames.C_MIME_TYPE)).lookup(Preferences.class);
+ } else if (MIMENames.CPLUSPLUS_MIME_TYPE.equals(mimeType)) {
+ return MimeLookup.getLookup(MimePath.parse(MIMENames.CPLUSPLUS_MIME_TYPE)).lookup(Preferences.class);
+ } else if (MIMENames.HEADER_MIME_TYPE.equals(mimeType)) {
+ return MimeLookup.getLookup(MimePath.parse(MIMENames.HEADER_MIME_TYPE)).lookup(Preferences.class);
+ }
+ return null;
+ }
+
+ @Override
+ public Preferences forDocument(Document doc, String mimeType) {
+ if (mimeType == null) {
+ mimeType = DocumentUtilities.getMimeType(doc);
+ }
+ if (MIMENames.C_MIME_TYPE.equals(mimeType)) {
+ return MimeLookup.getLookup(MimePath.parse(MIMENames.C_MIME_TYPE)).lookup(Preferences.class);
+ } else if (MIMENames.CPLUSPLUS_MIME_TYPE.equals(mimeType)) {
+ return MimeLookup.getLookup(MimePath.parse(MIMENames.CPLUSPLUS_MIME_TYPE)).lookup(Preferences.class);
+ } else if (MIMENames.HEADER_MIME_TYPE.equals(mimeType)) {
+ return MimeLookup.getLookup(MimePath.parse(MIMENames.HEADER_MIME_TYPE)).lookup(Preferences.class);
+ }
+ return null;
+ }
+
+}
--- a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/EditorOptions.java
+++ a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/EditorOptions.java
@@ -52,15 +52,19 @@
import java.util.prefs.PreferenceChangeEvent;
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.Preferences;
+import javax.swing.text.Document;
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.api.editor.mimelookup.MimePath;
import org.netbeans.api.editor.settings.SimpleValueNames;
import org.netbeans.modules.cnd.utils.MIMENames;
import org.netbeans.modules.cnd.editor.api.CodeStyle;
import org.netbeans.modules.cnd.editor.api.CodeStyle.BracePlacement;
+import static org.netbeans.modules.cnd.editor.api.CodeStyle.Language.C;
+import static org.netbeans.modules.cnd.editor.api.CodeStyle.Language.CPP;
+import static org.netbeans.modules.cnd.editor.api.CodeStyle.Language.HEADER;
import org.netbeans.modules.cnd.editor.api.CodeStyle.PreprocessorIndent;
+import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
import org.openide.util.NbBundle;
-import org.openide.util.NbPreferences;
/**
*
@@ -327,6 +331,7 @@
private static final String APACHE_PROFILE = "Apache"; // NOI18N
private static final String DEFAULT_PROFILE = "Default"; // NOI18N
+
private static final String GNU_PROFILE = "GNU"; // NOI18N
private static final String LUNIX_PROFILE = "Linux"; // NOI18N
private static final String ANSI_PROFILE = "ANSI"; // NOI18N
@@ -335,6 +340,10 @@
private static final String MYSQL_PROFILE = "MySQL"; // NOI18N
private static final String WHITESMITHS_PROFILE = "Whitesmiths"; // NOI18N
+ public static final String CODE_STYLE_PROFILE = "CodeStyle"; // NOI18N
+ public static final String CODE_STYLE_PROFILE_ID = "Profile_ID"; // NOI18N
+ public static final String CODE_STYLE_DISPLAY_NAME_SUFFIX = "Style_Name"; // NOI18N
+
static final String[] PREDEFINED_STYLES = new String[] {
DEFAULT_PROFILE, APACHE_PROFILE, GNU_PROFILE,
LUNIX_PROFILE, ANSI_PROFILE, OPEN_SOLARIS_PROFILE,
@@ -617,29 +626,86 @@
return defaults.get(id);
}
- public static String getCurrentProfileId(CodeStyle.Language language) {
+ public static String getCurrentProfileId(CodeStyle.Language language, Document doc) {
switch(language){
case C:
- return NbPreferences.forModule(CodeStyle.class).node("CodeStyle").get("C_Style", DEFAULT_PROFILE); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.C_MIME_TYPE).getPreferences().get(EditorOptions.CODE_STYLE_PROFILE_ID, DEFAULT_PROFILE); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get("C_Style", DEFAULT_PROFILE); // NOI18N
case HEADER:
- return NbPreferences.forModule(CodeStyle.class).node("CodeStyle").get("H_Style", DEFAULT_PROFILE); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.HEADER_MIME_TYPE).getPreferences().get(EditorOptions.CODE_STYLE_PROFILE_ID, DEFAULT_PROFILE); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get("H_Style", DEFAULT_PROFILE); // NOI18N
case CPP:
default:
- return NbPreferences.forModule(CodeStyle.class).node("CodeStyle").get("CPP_Style", DEFAULT_PROFILE); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.CPLUSPLUS_MIME_TYPE).getPreferences().get(EditorOptions.CODE_STYLE_PROFILE_ID, DEFAULT_PROFILE); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get("CPP_Style", DEFAULT_PROFILE); // NOI18N
+ }
+ }
+
+ public static String getCurrentProfileId(CodeStyle.Language language, Preferences pref) {
+ switch(language){
+ case C:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.C_MIME_TYPE);
+ }
+ return pref.get(EditorOptions.CODE_STYLE_PROFILE_ID, DEFAULT_PROFILE); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get("C_Style", DEFAULT_PROFILE); // NOI18N
+ case HEADER:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.HEADER_MIME_TYPE);
+ }
+ return pref.get(EditorOptions.CODE_STYLE_PROFILE_ID, DEFAULT_PROFILE); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get("H_Style", DEFAULT_PROFILE); // NOI18N
+ case CPP:
+ default:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.CPLUSPLUS_MIME_TYPE);
+ }
+ return pref.get(EditorOptions.CODE_STYLE_PROFILE_ID, DEFAULT_PROFILE); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get("CPP_Style", DEFAULT_PROFILE); // NOI18N
}
}
- public static void setCurrentProfileId(CodeStyle.Language language, String style) {
+ public static void setCurrentProfileId(CodeStyle.Language language, String style, Document doc) {
switch(language){
case C:
- NbPreferences.forModule(CodeStyle.class).node("CodeStyle").put("C_Style", style); // NOI18N
+ CodeStylePreferences.get(doc, MIMENames.C_MIME_TYPE).getPreferences().put(EditorOptions.CODE_STYLE_PROFILE_ID, style); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).put("C_Style", style); // NOI18N
break;
case HEADER:
- NbPreferences.forModule(CodeStyle.class).node("CodeStyle").put("H_Style", style); // NOI18N
+ CodeStylePreferences.get(doc, MIMENames.HEADER_MIME_TYPE).getPreferences().put(EditorOptions.CODE_STYLE_PROFILE_ID, style); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).put("H_Style", style); // NOI18N
break;
case CPP:
default:
- NbPreferences.forModule(CodeStyle.class).node("CodeStyle").put("CPP_Style", style); // NOI18N
+ CodeStylePreferences.get(doc, MIMENames.CPLUSPLUS_MIME_TYPE).getPreferences().put(EditorOptions.CODE_STYLE_PROFILE_ID, style); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).put("CPP_Style", style); // NOI18N
+ break;
+ }
+ }
+
+ public static void setCurrentProfileId(CodeStyle.Language language, String style, Preferences pref) {
+ switch(language){
+ case C:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.C_MIME_TYPE);
+ }
+ pref.put(EditorOptions.CODE_STYLE_PROFILE_ID, style); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).put("C_Style", style); // NOI18N
+ break;
+ case HEADER:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.HEADER_MIME_TYPE);
+ }
+ pref.put(EditorOptions.CODE_STYLE_PROFILE_ID, style); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).put("H_Style", style); // NOI18N
+ break;
+ case CPP:
+ default:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.CPLUSPLUS_MIME_TYPE);
+ }
+ pref.put(EditorOptions.CODE_STYLE_PROFILE_ID, style); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).put("CPP_Style", style); // NOI18N
break;
}
}
@@ -648,7 +714,7 @@
return NbBundle.getMessage(EditorOptions.class, key);
}
- public static String getStyleDisplayName(CodeStyle.Language language, String style) {
+ public static String getStyleDisplayName(CodeStyle.Language language, String style, Document doc) {
for (String name : EditorOptions.PREDEFINED_STYLES) {
if (style.equals(name)) {
return getString(style + "_Name"); // NOI18N
@@ -656,28 +722,88 @@
}
switch(language){
case C:
- return NbPreferences.forModule(CodeStyle.class).node("CodeStyle").get(style+"_Style_Name", style); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.C_MIME_TYPE).getPreferences().get(style+'.'+EditorOptions.CODE_STYLE_DISPLAY_NAME_SUFFIX, style); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get(style+"_Style_Name", style); // NOI18N
case HEADER:
- return NbPreferences.forModule(CodeStyle.class).node("CodeStyle").get(style+"_Style_Name", style); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.HEADER_MIME_TYPE).getPreferences().get(style+'.'+EditorOptions.CODE_STYLE_DISPLAY_NAME_SUFFIX, style); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get(style+"_Style_Name", style); // NOI18N
case CPP:
default:
- return NbPreferences.forModule(CodeStyle.class).node("CodeStyle").get(style+"_Style_Name", style); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.CPLUSPLUS_MIME_TYPE).getPreferences().get(style+'.'+EditorOptions.CODE_STYLE_DISPLAY_NAME_SUFFIX, style); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get(style+"_Style_Name", style); // NOI18N
+ }
+ }
+
+ public static String getStyleDisplayName(CodeStyle.Language language, String style, Preferences pref) {
+ for (String name : EditorOptions.PREDEFINED_STYLES) {
+ if (style.equals(name)) {
+ return getString(style + "_Name"); // NOI18N
+ }
+ }
+ switch(language){
+ case C:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.C_MIME_TYPE);
+ }
+ return pref.get(style+'.'+EditorOptions.CODE_STYLE_DISPLAY_NAME_SUFFIX, style); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get(style+"_Style_Name", style); // NOI18N
+ case HEADER:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.HEADER_MIME_TYPE);
+ }
+ return pref.get(style+'.'+EditorOptions.CODE_STYLE_DISPLAY_NAME_SUFFIX, style); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE).get(style+"_Style_Name", style); // NOI18N
+ case CPP:
+ default:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.CPLUSPLUS_MIME_TYPE);
+ }
+ return pref.get(style+'.'+EditorOptions.CODE_STYLE_DISPLAY_NAME_SUFFIX, style); // NOI18N
+ //return NbPreferences.forModule(CodeStyle.class).node(EditorOptions.CODE_STYLE_PROFILE").get(style+"_Style_Name", style); // NOI18N
}
}
- public static Preferences getPreferences(CodeStyle.Language language, String profileId) {
+ public static Preferences getPreferences(CodeStyle.Language language, String profileId, Document doc) {
switch(language){
case C:
- return NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").node(profileId); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.C_MIME_TYPE).getPreferences();
+ //return NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").node(profileId); // NOI18N
case HEADER:
- return NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").node(profileId); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.HEADER_MIME_TYPE).getPreferences();
+ //return NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").node(profileId); // NOI18N
case CPP:
default:
- return NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").node(profileId); // NOI18N
+ return CodeStylePreferences.get(doc, MIMENames.CPLUSPLUS_MIME_TYPE).getPreferences();
+ //return NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").node(profileId); // NOI18N
}
}
- public static List getAllStyles(CodeStyle.Language language) {
+ public static Preferences getPreferences(CodeStyle.Language language, String profileId, Preferences pref) {
+ switch(language){
+ case C:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.C_MIME_TYPE);
+ }
+ return pref;
+ //return NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").node(profileId); // NOI18N
+ case HEADER:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.HEADER_MIME_TYPE);
+ }
+ return pref;
+ //return NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").node(profileId); // NOI18N
+ case CPP:
+ default:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.CPLUSPLUS_MIME_TYPE);
+ }
+ return pref;
+ //return NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").node(profileId); // NOI18N
+ }
+ }
+
+
+ public static List getAllStyles(CodeStyle.Language language, Document doc) {
String styles = null;
StringBuilder def = new StringBuilder();
for(String s: PREDEFINED_STYLES){
@@ -688,14 +814,17 @@
}
switch(language){
case C:
- styles = NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
+ styles = CodeStylePreferences.get(doc, MIMENames.C_MIME_TYPE).getPreferences().get("List_Of_Styles", def.toString()); // NOI18N
+ //styles = NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
break;
case HEADER:
- styles = NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
+ styles = CodeStylePreferences.get(doc, MIMENames.HEADER_MIME_TYPE).getPreferences().get("List_Of_Styles", def.toString()); // NOI18N
+ //styles = NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
break;
case CPP:
default:
- styles = NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
+ styles = CodeStylePreferences.get(doc, MIMENames.CPLUSPLUS_MIME_TYPE).getPreferences().get("List_Of_Styles", def.toString()); // NOI18N
+ //styles = NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
break;
}
List res = new ArrayList();
@@ -706,32 +835,103 @@
return res;
}
- public static void setAllStyles(CodeStyle.Language language, String list) {
+ public static List getAllStyles(CodeStyle.Language language, Preferences pref) {
+ String styles = null;
+ StringBuilder def = new StringBuilder();
+ for(String s: PREDEFINED_STYLES){
+ if (def.length() > 0){
+ def.append(',');
+ }
+ def.append(s);
+ }
switch(language){
case C:
- NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.C_MIME_TYPE);
+ }
+ styles = pref.get("List_Of_Styles", def.toString()); // NOI18N
+ //styles = NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
break;
case HEADER:
- NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.HEADER_MIME_TYPE);
+ }
+ styles = pref.get("List_Of_Styles", def.toString()); // NOI18N
+ //styles = NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
break;
case CPP:
default:
- NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.CPLUSPLUS_MIME_TYPE);
+ }
+ styles = pref.get("List_Of_Styles", def.toString()); // NOI18N
+ //styles = NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").get("List_Of_Styles", def.toString()); // NOI18N
+ break;
+ }
+ List res = new ArrayList();
+ StringTokenizer st = new StringTokenizer(styles,","); // NOI18N
+ while(st.hasMoreTokens()) {
+ res.add(st.nextToken());
+ }
+ return res;
+ }
+
+ public static void setAllStyles(CodeStyle.Language language, String list, Document doc) {
+ switch(language){
+ case C:
+ CodeStylePreferences.get(doc, MIMENames.C_MIME_TYPE).getPreferences().put("List_Of_Styles", list); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ break;
+ case HEADER:
+ CodeStylePreferences.get(doc, MIMENames.HEADER_MIME_TYPE).getPreferences().put("List_Of_Styles", list); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ break;
+ case CPP:
+ default:
+ CodeStylePreferences.get(doc, MIMENames.CPLUSPLUS_MIME_TYPE).getPreferences().put("List_Of_Styles", list); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").put("List_Of_Styles", list); // NOI18N
break;
}
}
- public static CodeStyle createCodeStyle(CodeStyle.Language language, Preferences p, boolean useOverrideOption) {
- CodeStyle.getDefault(language);
- return codeStyleFactory.create(language, p, useOverrideOption);
+ public static void setAllStyles(CodeStyle.Language language, String list, Preferences pref) {
+ switch(language){
+ case C:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.C_MIME_TYPE);
+ }
+ pref.put("List_Of_Styles", list); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node("C_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ break;
+ case HEADER:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.HEADER_MIME_TYPE);
+ }
+ pref.put("List_Of_Styles", list); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node("H_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ break;
+ case CPP:
+ default:
+ if (pref == null) {
+ pref = new CodeStylePreferencesProvider().forDocument(null, MIMENames.CPLUSPLUS_MIME_TYPE);
+ }
+ pref.put("List_Of_Styles", list); // NOI18N
+ //NbPreferences.forModule(CodeStyle.class).node("CPP_CodeStyles").put("List_Of_Styles", list); // NOI18N
+ break;
+ }
}
- public static Preferences getPreferences(CodeStyle codeStyle){
- return codeStyleFactory.getPreferences(codeStyle);
+ public static CodeStyle createCodeStyle(CodeStyle.Language language, Preferences pref, String styleID, boolean useOverrideOption) {
+ CodeStyle.getDefault(language, pref);
+ return codeStyleFactory.create(language, pref, styleID, useOverrideOption);
+ }
+
+ public static PreferencesWrapper getPreferences(CodeStyle codeStyle){
+ return new PreferencesWrapper(codeStyleFactory.getPreferences(codeStyle), codeStyleFactory.getStyleID(codeStyle));
}
public static void resetToDefault(CodeStyle codeStyle){
- Preferences preferences = getPreferences(codeStyle);
+ PreferencesWrapper preferences = getPreferences(codeStyle);
for(Map.Entry entry : defaults.entrySet()){
if (entry.getValue() instanceof Boolean){
preferences.putBoolean(entry.getKey(), (Boolean)entry.getValue());
@@ -744,7 +944,7 @@
}
public static void resetToDefault(CodeStyle codeStyle, String name){
- Preferences preferences = getPreferences(codeStyle);
+ PreferencesWrapper preferences = getPreferences(codeStyle);
for(Map.Entry entry : namedDefaults.get(name).entrySet()){
if (entry.getValue() instanceof Boolean){
preferences.putBoolean(entry.getKey(), (Boolean)entry.getValue());
@@ -760,8 +960,8 @@
return defaults.keySet();
}
- public static void setPreferences(CodeStyle codeStyle, Preferences preferences){
- codeStyleFactory.setPreferences(codeStyle, preferences);
+ public static void setPreferences(CodeStyle codeStyle, Preferences preferences, String styleID){
+ codeStyleFactory.setPreferences(codeStyle, preferences, styleID);
}
public static void updateSimplePreferences(CodeStyle.Language language, CodeStyle codeStyle) {
@@ -849,8 +1049,30 @@
}
public static interface CodeStyleFactory {
- CodeStyle create(CodeStyle.Language language, Preferences preferences, boolean useOverrideOption);
+ CodeStyle create(CodeStyle.Language language, Preferences preferences, String styleID, boolean useOverrideOption);
Preferences getPreferences(CodeStyle codeStyle);
- void setPreferences(CodeStyle codeStyle, Preferences preferences);
+ String getStyleID(CodeStyle codeStyle);
+ void setPreferences(CodeStyle codeStyle, Preferences preferences, String styleID);
+ }
+
+ public static final class PreferencesWrapper {
+ private final Preferences delegate;
+ private final String styleID;
+ private PreferencesWrapper(Preferences delegate, String styleID) {
+ this.delegate = delegate;
+ this.styleID = styleID;
+ }
+
+ public void put(String key, String value) {
+ delegate.put(styleID+'.'+key, value);
+ }
+
+ public void putInt(String key, int value) {
+ delegate.putInt(styleID+'.'+key, value);
+ }
+
+ public void putBoolean(String key, boolean value) {
+ delegate.putBoolean(styleID+'.'+key, value);
+ }
}
}
--- a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/EditorOptionsPanelController.java
+++ a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/EditorOptionsPanelController.java
@@ -39,188 +39,228 @@
*
* Portions Copyrighted 2008 Sun Microsystems, Inc.
*/
-
package org.netbeans.modules.cnd.editor.options;
-import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.util.prefs.Preferences;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import org.netbeans.modules.cnd.editor.api.CodeStyle;
+import static org.netbeans.modules.cnd.editor.api.CodeStyle.Language.C;
+import static org.netbeans.modules.cnd.editor.api.CodeStyle.Language.CPP;
+import static org.netbeans.modules.cnd.editor.api.CodeStyle.Language.HEADER;
+import static org.netbeans.modules.cnd.editor.options.PreviewPreferencesModel.Filter.Alignment;
+import static org.netbeans.modules.cnd.editor.options.PreviewPreferencesModel.Filter.All;
+import static org.netbeans.modules.cnd.editor.options.PreviewPreferencesModel.Filter.BlankLines;
+import static org.netbeans.modules.cnd.editor.options.PreviewPreferencesModel.Filter.Braces;
+import static org.netbeans.modules.cnd.editor.options.PreviewPreferencesModel.Filter.Spaces;
+import static org.netbeans.modules.cnd.editor.options.PreviewPreferencesModel.Filter.TabsAndIndents;
import org.netbeans.modules.cnd.utils.MIMENames;
+import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
import org.netbeans.modules.options.editor.spi.PreviewProvider;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.text.CloneableEditorSupport;
import org.openide.util.HelpCtx;
-import org.openide.util.Lookup;
import org.openide.util.NbBundle;
/**
*
* @author Alexander Simon
*/
-public class EditorOptionsPanelController extends OptionsPanelController implements PreviewProvider {
+public class EditorOptionsPanelController implements PreferencesCustomizer.Factory {
- private JEditorPane previewPane;
- private final EditorPropertySheet panel;
private final CodeStyle.Language language;
- private static final boolean TRACE = false;
- private static final PreviewPreferencesModel preferencesModel = new PreviewPreferencesModel();
-
+ private final PreviewPreferencesModel.Filter filter;
+ private PreferencesCustomizerImpl customizer;
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
private boolean changed;
+ private final static PreviewPreferencesModel prefModel = new PreviewPreferencesModel();
-
- public EditorOptionsPanelController(CodeStyle.Language language, PreviewPreferencesModel.Filter filter){
- if (TRACE) {System.out.println("EditorOptionsPanelController.ctor()");} // NOI18N
+ public EditorOptionsPanelController(CodeStyle.Language language, PreviewPreferencesModel.Filter filter) {
this.language = language;
- this.panel = new EditorPropertySheet(this, language, preferencesModel, filter);
+ this.filter = filter;
}
@Override
- public void update() {
- if (TRACE) {System.out.println("EditorOptionsPanelController.update()");} // NOI18N
- changed = false;
- panel.load();
- }
-
- @Override
- public void applyChanges() {
- if (TRACE) {System.out.println("EditorOptionsPanelController.applyChanges()");} // NOI18N
- panel.store();
- }
-
- @Override
- public void cancel() {
- if (TRACE) {System.out.println("EditorOptionsPanelController.cancel()");} // NOI18N
- panel.cancel();
- }
-
- @Override
- public boolean isValid() {
- if (TRACE) {System.out.println("EditorOptionsPanelController.isValid()");} // NOI18N
- return true;
- }
-
- @Override
- public boolean isChanged() {
- if (TRACE) {System.out.println("EditorOptionsPanelController.isChanged()");} // NOI18N
- return changed;
+ public PreferencesCustomizer create(Preferences preferences) {
+ if (customizer == null) {
+ customizer = new PreferencesCustomizerImpl(this, language, filter, preferences);
+ }
+ return customizer;
}
- @Override
- public HelpCtx getHelpCtx() {
- return new HelpCtx("netbeans.optionsDialog.advanced.formEditor"); // NOI18N
- }
-
- @Override
- public JComponent getComponent(Lookup masterLookup) {
- if (TRACE) {System.out.println("EditorOptionsPanelController.getComponent()");} // NOI18N
- return panel;
+ public JComponent getPreviewComponent() {
+ return customizer.getPreviewComponent();
}
- @Override
- public void addPropertyChangeListener(PropertyChangeListener l) {
- pcs.addPropertyChangeListener(l);
- }
-
- @Override
- public void removePropertyChangeListener(PropertyChangeListener l) {
- pcs.removePropertyChangeListener(l);
- }
-
void changed() {
if (!changed) {
changed = true;
pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
}
pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
+ prefModel.storeTo(customizer.preferences);
}
- @Override
- public JComponent getPreviewComponent() {
- if (previewPane == null) {
- previewPane = new JEditorPane();
- previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(EditorOptionsPanelController.class, "AN_Preview")); //NOI18N
- previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(EditorOptionsPanelController.class, "AD_Preview")); //NOI18N
- previewPane.putClientProperty("HighlightsLayerIncludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.SyntaxHighlighting$"); //NOI18N
- switch (language){
- case C:
- previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(MIMENames.C_MIME_TYPE));
- break;
- case HEADER:
- previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(MIMENames.HEADER_MIME_TYPE));
- break;
- case CPP:
- default:
- previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(MIMENames.CPLUSPLUS_MIME_TYPE));
- break;
+ private static class PreferencesCustomizerImpl implements PreferencesCustomizer, PreviewProvider {
+
+ private final CodeStyle.Language language;
+ private final PreviewPreferencesModel.Filter filter;
+ private final EditorOptionsPanelController top;
+ private final Preferences preferences;
+ private EditorPropertySheet panel;
+ private JEditorPane previewPane;
+
+ public PreferencesCustomizerImpl(EditorOptionsPanelController top, CodeStyle.Language language, PreviewPreferencesModel.Filter filter, Preferences preferences) {
+ this.language = language;
+ this.filter = filter;
+ this.top = top;
+ this.preferences = preferences;
+ }
+
+ @Override
+ public String getId() {
+ return filter.name();
+// switch (filter) {
+// case TabsAndIndents:
+// return PreferencesCustomizer.TABS_AND_INDENTS_ID;
+// default:
+// return filter.name();
+// }
+ }
+
+ @Override
+ public String getDisplayName() {
+ switch (filter) {
+ case Alignment:
+ return EditorPropertySheet.getString("Filter_Alignment_name"); // NOI18N
+ case All:
+ return EditorPropertySheet.getString("Filter_All_name"); // NOI18N
+ case BlankLines:
+ return EditorPropertySheet.getString("Filter_BlankLines_name"); // NOI18N
+ case Braces:
+ return EditorPropertySheet.getString("Filter_Braces_name"); // NOI18N
+ case Spaces:
+ return EditorPropertySheet.getString("Filter_Spaces_name"); // NOI18N
+ case TabsAndIndents:
+ return EditorPropertySheet.getString("Filter_TabsAndIndents_name"); // NOI18N
}
- previewPane.setEditable(false);
+ return null;
}
- return previewPane;
+
+ @Override
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+ @Override
+ public JComponent getComponent() {
+ if (panel == null) {
+ prefModel.setPreferences(language, filter, preferences);
+ panel = new EditorPropertySheet(top, language, EditorOptionsPanelController.prefModel, filter);
+ }
+ return panel;
+ }
+
+ @Override
+ public JComponent getPreviewComponent() {
+ if (previewPane == null) {
+ previewPane = new JEditorPane();
+ previewPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage(EditorOptionsPanelController.class, "AN_Preview")); //NOI18N
+ previewPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(EditorOptionsPanelController.class, "AD_Preview")); //NOI18N
+ previewPane.putClientProperty("HighlightsLayerIncludes", "^org\\.netbeans\\.modules\\.editor\\.lib2\\.highlighting\\.SyntaxHighlighting$"); //NOI18N
+ switch (language) {
+ case C:
+ previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(MIMENames.C_MIME_TYPE));
+ break;
+ case HEADER:
+ previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(MIMENames.HEADER_MIME_TYPE));
+ break;
+ case CPP:
+ default:
+ previewPane.setEditorKit(CloneableEditorSupport.getEditorKit(MIMENames.CPLUSPLUS_MIME_TYPE));
+ break;
+ }
+ previewPane.setEditable(false);
+ }
+ return previewPane;
+ }
+
+ @Override
+ public void refreshPreview() {
+ panel.repaintPreview();
+ }
}
- @Override
- public void refreshPreview() {
- panel.repaintPreview();
+ public static PreferencesCustomizer.Factory getCController() {
+ return new EditorOptionsPanelController(CodeStyle.Language.C, PreviewPreferencesModel.Filter.All);
}
- public static OptionsPanelController getCController() {
- return new EditorOptionsPanelController(CodeStyle.Language.C, PreviewPreferencesModel.Filter.All);
- }
- public static OptionsPanelController getCControllerTabs() {
+ public static PreferencesCustomizer.Factory getCControllerTabs() {
return new EditorOptionsPanelController(CodeStyle.Language.C, PreviewPreferencesModel.Filter.TabsAndIndents);
}
- public static OptionsPanelController getCControllerAlignment() {
+
+ public static PreferencesCustomizer.Factory getCControllerAlignment() {
return new EditorOptionsPanelController(CodeStyle.Language.C, PreviewPreferencesModel.Filter.Alignment);
}
- public static OptionsPanelController getCControllerBraces() {
+
+ public static PreferencesCustomizer.Factory getCControllerBraces() {
return new EditorOptionsPanelController(CodeStyle.Language.C, PreviewPreferencesModel.Filter.Braces);
}
- public static OptionsPanelController getCControllerBlank() {
+
+ public static PreferencesCustomizer.Factory getCControllerBlank() {
return new EditorOptionsPanelController(CodeStyle.Language.C, PreviewPreferencesModel.Filter.BlankLines);
}
- public static OptionsPanelController getCControllerSpaces() {
+
+ public static PreferencesCustomizer.Factory getCControllerSpaces() {
return new EditorOptionsPanelController(CodeStyle.Language.C, PreviewPreferencesModel.Filter.Spaces);
}
- public static OptionsPanelController getCCController() {
+ public static PreferencesCustomizer.Factory getCCController() {
return new EditorOptionsPanelController(CodeStyle.Language.CPP, PreviewPreferencesModel.Filter.All);
}
- public static OptionsPanelController getCCControllerTabs() {
+
+ public static PreferencesCustomizer.Factory getCCControllerTabs() {
return new EditorOptionsPanelController(CodeStyle.Language.CPP, PreviewPreferencesModel.Filter.TabsAndIndents);
}
- public static OptionsPanelController getCCControllerAlignment() {
+
+ public static PreferencesCustomizer.Factory getCCControllerAlignment() {
return new EditorOptionsPanelController(CodeStyle.Language.CPP, PreviewPreferencesModel.Filter.Alignment);
}
- public static OptionsPanelController getCCControllerBraces() {
+
+ public static PreferencesCustomizer.Factory getCCControllerBraces() {
return new EditorOptionsPanelController(CodeStyle.Language.CPP, PreviewPreferencesModel.Filter.Braces);
}
- public static OptionsPanelController getCCControllerBlank() {
+
+ public static PreferencesCustomizer.Factory getCCControllerBlank() {
return new EditorOptionsPanelController(CodeStyle.Language.CPP, PreviewPreferencesModel.Filter.BlankLines);
}
- public static OptionsPanelController getCCControllerSpaces() {
+
+ public static PreferencesCustomizer.Factory getCCControllerSpaces() {
return new EditorOptionsPanelController(CodeStyle.Language.CPP, PreviewPreferencesModel.Filter.Spaces);
}
- public static OptionsPanelController getHController() {
+ public static PreferencesCustomizer.Factory getHController() {
return new EditorOptionsPanelController(CodeStyle.Language.HEADER, PreviewPreferencesModel.Filter.All);
}
- public static OptionsPanelController getHControllerTabs() {
+
+ public static PreferencesCustomizer.Factory getHControllerTabs() {
return new EditorOptionsPanelController(CodeStyle.Language.HEADER, PreviewPreferencesModel.Filter.TabsAndIndents);
}
- public static OptionsPanelController getHControllerAlignment() {
+
+ public static PreferencesCustomizer.Factory getHControllerAlignment() {
return new EditorOptionsPanelController(CodeStyle.Language.HEADER, PreviewPreferencesModel.Filter.Alignment);
}
- public static OptionsPanelController getHControllerBraces() {
+
+ public static PreferencesCustomizer.Factory getHControllerBraces() {
return new EditorOptionsPanelController(CodeStyle.Language.HEADER, PreviewPreferencesModel.Filter.Braces);
}
- public static OptionsPanelController getHControllerBlank() {
+
+ public static PreferencesCustomizer.Factory getHControllerBlank() {
return new EditorOptionsPanelController(CodeStyle.Language.HEADER, PreviewPreferencesModel.Filter.BlankLines);
}
- public static OptionsPanelController getHControllerSpaces() {
+
+ public static PreferencesCustomizer.Factory getHControllerSpaces() {
return new EditorOptionsPanelController(CodeStyle.Language.HEADER, PreviewPreferencesModel.Filter.Spaces);
}
-
}
--- a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/EditorPropertySheet.form
+++ a/cnd.editor/src/org/netbeans/modules/cnd/editor/options/EditorPropertySheet.form
@@ -1,4 +1,4 @@
-
+
+ org.netbeans.modules.editor.indent.project
+
+
+
+ 0-1
+ 1.13
+
+
+
org.netbeans.modules.extexecution
--- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/MakeCustomizerProvider.java
+++ a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/MakeCustomizerProvider.java
@@ -266,7 +266,7 @@
currentCommand = e.getActionCommand();
if (currentCommand.equals(COMMAND_OK) || currentCommand.equals(COMMAND_APPLY)) {
- makeCustomizer.save();
+ makeCustomizer.actionPerformed(e);
//non UI actions such as as update of MakeConfiguration accessing filesystem should be invoked from non EDT
RP_SAVE.post(new Runnable() {
@Override
--- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ui/CustomizerNode.java
+++ a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/ui/CustomizerNode.java
@@ -44,14 +44,16 @@
package org.netbeans.modules.cnd.makeproject.api.configurations.ui;
-import javax.swing.JPanel;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JComponent;
import org.netbeans.modules.cnd.makeproject.api.configurations.Configuration;
import org.netbeans.modules.cnd.makeproject.ui.customizer.MakeContext;
import org.openide.nodes.Sheet;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
-public class CustomizerNode {
+public class CustomizerNode implements ActionListener {
public static final String iconbase = "org/netbeans/modules/cnd/makeproject/ui/resources/general"; // NOI18N
public static final String icon = "org/netbeans/modules/cnd/makeproject/ui/resources/general.gif"; // NOI18N
@@ -60,6 +62,11 @@
private CustomizerNode[] children;
protected final Lookup lookup;
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ }
+
public enum CustomizerStyle {SHEET, PANEL};
public final MakeContext getContext(){
@@ -81,7 +88,7 @@
return null;
}
- public JPanel getPanel(Configuration configuration) {
+ public JComponent getPanel(Configuration configuration) {
return null;
}
--- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ui/ProjectPropPanel.form
+++ a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ui/ProjectPropPanel.form
@@ -1,4 +1,4 @@
-
+
--- a/cnd.refactoring/src/org/netbeans/modules/cnd/refactoring/plugins/EncapsulateFieldRefactoringPlugin.java
+++ a/cnd.refactoring/src/org/netbeans/modules/cnd/refactoring/plugins/EncapsulateFieldRefactoringPlugin.java
@@ -611,7 +611,8 @@
DeclarationGenerator.Kind declKind;
if (refactoring.isMethodInline()) {
declKind = DeclarationGenerator.Kind.INLINE_DEFINITION;
- if (CodeStyle.getDefault(CodeStyle.Language.CPP).getUseInlineKeyword()) {
+ Document doc = CsmUtilities.getDocument(fo);
+ if (CodeStyle.getDefault(CodeStyle.Language.CPP, doc).getUseInlineKeyword()) {
declKind = DeclarationGenerator.Kind.INLINE_DEFINITION_MAKRED_INLINE;
}
} else {