# HG changeset patch # Parent f05827a8a91a4c9d5bdcb95601321280844a292e diff --git a/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BMFClass2LayerFolder.java b/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BMFClass2LayerFolder.java deleted file mode 100644 --- a/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BMFClass2LayerFolder.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * Portions Copyrighted 2007 Sun Microsystems, Inc. - */ -package org.netbeans.modules.editor.bracesmatching; - -import org.netbeans.spi.editor.bracesmatching.BracesMatcherFactory; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * - * @author vita - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public final class BMFClass2LayerFolder implements Class2LayerFolder { - - public static final String FOLDER = "BracesMatchers"; //NOI18N - - public BMFClass2LayerFolder() { - } - - public Class getClazz() { - return BracesMatcherFactory.class; - } - - public String getLayerFolderName() { - return FOLDER; - } - - public InstanceProvider getInstanceProvider() { - return null; - } -} diff --git a/editor.bracesmatching/src/org/netbeans/spi/editor/bracesmatching/BracesMatcherFactory.java b/editor.bracesmatching/src/org/netbeans/spi/editor/bracesmatching/BracesMatcherFactory.java --- a/editor.bracesmatching/src/org/netbeans/spi/editor/bracesmatching/BracesMatcherFactory.java +++ b/editor.bracesmatching/src/org/netbeans/spi/editor/bracesmatching/BracesMatcherFactory.java @@ -43,7 +43,6 @@ */ package org.netbeans.spi.editor.bracesmatching; -import org.netbeans.modules.editor.bracesmatching.BMFClass2LayerFolder; import org.netbeans.spi.editor.mimelookup.MimeLocation; /** @@ -53,7 +52,7 @@ * * @author Vita Stejskal */ -@MimeLocation(subfolderName=BMFClass2LayerFolder.FOLDER) +@MimeLocation(subfolderName="BracesMatchers") public interface BracesMatcherFactory { /** diff --git a/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateClass2LayerFolder.java b/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateClass2LayerFolder.java deleted file mode 100644 --- a/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateClass2LayerFolder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.lib.editor.codetemplates; - - -import org.netbeans.lib.editor.codetemplates.spi.CodeTemplateProcessorFactory; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * Mapping the CodeTemplateProcessorFactories folder to CodeTemplateProcessorFactory class. - * - * @author Martin Roskanin - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class CodeTemplateClass2LayerFolder implements Class2LayerFolder { - - public CodeTemplateClass2LayerFolder() { - } - - public Class getClazz() { - return CodeTemplateProcessorFactory.class; - } - - public String getLayerFolderName() { - return "CodeTemplateProcessorFactories"; // NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateFilterClass2LayerFolder.java b/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateFilterClass2LayerFolder.java deleted file mode 100644 --- a/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateFilterClass2LayerFolder.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.lib.editor.codetemplates; - - -import org.netbeans.lib.editor.codetemplates.spi.CodeTemplateFilter; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * Mapping the CodeTemplateFilterFactories folder to CodeTemplateFilter.Factory class. - * - * @author Dusan Balek - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class CodeTemplateFilterClass2LayerFolder implements Class2LayerFolder { - - public CodeTemplateFilterClass2LayerFolder() { - } - - public Class getClazz() { - return CodeTemplateFilter.Factory.class; - } - - public String getLayerFolderName() { - return "CodeTemplateFilterFactories"; // NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.completion/src/org/netbeans/modules/editor/completion/CompletionProviderClass2LayerFolder.java b/editor.completion/src/org/netbeans/modules/editor/completion/CompletionProviderClass2LayerFolder.java deleted file mode 100644 --- a/editor.completion/src/org/netbeans/modules/editor/completion/CompletionProviderClass2LayerFolder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.modules.editor.completion; - - -import org.netbeans.spi.editor.completion.CompletionProvider; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * Mapping the CompletionProviders folder to CompletionProvider class. - * - * @author Martin Roskanin - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class CompletionProviderClass2LayerFolder implements Class2LayerFolder { - - public CompletionProviderClass2LayerFolder() { - } - - public Class getClazz() { - return CompletionProvider.class; - } - - public String getLayerFolderName() { - return "CompletionProviders"; // NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationViewDataImpl.java b/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationViewDataImpl.java --- a/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationViewDataImpl.java +++ b/editor.errorstripe/src/org/netbeans/modules/editor/errorstripe/AnnotationViewDataImpl.java @@ -76,6 +76,7 @@ import org.openide.ErrorManager; import org.netbeans.modules.editor.errorstripe.apimodule.SPIAccessor; import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; +import org.netbeans.spi.editor.mimelookup.MimeLocation; import org.openide.cookies.InstanceCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; @@ -638,51 +639,11 @@ return get(ann.getSeverity()); } - @org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) - public static final class UpToDateStatusProviderFactoriesProvider implements Class2LayerFolder { - - public UpToDateStatusProviderFactoriesProvider() { - - } - - public Class getClazz() { - return UpToDateStatusProviderFactory.class; - } - - public String getLayerFolderName() { - return UP_TO_DATE_STATUS_PROVIDER_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return null; - } - } // End of UpToDateStatusProviderFactoriesProvider class - - @org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) - public static final class MarkProviderCreatorsProvider implements Class2LayerFolder { - - public MarkProviderCreatorsProvider() { - - } - - public Class getClazz() { - return MarkProviderCreator.class; - } - - public String getLayerFolderName() { - return UP_TO_DATE_STATUS_PROVIDER_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return null; - } - } // End of UpToDateStatusProviderFactoriesProvider class - // XXX: This is here to help to deal with legacy code // that registered stuff in text/base. The artificial text/base // mime type is deprecated and should not be used anymore. - @org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) - public static final class LegacyCrapProvider implements Class2LayerFolder, InstanceProvider { + @MimeLocation(subfolderName=UP_TO_DATE_STATUS_PROVIDER_FOLDER_NAME, instanceProviderClass=LegacyCrapProvider.class) + public static final class LegacyCrapProvider implements InstanceProvider { private final List instanceFiles; private List creators; @@ -710,18 +671,6 @@ return factories; } - public Class getClazz(){ - return LegacyCrapProvider.class; - } - - public String getLayerFolderName(){ - return UP_TO_DATE_STATUS_PROVIDER_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return new LegacyCrapProvider(); - } - public Object createInstance(List fileObjectList) { ArrayList textBaseFilesList = new ArrayList(); diff --git a/editor.fold/src/org/netbeans/modules/editor/fold/FoldManagerClass2LayerFolder.java b/editor.fold/src/org/netbeans/modules/editor/fold/FoldManagerClass2LayerFolder.java deleted file mode 100644 --- a/editor.fold/src/org/netbeans/modules/editor/fold/FoldManagerClass2LayerFolder.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.modules.editor.fold; - - -import org.netbeans.spi.editor.fold.FoldManagerFactory; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * Mapping the FoldManager folder to FoldManagerFactory class. - * - * @author Martin Roskanin - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class FoldManagerClass2LayerFolder implements Class2LayerFolder { - - public FoldManagerClass2LayerFolder() { - } - - public Class getClazz() { - return FoldManagerFactory.class; - } - - public String getLayerFolderName() { - return "FoldManager"; // NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java b/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java --- a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java +++ b/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkOperation.java @@ -278,7 +278,7 @@ mimeType = this.operationMimeType; } - Collection extProviders = HyperlinkProviderManagerExt.getHyperlinkProviderExts(mimeType); + Collection extProviders = getHyperlinkProviderExts(mimeType); for (HyperlinkProviderExt provider : extProviders) { if (provider.getSupportedHyperlinkTypes().contains(type) && provider.isHyperlinkPoint(component.getDocument(), position, type)) { @@ -290,7 +290,7 @@ return null; } - Collection providers = HyperlinkProviderManager.getHyperlinkProviders(mimeType); + Collection providers = getHyperlinkProviders(mimeType); for (final HyperlinkProvider provider : providers) { if (provider.isHyperlinkPoint(component.getDocument(), position)) { @@ -431,6 +431,30 @@ return bag; } + /** + * Gets the list of HyperlinkProviders for a given mime type. + * + * @param mimeType mime type to get the HyperlinkProviders for + * + * @return The list of HyperlinkProviders available for the given mime type. + */ + public static Collection getHyperlinkProviders(String mimeType) { + MimePath mimePath = MimePath.parse(mimeType); + return MimeLookup.getLookup(mimePath).lookupAll(HyperlinkProvider.class); + } + + /** + * Gets the list of HyperlinkProviders for a given mime type. + * + * @param mimeType mime type to get the HyperlinkProviders for + * + * @return The list of HyperlinkProviders available for the given mime type. + */ + public static Collection getHyperlinkProviderExts(String mimeType) { + MimePath mimePath = MimePath.parse(mimeType); + return MimeLookup.getLookup(mimePath).lookupAll(HyperlinkProviderExt.class); + } + private static AttributeSet defaultHyperlinksHighlight = AttributesUtilities.createImmutable(StyleConstants.Foreground, Color.BLUE, StyleConstants.Underline, Color.BLUE); public static final class HighlightFactoryImpl implements HighlightsLayerFactory { diff --git a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkProviderManager.java b/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkProviderManager.java deleted file mode 100644 --- a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkProviderManager.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.lib.editor.hyperlink; - -import java.util.Collection; -import org.netbeans.api.editor.mimelookup.MimeLookup; -import org.netbeans.api.editor.mimelookup.MimePath; -import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * This class provides a list of HyperlinkProvider(s) for a given mime type. - * - * @author Jan Lahoda - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public final class HyperlinkProviderManager implements Class2LayerFolder { - - /** - * Gets the list of HyperlinkProviders for a given mime type. - * - * @param mimeType mime type to get the HyperlinkProviders for - * - * @return The list of HyperlinkProviders available for the given mime type. - */ - public static Collection getHyperlinkProviders(String mimeType) { - MimePath mimePath = MimePath.parse(mimeType); - return MimeLookup.getLookup(mimePath).lookupAll(HyperlinkProvider.class); - } - - public HyperlinkProviderManager() { - - } - - public Class getClazz() { - return HyperlinkProvider.class; - } - - public String getLayerFolderName() { - return "HyperlinkProviders"; // NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } -} diff --git a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkProviderManagerExt.java b/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkProviderManagerExt.java deleted file mode 100644 --- a/editor.lib/src/org/netbeans/lib/editor/hyperlink/HyperlinkProviderManagerExt.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.lib.editor.hyperlink; - -import java.util.Collection; -import org.netbeans.api.editor.mimelookup.MimeLookup; -import org.netbeans.api.editor.mimelookup.MimePath; -import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * This class provides a list of HyperlinkProviderExt(s) for a given mime type. - * - * @author Jan Lahoda - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public final class HyperlinkProviderManagerExt implements Class2LayerFolder { - - /** - * Gets the list of HyperlinkProviders for a given mime type. - * - * @param mimeType mime type to get the HyperlinkProviders for - * - * @return The list of HyperlinkProviders available for the given mime type. - */ - public static Collection getHyperlinkProviderExts(String mimeType) { - MimePath mimePath = MimePath.parse(mimeType); - return MimeLookup.getLookup(mimePath).lookupAll(HyperlinkProviderExt.class); - } - - public HyperlinkProviderManagerExt() { - - } - - public Class getClazz() { - return HyperlinkProviderExt.class; - } - - public String getLayerFolderName() { - return "HyperlinkProviders"; // NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } -} diff --git a/editor.lib2/src/org/netbeans/modules/editor/lib2/codegen/ContextProviderClass2LayerFolder.java b/editor.lib2/src/org/netbeans/modules/editor/lib2/codegen/ContextProviderClass2LayerFolder.java deleted file mode 100644 --- a/editor.lib2/src/org/netbeans/modules/editor/lib2/codegen/ContextProviderClass2LayerFolder.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.modules.editor.lib2.codegen; - - -import org.netbeans.spi.editor.codegen.CodeGeneratorContextProvider; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * - * - * @author Dusan Balek - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class ContextProviderClass2LayerFolder implements Class2LayerFolder { - - public Class getClazz() { - return CodeGeneratorContextProvider.class; - } - - public String getLayerFolderName() { - return "CodeGeneratorContextProviders"; //NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.lib2/src/org/netbeans/modules/editor/lib2/codegen/GeneratorFactoryClass2LayerFolder.java b/editor.lib2/src/org/netbeans/modules/editor/lib2/codegen/GeneratorFactoryClass2LayerFolder.java deleted file mode 100644 --- a/editor.lib2/src/org/netbeans/modules/editor/lib2/codegen/GeneratorFactoryClass2LayerFolder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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 2007 Sun Microsystems, Inc. - */ - -package org.netbeans.modules.editor.lib2.codegen; - -import org.netbeans.spi.editor.codegen.CodeGenerator.Factory; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * - * @author Jan Lahoda - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class GeneratorFactoryClass2LayerFolder implements Class2LayerFolder { - - public Class getClazz() { - return Factory.class; - } - - public String getLayerFolderName() { - return "CodeGenerators"; //NOI18N - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/ClassInfoStorage.java b/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/ClassInfoStorage.java deleted file mode 100644 --- a/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/ClassInfoStorage.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.modules.editor.mimelookup.impl; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.lang.ref.Reference; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.logging.Logger; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.Utilities; -import org.openide.util.WeakListeners; - -/** - * - * @author vita - */ -public final class ClassInfoStorage { - - public static final String PROP_CLASS_INFO_CHANGED = "Class2Paths.PROP_CLASS_MAPPING_CHANGED"; //NOI18N - public static final String PROP_CLASS_INFO_ADDED = "Class2Paths.PROP_CLASS_MAPPING_ADDED"; //NOI18N - public static final String PROP_CLASS_INFO_REMOVED = "Class2Paths.PROP_CLASS_MAPPING_REMOVED"; //NOI18N - - private static Logger LOG = Logger.getLogger(ClassInfoStorage.class.getName()); - - private static ClassInfoStorage instance = null; - - public static synchronized ClassInfoStorage getInstance() { - if (instance == null) { - instance = new ClassInfoStorage(); - } - return instance; - } - - private Lookup.Result mappers = null; - private L mappersListener = null; - - private final String LOCK = new String("Class2Paths.LOCK"); //NOI18N - private Map mapping = new HashMap(); - - private PropertyChangeSupport pcs = new PropertyChangeSupport(this); - - /** Creates a new instance of Class2Paths */ - private ClassInfoStorage() { - mappers = Lookup.getDefault().lookupResult(Class2LayerFolder.class); - - mappersListener = new L(); - mappers.addLookupListener(WeakListeners.create(LookupListener.class, mappersListener, mappers)); - - rebuild(); - } - - public Info getInfo(String className) { - synchronized (LOCK) { - if (mapping.containsKey(className)) { - return mapping.get(className); - } else { - return new Info(this, className, null, null); - } - } - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - pcs.addPropertyChangeListener(l); - } - - public void removePropertyChangeListener(PropertyChangeListener l) { - pcs.removePropertyChangeListener(l); - } - - private List rebuild() { - synchronized (LOCK) { - // Gather the new mapping information - Map newMapping = new HashMap(); - for (Class2LayerFolder mapper : mappers.allInstances()) { - String className = mapper.getClazz().getName(); - String path = mapper.getLayerFolderName(); - InstanceProvider ip = mapper.getInstanceProvider(); - - if (path != null) { - path = path.trim(); - } - - if ((path == null || path.length() == 0) && ip == null) { - // Hmm, why anybody registered mapper, which doesn't provide any info. - continue; - } - - if (!newMapping.containsKey(className)) { - newMapping.put(className, new Info(this, className, path, ip)); - } else { - LOG.warning("The mapping for class '" + className + "' to folder '" + //NOI18N - path + "' and InstanceProvider '" + ip + "' has already been " + //NOI18N - "defined by another mapper. Ignoring mapper " + mapper); //NOI18N - } - } - - // Compute differences - Set removed = new HashSet(mapping.keySet()); - removed.removeAll(newMapping.keySet()); - - Set added = new HashSet(newMapping.keySet()); - added.removeAll(mapping.keySet()); - - Set changed = new HashSet(); - for (String className : newMapping.keySet()) { - if (mapping.containsKey(className) && - !Utilities.compareObjects(newMapping.get(className), mapping.get(className))) - { - changed.add(className); - } - } - - // Update the mapping - mapping.clear(); - mapping.putAll(newMapping); - - // Generate events - List events = new ArrayList(3); - if (!removed.isEmpty()) { - events.add(new PropertyChangeEvent(this, PROP_CLASS_INFO_REMOVED, null, removed)); - } - if (!added.isEmpty()) { - events.add(new PropertyChangeEvent(this, PROP_CLASS_INFO_ADDED, null, added)); - } - if (!changed.isEmpty()) { - events.add(new PropertyChangeEvent(this, PROP_CLASS_INFO_CHANGED, null, changed)); - } - - return events; - } - } - - private class L implements LookupListener { - - public void resultChanged(LookupEvent ev) { - // Update mapping information & fire change events if neccessary - for (PropertyChangeEvent event : rebuild()) { - pcs.firePropertyChange(event); - } - } - - } // End of L class - - public static final class Info { - private ClassInfoStorage storage; - private String className; - private String extraPath; - private String instanceProviderClass; - private Reference> ref; // TODO: This should really be a timed-weak-ref - - private Info(ClassInfoStorage storage, String className, String extraPath, InstanceProvider instanceProvider) { - this.storage = storage; - this.className = className; - this.extraPath = extraPath == null ? "" : extraPath; //NOI18N - if (instanceProvider != null) { - this.instanceProviderClass = instanceProvider.getClass().getName(); - this.ref = new WeakReference>(instanceProvider); - } - } - - public String getClassName() { - return className; - } - - public String getExtraPath() { - return extraPath; - } - - public String getInstanceProviderClass() { - return instanceProviderClass; - } - - public InstanceProvider getInstanceProvider() { - synchronized (storage.LOCK) { - // There was no instance provider specified - if (ref == null) { - return null; - } - - InstanceProvider ip = (InstanceProvider) ref.get(); - if (ip == null) { - // Instance provider has been GCed, recreate it - for (Class2LayerFolder mapper : storage.mappers.allInstances()) { - String className = mapper.getClazz().getName(); - - if (this.className.equals(className)) { - ip = mapper.getInstanceProvider(); - break; - } - } - - if (ip != null) { - ref = new WeakReference>(ip); - } - } - - return ip; - } - } - - public @Override boolean equals(Object obj) { - if (obj instanceof Info) { - Info info = (Info) obj; - return this.className.equals(info.className) && - Utilities.compareObjects(this.extraPath, info.extraPath) && - Utilities.compareObjects(this.instanceProviderClass, info.instanceProviderClass); - } else { - return false; - } - } - - public @Override int hashCode() { - int hashCode = className.hashCode(); - - if (extraPath != null) { - hashCode += 7 * extraPath.hashCode(); - } - if (instanceProviderClass != null) { - hashCode += 13 * instanceProviderClass.hashCode(); - } - - return hashCode; - } - - public @Override String toString() { - return "ClassInfoStorage.Info[className=" + className + ",extraPath=" + extraPath + ",instanceProviderClass=" + instanceProviderClass + "]"; // NOI18N - } - - } // End of Info class -} diff --git a/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java b/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java --- a/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java +++ b/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java @@ -44,22 +44,19 @@ package org.netbeans.modules.editor.mimelookup.impl; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; +import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.editor.mimelookup.MimePath; import org.netbeans.spi.editor.mimelookup.InstanceProvider; +import org.netbeans.spi.editor.mimelookup.MimeLocation; +import org.openide.util.Exceptions; import org.openide.util.Lookup; -import org.openide.util.NbCollections; -import org.openide.util.WeakListeners; import org.openide.util.lookup.ProxyLookup; /** @@ -76,22 +73,13 @@ private final String LOCK = new String("SwitchLookup.LOCK"); //NOI18N - private MappingListener listener; - - private Map classLookups = new HashMap(); + private Map,UpdatableProxyLookup> classLookups = new HashMap, UpdatableProxyLookup>(); private Map,Lookup> pathsLookups = new HashMap,Lookup>(); - private Map classInfos = new HashMap(); - private Map,Set> pathsToClasses = new HashMap,Set>(); - public SwitchLookup(MimePath mimePath) { super(); this.mimePath = mimePath; - - this.listener = new MappingListener(); - ClassInfoStorage.getInstance().addPropertyChangeListener( - WeakListeners.propertyChange(listener, ClassInfoStorage.getInstance())); } public Lookup.Result lookup(Lookup.Template template) { @@ -102,42 +90,56 @@ return findLookup(clazz).lookup(clazz); } - private Lookup findLookup(Class clazz) { + private Lookup findLookup(Class clazz) { synchronized (LOCK) { - String className = clazz.getName(); - UpdatableProxyLookup lookup = classLookups.get(className); + UpdatableProxyLookup lookup = classLookups.get(clazz); if (lookup == null) { - // Get the the class info and remember it - ClassInfoStorage.Info classInfo = ClassInfoStorage.getInstance().getInfo(className); - classInfos.put(className, classInfo); - // Create lookup - Lookup innerLookup = createLookup(classInfo); + Lookup innerLookup = createLookup(clazz); lookup = new UpdatableProxyLookup(innerLookup); - classLookups.put(className, lookup); + classLookups.put(clazz, lookup); } return lookup; } } - private Lookup createLookup(ClassInfoStorage.Info classInfo) { - List paths = computePaths(mimePath, ROOT_FOLDER, classInfo.getExtraPath()); + private Lookup createLookup(Class forClass) { + MimeLocation loc = forClass.getAnnotation(MimeLocation.class); + + if (loc == null) { + loc = new MimeLocation() { + @Override + public String subfolderName() { + return null; + } + @Override + public Class instanceProviderClass() { + return null; + } + + @Override + public Class annotationType() { + return MimeLocation.class; + } + }; + } + List paths = computePaths(mimePath, ROOT_FOLDER, loc.subfolderName()); Lookup lookup; - if (classInfo.getInstanceProviderClass() != null) { - // Get a lookup for the new instance provider - lookup = getLookupForProvider(paths, classInfo.getInstanceProvider()); + if (loc.instanceProviderClass() != null && loc.instanceProviderClass() != InstanceProvider.class) { + try { + // Get a lookup for the new instance provider + lookup = getLookupForProvider(paths, loc.instanceProviderClass().newInstance()); + } catch (InstantiationException ex) { + Exceptions.printStackTrace(ex); + lookup = Lookup.EMPTY; + } catch (IllegalAccessException ex) { + Exceptions.printStackTrace(ex); + lookup = Lookup.EMPTY; + } } else { - // Add the className to the list of users of the new paths - Set pathsUsers = pathsToClasses.get(paths); - if (pathsUsers == null) { - pathsUsers = new HashSet(); - pathsToClasses.put(paths, pathsUsers); - } - pathsUsers.add(classInfo.getClassName()); - // Get a lookup for the new paths lookup = getLookupForPaths(paths); } @@ -159,44 +161,6 @@ return new InstanceProviderLookup(paths.toArray(new String[paths.size()]), instanceProvider); } - private void rebuildLookup(String className) { - synchronized (LOCK) { - UpdatableProxyLookup classLookup = classLookups.get(className); - if (classLookup == null) { - // no lookup for the class, nothing to do - return; - } - - ClassInfoStorage.Info currentClassInfo = classInfos.get(className); - ClassInfoStorage.Info classInfo = ClassInfoStorage.getInstance().getInfo(className); - - if (currentClassInfo.equals(classInfo)) { - // bogus change event, the class information hasn't changed, nothing to do - return; - } - - if (currentClassInfo.getInstanceProviderClass() == null) { - List currentPaths = computePaths(mimePath, ROOT_FOLDER, currentClassInfo.getExtraPath()); - - // Remove the className from the list of users of the current paths - Set currentPathsUsers = pathsToClasses.get(currentPaths); - currentPathsUsers.remove(className); - - if (currentPathsUsers.isEmpty()) { - pathsToClasses.remove(currentPaths); - pathsLookups.remove(currentPaths); - } - } - - // Remember the new class info - classInfos.put(className, classInfo); - - // Update the classLookup - Lookup innerLookup = createLookup(classInfo); - classLookup.setLookupsEx(innerLookup); - } - } - private static List computePaths(MimePath mimePath, String prefixPath, String suffixPath) { try { Method m = MimePath.class.getDeclaredMethod("getInheritedPaths", String.class, String.class); //NOI18N @@ -246,12 +210,4 @@ } } // End of UpdatableProxyLookup class - private final class MappingListener implements PropertyChangeListener { - public void propertyChange(PropertyChangeEvent evt) { - for (String className : NbCollections.checkedSetByFilter((Set) evt.getNewValue(), String.class, true)) { - rebuildLookup(className); - } - } - } // End of MappingListsner class - } diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/ClassInfoStorageTest.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/ClassInfoStorageTest.java deleted file mode 100644 --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/ClassInfoStorageTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.modules.editor.mimelookup.impl; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import org.netbeans.junit.NbTestCase; -import org.netbeans.junit.RandomlyFails; - -/** - * - * @author vita - */ -@RandomlyFails // uses TestUtilities.sleepForWhile() -public class ClassInfoStorageTest extends NbTestCase { - - public ClassInfoStorageTest(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - clearWorkDir(); - // Set up the default lookup, repository, etc. - EditorTestLookup.setLookup(new String[0], getWorkDir(), new Object[] {}, - getClass().getClassLoader(), - null - ); - } - - public void testNoMapper() { - ClassInfoStorage.Info info = ClassInfoStorage.getInstance().getInfo(DummySetting.class.getName()); - assertTrue("There should be no mapper registered", isEmpty(info)); - } - - public void testDummyMapper() throws Exception { - TestUtilities.createFile(getWorkDir(), "Services/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolderWithInstanceProvider.instance"); - TestUtilities.sleepForWhile(); - - ClassInfoStorage.Info info = ClassInfoStorage.getInstance().getInfo(DummySetting.class.getName()); - assertNotNull("The mapper not found", info); - assertEquals("Wrang mapper class", DummySetting.class.getName(), info.getClassName()); - assertEquals("Wrong wrapper extra path", "DummyFolder", info.getExtraPath()); - assertEquals("Wrong instance provider class", DummyInstanceProvider.class.getName(), info.getInstanceProviderClass()); - assertNotNull("Instance provider should not be null", info.getInstanceProvider()); - assertTrue("Wrong instance provider", info.getInstanceProvider() instanceof DummyInstanceProvider); - } - - public void testAddingMapper() throws Exception { - ClassInfoStorage.Info info = ClassInfoStorage.getInstance().getInfo(DummySetting.class.getName()); - assertTrue("There should be no mapper registered: " + info, isEmpty(info)); - - L listener = new L(); - ClassInfoStorage.getInstance().addPropertyChangeListener(listener); - try { - // Add the mapper - TestUtilities.createFile(getWorkDir(), "Services/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolderWithInstanceProvider.instance"); - TestUtilities.sleepForWhile(); - - assertEquals("Wrong number of change events", 1, listener.changeEventsCnt); - assertNotNull("Invalid change event", listener.events.get(0)); - assertEquals("Wrong change event", - ClassInfoStorage.PROP_CLASS_INFO_ADDED, listener.events.get(0).getPropertyName()); - - Set value = (Set) listener.events.get(0).getNewValue(); - assertEquals("Invalid number of class in the change event", 1, value.size()); - assertTrue("Wrong change event value", value.contains(DummySetting.class.getName())); - } finally { - ClassInfoStorage.getInstance().removePropertyChangeListener(listener); - } - - info = ClassInfoStorage.getInstance().getInfo(DummySetting.class.getName()); - checkInfo(info, "DummyFolder", DummySetting.class, DummyInstanceProvider.class); - } - - public void testRemovingMapper() throws Exception { - TestUtilities.createFile(getWorkDir(), "Services/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolderWithInstanceProvider.instance"); - TestUtilities.sleepForWhile(); - - ClassInfoStorage.Info info = ClassInfoStorage.getInstance().getInfo(DummySetting.class.getName()); - checkInfo(info, "DummyFolder", DummySetting.class, DummyInstanceProvider.class); - - L listener = new L(); - ClassInfoStorage.getInstance().addPropertyChangeListener(listener); - try { - // Remove the mapper - TestUtilities.deleteFile(getWorkDir(), "Services/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolderWithInstanceProvider.instance"); - TestUtilities.sleepForWhile(); - - assertEquals("Wrong number of change events", 1, listener.changeEventsCnt); - assertNotNull("Invalid change event", listener.events.get(0)); - assertEquals("Wrong change event", - ClassInfoStorage.PROP_CLASS_INFO_REMOVED, listener.events.get(0).getPropertyName()); - - Set value = (Set) listener.events.get(0).getNewValue(); - assertEquals("Invalid number of class in the change event", 1, value.size()); - assertTrue("Wrong change event value", value.contains(DummySetting.class.getName())); - } finally { - ClassInfoStorage.getInstance().removePropertyChangeListener(listener); - } - - info = ClassInfoStorage.getInstance().getInfo(DummySetting.class.getName()); - assertTrue("There should be no mapper registered: " + info, isEmpty(info)); - } - - private void checkInfo(ClassInfoStorage.Info info, String extraPath, Class infoClass, Class instanceProviderClass) { - assertNotNull("The mapper not found", info); - assertEquals("Wrang mapper class", infoClass.getName(), info.getClassName()); - assertEquals("Wrong wrapper extra path", extraPath, info.getExtraPath()); - assertEquals("Wrong instance provider class", instanceProviderClass.getName(), info.getInstanceProviderClass()); - assertNotNull("Instance provider should not be null", info.getInstanceProvider()); - assertEquals("Wrong instance provider", instanceProviderClass, info.getInstanceProvider().getClass()); - } - - private boolean isEmpty(ClassInfoStorage.Info info) { - return info.getExtraPath().length() == 0 && - info.getInstanceProviderClass() == null && - info.getInstanceProvider() == null; - } - - private static class L implements PropertyChangeListener { - - public int changeEventsCnt = 0; - public List events = new ArrayList(); - - public void propertyChange(PropertyChangeEvent evt) { - changeEventsCnt++; - events.add(evt); - } - - public void reset() { - changeEventsCnt = 0; - events.clear(); - } - } -} diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummyClass2LayerFolder.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummyClass2LayerFolder.java deleted file mode 100644 --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummyClass2LayerFolder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.modules.editor.mimelookup.impl; - -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * - * @author vita - */ -public class DummyClass2LayerFolder implements Class2LayerFolder { - - /** Creates a new instance of DummyClass2LayerFolder */ - public DummyClass2LayerFolder() { - } - - public String getLayerFolderName() { - return "DummyFolder"; - } - - public InstanceProvider getInstanceProvider() { - return null; - } - - public Class getClazz() { - return DummySetting.class; - } - -} diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummyClass2LayerFolderWithInstanceProvider.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummyClass2LayerFolderWithInstanceProvider.java deleted file mode 100644 --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummyClass2LayerFolderWithInstanceProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - -package org.netbeans.modules.editor.mimelookup.impl; - -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * - * @author vita - */ -public class DummyClass2LayerFolderWithInstanceProvider implements Class2LayerFolder { - - /** Creates a new instance of DummyClass2LayerFolder */ - public DummyClass2LayerFolderWithInstanceProvider() { - } - - public String getLayerFolderName() { - return "DummyFolder"; - } - - public InstanceProvider getInstanceProvider() { - return new DummyInstanceProvider(); - } - - public Class getClazz() { - return DummySetting.class; - } - -} diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySetting.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySetting.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySetting.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySetting.java @@ -44,6 +44,8 @@ package org.netbeans.modules.editor.mimelookup.impl; +import org.netbeans.spi.editor.mimelookup.MimeLocation; + /** * * @author vita diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySettingImpl.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySettingImpl.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySettingImpl.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySettingImpl.java @@ -46,24 +46,25 @@ import java.util.ArrayList; import java.util.List; +import org.openide.filesystems.FileObject; /** * * @author vita */ -public class DummySettingImpl implements DummySetting { +public class DummySettingImpl implements DummySetting, DummySettingWithPath { - private List files = null; + private List files = null; /** Creates a new instance of DummySettingImpl */ public DummySettingImpl() { } - public DummySettingImpl(List files) { - files = new ArrayList(files); + public DummySettingImpl(List files) { + this.files = new ArrayList(files); } - public List getFiles() { + public List getFiles() { return files; } } diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySetting.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySettingWithPath.java copy from editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySetting.java copy to editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySettingWithPath.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySetting.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/DummySettingWithPath.java @@ -44,10 +44,13 @@ package org.netbeans.modules.editor.mimelookup.impl; +import org.netbeans.spi.editor.mimelookup.MimeLocation; + /** * * @author vita */ -public interface DummySetting { +@MimeLocation(subfolderName="DummyFolder") +public interface DummySettingWithPath { } diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/FolderPathLookupTest.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/FolderPathLookupTest.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/FolderPathLookupTest.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/FolderPathLookupTest.java @@ -83,19 +83,19 @@ } public void testSimple() throws Exception { - TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolder.instance"); - + TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummySettingImpl.instance"); + // Create lookup over an existing folder Lookup lookup = new FolderPathLookup(new String [] { "Tmp/A/B/C/D" }); - Collection instances = lookup.lookupAll(Class2LayerFolder.class); - + Collection instances = lookup.lookupAll(DummySetting.class); + assertEquals("Wrong number of instances", 1, instances.size()); - assertEquals("Wrong instance", DummyClass2LayerFolder.class, instances.iterator().next().getClass()); - + assertEquals("Wrong instance", DummySettingImpl.class, instances.iterator().next().getClass()); + // Now create lookup over a non-existing folder lookup = new FolderPathLookup(new String [] { "Tmp/X/Y/Z" }); instances = lookup.lookupAll(Object.class); - + assertEquals("Wrong number of instances", 0, instances.size()); } @@ -103,36 +103,36 @@ // Create lookup over a non-existing folder Lookup lookup = new FolderPathLookup(new String [] { "Tmp/A/B/C/D" }); Collection instances = lookup.lookupAll(Class2LayerFolder.class); - + assertEquals("Wrong number of instances", 0, instances.size()); // Create the folder and the instance - TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolder.instance"); - - instances = lookup.lookupAll(Class2LayerFolder.class); + TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummySettingImpl.instance"); + + instances = lookup.lookupAll(DummySetting.class); assertEquals("Wrong number of instances", 1, instances.size()); - assertEquals("Wrong instance", DummyClass2LayerFolder.class, instances.iterator().next().getClass()); + assertEquals("Wrong instance", DummySettingImpl.class, instances.iterator().next().getClass()); } public void testRemovingFolders() throws Exception { - TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolder.instance"); - + TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummySettingImpl.instance"); + // Create lookup over an existing folder Lookup lookup = new FolderPathLookup(new String [] { "Tmp/A/B/C/D" }); - Collection instances = lookup.lookupAll(Class2LayerFolder.class); - + Collection instances = lookup.lookupAll(DummySetting.class); + assertEquals("Wrong number of instances", 1, instances.size()); - assertEquals("Wrong instance", DummyClass2LayerFolder.class, instances.iterator().next().getClass()); + assertEquals("Wrong instance", DummySettingImpl.class, instances.iterator().next().getClass()); // Delete the folders TestUtilities.deleteFile(getWorkDir(), "Tmp"); - + instances = lookup.lookupAll(Class2LayerFolder.class); assertEquals("Wrong number of instances", 0, instances.size()); } public void testChangeEvents() throws Exception { - Lookup.Result lr = new FolderPathLookup(new String [] { "Tmp/A/B/C/D" }).lookupResult(Class2LayerFolder.class); + Lookup.Result lr = new FolderPathLookup(new String [] { "Tmp/A/B/C/D" }).lookupResult(DummySetting.class); L listener = new L(); lr.addLookupListener(listener); @@ -140,13 +140,13 @@ assertEquals("Wrong number of instances", 0, instances.size()); // Create the folder and the instance - TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolder.instance"); + TestUtilities.createFile(getWorkDir(), "Tmp/A/B/C/D/org-netbeans-modules-editor-mimelookup-impl-DummySettingImpl.instance"); assertEquals("Wrong number of events", 1, listener.resultChangedCnt); - + instances = lr.allInstances(); assertEquals("Wrong number of instances", 1, instances.size()); - assertEquals("Wrong instance", DummyClass2LayerFolder.class, instances.iterator().next().getClass()); + assertEquals("Wrong instance", DummySettingImpl.class, instances.iterator().next().getClass()); // Reset the listener listener.resultChangedCnt = 0; @@ -155,7 +155,7 @@ TestUtilities.deleteFile(getWorkDir(), "Tmp"); assertEquals("Wrong number of events", 1, listener.resultChangedCnt); - + instances = lr.allInstances(); assertEquals("Wrong number of instances", 0, instances.size()); } diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/PopupActions.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/PopupActions.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/PopupActions.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/PopupActions.java @@ -52,6 +52,7 @@ import javax.swing.JPanel; import javax.swing.JSeparator; import org.netbeans.spi.editor.mimelookup.InstanceProvider; +import org.netbeans.spi.editor.mimelookup.MimeLocation; import org.openide.cookies.InstanceCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; @@ -62,6 +63,7 @@ * * @author Martin Roskanin */ +@MimeLocation(subfolderName="Popup", instanceProviderClass=PopupActions.class) public class PopupActions implements InstanceProvider{ static final Object LOCK = new JPanel().getTreeLock(); diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/PopupInitializer.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/PopupInitializer.java deleted file mode 100644 --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/PopupInitializer.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - - -package org.netbeans.modules.editor.mimelookup.impl; - -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; -import org.openide.actions.DeleteAction; -import org.openide.util.actions.CallbackSystemAction; -/** - * - * @author Martin Roskanin - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class PopupInitializer implements Class2LayerFolder{ - - /** Creates a new instance of TestClass2LayerFolderInitializer */ - public PopupInitializer() { - } - - public Class getClazz(){ - return PopupActions.class; - } - - /** Gets layer folder name, where the class should be found. - * Folder should be located in the appropriate mime type path, i.e. - * Editors/text/x-java/@lt;desired-layer-folder-name@gt; - * - * @return layer folder name - */ - public String getLayerFolderName(){ - return "Popup"; //NOI18N - } - - public InstanceProvider getInstanceProvider() { - return new PopupActions(); - } - -} diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookupTest.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookupTest.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookupTest.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookupTest.java @@ -238,53 +238,15 @@ public void testReadFromSpecialFolders() throws Exception { TestUtilities.createFile(getWorkDir(), "Editors/text/x-java/DummyFolder/org-netbeans-modules-editor-mimelookup-impl-DummySettingImpl.instance"); - TestUtilities.createFile(getWorkDir(), "Services/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolder.instance"); TestUtilities.sleepForWhile(); Lookup lookup = new SwitchLookup(MimePath.parse("text/x-jsp/text/x-java")); - Collection instances = lookup.lookupAll(DummySetting.class); + Collection instances = lookup.lookupAll(DummySettingWithPath.class); assertEquals("Wrong number of instances", 1, instances.size()); assertEquals("Wrong instance", DummySettingImpl.class, instances.iterator().next().getClass()); } - // test that adding/removing a Class2LayerFolder provider updates the lookup for its class - - public void testChangeInMappers() throws Exception { - TestUtilities.createFile(getWorkDir(), "Editors/text/x-java/DummyFolder/org-netbeans-modules-editor-mimelookup-impl-DummySettingImpl.instance"); - TestUtilities.sleepForWhile(); - - Lookup lookup = new SwitchLookup(MimePath.parse("text/x-jsp/text/x-java")); - Lookup.Result result = lookup.lookupResult(DummySetting.class); - L listener = new L(); - - result.addLookupListener(listener); - Collection instances = result.allInstances(); - - assertEquals("Wrong number of change events", 0, listener.resultChangedCnt); - assertEquals("Wrong number of instances", 0, instances.size()); - - // Add the mapper - TestUtilities.createFile(getWorkDir(), "Services/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolder.instance"); - TestUtilities.sleepForWhile(); - - instances = result.allInstances(); - assertEquals("Wrong number of change events", 1, listener.resultChangedCnt); - assertEquals("Wrong number of instances", 1, instances.size()); - assertEquals("Wrong instance", DummySettingImpl.class, instances.iterator().next().getClass()); - - // Reset the listener - listener.resultChangedCnt = 0; - - // Remove the mapper - TestUtilities.deleteFile(getWorkDir(), "Services/org-netbeans-modules-editor-mimelookup-impl-DummyClass2LayerFolder.instance"); - TestUtilities.sleepForWhile(); - - assertEquals("Wrong number of change events", 1, listener.resultChangedCnt); - instances = result.allInstances(); - assertEquals("Wrong number of instances", 0, instances.size()); - } - private static final class L implements LookupListener { public int resultChangedCnt = 0; public void resultChanged(LookupEvent ev) { diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestClass2LayerFolderInitializer.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestClass2LayerFolderInitializer.java deleted file mode 100644 --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestClass2LayerFolderInitializer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - - -package org.netbeans.modules.editor.mimelookup.impl; - -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -/** - * - * @author Martin Roskanin - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class TestClass2LayerFolderInitializer implements Class2LayerFolder{ - - /** Creates a new instance of TestClass2LayerFolderInitializer */ - public TestClass2LayerFolderInitializer() { - } - - public Class getClazz(){ - return TestLookupObject.class; - } - - /** Gets layer folder name, where the class should be found. - * Folder should be located in the appropriate mime type path, i.e. - * Editors/text/x-java/@lt;desired-layer-folder-name@gt; - * - * @return layer folder name - */ - public String getLayerFolderName(){ - return "testLookup"; - } - - public org.netbeans.spi.editor.mimelookup.InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestClass2LayerFolderInitializerTwo.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestClass2LayerFolderInitializerTwo.java deleted file mode 100644 --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestClass2LayerFolderInitializerTwo.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ - - -package org.netbeans.modules.editor.mimelookup.impl; - -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -/** - * - * @author Martin Roskanin - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class TestClass2LayerFolderInitializerTwo implements Class2LayerFolder{ - - /** Creates a new instance of TestClass2LayerFolderInitializer */ - public TestClass2LayerFolderInitializerTwo() { - } - - public Class getClazz(){ - return TestLookupObjectTwo.class; - } - - /** Gets layer folder name, where the class should be found. - * Folder should be located in the appropriate mime type path, i.e. - * Editors/text/x-java/@lt;desired-layer-folder-name@gt; - * - * @return layer folder name - */ - public String getLayerFolderName(){ - return "testLookupTwo"; - } - - public org.netbeans.spi.editor.mimelookup.InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObject.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObject.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObject.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObject.java @@ -45,10 +45,13 @@ package org.netbeans.modules.editor.mimelookup.impl; +import org.netbeans.spi.editor.mimelookup.MimeLocation; + /** * * @author Martin Roskanin */ +@MimeLocation(subfolderName="testLookup") public class TestLookupObject { /** Creates a new instance of TestLookupObject */ diff --git a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObjectTwo.java b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObjectTwo.java --- a/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObjectTwo.java +++ b/editor.mimelookup.impl/test/unit/src/org/netbeans/modules/editor/mimelookup/impl/TestLookupObjectTwo.java @@ -10,10 +10,13 @@ package org.netbeans.modules.editor.mimelookup.impl; +import org.netbeans.spi.editor.mimelookup.MimeLocation; + /** * * @author mato */ +@MimeLocation(subfolderName="testLookupTwo") public class TestLookupObjectTwo { /** Creates a new instance of TestLookupObject */ diff --git a/editor.mimelookup/apichanges.xml b/editor.mimelookup/apichanges.xml --- a/editor.mimelookup/apichanges.xml +++ b/editor.mimelookup/apichanges.xml @@ -108,6 +108,18 @@ + + Class2LayerFolder Deprecated and not used + + + + + + Class2LayerFolder has been deprecated and is ignored. + + + + @MimeLocation, @MimeRegistration and @MimeRegistrations added diff --git a/editor.mimelookup/manifest.mf b/editor.mimelookup/manifest.mf --- a/editor.mimelookup/manifest.mf +++ b/editor.mimelookup/manifest.mf @@ -1,7 +1,7 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.editor.mimelookup/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/mimelookup/Bundle.properties -OpenIDE-Module-Specification-Version: 1.19 +OpenIDE-Module-Specification-Version: 1.20 OpenIDE-Module-Recommends: org.netbeans.spi.editor.mimelookup.MimeDataProvider AutoUpdate-Essential-Module: true diff --git a/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java b/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java --- a/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java +++ b/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java @@ -47,10 +47,16 @@ import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; import javax.lang.model.element.Name; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.ExecutableType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; +import javax.lang.model.util.Types; +import javax.tools.Diagnostic.Kind; import org.openide.filesystems.annotations.LayerGeneratingProcessor; import org.openide.filesystems.annotations.LayerGenerationException; import org.openide.util.lookup.ServiceProvider; @@ -59,7 +65,7 @@ * * @author Jan Lahoda */ -@SupportedAnnotationTypes({"org.netbeans.api.editor.mimelookup.MimeRegistration", "org.netbeans.api.editor.mimelookup.MimeRegistrations"}) +@SupportedAnnotationTypes({"org.netbeans.api.editor.mimelookup.MimeRegistration", "org.netbeans.api.editor.mimelookup.MimeRegistrations", "org.netbeans.spi.editor.mimelookup.MimeLocation"}) @SupportedSourceVersion(SourceVersion.RELEASE_6) @ServiceProvider(service=Processor.class) public class CreateRegistrationProcessor extends LayerGeneratingProcessor { @@ -96,6 +102,18 @@ } } + TypeElement mimeLocation = processingEnv.getElementUtils().getTypeElement("org.netbeans.spi.editor.mimelookup.MimeLocation"); + + for (TypeElement el : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(mimeLocation))) { + for (AnnotationMirror am : el.getAnnotationMirrors()) { + if (!mimeLocation.equals(am.getAnnotationType().asElement())) { + continue; + } + + checkMimeLocation(el, am); + } + } + return true; } @@ -212,6 +230,63 @@ return result; } + private void checkMimeLocation(TypeElement clazz, AnnotationMirror am) { + for (Entry e : am.getElementValues().entrySet()) { + if (!e.getKey().getSimpleName().contentEquals("instanceProviderClass")) continue; + + TypeMirror ipc = (TypeMirror) e.getValue().getValue(); + + if (ipc == null || ipc.getKind() != TypeKind.DECLARED) continue; //the compiler should have given the error + + TypeElement instanceProvider = processingEnv.getElementUtils().getTypeElement("org.netbeans.spi.editor.mimelookup.InstanceProvider"); + + if (instanceProvider == null) { + return ; + } + + ExecutableElement createInstance = null; + + for (ExecutableElement ee : ElementFilter.methodsIn(instanceProvider.getEnclosedElements())) { + if (ee.getSimpleName().contentEquals("createInstance")) { //TODO: check parameters + createInstance = ee; + break; + } + } + + if (createInstance == null) { + throw new IllegalStateException("No instanceCreate in InstanceProvider!"); + } + + DeclaredType dipc = (DeclaredType) ipc; + + Types tu = processingEnv.getTypeUtils(); + ExecutableType member = (ExecutableType) tu.asMemberOf(dipc, createInstance); + TypeMirror result = member.getReturnType(); + TypeMirror jlObject = processingEnv.getElementUtils().getTypeElement("java.lang.Object").asType(); + + if (!tu.isSameType(tu.erasure(result), jlObject)) { + if (!tu.isSubtype(tu.erasure(result), tu.erasure(clazz.asType()))) { + processingEnv.getMessager().printMessage(Kind.ERROR, "The InstanceProvider does not create instances of type " + clazz.getQualifiedName(), clazz, am, e.getValue()); + } + } + + TypeElement tipc = (TypeElement) dipc.asElement(); + + if (!tipc.getModifiers().contains(Modifier.PUBLIC)) { + processingEnv.getMessager().printMessage(Kind.ERROR, "The InstanceProvider implementation is not public.", clazz, am, e.getValue()); + } + + for (ExecutableElement c : ElementFilter.constructorsIn(tipc.getEnclosedElements())) { + if (c.getParameters().isEmpty() && c.getModifiers().contains(Modifier.PUBLIC)) { + //OK + return; + } + } + + processingEnv.getMessager().printMessage(Kind.ERROR, "The InstanceProvider implementation does not provide a public no-arg constructor.", clazz, am, e.getValue()); + } + } + private static final class TypeCompletion implements Completion { private final String type; diff --git a/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/Class2LayerFolder.java b/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/Class2LayerFolder.java --- a/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/Class2LayerFolder.java +++ b/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/Class2LayerFolder.java @@ -79,7 +79,9 @@ * @param T type of instance which will be created * * @author Miloslav Metelka, Martin Roskanin, Vita Stejskal + * @deprecated Use {@link MimeLocation} instead */ +@Deprecated public interface Class2LayerFolder { /** diff --git a/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/MimeLocation.java b/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/MimeLocation.java --- a/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/MimeLocation.java +++ b/editor.mimelookup/src/org/netbeans/spi/editor/mimelookup/MimeLocation.java @@ -66,4 +66,7 @@ */ public String subfolderName(); + @SuppressWarnings("rawtypes") + public Class instanceProviderClass() default InstanceProvider.class; + } diff --git a/editor.structure/src/org/netbeans/modules/editor/structure/DocumentModelProviderClass2Layer.java b/editor.structure/src/org/netbeans/modules/editor/structure/DocumentModelProviderClass2Layer.java deleted file mode 100644 --- a/editor.structure/src/org/netbeans/modules/editor/structure/DocumentModelProviderClass2Layer.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.modules.editor.structure; - -import org.netbeans.modules.editor.structure.spi.DocumentModelProvider; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * Mapping the DocumentModel folder to DocumentModelProvider class. - * - * @author Marek Fukala - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class DocumentModelProviderClass2Layer implements Class2LayerFolder { - - public DocumentModelProviderClass2Layer() { - } - - public Class getClazz() { - return DocumentModelProvider.class; - } - - public String getLayerFolderName() { - return DocumentModelProviderFactory.FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/editor/src/org/netbeans/modules/editor/impl/EditorActionsProvider.java b/editor/src/org/netbeans/modules/editor/impl/EditorActionsProvider.java --- a/editor/src/org/netbeans/modules/editor/impl/EditorActionsProvider.java +++ b/editor/src/org/netbeans/modules/editor/impl/EditorActionsProvider.java @@ -59,9 +59,8 @@ * @author Vita Stejskal * @since 1.39 */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -@MimeLocation(subfolderName=EditorActionsProvider.EDITOR_ACTIONS_FOLDER_NAME) -public final class EditorActionsProvider extends ActionsList implements Class2LayerFolder, InstanceProvider { +@MimeLocation(subfolderName=EditorActionsProvider.EDITOR_ACTIONS_FOLDER_NAME, instanceProviderClass=EditorActionsProvider.class) +public final class EditorActionsProvider extends ActionsList implements InstanceProvider { static final String EDITOR_ACTIONS_FOLDER_NAME = "Actions"; //NOI18N @@ -85,18 +84,6 @@ super(keys, false, true); // prohibit separators and action-names } - public Class getClazz(){ - return EditorActionsProvider.class; - } - - public String getLayerFolderName(){ - return EDITOR_ACTIONS_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return new EditorActionsProvider(); - } - public EditorActionsProvider createInstance(List fileObjectList) { return new EditorActionsProvider(fileObjectList); } diff --git a/editor/src/org/netbeans/modules/editor/impl/GlyphGutterActionsProvider.java b/editor/src/org/netbeans/modules/editor/impl/GlyphGutterActionsProvider.java --- a/editor/src/org/netbeans/modules/editor/impl/GlyphGutterActionsProvider.java +++ b/editor/src/org/netbeans/modules/editor/impl/GlyphGutterActionsProvider.java @@ -57,9 +57,8 @@ * * @author Vita Stejskal */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -@MimeLocation(subfolderName=GlyphGutterActionsProvider.GLYPH_GUTTER_ACTIONS_FOLDER_NAME) -public final class GlyphGutterActionsProvider extends ActionsList implements Class2LayerFolder, InstanceProvider { +@MimeLocation(subfolderName=GlyphGutterActionsProvider.GLYPH_GUTTER_ACTIONS_FOLDER_NAME, instanceProviderClass=GlyphGutterActionsProvider.class) +public final class GlyphGutterActionsProvider extends ActionsList implements InstanceProvider { public static final String GLYPH_GUTTER_ACTIONS_FOLDER_NAME = "GlyphGutterActions"; //NOI18N @@ -77,18 +76,6 @@ super(keys, false, false); } - public Class getClazz() { - return GlyphGutterActionsProvider.class; - } - - public String getLayerFolderName(){ - return GLYPH_GUTTER_ACTIONS_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return new GlyphGutterActionsProvider(); - } - public GlyphGutterActionsProvider createInstance(List fileObjectList) { return new GlyphGutterActionsProvider(fileObjectList); } diff --git a/editor/src/org/netbeans/modules/editor/impl/PopupMenuActionsProvider.java b/editor/src/org/netbeans/modules/editor/impl/PopupMenuActionsProvider.java --- a/editor/src/org/netbeans/modules/editor/impl/PopupMenuActionsProvider.java +++ b/editor/src/org/netbeans/modules/editor/impl/PopupMenuActionsProvider.java @@ -57,9 +57,8 @@ * * @author Vita Stejskal */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -@MimeLocation(subfolderName=PopupMenuActionsProvider.POPUP_MENU_ACTIONS_FOLDER_NAME) -public final class PopupMenuActionsProvider extends ActionsList implements Class2LayerFolder, InstanceProvider { +@MimeLocation(subfolderName=PopupMenuActionsProvider.POPUP_MENU_ACTIONS_FOLDER_NAME, instanceProviderClass=PopupMenuActionsProvider.class) +public final class PopupMenuActionsProvider extends ActionsList implements InstanceProvider { static final String POPUP_MENU_ACTIONS_FOLDER_NAME = "Popup"; //NOI18N @@ -77,18 +76,6 @@ super(keys, false, false); } - public Class getClazz(){ - return PopupMenuActionsProvider.class; - } - - public String getLayerFolderName(){ - return POPUP_MENU_ACTIONS_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return new PopupMenuActionsProvider(); - } - public PopupMenuActionsProvider createInstance(List fileObjectList) { return new PopupMenuActionsProvider(fileObjectList); } diff --git a/editor/src/org/netbeans/modules/editor/impl/SideBarFactoriesProvider.java b/editor/src/org/netbeans/modules/editor/impl/SideBarFactoriesProvider.java --- a/editor/src/org/netbeans/modules/editor/impl/SideBarFactoriesProvider.java +++ b/editor/src/org/netbeans/modules/editor/impl/SideBarFactoriesProvider.java @@ -54,7 +54,6 @@ import java.util.logging.Logger; import org.netbeans.editor.SideBarFactory; import org.netbeans.modules.editor.impl.CustomizableSideBar.SideBarPosition; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; import org.netbeans.spi.editor.mimelookup.InstanceProvider; import org.netbeans.spi.editor.mimelookup.MimeLocation; import org.openide.cookies.InstanceCookie; @@ -65,9 +64,8 @@ * * @author Martin Roskanin */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -@MimeLocation(subfolderName=SideBarFactoriesProvider.SIDEBAR_COMPONENTS_FOLDER_NAME) -public final class SideBarFactoriesProvider implements Class2LayerFolder, InstanceProvider { +@MimeLocation(subfolderName=SideBarFactoriesProvider.SIDEBAR_COMPONENTS_FOLDER_NAME, instanceProviderClass=SideBarFactoriesProvider.class) +public final class SideBarFactoriesProvider implements InstanceProvider { private static final Logger LOG = Logger.getLogger(SideBarFactoriesProvider.class.getName()); @@ -76,7 +74,6 @@ private final List instanceFiles; private Map> factories; - /** Creates a new instance of TestClass2LayerFolderInitializer */ public SideBarFactoriesProvider() { this(Collections.emptyList()); } @@ -92,24 +89,6 @@ return factories; } - public Class getClazz(){ - return SideBarFactoriesProvider.class; - } - - /** Gets layer folder name, where the class should be found. - * Folder should be located in the appropriate mime type path, i.e. - * Editors/text/x-java/@lt;desired-layer-folder-name@gt; - * - * @return layer folder name - */ - public String getLayerFolderName(){ - return SIDEBAR_COMPONENTS_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return new SideBarFactoriesProvider(); - } - public SideBarFactoriesProvider createInstance(List fileObjectList) { return new SideBarFactoriesProvider(fileObjectList); } diff --git a/editor/src/org/netbeans/modules/editor/impl/ToolbarActionsProvider.java b/editor/src/org/netbeans/modules/editor/impl/ToolbarActionsProvider.java --- a/editor/src/org/netbeans/modules/editor/impl/ToolbarActionsProvider.java +++ b/editor/src/org/netbeans/modules/editor/impl/ToolbarActionsProvider.java @@ -61,9 +61,8 @@ * * @author Vita Stejskal */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -@MimeLocation(subfolderName=ToolbarActionsProvider.TOOLBAR_ACTIONS_FOLDER_NAME) -public final class ToolbarActionsProvider extends ActionsList implements Class2LayerFolder, InstanceProvider { +@MimeLocation(subfolderName=ToolbarActionsProvider.TOOLBAR_ACTIONS_FOLDER_NAME, instanceProviderClass=ToolbarActionsProvider.class) +public final class ToolbarActionsProvider extends ActionsList implements InstanceProvider { private static final Logger LOG = Logger.getLogger(ToolbarActionsProvider.class.getName()); @@ -89,18 +88,6 @@ super(keys, true, false); } - public Class getClazz(){ - return ToolbarActionsProvider.class; - } - - public String getLayerFolderName(){ - return TOOLBAR_ACTIONS_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return new ToolbarActionsProvider(); - } - public ToolbarActionsProvider createInstance(List fileObjectList) { return new ToolbarActionsProvider(fileObjectList); } @@ -108,8 +95,8 @@ // XXX: This is here to help NbEditorToolbar to deal with legacy code // that registered toolbar actions in text/base. The artificial text/base // mime type is deprecated and should not be used anymore. - @org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) - public static final class LegacyToolbarActionsProvider extends ActionsList implements Class2LayerFolder, InstanceProvider { + @MimeLocation(subfolderName=TOOLBAR_ACTIONS_FOLDER_NAME, instanceProviderClass=LegacyToolbarActionsProvider.class) + public static final class LegacyToolbarActionsProvider extends ActionsList implements InstanceProvider { public LegacyToolbarActionsProvider() { this(null); @@ -119,18 +106,6 @@ super(keys, false, false); } - public Class getClazz(){ - return LegacyToolbarActionsProvider.class; - } - - public String getLayerFolderName(){ - return TOOLBAR_ACTIONS_FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return new LegacyToolbarActionsProvider(); - } - public LegacyToolbarActionsProvider createInstance(List fileObjectList) { ArrayList textBaseFilesList = new ArrayList(); diff --git a/lexer.nbbridge/src/org/netbeans/modules/lexer/nbbridge/MimeLookupFolderInfo.java b/lexer.nbbridge/src/org/netbeans/modules/lexer/nbbridge/MimeLookupFolderInfo.java --- a/lexer.nbbridge/src/org/netbeans/modules/lexer/nbbridge/MimeLookupFolderInfo.java +++ b/lexer.nbbridge/src/org/netbeans/modules/lexer/nbbridge/MimeLookupFolderInfo.java @@ -53,9 +53,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.lexer.Language; -import org.netbeans.api.lexer.TokenId; import org.netbeans.lib.lexer.LanguageManager; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; import org.netbeans.spi.editor.mimelookup.InstanceProvider; import org.netbeans.spi.editor.mimelookup.MimeLocation; import org.netbeans.spi.lexer.LanguageEmbedding; @@ -65,27 +63,14 @@ * * @author vita */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class MimeLookupFolderInfo implements Class2LayerFolder, InstanceProvider { +@MimeLocation(subfolderName="languagesEmbeddingMap", instanceProviderClass=MimeLookupFolderInfo.class) +public class MimeLookupFolderInfo implements InstanceProvider { private static final Logger LOG = Logger.getLogger(MimeLookupFolderInfo.class.getName()); - /** Creates a new instance of MimeLookupFolderInfo */ public MimeLookupFolderInfo() { } - public Class getClazz() { - return LanguagesEmbeddingMap.class; - } - - public String getLayerFolderName() { - return "languagesEmbeddingMap"; //NOI18N - } - - public InstanceProvider getInstanceProvider() { - return this; - } - public Object createInstance(List fileObjectList) { HashMap> map = new HashMap>(); diff --git a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java --- a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java +++ b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/RefactoringContextActionsProvider.java @@ -73,10 +73,9 @@ *

