Introducing @DataObject.Registrations DataObjectRegistrations-208670
authorskygo@netbeans.org
Mon, 27 Feb 2012 10:18:54 +0100
branchDataObjectRegistrations-208670
changeset 2206636e2895db0772
parent 220534 81cafa2674cb
child 220671 e1113a819b22
Introducing @DataObject.Registrations
openide.loaders/apichanges.xml
openide.loaders/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessor.java
openide.loaders/src/org/openide/loaders/DataObject.java
openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessorTest.java
openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPDataObject.java
openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPDataObjectMultiple.java
openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPMIMEType.java
     1.1 --- a/openide.loaders/apichanges.xml	Sat Feb 25 17:26:54 2012 +0100
     1.2 +++ b/openide.loaders/apichanges.xml	Mon Feb 27 10:18:54 2012 +0100
     1.3 @@ -111,7 +111,7 @@
     1.4    <changes>
     1.5        <change id="DataObjec.Registration">
     1.6            <api name="loaders"/>
     1.7 -          <summary>Introduced <code>DataObject.Registration</code></summary>
     1.8 +          <summary>Introduced <code>DataObject.Registration</code> and <code>DataObject.Registrations</code></summary>
     1.9            <version major="7" minor="36"/>
    1.10            <date day="23" month="1" year="2012"/>
    1.11            <author login="skygo"/>
    1.12 @@ -123,6 +123,7 @@
    1.13            </description>
    1.14            <class package="org.openide.loaders" name="DataObject"/>
    1.15            <issue number="207219"/>
    1.16 +          <issue number="208670"/>
    1.17        </change>
    1.18        <change id="ToolbarPool.isFinished">
    1.19            <api name="awt"/>
     2.1 --- a/openide.loaders/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessor.java	Sat Feb 25 17:26:54 2012 +0100
     2.2 +++ b/openide.loaders/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessor.java	Mon Feb 27 10:18:54 2012 +0100
     2.3 @@ -68,116 +68,121 @@
     2.4   */
     2.5  @ServiceProvider(service = Processor.class)
     2.6  @SupportedSourceVersion(SourceVersion.RELEASE_6)
     2.7 -@SupportedAnnotationTypes("org.openide.loaders.DataObject.Registration")
     2.8 +@SupportedAnnotationTypes({"org.openide.loaders.DataObject.Registration", "org.openide.loaders.DataObject.Registrations"})
     2.9  public class DataObjectFactoryProcessor extends LayerGeneratingProcessor {
    2.10 +
    2.11      @Override
    2.12      protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
    2.13          if (roundEnv.processingOver()) {
    2.14              return false;
    2.15          }
    2.16 -        TypeMirror dataObjectType = type(DataObject.class);
    2.17 -        TypeMirror fileObjectType = type(FileObject.class);
    2.18 -        TypeMirror multiFileLoaderType = type(MultiFileLoader.class);
    2.19 -        TypeMirror dataObjectFactoryType = type(DataObject.Factory.class);
    2.20 -
    2.21  
    2.22          for (Element e : roundEnv.getElementsAnnotatedWith(DataObject.Registration.class)) {
    2.23              DataObject.Registration dfr = e.getAnnotation(DataObject.Registration.class);
    2.24              if (dfr == null) {
    2.25                  continue;
    2.26              }
    2.27 -            LayerBuilder builder = layer(e);
    2.28 -            //need class name to generate id and factory dataObjectClass parameter
    2.29 -            String className = processingEnv.getElementUtils().getBinaryName((TypeElement)e).toString();
    2.30 -            String factoryId = className.replace(".", "-");
    2.31 -
    2.32 -            boolean useFactory = true;
    2.33 -
    2.34 -            // test if enclosing element is of DataObject type;
    2.35 -
    2.36 -            if (isAssignable(e.asType(), dataObjectType)) {
    2.37 -                //attempt to use default factory 
    2.38 -                List<Element> ee = new LinkedList<Element>();
    2.39 -                // should be a public constructor with FileObject and MultiFileLoader as param
    2.40 -                for (ExecutableElement element : ElementFilter.constructorsIn(e.getEnclosedElements())) {
    2.41 -
    2.42 -                    if ((element.getKind() == ElementKind.CONSTRUCTOR) && (element.getModifiers().contains(Modifier.PUBLIC))) {  // found a public constructor ;                        
    2.43 -                        if ((element.getParameters().size() == 2) // parameters of constructor ok
    2.44 -                                && (isAssignable(element.getParameters().get(0).asType(), fileObjectType))
    2.45 -                                && (isAssignable(element.getParameters().get(1).asType(), multiFileLoaderType))) {
    2.46 -                            ee.add(element);
    2.47 -                        }
    2.48 -                    }
    2.49 -                }
    2.50 -                // nothing is found 
    2.51 -                if (ee.isEmpty()) {
    2.52 -                    throw new LayerGenerationException("DataObject subclass with @DataObject.Registration needs a public constructor with FileObject and MultiFileLoader parameters", e, processingEnv, dfr); // NOI18N
    2.53 -                } else {
    2.54 -                    useFactory = true;
    2.55 -                }
    2.56 -
    2.57 -            } else if (isAssignable(e.asType(), dataObjectFactoryType)) {
    2.58 -                List<Element> ee = new LinkedList<Element>();
    2.59 -                for (ExecutableElement element : ElementFilter.constructorsIn(e.getEnclosedElements())) {
    2.60 -                    if ((element.getKind() == ElementKind.CONSTRUCTOR) && (element.getModifiers().contains(Modifier.PUBLIC))) {  // found a public constructor ;                        
    2.61 -                        if ((element.getParameters().isEmpty())) {// parameters of constructor ok
    2.62 -                            ee.add(element);
    2.63 -                        }
    2.64 -                    }
    2.65 -                }
    2.66 -                if (ee.isEmpty()) {
    2.67 -                    throw new LayerGenerationException("DataObject.Factory subclass with @DataObject.Registration needs a public default constructor", e, processingEnv, dfr); // NOI18N
    2.68 -                } else {
    2.69 -                    useFactory = false;
    2.70 -                    factoryId = className.replace(".class", "").replace(".", "-");
    2.71 -                }
    2.72 -            } else {
    2.73 -                throw new LayerGenerationException("Usage @DataObject.Registration only on DataObject.Factory subclass or DataObject subclass", e, processingEnv, dfr); // NOI18N
    2.74 +            process(e, dfr);
    2.75 +        }
    2.76 +        for (Element e : roundEnv.getElementsAnnotatedWith(DataObject.Registrations.class)) {
    2.77 +            DataObject.Registrations dfrr = e.getAnnotation(DataObject.Registrations.class);
    2.78 +            if (dfrr == null) {
    2.79 +                continue;
    2.80              }
    2.81 -
    2.82 -            // check if mimeType annotation is set
    2.83 -            if (dfr.mimeType().length == 0) {
    2.84 -                throw new LayerGenerationException("@DataObject.Factory.Registration mimeTypes() cannot be null", e, processingEnv, dfr, "mimeTypes");
    2.85 +            for (DataObject.Registration t : dfrr.value()) {
    2.86 +                process(e, t);
    2.87              }
    2.88 -            // verify if all mimeType are valid
    2.89 -            for (String aMimeType : dfr.mimeType()) {
    2.90 -                if (aMimeType.isEmpty()) {
    2.91 -                    throw new LayerGenerationException("@DataObject.Factory.Registration mimeTypes() cannot have a empty mimeType", e, processingEnv, dfr, "mimeTypes");
    2.92 -                }
    2.93 -            }
    2.94 -
    2.95 -
    2.96 -            for (String aMimeType : dfr.mimeType()) {
    2.97 -                LayerBuilder.File f = builder.file("Loaders/" + aMimeType + "/Factories/" + factoryId + ".instance");
    2.98 -
    2.99 -                // iconBase is optional but if set then shoud be in classpath
   2.100 -                if (dfr.iconBase().length() > 0) {
   2.101 -                    builder.validateResource(dfr.iconBase(), e.getEnclosingElement(), dfr, "icon", true);
   2.102 -                    f.stringvalue("iconBase", dfr.iconBase());
   2.103 -                }
   2.104 -                // position LayerBuilder 
   2.105 -                f.position(dfr.position());
   2.106 -
   2.107 -                if (!dfr.displayName().isEmpty()) {
   2.108 -                    f.bundlevalue("displayName", dfr.displayName(), dfr, "displayName");
   2.109 -                }
   2.110 -
   2.111 -                if (useFactory) {
   2.112 -                    f.methodvalue("instanceCreate", "org.openide.loaders.DataLoaderPool", "factory");
   2.113 -                    f.stringvalue("dataObjectClass", className);
   2.114 -                    // if factory mimetype is needed otherwise not
   2.115 -                    f.stringvalue("mimeType", aMimeType);
   2.116 -
   2.117 -                }
   2.118 -                f.write();
   2.119 -            }
   2.120 -
   2.121          }
   2.122 -
   2.123          return true;
   2.124      }
   2.125  
   2.126 -    // reuse from Action Processor
   2.127 +    //
   2.128 +    private void process(Element e, DataObject.Registration dfr) throws LayerGenerationException {
   2.129 +        TypeMirror dataObjectType = type(DataObject.class);
   2.130 +        TypeMirror fileObjectType = type(FileObject.class);
   2.131 +        TypeMirror multiFileLoaderType = type(MultiFileLoader.class);
   2.132 +        TypeMirror dataObjectFactoryType = type(DataObject.Factory.class);
   2.133 +        LayerBuilder builder = layer(e);
   2.134 +        //need class name to generate id and factory dataObjectClass parameter
   2.135 +        String className = processingEnv.getElementUtils().getBinaryName((TypeElement) e).toString();
   2.136 +        String factoryId = className.replace(".", "-");
   2.137 +
   2.138 +        boolean useFactory = true;
   2.139 +
   2.140 +        // test if enclosing element is of DataObject type;
   2.141 +
   2.142 +        if (isAssignable(e.asType(), dataObjectType)) {
   2.143 +            //attempt to use default factory 
   2.144 +            List<Element> ee = new LinkedList<Element>();
   2.145 +            // should be a public constructor with FileObject and MultiFileLoader as param
   2.146 +            for (ExecutableElement element : ElementFilter.constructorsIn(e.getEnclosedElements())) {
   2.147 +
   2.148 +                if ((element.getKind() == ElementKind.CONSTRUCTOR) && (element.getModifiers().contains(Modifier.PUBLIC))) {  // found a public constructor ;                        
   2.149 +                    if ((element.getParameters().size() == 2) // parameters of constructor ok
   2.150 +                            && (isAssignable(element.getParameters().get(0).asType(), fileObjectType))
   2.151 +                            && (isAssignable(element.getParameters().get(1).asType(), multiFileLoaderType))) {
   2.152 +                        ee.add(element);
   2.153 +                    }
   2.154 +                }
   2.155 +            }
   2.156 +            // nothing is found 
   2.157 +            if (ee.isEmpty()) {
   2.158 +                throw new LayerGenerationException("DataObject subclass with @DataObject.Registration needs a public constructor with FileObject and MultiFileLoader parameters", e, processingEnv, dfr); // NOI18N
   2.159 +            } else {
   2.160 +                useFactory = true;
   2.161 +            }
   2.162 +
   2.163 +        } else if (isAssignable(e.asType(), dataObjectFactoryType)) {
   2.164 +            List<Element> ee = new LinkedList<Element>();
   2.165 +            for (ExecutableElement element : ElementFilter.constructorsIn(e.getEnclosedElements())) {
   2.166 +                if ((element.getKind() == ElementKind.CONSTRUCTOR) && (element.getModifiers().contains(Modifier.PUBLIC))) {  // found a public constructor ;                        
   2.167 +                    if ((element.getParameters().isEmpty())) {// parameters of constructor ok
   2.168 +                        ee.add(element);
   2.169 +                    }
   2.170 +                }
   2.171 +            }
   2.172 +            if (ee.isEmpty()) {
   2.173 +                throw new LayerGenerationException("DataObject.Factory subclass with @DataObject.Registration needs a public default constructor", e, processingEnv, dfr); // NOI18N
   2.174 +            } else {
   2.175 +                useFactory = false;
   2.176 +                factoryId = className.replace(".class", "").replace(".", "-");
   2.177 +            }
   2.178 +        } else {
   2.179 +            throw new LayerGenerationException("Usage @DataObject.Registration only on DataObject.Factory subclass or DataObject subclass", e, processingEnv, dfr); // NOI18N
   2.180 +        }
   2.181 +
   2.182 +        // check if mimeType annotation is set
   2.183 +        if (dfr.mimeType() == null) {
   2.184 +            throw new LayerGenerationException("@DataObject.Factory.Registration mimeType() cannot be null", e, processingEnv, dfr, "mimeTypes");
   2.185 +        }
   2.186 +        // verify if all mimeType are valid
   2.187 +
   2.188 +        String aMimeType = dfr.mimeType();
   2.189 +        LayerBuilder.File f = builder.file("Loaders/" + aMimeType + "/Factories/" + factoryId + ".instance");
   2.190 +
   2.191 +        // iconBase is optional but if set then shoud be in classpath
   2.192 +        if (dfr.iconBase().length() > 0) {
   2.193 +            builder.validateResource(dfr.iconBase(), e.getEnclosingElement(), dfr, "icon", true);
   2.194 +            f.stringvalue("iconBase", dfr.iconBase());
   2.195 +        }
   2.196 +
   2.197 +        // position LayerBuilder 
   2.198 +        f.position(dfr.position());
   2.199 +
   2.200 +        if (!dfr.displayName().isEmpty()) {
   2.201 +            f.bundlevalue("displayName", dfr.displayName(), dfr, "displayName");
   2.202 +        }
   2.203 +
   2.204 +        if (useFactory) {
   2.205 +            f.methodvalue("instanceCreate", "org.openide.loaders.DataLoaderPool", "factory");
   2.206 +            f.stringvalue("dataObjectClass", className);
   2.207 +            // if factory mimetype is needed otherwise not
   2.208 +            f.stringvalue("mimeType", aMimeType);
   2.209 +        }
   2.210 +        f.write();
   2.211 +
   2.212 +    }
   2.213 +// reuse from Action Processor
   2.214      private TypeMirror type(Class<?> type) {
   2.215          final TypeElement e = processingEnv.getElementUtils().getTypeElement(type.getCanonicalName());
   2.216          return e == null ? null : e.asType();
     3.1 --- a/openide.loaders/src/org/openide/loaders/DataObject.java	Sat Feb 25 17:26:54 2012 +0100
     3.2 +++ b/openide.loaders/src/org/openide/loaders/DataObject.java	Mon Feb 27 10:18:54 2012 +0100
     3.3 @@ -1185,7 +1185,7 @@
     3.4           * {@link MIMEResolver.ExtensionRegistration} and co. to assign
     3.5           * a mime types to {@link FileObject files} in the system.
     3.6           */
     3.7 -        String[] mimeType();
     3.8 +        String mimeType();
     3.9  
    3.10          /**
    3.11           * Display name for the file type created by this registration.
    3.12 @@ -1206,6 +1206,18 @@
    3.13          int position() default Integer.MAX_VALUE;
    3.14      }
    3.15      
    3.16 +     /**
    3.17 +     * May be uses to allow multiple {@link DataObject.Registration DataObject.Registration} at one place.
    3.18 +     * @since 7.36
    3.19 +     */
    3.20 +    @Retention(RetentionPolicy.SOURCE)
    3.21 +    @Target({ElementType.TYPE})
    3.22 +    public static @interface Registrations {
    3.23 +        
    3.24 +        Registration[] value();
    3.25 +    }
    3.26 +    
    3.27 +    
    3.28      /** Registry of modified data objects.
    3.29       * The registry permits attaching of a change listener
    3.30      * to be informed when the count of modified objects changes.
     4.1 --- a/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessorTest.java	Sat Feb 25 17:26:54 2012 +0100
     4.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessorTest.java	Mon Feb 27 10:18:54 2012 +0100
     4.3 @@ -45,9 +45,9 @@
     4.4  import java.io.ByteArrayOutputStream;
     4.5  import java.io.IOException;
     4.6  import java.io.OutputStream;
     4.7 -import java.io.PrintStream;
     4.8  import org.netbeans.junit.NbTestCase;
     4.9  import org.netbeans.modules.openide.loaders.data.DoFPDataObject;
    4.10 +import org.netbeans.modules.openide.loaders.data.DoFPDataObjectMultiple;
    4.11  import org.openide.filesystems.FileLock;
    4.12  import org.openide.filesystems.FileObject;
    4.13  import org.openide.filesystems.FileUtil;
    4.14 @@ -78,7 +78,6 @@
    4.15      @Override
    4.16      protected void setUp() throws Exception {
    4.17          super.setUp();
    4.18 -        createMIMEs();
    4.19      }
    4.20  
    4.21  // Several test for javac
    4.22 @@ -209,8 +208,7 @@
    4.23              assertEquals("Icon found", "org/openide/loaders/unknown.gif", icon);
    4.24              assertEquals("DataObjectClass found", DoFPDataObject.class.getName(), fo.getAttribute("dataObjectClass"));
    4.25  
    4.26 -        }
    4.27 -
    4.28 +        }        
    4.29      }
    4.30  
    4.31  // use external DoFP* class and their registration to test if dataobject return is good
    4.32 @@ -223,35 +221,19 @@
    4.33              assertEquals("DataLoader type", DoFPDataObject.class, find.getClass());
    4.34          }
    4.35          {
    4.36 -            FileObject fo = createXmlFile("sdfsdf", ".tt2");
    4.37 -            assertEquals("text/test2", fo.getMIMEType());
    4.38 -            DataObject find = DataObject.find(fo);
    4.39 -            assertEquals("DataLoader type", DoFPDataObject.class, find.getClass());
    4.40 -        }
    4.41 -        {
    4.42              FileObject fo = createXmlFile("sdfsdf", ".tt3");
    4.43              assertEquals("text/test3", fo.getMIMEType());
    4.44              // XXX DoFPCustomLoader not loaded cannot assert for loader
    4.45          }
    4.46 +        {
    4.47 +            FileObject fo = createXmlFile("sdfsdf", ".ttm2");
    4.48 +            assertEquals("text/testm2", fo.getMIMEType());
    4.49 +            DataObject find = DataObject.find(fo);
    4.50 +            assertEquals("DataLoader type", DoFPDataObjectMultiple.class, find.getClass());
    4.51 +        }
    4.52      }
    4.53  
    4.54 -    // utility method inspired by FsMimeResolverTest
    4.55 -    private void createMIMEs() throws Exception {
    4.56 -// create  resolver to get tt1 extension resolve as test/test1 and do so for 3 different
    4.57 -        FileObject resolver = FileUtil.createData(FileUtil.getConfigRoot(), "Services/MIMEResolver/resolver.xml");
    4.58 -        OutputStream os = resolver.getOutputStream();
    4.59 -        PrintStream ps = new PrintStream(os);
    4.60 -        ps.println("<!DOCTYPE MIME-resolver PUBLIC '-//NetBeans//DTD MIME Resolver 1.0//EN' 'http://www.netbeans.org/dtds/mime-resolver-1_0.dtd'>");
    4.61 -        ps.println("<MIME-resolver>");
    4.62 -        for (int i = 1; i < 4; i++) {
    4.63 -            ps.println(" <file>");
    4.64 -            ps.println("  <ext name=\"tt" + i + "\"/>");
    4.65 -            ps.println("    <resolver mime=\"text/test" + i + "\"/>");
    4.66 -            ps.println(" </file>");
    4.67 -        }
    4.68 -        ps.println("</MIME-resolver>");
    4.69 -        os.close();
    4.70 -    }
    4.71 +   
    4.72  
    4.73      private FileObject createXmlFile(String content, String ext) throws Exception {
    4.74          FileObject file = FileUtil.createMemoryFileSystem().getRoot().createData("file" + ext);
     5.1 --- a/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPDataObject.java	Sat Feb 25 17:26:54 2012 +0100
     5.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPDataObject.java	Mon Feb 27 10:18:54 2012 +0100
     5.3 @@ -53,7 +53,7 @@
     5.4   * @see DataObjectFactoryProcessorTest
     5.5   * @author Eric Barboni <skygo@netbeans.org>
     5.6   */
     5.7 -@DataObject.Registration(mimeType =  {"text/test1","text/test2"}, displayName = "labeltest", position = 3565, iconBase = "org/openide/loaders/unknown.gif")
     5.8 +@DataObject.Registration(mimeType =  "text/test1", displayName = "labeltest", position = 3565, iconBase = "org/openide/loaders/unknown.gif")
     5.9  public class DoFPDataObject extends DataObject {
    5.10  
    5.11      public DoFPDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException {
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPDataObjectMultiple.java	Mon Feb 27 10:18:54 2012 +0100
     6.3 @@ -0,0 +1,114 @@
     6.4 +/*
     6.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     6.6 + *
     6.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
     6.8 + *
     6.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    6.10 + * Other names may be trademarks of their respective owners.
    6.11 + *
    6.12 + * The contents of this file are subject to the terms of either the GNU
    6.13 + * General Public License Version 2 only ("GPL") or the Common
    6.14 + * Development and Distribution License("CDDL") (collectively, the
    6.15 + * "License"). You may not use this file except in compliance with the
    6.16 + * License. You can obtain a copy of the License at
    6.17 + * http://www.netbeans.org/cddl-gplv2.html
    6.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    6.19 + * specific language governing permissions and limitations under the
    6.20 + * License.  When distributing the software, include this License Header
    6.21 + * Notice in each file and include the License file at
    6.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    6.23 + * particular file as subject to the "Classpath" exception as provided
    6.24 + * by Oracle in the GPL Version 2 section of the License file that
    6.25 + * accompanied this code. If applicable, add the following below the
    6.26 + * License Header, with the fields enclosed by brackets [] replaced by
    6.27 + * your own identifying information:
    6.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    6.29 + *
    6.30 + * If you wish your version of this file to be governed by only the CDDL
    6.31 + * or only the GPL Version 2, indicate your decision by adding
    6.32 + * "[Contributor] elects to include this software in this distribution
    6.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    6.34 + * single choice of license, a recipient has the option to distribute
    6.35 + * your version of this file under either the CDDL, the GPL Version 2 or
    6.36 + * to extend the choice of license to its licensees as provided above.
    6.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    6.38 + * Version 2 license, then the option applies only if the new code is
    6.39 + * made subject to such option by the copyright holder.
    6.40 + *
    6.41 + * Contributor(s):
    6.42 + *
    6.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
    6.44 + */
    6.45 +package org.netbeans.modules.openide.loaders.data;
    6.46 +
    6.47 +import java.io.IOException;
    6.48 +import org.openide.filesystems.FileObject;
    6.49 +import org.openide.loaders.DataFolder;
    6.50 +import org.openide.loaders.DataObject;
    6.51 +import org.openide.loaders.DataObjectExistsException;
    6.52 +import org.openide.loaders.MultiFileLoader;
    6.53 +import org.openide.util.HelpCtx;
    6.54 +
    6.55 +/**
    6.56 + * @see DataObjectFactoryProcessorTest
    6.57 + * @author Eric Barboni <skygo@netbeans.org>
    6.58 + */
    6.59 +@DataObject.Registrations({
    6.60 +    @DataObject.Registration(mimeType = "text/testm1", displayName = "labeltest", position = 3565, iconBase = "org/openide/loaders/unknown.gif"),
    6.61 +    @DataObject.Registration(mimeType = "text/testm2", displayName = "labeltestm1", position = 4050, iconBase = "org/openide/loaders/unknown.gif")})
    6.62 +public class DoFPDataObjectMultiple extends DataObject {
    6.63 +
    6.64 +    public DoFPDataObjectMultiple(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException {
    6.65 +        super(pf, loader);
    6.66 +    }
    6.67 +
    6.68 +    @Override
    6.69 +    public boolean isDeleteAllowed() {
    6.70 +        throw new UnsupportedOperationException("Not supported yet.");
    6.71 +    }
    6.72 +
    6.73 +    @Override
    6.74 +    public boolean isCopyAllowed() {
    6.75 +        throw new UnsupportedOperationException("Not supported yet.");
    6.76 +    }
    6.77 +
    6.78 +    @Override
    6.79 +    public boolean isMoveAllowed() {
    6.80 +        throw new UnsupportedOperationException("Not supported yet.");
    6.81 +    }
    6.82 +
    6.83 +    @Override
    6.84 +    public boolean isRenameAllowed() {
    6.85 +        throw new UnsupportedOperationException("Not supported yet.");
    6.86 +    }
    6.87 +
    6.88 +    @Override
    6.89 +    public HelpCtx getHelpCtx() {
    6.90 +        throw new UnsupportedOperationException("Not supported yet.");
    6.91 +    }
    6.92 +
    6.93 +    @Override
    6.94 +    protected DataObject handleCopy(DataFolder f) throws IOException {
    6.95 +        throw new UnsupportedOperationException("Not supported yet.");
    6.96 +    }
    6.97 +
    6.98 +    @Override
    6.99 +    protected void handleDelete() throws IOException {
   6.100 +        throw new UnsupportedOperationException("Not supported yet.");
   6.101 +    }
   6.102 +
   6.103 +    @Override
   6.104 +    protected FileObject handleRename(String name) throws IOException {
   6.105 +        throw new UnsupportedOperationException("Not supported yet.");
   6.106 +    }
   6.107 +
   6.108 +    @Override
   6.109 +    protected FileObject handleMove(DataFolder df) throws IOException {
   6.110 +        throw new UnsupportedOperationException("Not supported yet.");
   6.111 +    }
   6.112 +
   6.113 +    @Override
   6.114 +    protected DataObject handleCreateFromTemplate(DataFolder df, String name) throws IOException {
   6.115 +        throw new UnsupportedOperationException("Not supported yet.");
   6.116 +    }
   6.117 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPMIMEType.java	Mon Feb 27 10:18:54 2012 +0100
     7.3 @@ -0,0 +1,67 @@
     7.4 +/*
     7.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     7.6 + *
     7.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
     7.8 + *
     7.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    7.10 + * Other names may be trademarks of their respective owners.
    7.11 + *
    7.12 + * The contents of this file are subject to the terms of either the GNU
    7.13 + * General Public License Version 2 only ("GPL") or the Common
    7.14 + * Development and Distribution License("CDDL") (collectively, the
    7.15 + * "License"). You may not use this file except in compliance with the
    7.16 + * License. You can obtain a copy of the License at
    7.17 + * http://www.netbeans.org/cddl-gplv2.html
    7.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    7.19 + * specific language governing permissions and limitations under the
    7.20 + * License.  When distributing the software, include this License Header
    7.21 + * Notice in each file and include the License file at
    7.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    7.23 + * particular file as subject to the "Classpath" exception as provided
    7.24 + * by Oracle in the GPL Version 2 section of the License file that
    7.25 + * accompanied this code. If applicable, add the following below the
    7.26 + * License Header, with the fields enclosed by brackets [] replaced by
    7.27 + * your own identifying information:
    7.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    7.29 + *
    7.30 + * If you wish your version of this file to be governed by only the CDDL
    7.31 + * or only the GPL Version 2, indicate your decision by adding
    7.32 + * "[Contributor] elects to include this software in this distribution
    7.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    7.34 + * single choice of license, a recipient has the option to distribute
    7.35 + * your version of this file under either the CDDL, the GPL Version 2 or
    7.36 + * to extend the choice of license to its licensees as provided above.
    7.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    7.38 + * Version 2 license, then the option applies only if the new code is
    7.39 + * made subject to such option by the copyright holder.
    7.40 + *
    7.41 + * Contributor(s):
    7.42 + *
    7.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
    7.44 + */
    7.45 +package org.netbeans.modules.openide.loaders.data;
    7.46 +
    7.47 +import org.openide.filesystems.MIMEResolver;
    7.48 +
    7.49 +/**
    7.50 + *
    7.51 + * @author Eric Barboni <skygo@netbeans.org>
    7.52 + */
    7.53 +public class DoFPMIMEType {
    7.54 +
    7.55 +    @MIMEResolver.ExtensionRegistration(displayName = "tt1", extension = "tt1", mimeType = "text/test1",position=1000)
    7.56 +    public void tt1() {
    7.57 +    }
    7.58 +
    7.59 +    @MIMEResolver.ExtensionRegistration(displayName = "tt3", extension = "tt3", mimeType = "text/test3",position=1002)
    7.60 +    public void tt3() {
    7.61 +    }
    7.62 +
    7.63 +    @MIMEResolver.ExtensionRegistration(displayName = "ttm1", extension = "ttm1", mimeType = "text/testm1",position=1003)
    7.64 +    public void ttm1() {
    7.65 +    }
    7.66 +
    7.67 +    @MIMEResolver.ExtensionRegistration(displayName = "ttm2", extension = "ttm2", mimeType = "text/testm2",position=1004)
    7.68 +    public void ttm2() {
    7.69 +    }
    7.70 +}