This document lists changes made to the Editor Indentation for Projects API.
+ + +@FOOTER@
+ + +
+ The
+ The module's functionality can be tested by QA functional tests. +
++ There are no estimates. +
+
+ Modules can use o.n.m.editor.indent.project.Customizers.createFormattingCategoryProvider()
+ in their XML layer to add Formatting settings customizer to their project type's properties dialog.
+
+ This project accomodates project-related editor stuff in order to keep the rest + of the editor infrastructure isolated from project APIs. +
++ No influence. +
++ Yes. +
++ No. +
++ Yes. +
++ Any version required by current Netbeans version. +
++ JRE is enough. +
++ None. +
++ It runs on all platforms withouth any difference. +
++ They have to declare a module dependency. +
++ Just the module JAR. +
++ Yes. +
++ Yes. +
++ This module can be installed anywhere. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
+
+ The API is threadsafe. Internally the code uses synchronized sections and ProjectManager.mutex()
.
+
+ None. +
++ None. +
++ None. +
++ No. +
+
+ The module registers implementation of CodeStylePreferences.Provider
in the default Lookup.
+
+ No. +
++ No. +
++ No. +
++ No. +
++ No estimates. +
++ No. +
++ No. +
++ No idea. +
++ No code can be plugged. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
+FileObject
attributes
*
* @return A new 'Formatting' category provider.
- * @since 1.10
+ * @since 1.0
+ * @deprecated Use {@link Customizers#createFormattingCategoryProvider(java.util.Map) } instead.
*/
+ @Deprecated
public static ProjectCustomizer.CompositeCategoryProvider createCategoryProvider(Map attrs) {
- return new Factory((String)attrs.get("allowedMimeTypes")); //NOI18N
+ return Customizers.createFormattingCategoryProvider(attrs);
}
public static class Factory implements ProjectCustomizer.CompositeCategoryProvider {
@@ -241,7 +248,7 @@
.add(loadButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.add(layout.createSequentialGroup()
.add(12, 12, 12)
- .add(customizerPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 490, Short.MAX_VALUE))
+ .add(customizerPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
diff --git a/editor.indent.project/src/org/netbeans/modules/editor/indent/project/ProjectAwareCodeStylePreferences.java b/editor.indent.project/src/org/netbeans/modules/editor/indent/project/ProjectAwareCodeStylePreferences.java
new file mode 100644
--- /dev/null
+++ b/editor.indent.project/src/org/netbeans/modules/editor/indent/project/ProjectAwareCodeStylePreferences.java
@@ -0,0 +1,252 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2010 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.editor.indent.project;
+
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.logging.Logger;
+import java.util.prefs.AbstractPreferences;
+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.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.modules.editor.indent.api.IndentUtils;
+import org.netbeans.modules.editor.indent.spi.CodeStylePreferences;
+import org.openide.filesystems.FileObject;
+import org.openide.loaders.DataObject;
+import org.openide.util.Utilities;
+import org.openide.util.WeakListeners;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author vita
+ */
+@ServiceProvider(service=CodeStylePreferences.Provider.class)
+public final class ProjectAwareCodeStylePreferences implements CodeStylePreferences.Provider {
+
+ @Override
+ public Preferences forFile(FileObject file, String mimeType) {
+ return singleton.forFile(file, mimeType);
+ }
+
+ @Override
+ public Preferences forDocument(Document doc, String mimeType) {
+ return singleton.forDocument(doc, mimeType);
+ }
+
+ // ----------------------------------------------------------------------
+ // private implementation
+ // ----------------------------------------------------------------------
+
+ private static final Logger LOG = Logger.getLogger(ProjectAwareCodeStylePreferences.class.getName());
+ private static final CodeStylePreferences.Provider singleton = new CodeStylePreferences.Provider() {
+
+ @Override
+ public Preferences forFile(FileObject file, String mimeType) {
+ return getCsp(file, mimeType).getPreferences();
+ }
+
+ @Override
+ public Preferences forDocument(Document doc, String mimeType) {
+ return getCsp(doc, mimeType).getPreferences();
+ }
+
+ // --------------------------------------------------------------------
+ // private implementation
+ // --------------------------------------------------------------------
+
+ private final MapUsual API clients do not have to be concerned about this. It was created
+ * in order to seprate the project-dependent implementation of code style preferences
+ * storage from the rest of the editor infrastructure.
+ *
+ * @Since 1.18
+ */
+ public static interface Provider {
+ Preferences forFile(FileObject file, String mimeType);
+ Preferences forDocument(Document doc, String mimeType);
+ }
+
+ // ------------------------------------------------------------------------
+ // Private implementation
+ // ------------------------------------------------------------------------
+
private static final Logger LOG = Logger.getLogger(CodeStylePreferences.class.getName());
-
- private static final String NODE_CODE_STYLE = "CodeStyle"; //NOI18N
- private static final String PROP_USED_PROFILE = "usedProfile"; // NOI18N
- private static final String DEFAULT_PROFILE = "default"; // NOI18N
- private static final String PROJECT_PROFILE = "project"; // NOI18N
- private static final Map
+ Moving FormattingCustomizerPanel
class to editor.indent.project
module.
+