* @author Jan Pokorsky */ -@ServiceProvider(service=Class2LayerFolder.class) -@MimeLocation(subfolderName="RefactoringActions") +@MimeLocation(subfolderName="RefactoringActions", instanceProviderClass=RefactoringContextActionsProvider.class) public final class RefactoringContextActionsProvider - implements Class2LayerFolder, InstanceProvider { + implements InstanceProvider { private static final Logger LOG = Logger.getLogger(RefactoringContextActionsProvider.class.getName()); @@ -91,18 +90,6 @@ this.fileObjectList = fileObjectList; } - public Class getClazz() { - return RefactoringContextActionsProvider.class; - } - - public String getLayerFolderName() { - return "RefactoringActions"; // NOI18N - } - - public InstanceProvider getInstanceProvider() { - return this; - } - public RefactoringContextActionsProvider createInstance(List fileObjectList) { return new RefactoringContextActionsProvider(fileObjectList); } diff --git a/spellchecker/src/org/netbeans/modules/spellchecker/TokenListProviderFolder.java b/spellchecker/src/org/netbeans/modules/spellchecker/TokenListProviderFolder.java deleted file mode 100644 --- a/spellchecker/src/org/netbeans/modules/spellchecker/TokenListProviderFolder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.modules.spellchecker; - -import org.netbeans.modules.spellchecker.spi.language.TokenListProvider; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * - * @author Jan Lahoda - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class TokenListProviderFolder implements Class2LayerFolder { - - /** Creates a new instance of TokenListProviderFolder */ - public TokenListProviderFolder() { - } - - public Class getClazz() { - return TokenListProvider.class; - } - - public String getLayerFolderName() { - return "TokenListProvider"; - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/AutoTagImporterProviderClass2Layer.java b/web.core.syntax/src/org/netbeans/modules/web/core/syntax/AutoTagImporterProviderClass2Layer.java deleted file mode 100644 --- a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/AutoTagImporterProviderClass2Layer.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 1997-2010 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]" - * - * Contributor(s): - * - * The Original Software is NetBeans. The Initial Developer of the Original - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun - * Microsystems, Inc. All Rights Reserved. - * - * 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. - */ -package org.netbeans.modules.web.core.syntax; - -import org.netbeans.modules.web.core.syntax.spi.AutoTagImporterProvider; -import org.netbeans.spi.editor.mimelookup.Class2LayerFolder; -import org.netbeans.spi.editor.mimelookup.InstanceProvider; - -/** - * Mapping the AutoTagImportProvider folder to AutoTagImportProvider class. - * - * @author Marek Fukala - */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.spi.editor.mimelookup.Class2LayerFolder.class) -public class AutoTagImporterProviderClass2Layer implements Class2LayerFolder { - - public static final String FOLDER_NAME = "AutoTagImportProviders"; - - public AutoTagImporterProviderClass2Layer() { - } - - public Class getClazz() { - return AutoTagImporterProvider.class; - } - - public String getLayerFolderName() { - return FOLDER_NAME; - } - - public InstanceProvider getInstanceProvider() { - return null; - } - -} diff --git a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/spi/AutoTagImporterProvider.java b/web.core.syntax/src/org/netbeans/modules/web/core/syntax/spi/AutoTagImporterProvider.java --- a/web.core.syntax/src/org/netbeans/modules/web/core/syntax/spi/AutoTagImporterProvider.java +++ b/web.core.syntax/src/org/netbeans/modules/web/core/syntax/spi/AutoTagImporterProvider.java @@ -45,7 +45,6 @@ package org.netbeans.modules.web.core.syntax.spi; import javax.swing.text.Document; -import org.netbeans.modules.web.core.syntax.AutoTagImporterProviderClass2Layer; import org.netbeans.spi.editor.mimelookup.MimeLocation; /** @@ -66,7 +65,7 @@ * filesystem (in layer file) in the folder * Editors/${mime-types}/AutoTagImportProviders */ -@MimeLocation(subfolderName=AutoTagImporterProviderClass2Layer.FOLDER_NAME) +@MimeLocation(subfolderName="AutoTagImportProviders") public interface AutoTagImporterProvider { /** The method is called, when user select a tag in