Merging two heads on marshall-mime-resolvers-191777 marshall-mime-resolvers-191777
authorJaroslav Tulach <jtulach@netbeans.org>
Fri, 03 Feb 2012 21:47:17 +0100
branchmarshall-mime-resolvers-191777
changeset 2189159cbd91255edb
parent 218914 0bcc265ca338
parent 218796 209110501a29
child 218916 b4b9d55ccd55
Merging two heads on marshall-mime-resolvers-191777
     1.1 --- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml	Fri Feb 03 21:42:16 2012 +0100
     1.2 +++ b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/common/layer.xml	Fri Feb 03 21:47:17 2012 +0100
     1.3 @@ -72,6 +72,7 @@
     1.4              <file name="templateDataNode.java" url="../loader/templateDataNode.javx"/>
     1.5              <file name="templateDataObject.java" url="../loader/templateDataObject.javx"/>
     1.6              <file name="templateDataObjectWithLookup.java" url="../loader/templateDataObjectWithLookup.javx"/>
     1.7 +            <file name="templateDataObjectAnno.java" url="../loader/templateDataObjectAnno.javx"/>
     1.8              <file name="templateDataObjectMulti.java" url="../loader/templateDataObjectMulti.javx"/>
     1.9              <file name="templateDataObjectMultiForm.java" url="../loader/templateDataObjectMultiVisual.javx"/>
    1.10              <file name="templateDataObjectMultiForm.form" url="../loader/templateDataObjectMultiVisual.forx"/>
     2.1 --- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/NewLoaderIterator.java	Fri Feb 03 21:42:16 2012 +0100
     2.2 +++ b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/NewLoaderIterator.java	Fri Feb 03 21:47:17 2012 +0100
     2.3 @@ -217,12 +217,15 @@
     2.4  
     2.5          boolean loaderlessObject;
     2.6          boolean lookupReadyObject;
     2.7 +        boolean annotationReadyObject;
     2.8          try {
     2.9              SpecificationVersion current = model.getModuleInfo().getDependencyVersion("org.openide.loaders"); // NOI18N
    2.10 +            annotationReadyObject = current == null || current.compareTo(new SpecificationVersion("7.36")) >= 0; // NOI18N
    2.11              loaderlessObject = current == null || current.compareTo(new SpecificationVersion("7.1")) >= 0; // NOI18N
    2.12              lookupReadyObject = current == null || current.compareTo(new SpecificationVersion("6.0")) >= 0; // NOI18N
    2.13          } catch (IOException ex) {
    2.14              Logger.getLogger(NewLoaderIterator.class.getName()).log(Level.INFO, null, ex);
    2.15 +            annotationReadyObject = false;
    2.16              loaderlessObject = false;
    2.17              lookupReadyObject = false;
    2.18          }
    2.19 @@ -234,8 +237,19 @@
    2.20          replaceTokens.put("PREFIX", namePrefix);//NOI18N
    2.21          replaceTokens.put("PACKAGENAME", packageName);//NOI18N
    2.22          replaceTokens.put("MIMETYPE", mime);//NOI18N
    2.23 -        replaceTokens.put("EXTENSIONS", formatExtensions(model.isExtensionBased(), model.getExtension(), mime));//NOI18N
    2.24 -        replaceTokens.put("NAMESPACES", formatNameSpace(model.isExtensionBased(), model.getNamespace(), mime));//NOI18N
    2.25 +        if (model.isExtensionBased()) {
    2.26 +            if (annotationReadyObject) {
    2.27 +                replaceTokens.put("EXTENSIONS", formatToList(model.getExtension())); // NOI18N
    2.28 +            } else {
    2.29 +                replaceTokens.put("EXTENSIONS", formatExtensions(model.isExtensionBased(), model.getExtension(), mime));//NOI18N
    2.30 +            }
    2.31 +        } else {
    2.32 +            if (annotationReadyObject) {
    2.33 +                replaceTokens.put("NAMESPACES", formatToList(model.getNamespace())); // NOI18N
    2.34 +            } else {
    2.35 +                replaceTokens.put("NAMESPACES", formatNameSpace(model.isExtensionBased(), model.getNamespace(), mime));//NOI18N
    2.36 +            }
    2.37 +        }
    2.38          
    2.39          // Copy action icon
    2.40          File origIconPath = model.getIconPath();
    2.41 @@ -282,20 +296,25 @@
    2.42          
    2.43          String doName = model.getDefaultPackagePath(namePrefix + "DataObject.java", false); // NOI18N
    2.44          template = null;
    2.45 -        if (loaderlessObject) {
    2.46 +        if (annotationReadyObject) {
    2.47 +            template = CreatedModifiedFiles.getTemplate("templateDataObjectAnno.java");//NOI18N
    2.48 +            if (model.isUseMultiview()) {
    2.49 +                replaceTokens.put("MULTIVIEW", "true"); // NOI18N
    2.50 +            }
    2.51 +        } else if (loaderlessObject) {
    2.52              if (model.isUseMultiview()) {
    2.53                  template = CreatedModifiedFiles.getTemplate("templateDataObjectMulti.java");//NOI18N
    2.54              } else {
    2.55                  template = CreatedModifiedFiles.getTemplate("templateDataObjectInLayer.java");//NOI18N
    2.56              }
    2.57 -        } else {
    2.58 -            if (lookupReadyObject) {
    2.59 -                template = CreatedModifiedFiles.getTemplate("templateDataObjectWithLookup.java");//NOI18N
    2.60 -            }
    2.61 +        } else if (lookupReadyObject) {
    2.62 +            template = CreatedModifiedFiles.getTemplate("templateDataObjectWithLookup.java");//NOI18N
    2.63          }
    2.64          if (template == null) {
    2.65              template = CreatedModifiedFiles.getTemplate("templateDataObject.java");//NOI18N
    2.66          }
    2.67 +        
    2.68 +        
    2.69          fileChanges.add(fileChanges.createFileWithSubstitutions(doName, template, replaceTokens));
    2.70          if (model.isUseMultiview()) {
    2.71              String formName = model.getDefaultPackagePath(namePrefix + "VisualElement.form", false); // NOI18N
    2.72 @@ -313,13 +332,15 @@
    2.73              fileChanges.add(fileChanges.createFileWithSubstitutions(nodeName, template, replaceTokens));
    2.74          }
    2.75          
    2.76 -        // 4. mimetyperesolver file
    2.77 -        template = CreatedModifiedFiles.getTemplate("templateresolver.xml");//NOI18N
    2.78 -        fileChanges.add(fileChanges.createLayerEntry("Services/MIMEResolver/" + namePrefix + "Resolver.xml", //NOI18N
    2.79 -                template,
    2.80 -                replaceTokens,
    2.81 -                namePrefix + " Files",//NOI18N
    2.82 -                null));
    2.83 +        if (!annotationReadyObject) {
    2.84 +            // 4. mimetyperesolver file
    2.85 +            template = CreatedModifiedFiles.getTemplate("templateresolver.xml");//NOI18N
    2.86 +            fileChanges.add(fileChanges.createLayerEntry("Services/MIMEResolver/" + namePrefix + "Resolver.xml", //NOI18N
    2.87 +                    template,
    2.88 +                    replaceTokens,
    2.89 +                    namePrefix + " Files",//NOI18N
    2.90 +                    null));
    2.91 +        }
    2.92          
    2.93          //5. update project.xml with dependencies
    2.94          fileChanges.add(fileChanges.addModuleDependency("org.openide.filesystems")); //NOI18N
    2.95 @@ -338,6 +359,10 @@
    2.96              fileChanges.add(fileChanges.addModuleDependency("org.netbeans.core.multiview")); //NOI18N
    2.97              fileChanges.add(fileChanges.addModuleDependency("org.openide.awt")); //NOI18N
    2.98          }
    2.99 +        if (annotationReadyObject) {
   2.100 +            fileChanges.add(fileChanges.addModuleDependency("org.openide.awt")); //NOI18N
   2.101 +            fileChanges.add(fileChanges.addModuleDependency("org.openide.dialogs")); // NOI18N
   2.102 +        }
   2.103  
   2.104          if (!loaderlessObject) {
   2.105          // 6. update/create bundle file
   2.106 @@ -345,9 +370,11 @@
   2.107          fileChanges.add(fileChanges.bundleKey(bundlePath, "LBL_" + namePrefix + "_loader_name",  // NOI18N
   2.108                  namePrefix + " Files")); //NOI18N
   2.109          }
   2.110 -        
   2.111 -        if (loaderlessObject) {
   2.112 +        if (annotationReadyObject) {
   2.113 +            // registration via processors
   2.114 +        } else if (loaderlessObject) {
   2.115              // 7. register in layer
   2.116 +            if (!annotationReadyObject) {
   2.117              String path = "Loaders/" + mime + "/Factories/" + namePrefix + "DataLoader.instance";
   2.118              Map<String,Object> attrs = new HashMap<String, Object>();
   2.119              attrs.put("instanceCreate", "methodvalue:org.openide.loaders.DataLoaderPool.factory"); //NOI18N
   2.120 @@ -359,7 +386,7 @@
   2.121              fileChanges.add(
   2.122                  fileChanges.createLayerEntry(path, null, null, null, attrs)
   2.123              );
   2.124 -            
   2.125 +            }
   2.126          } else {
   2.127              // 7. register manifest entry
   2.128              boolean isXml = Pattern.matches("(application/([a-zA-Z0-9_.-])*\\+xml|text/([a-zA-Z0-9_.-])*\\+xml)", //NOI18N
   2.129 @@ -377,7 +404,8 @@
   2.130          
   2.131          //8. create layerfile actions subsection
   2.132          
   2.133 -        fileChanges.add(fileChanges.layerModifications(new CreatedModifiedFiles.LayerOperation() {
   2.134 +        if (!annotationReadyObject) fileChanges.add(fileChanges.layerModifications(new CreatedModifiedFiles.LayerOperation() {
   2.135 +            @Override
   2.136              public void run(FileSystem layer) throws IOException {
   2.137                  List<String> actions = new ArrayList<String>();
   2.138                  if (isEditable) {
   2.139 @@ -432,6 +460,8 @@
   2.140                  assert false: ex;
   2.141              }
   2.142          }
   2.143 +        replaceTokens.put("TEMPLATE_NAME", suffix);
   2.144 +        
   2.145          boolean useTR = false;
   2.146          NbModuleProvider nbmp = model.getModuleInfo();
   2.147          try {
   2.148 @@ -446,14 +476,16 @@
   2.149          String templateName = namePrefix + suffix;
   2.150          if (useTR) {
   2.151              fileChanges.add(fileChanges.createFileWithSubstitutions(model.getDefaultPackagePath(templateName, true), template, replaceTokens));
   2.152 -            Map<String,Map<String,?>> annos = new LinkedHashMap<String,Map<String,?>>();
   2.153 -            Map<String,Object> tr = new LinkedHashMap<String,Object>();
   2.154 -            tr.put("folder", "Other");
   2.155 -            tr.put("displayName", "#" + namePrefix + "template_displayName");
   2.156 -            tr.put("content", templateName);
   2.157 -            annos.put("org.netbeans.api.templates.TemplateRegistration", tr);
   2.158 -            annos.put("org.openide.util.NbBundle.Messages", Collections.singletonMap("value", namePrefix + "template_displayName=" + displayName));
   2.159 -            fileChanges.add(fileChanges.packageInfo(packageName, annos));
   2.160 +            if (!annotationReadyObject) {
   2.161 +                Map<String,Map<String,?>> annos = new LinkedHashMap<String,Map<String,?>>();
   2.162 +                Map<String,Object> tr = new LinkedHashMap<String,Object>();
   2.163 +                tr.put("folder", "Other");
   2.164 +                tr.put("displayName", "#" + namePrefix + "template_displayName");
   2.165 +                tr.put("content", templateName);
   2.166 +                annos.put("org.netbeans.api.templates.TemplateRegistration", tr);
   2.167 +                annos.put("org.openide.util.NbBundle.Messages", Collections.singletonMap("value", namePrefix + "template_displayName=" + displayName));
   2.168 +                fileChanges.add(fileChanges.packageInfo(packageName, annos));
   2.169 +            }
   2.170          } else {
   2.171              fileChanges.add(fileChanges.createLayerEntry("Templates/Other/" + templateName, template, replaceTokens, displayName, Collections.singletonMap("template", true)));
   2.172          }
   2.173 @@ -476,7 +508,21 @@
   2.174          buff.append("        <resolver mime=\"").append(mime).append("\"/>"); //NOI18N
   2.175          return buff.toString();
   2.176      }
   2.177 -    
   2.178 +
   2.179 +    private static String formatToList(String ext) {
   2.180 +        StringBuilder buff = new StringBuilder();
   2.181 +        buff.append("{ ");
   2.182 +        StringTokenizer tokens = new StringTokenizer(ext, " ,"); // NOI18N
   2.183 +        String sep = "";
   2.184 +        while (tokens.hasMoreTokens()) {
   2.185 +            String element = tokens.nextToken().trim();
   2.186 +            buff.append(sep).append("\"").append(element).append("\"");
   2.187 +            sep = ", ";
   2.188 +        }
   2.189 +        buff.append(" }");
   2.190 +        return buff.toString();
   2.191 +    }
   2.192 +
   2.193      private static String getFirstExtension(String ext) {
   2.194          StringTokenizer tokens = new StringTokenizer(ext," ,"); // NOI18N
   2.195          String element = "someextension"; // NOI18N
     3.1 --- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObject.javx	Fri Feb 03 21:42:16 2012 +0100
     3.2 +++ b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObject.javx	Fri Feb 03 21:47:17 2012 +0100
     3.3 @@ -7,12 +7,13 @@
     3.4  
     3.5  import java.io.IOException;
     3.6  import org.openide.filesystems.FileObject;
     3.7 +${DATAOBJECT_REGISTRATION_IMPORT}
     3.8  import org.openide.loaders.DataObjectExistsException;
     3.9  import org.openide.loaders.MultiDataObject;
    3.10  import org.openide.nodes.CookieSet;
    3.11  import org.openide.nodes.Node;
    3.12  ${EDITOR_SUPPORT_IMPORT}
    3.13 -
    3.14 +${DATAOBJECT_REGISTRATION}
    3.15  public class ${PREFIX}DataObject extends MultiDataObject {
    3.16  
    3.17      public ${PREFIX}DataObject(FileObject pf, ${PREFIX}DataLoader loader) throws DataObjectExistsException, IOException {
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObjectAnno.javx	Fri Feb 03 21:47:17 2012 +0100
     4.3 @@ -0,0 +1,133 @@
     4.4 +<#assign licenseFirst = "/*">
     4.5 +<#assign licensePrefix = " * ">
     4.6 +<#assign licenseLast = " */">
     4.7 +<#include "../Licenses/license-${project.license}.txt">
     4.8 +
     4.9 +package ${PACKAGENAME};
    4.10 +
    4.11 +import java.io.IOException;
    4.12 +import org.netbeans.api.templates.TemplateRegistration;
    4.13 +<#if MULTIVIEW??>
    4.14 +import org.netbeans.core.spi.multiview.MultiViewElement;
    4.15 +import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
    4.16 +</#if>
    4.17 +import org.openide.WizardDescriptor;
    4.18 +import org.openide.awt.ActionID;
    4.19 +import org.openide.awt.ActionReference;
    4.20 +import org.openide.awt.ActionReferences;
    4.21 +import org.openide.filesystems.FileObject;
    4.22 +import org.openide.filesystems.MIMEResolver;
    4.23 +import org.openide.loaders.DataObject;
    4.24 +import org.openide.loaders.DataObjectExistsException;
    4.25 +import org.openide.loaders.MultiDataObject;
    4.26 +import org.openide.loaders.MultiFileLoader;
    4.27 +import org.openide.util.Lookup;
    4.28 +import org.openide.util.NbBundle.Messages;
    4.29 +import org.openide.windows.TopComponent;
    4.30 +
    4.31 +@Messages({
    4.32 +    "LBL_${PREFIX}_LOADER=Files of ${PREFIX}"
    4.33 +})
    4.34 +<#if NAMESPACES??>
    4.35 +@MIMEResolver.NamespaceRegistration(
    4.36 +    displayName="#LBL_${PREFIX}_LOADER",
    4.37 +    mimeType="${MIMETYPE}",
    4.38 +    elementNS=${NAMESPACES}
    4.39 +)
    4.40 +<#else>
    4.41 +@MIMEResolver.ExtensionRegistration(
    4.42 +    displayName="#LBL_${PREFIX}_LOADER",
    4.43 +    mimeType="${MIMETYPE}",
    4.44 +    extension=${EXTENSIONS}
    4.45 +)
    4.46 +</#if>
    4.47 +@DataObject.Registration(
    4.48 +    mimeType = "${MIMETYPE}", 
    4.49 +    iconBase = "${ICONPATH}",
    4.50 +    displayName="#LBL_${PREFIX}_LOADER",
    4.51 +    position=300
    4.52 +)
    4.53 +@ActionReferences({
    4.54 +    @ActionReference(
    4.55 +        path="Loaders/${MIMETYPE}/Actions", 
    4.56 +        id=@ActionID(category="System", id="org.openide.actions.OpenAction"),
    4.57 +        position=100, 
    4.58 +        separatorAfter=200
    4.59 +    ),
    4.60 +    @ActionReference(
    4.61 +        path="Loaders/${MIMETYPE}/Actions", 
    4.62 +        id=@ActionID(category="Edit", id="org.openide.actions.CutAction"),
    4.63 +        position=300
    4.64 +    ),
    4.65 +    @ActionReference(
    4.66 +        path="Loaders/${MIMETYPE}/Actions", 
    4.67 +        id=@ActionID(category="Edit", id="org.openide.actions.CopyAction"),
    4.68 +        position=400,
    4.69 +        separatorAfter=500
    4.70 +    ),
    4.71 +    @ActionReference(
    4.72 +        path="Loaders/${MIMETYPE}/Actions", 
    4.73 +        id=@ActionID(category="Edit", id="org.openide.actions.DeleteAction"),
    4.74 +        position=600
    4.75 +    ),
    4.76 +    @ActionReference(
    4.77 +        path="Loaders/${MIMETYPE}/Actions", 
    4.78 +        id=@ActionID(category="System", id="org.openide.actions.RenameAction"),
    4.79 +        position=700,
    4.80 +        separatorAfter=800
    4.81 +    ),
    4.82 +    @ActionReference(
    4.83 +        path="Loaders/${MIMETYPE}/Actions", 
    4.84 +        id=@ActionID(category="System", id="org.openide.actions.SaveAsTemplateAction"),
    4.85 +        position=900,
    4.86 +        separatorAfter=1000
    4.87 +    ),
    4.88 +    @ActionReference(
    4.89 +        path="Loaders/${MIMETYPE}/Actions", 
    4.90 +        id=@ActionID(category="System", id="org.openide.actions.FileSystemAction"),
    4.91 +        position=1100,
    4.92 +        separatorAfter=1200
    4.93 +    ),
    4.94 +    @ActionReference(
    4.95 +        path="Loaders/${MIMETYPE}/Actions", 
    4.96 +        id=@ActionID(category="System", id="org.openide.actions.ToolsAction"),
    4.97 +        position=1300
    4.98 +    ),
    4.99 +    @ActionReference(
   4.100 +        path="Loaders/${MIMETYPE}/Actions", 
   4.101 +        id=@ActionID(category="System", id="org.openide.actions.PropertiesAction"),
   4.102 +        position=1400
   4.103 +    )
   4.104 +})
   4.105 +public class ${PREFIX}DataObject extends MultiDataObject {
   4.106 +
   4.107 +    public ${PREFIX}DataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
   4.108 +        super(pf, loader);
   4.109 +        registerEditor("${MIMETYPE}", <#if MULTIVIEW??>true<#else>false</#if>);
   4.110 +    }
   4.111 +
   4.112 +    @Override
   4.113 +    protected int associateLookup() {
   4.114 +        return 1;
   4.115 +    }
   4.116 +
   4.117 +    <#if MULTIVIEW??>
   4.118 +    @MultiViewElement.Registration(
   4.119 +        displayName = "#LBL_${PREFIX}_EDITOR",
   4.120 +        iconBase = "${ICONPATH}",
   4.121 +        mimeType = "${MIMETYPE}",
   4.122 +        persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED,
   4.123 +        preferredID = "${PREFIX}",
   4.124 +        position = 1000
   4.125 +    )
   4.126 +    @Messages("LBL_${PREFIX}_EDITOR=Source")
   4.127 +    public static MultiViewEditorElement createEditor(Lookup lkp) {
   4.128 +        return new MultiViewEditorElement(lkp);
   4.129 +    }
   4.130 +    </#if>
   4.131 +
   4.132 +    @TemplateRegistration(folder="Other", content="${PREFIX}${TEMPLATE_NAME}")
   4.133 +    public static WizardDescriptor.InstantiatingIterator templateIterator() {
   4.134 +        return null;
   4.135 +    }
   4.136 +}
     5.1 --- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObjectInLayer.javx	Fri Feb 03 21:42:16 2012 +0100
     5.2 +++ b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObjectInLayer.javx	Fri Feb 03 21:47:17 2012 +0100
     5.3 @@ -8,6 +8,7 @@
     5.4  import java.io.IOException;
     5.5  import org.openide.filesystems.FileObject;
     5.6  import org.openide.loaders.DataNode;
     5.7 +${DATAOBJECT_REGISTRATION_IMPORT}
     5.8  import org.openide.loaders.DataObjectExistsException;
     5.9  import org.openide.loaders.MultiDataObject;
    5.10  import org.openide.loaders.MultiFileLoader;
    5.11 @@ -16,7 +17,7 @@
    5.12  import org.openide.nodes.Children;
    5.13  import org.openide.util.Lookup;
    5.14  ${EDITOR_SUPPORT_IMPORT}
    5.15 -
    5.16 +${DATAOBJECT_REGISTRATION}
    5.17  public class ${PREFIX}DataObject extends MultiDataObject {
    5.18  
    5.19      public ${PREFIX}DataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
     6.1 --- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObjectMulti.javx	Fri Feb 03 21:42:16 2012 +0100
     6.2 +++ b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObjectMulti.javx	Fri Feb 03 21:47:17 2012 +0100
     6.3 @@ -15,7 +15,6 @@
     6.4  import org.openide.util.Lookup;
     6.5  import org.openide.util.NbBundle.Messages;
     6.6  import org.openide.windows.TopComponent;
     6.7 -
     6.8  public class ${PREFIX}DataObject extends MultiDataObject {
     6.9  
    6.10      public ${PREFIX}DataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
     7.1 --- a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObjectWithLookup.javx	Fri Feb 03 21:42:16 2012 +0100
     7.2 +++ b/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/templateDataObjectWithLookup.javx	Fri Feb 03 21:47:17 2012 +0100
     7.3 @@ -7,13 +7,14 @@
     7.4  
     7.5  import java.io.IOException;
     7.6  import org.openide.filesystems.FileObject;
     7.7 +${DATAOBJECT_REGISTRATION_IMPORT}
     7.8  import org.openide.loaders.DataObjectExistsException;
     7.9  import org.openide.loaders.MultiDataObject;
    7.10  import org.openide.nodes.CookieSet;
    7.11  import org.openide.nodes.Node;
    7.12  import org.openide.util.Lookup;
    7.13  ${EDITOR_SUPPORT_IMPORT}
    7.14 -
    7.15 +${DATAOBJECT_REGISTRATION}
    7.16  public class ${PREFIX}DataObject extends MultiDataObject {
    7.17  
    7.18      public ${PREFIX}DataObject(FileObject pf, ${PREFIX}DataLoader loader) throws DataObjectExistsException, IOException {
     8.1 --- a/ide.branding/release-toplevel/CREDITS.html	Fri Feb 03 21:42:16 2012 +0100
     8.2 +++ b/ide.branding/release-toplevel/CREDITS.html	Fri Feb 03 21:47:17 2012 +0100
     8.3 @@ -21,6 +21,7 @@
     8.4    <li>Christina Ahrens         <i>(cahrens at the host mathworks dot com)</i></li>
     8.5    <li>Asgeir Orn Asgeirsson    <i>(asgeir at the host dimonsoftware dot com)</i></li>
     8.6    <li>Christopher Atlan        <i>(lordy at the host restoroot dot org)</i></li>
     8.7 +  <li>Eric Barboni             <i>(skygo)</i></li> 
     8.8    <li>Carel Bast               <i>(Carel dot Bast at the host nl dot compuware dot com)</i></li>
     8.9    <li>David Beer               <i>(david dot m dot beer at the host gmail dot com)</i></li>
    8.10    <li>Steve Benigan            <i>(benigan_steve at the host hotmail dot com)</i></li>
     9.1 --- a/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java	Fri Feb 03 21:42:16 2012 +0100
     9.2 +++ b/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java	Fri Feb 03 21:47:17 2012 +0100
     9.3 @@ -336,11 +336,8 @@
     9.4              if (refs == null) {
     9.5                  continue;
     9.6              }
     9.7 -            if (e.getKind() != ElementKind.PACKAGE) {
     9.8 -                ActionID id = e.getAnnotation(ActionID.class);
     9.9 -                if (id == null) {
    9.10 -                    throw new LayerGenerationException("Don't use @ActionReferences without @ActionRegistration", e, processingEnv, refs);
    9.11 -                }
    9.12 +            ActionID id = e.getAnnotation(ActionID.class);
    9.13 +            if (id != null) {
    9.14                  for (ActionReference actionReference : refs.value()) {
    9.15                      if (!actionReference.id().id().isEmpty() || !actionReference.id().category().isEmpty()) {
    9.16                          throw new LayerGenerationException("Don't specify additional id=@ActionID(...) when using @ActionID on the element", e, processingEnv, actionReference.id());
    10.1 --- a/openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionProcessorTest.java	Fri Feb 03 21:42:16 2012 +0100
    10.2 +++ b/openide.awt/test/unit/src/org/netbeans/modules/openide/awt/ActionProcessorTest.java	Fri Feb 03 21:47:17 2012 +0100
    10.3 @@ -127,7 +127,15 @@
    10.4              cnt += e.getID();
    10.5          }
    10.6      }
    10.7 -
    10.8 +    
    10.9 +    @ActionReferences({
   10.10 +        @ActionReference(
   10.11 +            path="Loaders/text/x-my/Actions", 
   10.12 +            id=@ActionID(category="System", id="org.openide.actions.OpenAction"),
   10.13 +            position=100, 
   10.14 +            separatorAfter=200
   10.15 +        )
   10.16 +    })
   10.17      public void testAlwaysEnabledAction() throws Exception {
   10.18          assertEquals("Not created yet", 0, Always.created);
   10.19          Action a = Actions.forID("Tools", "my.test.Always");
   10.20 @@ -750,7 +758,7 @@
   10.21              "import org.openide.awt.ActionReferences;\n" +
   10.22              "import java.awt.event.*;\n" +
   10.23              "@ActionReferences({\n" +
   10.24 -            "  @ActionReference(path=\"manka\", position=11, id=@ActionID(category=\"Cat\",id=\"x.y.z\"))" +
   10.25 +            "  @ActionReference(path=\"manka\", position=11)" +
   10.26              "})\n" +
   10.27              "public class A implements ActionListener {\n" +
   10.28              "    public void actionPerformed(ActionEvent e) {}" +
    11.1 --- a/openide.filesystems/src/org/openide/filesystems/MIMEResolver.java	Fri Feb 03 21:42:16 2012 +0100
    11.2 +++ b/openide.filesystems/src/org/openide/filesystems/MIMEResolver.java	Fri Feb 03 21:47:17 2012 +0100
    11.3 @@ -301,7 +301,7 @@
    11.4       * {@link MIMEResolver.ExtensionRegistration}.
    11.5       * 
    11.6       * <p>
    11.7 -     * The <code>value</code>
    11.8 +     * The <code>resource</code>
    11.9       * attribute of the annotation should be a relative reference to
   11.10       * an XML like <a href="doc-files/HOWTO-MIME.html">document</a> describing
   11.11       * the rules that will be interpreted by the mime recognizing infrastructure.
    12.1 --- a/openide.loaders/apichanges.xml	Fri Feb 03 21:42:16 2012 +0100
    12.2 +++ b/openide.loaders/apichanges.xml	Fri Feb 03 21:47:17 2012 +0100
    12.3 @@ -109,6 +109,21 @@
    12.4  <!-- ACTUAL CHANGES BEGIN HERE: -->
    12.5  
    12.6    <changes>
    12.7 +      <change id="DataObjec.Registration">
    12.8 +          <api name="loaders"/>
    12.9 +          <summary>Introduced <code>DataObject.Registration</code></summary>
   12.10 +          <version major="7" minor="36"/>
   12.11 +          <date day="23" month="1" year="2012"/>
   12.12 +          <author login="skygo"/>
   12.13 +          <compatibility addition="yes"/>
   12.14 +          <description>
   12.15 +             <p>
   12.16 +                  Introduced a new annotation for registering DataObject.
   12.17 +              </p>
   12.18 +          </description>
   12.19 +          <class package="org.openide.loaders" name="DataObject"/>
   12.20 +          <issue number="207219"/>
   12.21 +      </change>
   12.22        <change id="ToolbarPool.isFinished">
   12.23            <api name="awt"/>
   12.24            <summary><code>ToolbarPool.isFinished</code></summary>
    13.1 --- a/openide.loaders/manifest.mf	Fri Feb 03 21:42:16 2012 +0100
    13.2 +++ b/openide.loaders/manifest.mf	Fri Feb 03 21:47:17 2012 +0100
    13.3 @@ -1,6 +1,6 @@
    13.4  Manifest-Version: 1.0
    13.5  OpenIDE-Module: org.openide.loaders
    13.6 -OpenIDE-Module-Specification-Version: 7.35
    13.7 +OpenIDE-Module-Specification-Version: 7.36
    13.8  OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
    13.9  OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
   13.10  OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
    14.1 --- a/openide.loaders/nbproject/project.xml	Fri Feb 03 21:42:16 2012 +0100
    14.2 +++ b/openide.loaders/nbproject/project.xml	Fri Feb 03 21:47:17 2012 +0100
    14.3 @@ -122,7 +122,7 @@
    14.4                      <build-prerequisite/>
    14.5                      <compile-dependency/>
    14.6                      <run-dependency>
    14.7 -                        <specification-version>7.56</specification-version>
    14.8 +                        <specification-version>7.58</specification-version>
    14.9                      </run-dependency>
   14.10                  </dependency>
   14.11                  <dependency>
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/openide.loaders/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessor.java	Fri Feb 03 21:47:17 2012 +0100
    15.3 @@ -0,0 +1,202 @@
    15.4 +/*
    15.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    15.6 + *
    15.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
    15.8 + *
    15.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   15.10 + * Other names may be trademarks of their respective owners.
   15.11 + *
   15.12 + * The contents of this file are subject to the terms of either the GNU
   15.13 + * General Public License Version 2 only ("GPL") or the Common
   15.14 + * Development and Distribution License("CDDL") (collectively, the
   15.15 + * "License"). You may not use this file except in compliance with the
   15.16 + * License. You can obtain a copy of the License at
   15.17 + * http://www.netbeans.org/cddl-gplv2.html
   15.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   15.19 + * specific language governing permissions and limitations under the
   15.20 + * License.  When distributing the software, include this License Header
   15.21 + * Notice in each file and include the License file at
   15.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   15.23 + * particular file as subject to the "Classpath" exception as provided
   15.24 + * by Oracle in the GPL Version 2 section of the License file that
   15.25 + * accompanied this code. If applicable, add the following below the
   15.26 + * License Header, with the fields enclosed by brackets [] replaced by
   15.27 + * your own identifying information:
   15.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   15.29 + *
   15.30 + * If you wish your version of this file to be governed by only the CDDL
   15.31 + * or only the GPL Version 2, indicate your decision by adding
   15.32 + * "[Contributor] elects to include this software in this distribution
   15.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   15.34 + * single choice of license, a recipient has the option to distribute
   15.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   15.36 + * to extend the choice of license to its licensees as provided above.
   15.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   15.38 + * Version 2 license, then the option applies only if the new code is
   15.39 + * made subject to such option by the copyright holder.
   15.40 + *
   15.41 + * Contributor(s):
   15.42 + *
   15.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
   15.44 + */
   15.45 +package org.netbeans.modules.openide.loaders;
   15.46 +
   15.47 +import java.util.Arrays;
   15.48 +import java.util.HashSet;
   15.49 +import java.util.LinkedList;
   15.50 +import java.util.List;
   15.51 +import java.util.Set;
   15.52 +import javax.annotation.processing.Processor;
   15.53 +import javax.annotation.processing.RoundEnvironment;
   15.54 +import javax.annotation.processing.SupportedSourceVersion;
   15.55 +import javax.lang.model.SourceVersion;
   15.56 +import javax.lang.model.element.Element;
   15.57 +import javax.lang.model.element.ElementKind;
   15.58 +import javax.lang.model.element.ExecutableElement;
   15.59 +import javax.lang.model.element.Modifier;
   15.60 +import javax.lang.model.element.TypeElement;
   15.61 +import javax.lang.model.type.TypeMirror;
   15.62 +import javax.lang.model.util.ElementFilter;
   15.63 +import org.openide.filesystems.FileObject;
   15.64 +import org.openide.filesystems.annotations.LayerBuilder;
   15.65 +import org.openide.filesystems.annotations.LayerGeneratingProcessor;
   15.66 +import org.openide.filesystems.annotations.LayerGenerationException;
   15.67 +import org.openide.loaders.DataObject;
   15.68 +import org.openide.loaders.MultiFileLoader;
   15.69 +import org.openide.util.lookup.ServiceProvider;
   15.70 +
   15.71 +/**
   15.72 + *
   15.73 + * @author Eric Barboni <skygo@netbeans.org>
   15.74 + */
   15.75 +@ServiceProvider(service = Processor.class)
   15.76 +@SupportedSourceVersion(SourceVersion.RELEASE_6)
   15.77 +public class DataObjectFactoryProcessor extends LayerGeneratingProcessor {
   15.78 +
   15.79 +    @Override
   15.80 +    public Set<String> getSupportedAnnotationTypes() {
   15.81 +        return new HashSet<String>(Arrays.asList(DataObject.Registration.class.getCanonicalName()));
   15.82 +    }
   15.83 +
   15.84 +    @Override
   15.85 +    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
   15.86 +        if (roundEnv.processingOver()) {
   15.87 +            return false;
   15.88 +        }
   15.89 +        TypeMirror dataObjectType = type(DataObject.class);
   15.90 +        TypeMirror fileObjectType = type(FileObject.class);
   15.91 +        TypeMirror multiFileLoaderType = type(MultiFileLoader.class);
   15.92 +        TypeMirror dataObjectFactoryType = type(DataObject.Factory.class);
   15.93 +
   15.94 +
   15.95 +        for (Element e : roundEnv.getElementsAnnotatedWith(DataObject.Registration.class)) {
   15.96 +            DataObject.Registration dfr = e.getAnnotation(DataObject.Registration.class);
   15.97 +            if (dfr == null) {
   15.98 +                continue;
   15.99 +            }
  15.100 +            LayerBuilder builder = layer(e);
  15.101 +            //need class name to generate id and factory dataObjectClass parameter
  15.102 +            String className = processingEnv.getElementUtils().getBinaryName((TypeElement)e).toString();
  15.103 +            String factoryId = className.replace(".", "-");
  15.104 +
  15.105 +            boolean useFactory = true;
  15.106 +
  15.107 +            // test if enclosing element is of DataObject type;
  15.108 +
  15.109 +            if (isAssignable(e.asType(), dataObjectType)) {
  15.110 +                //attempt to use default factory 
  15.111 +                List<Element> ee = new LinkedList<Element>();
  15.112 +                // should be a public constructor with FileObject and MultiFileLoader as param
  15.113 +                for (ExecutableElement element : ElementFilter.constructorsIn(e.getEnclosedElements())) {
  15.114 +
  15.115 +                    if ((element.getKind() == ElementKind.CONSTRUCTOR) && (element.getModifiers().contains(Modifier.PUBLIC))) {  // found a public constructor ;                        
  15.116 +                        if ((element.getParameters().size() == 2) // parameters of constructor ok
  15.117 +                                && (isAssignable(element.getParameters().get(0).asType(), fileObjectType))
  15.118 +                                && (isAssignable(element.getParameters().get(1).asType(), multiFileLoaderType))) {
  15.119 +                            ee.add(element);
  15.120 +                        }
  15.121 +                    }
  15.122 +                }
  15.123 +                // nothing is found 
  15.124 +                if (ee.isEmpty()) {
  15.125 +                    throw new LayerGenerationException("DataObject subclass with @DataObject.Registration needs a public constructor with FileObject and MultiFileLoader parameters", e, processingEnv, dfr); // NOI18N
  15.126 +                } else {
  15.127 +                    useFactory = true;
  15.128 +                }
  15.129 +
  15.130 +            } else if (isAssignable(e.asType(), dataObjectFactoryType)) {
  15.131 +                List<Element> ee = new LinkedList<Element>();
  15.132 +                for (ExecutableElement element : ElementFilter.constructorsIn(e.getEnclosedElements())) {
  15.133 +                    if ((element.getKind() == ElementKind.CONSTRUCTOR) && (element.getModifiers().contains(Modifier.PUBLIC))) {  // found a public constructor ;                        
  15.134 +                        if ((element.getParameters().isEmpty())) {// parameters of constructor ok
  15.135 +                            ee.add(element);
  15.136 +                        }
  15.137 +                    }
  15.138 +                }
  15.139 +                if (ee.isEmpty()) {
  15.140 +                    throw new LayerGenerationException("DataObject.Factory subclass with @DataObject.Registration needs a public default constructor", e, processingEnv, dfr); // NOI18N
  15.141 +                } else {
  15.142 +                    useFactory = false;
  15.143 +                    factoryId = className.replace(".class", "").replace(".", "-");
  15.144 +                }
  15.145 +            } else {
  15.146 +                throw new LayerGenerationException("Usage @DataObject.Registration only on DataObject.Factory subclass or DataObject subclass", e, processingEnv, dfr); // NOI18N
  15.147 +            }
  15.148 +
  15.149 +            // check if mimeType annotation is set
  15.150 +            if (dfr.mimeType().length == 0) {
  15.151 +                throw new LayerGenerationException("@DataObject.Factory.Registration mimeTypes() cannot be null", e, processingEnv, dfr, "mimeTypes");
  15.152 +            }
  15.153 +            // verify if all mimeType are valid
  15.154 +            for (String aMimeType : dfr.mimeType()) {
  15.155 +                if (aMimeType.isEmpty()) {
  15.156 +                    throw new LayerGenerationException("@DataObject.Factory.Registration mimeTypes() cannot have a empty mimeType", e, processingEnv, dfr, "mimeTypes");
  15.157 +                }
  15.158 +            }
  15.159 +
  15.160 +
  15.161 +            for (String aMimeType : dfr.mimeType()) {
  15.162 +                LayerBuilder.File f = builder.file("Loaders/" + aMimeType + "/Factories/" + factoryId + ".instance");
  15.163 +
  15.164 +                // iconBase is optional but if set then shoud be in classpath
  15.165 +                if (dfr.iconBase().length() > 0) {
  15.166 +                    builder.validateResource(dfr.iconBase(), e.getEnclosingElement(), dfr, "icon", true);
  15.167 +                    f.stringvalue("iconBase", dfr.iconBase());
  15.168 +                }
  15.169 +                // position LayerBuilder 
  15.170 +                f.position(dfr.position());
  15.171 +
  15.172 +                if (!dfr.displayName().isEmpty()) {
  15.173 +                    f.bundlevalue("displayName", dfr.displayName(), dfr, "displayName");
  15.174 +                }
  15.175 +
  15.176 +                if (useFactory) {
  15.177 +                    f.methodvalue("instanceCreate", "org.openide.loaders.DataLoaderPool", "factory");
  15.178 +                    f.stringvalue("dataObjectClass", className);
  15.179 +                    // if factory mimetype is needed otherwise not
  15.180 +                    f.stringvalue("mimeType", aMimeType);
  15.181 +
  15.182 +                }
  15.183 +                f.write();
  15.184 +            }
  15.185 +
  15.186 +        }
  15.187 +
  15.188 +        return true;
  15.189 +    }
  15.190 +
  15.191 +    // reuse from Action Processor
  15.192 +    private TypeMirror type(Class<?> type) {
  15.193 +        final TypeElement e = processingEnv.getElementUtils().getTypeElement(type.getCanonicalName());
  15.194 +        return e == null ? null : e.asType();
  15.195 +    }
  15.196 +
  15.197 +    // reuse from Action Processor
  15.198 +    private boolean isAssignable(TypeMirror first, TypeMirror snd) {
  15.199 +        if (snd == null) {
  15.200 +            return false;
  15.201 +        } else {
  15.202 +            return processingEnv.getTypeUtils().isAssignable(first, snd);
  15.203 +        }
  15.204 +    }
  15.205 +}
    16.1 --- a/openide.loaders/src/org/openide/loaders/DataLoaderPool.java	Fri Feb 03 21:42:16 2012 +0100
    16.2 +++ b/openide.loaders/src/org/openide/loaders/DataLoaderPool.java	Fri Feb 03 21:47:17 2012 +0100
    16.3 @@ -640,7 +640,7 @@
    16.4       *   &lt;attr name="instanceCreate" methodvalue="org.openide.loaders.DataLoaderPool.factory"/&gt;
    16.5       *   &lt;attr name="dataObjectClass" stringvalue="org.your.pkg.YourDataObject"/&gt;
    16.6       *   &lt;attr name="mimeType" stringvalue="yourmime/type"/&gt;
    16.7 -     *   &lt;attr name="SystemFileSystem.localizingIcon" stringvalue="org/your/pkg/YourDataObject.png"/&gt;
    16.8 +     *   &lt;attr name="iconBase" stringvalue="org/your/pkg/YourDataObject.png"/&gt;
    16.9       * &lt;/file&gt;
   16.10       * </pre>
   16.11       * @param clazz the class of the data object to create. Must have appropriate
    17.1 --- a/openide.loaders/src/org/openide/loaders/DataObject.java	Fri Feb 03 21:42:16 2012 +0100
    17.2 +++ b/openide.loaders/src/org/openide/loaders/DataObject.java	Fri Feb 03 21:47:17 2012 +0100
    17.3 @@ -49,6 +49,10 @@
    17.4  import java.awt.Graphics;
    17.5  import java.beans.*;
    17.6  import java.io.*;
    17.7 +import java.lang.annotation.ElementType;
    17.8 +import java.lang.annotation.Retention;
    17.9 +import java.lang.annotation.RetentionPolicy;
   17.10 +import java.lang.annotation.Target;
   17.11  import java.text.DateFormat;
   17.12  import java.util.*;
   17.13  import java.util.logging.Level;
   17.14 @@ -1165,6 +1169,43 @@
   17.15          public void removePropertyChangeListener (PropertyChangeListener l);
   17.16      }
   17.17  
   17.18 +    /** Registers new file type into the system.
   17.19 +     * Apply this annotation to a class that extends either 
   17.20 +     * (@link org.openide.loaders.DataObject.Factory) or 
   17.21 +     *(@link org.openide.loaders.DataObject). This methods generates
   17.22 +     * a layer registration as described by {@link DataLoaderPool#factory(java.lang.Class, java.lang.String, java.awt.Image)}.
   17.23 +     * 
   17.24 +     * @since 7.36
   17.25 +     */
   17.26 +    @Retention(RetentionPolicy.SOURCE)
   17.27 +    @Target({ElementType.TYPE})
   17.28 +    public static @interface Registration {
   17.29 +        /**
   17.30 +         * Mime type or list of mime types to recognize. Use 
   17.31 +         * {@link MIMEResolver.ExtensionRegistration} and co. to assign
   17.32 +         * a mime types to {@link FileObject files} in the system.
   17.33 +         */
   17.34 +        String[] mimeType();
   17.35 +
   17.36 +        /**
   17.37 +         * Display name for the file type created by this registration.
   17.38 +         */
   17.39 +        String displayName() default "";
   17.40 +
   17.41 +        /**
   17.42 +         * Path to icon to be used by default for nodes created by
   17.43 +         * this registration. 
   17.44 +         */
   17.45 +        String iconBase() default "";
   17.46 +
   17.47 +        /**
   17.48 +         * Position of the registration among other {@link DataObject.Factory 
   17.49 +         * factories} registered for the given
   17.50 +         * {@link #mimeType() mime type}.
   17.51 +         */
   17.52 +        int position() default Integer.MAX_VALUE;
   17.53 +    }
   17.54 +    
   17.55      /** Registry of modified data objects.
   17.56       * The registry permits attaching of a change listener
   17.57      * to be informed when the count of modified objects changes.
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/DataObjectFactoryProcessorTest.java	Fri Feb 03 21:47:17 2012 +0100
    18.3 @@ -0,0 +1,316 @@
    18.4 +/*
    18.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    18.6 + *
    18.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
    18.8 + *
    18.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   18.10 + * Other names may be trademarks of their respective owners.
   18.11 + *
   18.12 + * The contents of this file are subject to the terms of either the GNU
   18.13 + * General Public License Version 2 only ("GPL") or the Common
   18.14 + * Development and Distribution License("CDDL") (collectively, the
   18.15 + * "License"). You may not use this file except in compliance with the
   18.16 + * License. You can obtain a copy of the License at
   18.17 + * http://www.netbeans.org/cddl-gplv2.html
   18.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   18.19 + * specific language governing permissions and limitations under the
   18.20 + * License.  When distributing the software, include this License Header
   18.21 + * Notice in each file and include the License file at
   18.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   18.23 + * particular file as subject to the "Classpath" exception as provided
   18.24 + * by Oracle in the GPL Version 2 section of the License file that
   18.25 + * accompanied this code. If applicable, add the following below the
   18.26 + * License Header, with the fields enclosed by brackets [] replaced by
   18.27 + * your own identifying information:
   18.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   18.29 + *
   18.30 + * If you wish your version of this file to be governed by only the CDDL
   18.31 + * or only the GPL Version 2, indicate your decision by adding
   18.32 + * "[Contributor] elects to include this software in this distribution
   18.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   18.34 + * single choice of license, a recipient has the option to distribute
   18.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   18.36 + * to extend the choice of license to its licensees as provided above.
   18.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   18.38 + * Version 2 license, then the option applies only if the new code is
   18.39 + * made subject to such option by the copyright holder.
   18.40 + *
   18.41 + * Contributor(s):
   18.42 + *
   18.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
   18.44 + */
   18.45 +package org.netbeans.modules.openide.loaders;
   18.46 +
   18.47 +import java.awt.GraphicsEnvironment;
   18.48 +import java.io.ByteArrayOutputStream;
   18.49 +import java.io.IOException;
   18.50 +import java.io.OutputStream;
   18.51 +import java.io.PrintStream;
   18.52 +import org.netbeans.junit.NbTestCase;
   18.53 +import org.netbeans.modules.openide.loaders.data.DoFPDataObject;
   18.54 +import org.openide.filesystems.FileLock;
   18.55 +import org.openide.filesystems.FileObject;
   18.56 +import org.openide.filesystems.FileUtil;
   18.57 +import org.openide.loaders.DataObject;
   18.58 +import org.openide.util.test.AnnotationProcessorTestUtils;
   18.59 +
   18.60 +/**
   18.61 + *
   18.62 + * @author Eric Barboni <skygo@netbeans.org>
   18.63 + */
   18.64 +public class DataObjectFactoryProcessorTest extends NbTestCase {
   18.65 +// XXX inner class for DataObject fail
   18.66 +//
   18.67 +
   18.68 +    static {
   18.69 +        System.setProperty("java.awt.headless", "true");
   18.70 +    }
   18.71 +
   18.72 +    public DataObjectFactoryProcessorTest(String n) {
   18.73 +        super(n);
   18.74 +    }
   18.75 +
   18.76 +    @Override
   18.77 +    protected boolean runInEQ() {
   18.78 +        return true;
   18.79 +    }
   18.80 +
   18.81 +    @Override
   18.82 +    protected void setUp() throws Exception {
   18.83 +        super.setUp();
   18.84 +        createMIMEs();
   18.85 +    }
   18.86 +
   18.87 +// Several test for javac
   18.88 +    public void testConstructorWrongType() throws IOException {
   18.89 +        clearWorkDir();
   18.90 +        assertTrue("Headless run", GraphicsEnvironment.isHeadless());
   18.91 +        AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.A",
   18.92 +                "import org.openide.loaders.DataObject;\n"
   18.93 +                + "@DataObject.Registration(mimeType=\"text/testa\")"
   18.94 +                + "public class A {\n"
   18.95 +                + "    A() {}"
   18.96 +                + "}\n");
   18.97 +        ByteArrayOutputStream os = new ByteArrayOutputStream();
   18.98 +        boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
   18.99 +        assertFalse("Compilation has to fail:\n" + os, r);
  18.100 +    }
  18.101 +
  18.102 +    public void testWrongAmountofParameterInConstructorTypeDataObject() throws IOException {
  18.103 +        {
  18.104 +            clearWorkDir();
  18.105 +            assertTrue("Headless run", GraphicsEnvironment.isHeadless());
  18.106 +            AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.B",
  18.107 +                    DUMMYCLASSIMPORTPART
  18.108 +                    + "@DataObject.Registration(mimeType = \"text/testb\")"
  18.109 +                    + DUMMYCLASSDEFPART
  18.110 +                    + "public B(int a,int b, int c){}"
  18.111 +                    + DUMMYCLASSOVERRIDEPART);
  18.112 +
  18.113 +            ByteArrayOutputStream os = new ByteArrayOutputStream();
  18.114 +            boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
  18.115 +            assertFalse("Compilation has to fail:\n" + os, r);
  18.116 +        }
  18.117 +        {
  18.118 +            clearWorkDir();
  18.119 +            assertTrue("Headless run", GraphicsEnvironment.isHeadless());
  18.120 +            AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.B",
  18.121 +                    DUMMYCLASSIMPORTPART
  18.122 +                    + "@DataObject.Registration(mimeType = \"text/testb\")"
  18.123 +                    + DUMMYCLASSDEFPART
  18.124 +                    + "public B(){}"
  18.125 +                    + DUMMYCLASSOVERRIDEPART);
  18.126 +
  18.127 +            ByteArrayOutputStream os = new ByteArrayOutputStream();
  18.128 +            boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
  18.129 +            assertFalse("Compilation has to fail:\n" + os, r);
  18.130 +        }
  18.131 +    }
  18.132 +
  18.133 +    public void testConstructorTypeDataObject() throws IOException {
  18.134 +        {
  18.135 +            clearWorkDir();
  18.136 +            assertTrue("Headless run", GraphicsEnvironment.isHeadless());
  18.137 +            AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.B",
  18.138 +                    DUMMYCLASSIMPORTPART
  18.139 +                    + "@DataObject.Registration(mimeType = \"text/testb\")"
  18.140 +                    + DUMMYCLASSDEFPART
  18.141 +                    + "public B(FileObject fo,DataLoader dol)throws DataObjectExistsException {        super(fo,dol);    }"
  18.142 +                    + DUMMYCLASSOVERRIDEPART);
  18.143 +
  18.144 +
  18.145 +
  18.146 +            ByteArrayOutputStream os = new ByteArrayOutputStream();
  18.147 +            boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
  18.148 +            assertFalse("Compilation has to fail:\n" + os, r);
  18.149 +        }
  18.150 +        {
  18.151 +            clearWorkDir();
  18.152 +            assertTrue("Headless run", GraphicsEnvironment.isHeadless());
  18.153 +            AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.B",
  18.154 +                    DUMMYCLASSIMPORTPART
  18.155 +                    + "@DataObject.Registration(mimeType = \"text/testb\")"
  18.156 +                    + DUMMYCLASSDEFPART
  18.157 +                    + "public B(FileObject fo,MultiFileLoader dol)throws DataObjectExistsException {        super(fo,dol);    }"
  18.158 +                    + DUMMYCLASSOVERRIDEPART);
  18.159 +
  18.160 +
  18.161 +
  18.162 +            ByteArrayOutputStream os = new ByteArrayOutputStream();
  18.163 +            boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
  18.164 +            assertTrue("Compilation has to succed:\n" + os, r);
  18.165 +        }
  18.166 +    }
  18.167 +
  18.168 +    public void testConstructorTypeDataObjectFactory() throws IOException {
  18.169 +        {
  18.170 +            clearWorkDir();
  18.171 +            assertTrue("Headless run", GraphicsEnvironment.isHeadless());
  18.172 +            AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.B",
  18.173 +                    DUMMYFACTORYCLASSIMPORTPART
  18.174 +                    + "@DataObject.Registration(mimeType = \"text/testb\")"
  18.175 +                    + DUMMYFACTORYCLASSDEFPART
  18.176 +                    + "public B() { super( \"test\"); }"
  18.177 +                    + DUMMYFACTORYCLASSOVERRIDEPART);
  18.178 +
  18.179 +
  18.180 +
  18.181 +            ByteArrayOutputStream os = new ByteArrayOutputStream();
  18.182 +            boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
  18.183 +            assertTrue("Compilation has to succed:\n" + os, r);
  18.184 +        }
  18.185 +        {
  18.186 +            clearWorkDir();
  18.187 +            assertTrue("Headless run", GraphicsEnvironment.isHeadless());
  18.188 +            AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.B",
  18.189 +                    DUMMYFACTORYCLASSIMPORTPART
  18.190 +                    + "@DataObject.Registration(mimeType = \"text/testb\")"
  18.191 +                    + DUMMYFACTORYCLASSDEFPART
  18.192 +                    + "protected B() { super( \"test\"); }"
  18.193 +                    + DUMMYFACTORYCLASSOVERRIDEPART);
  18.194 +            ByteArrayOutputStream os = new ByteArrayOutputStream();
  18.195 +            boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
  18.196 +            assertFalse("Compilation has to fail:\n" + os, r);
  18.197 +        }
  18.198 +    }
  18.199 +
  18.200 +    // use external DoFP* class and check if registration is good
  18.201 +    public void testSeveralMimeType() throws IOException {
  18.202 +        clearWorkDir();
  18.203 +        {
  18.204 +            FileObject fo = FileUtil.getConfigFile(
  18.205 +                    "Loaders/text/test1/Factories/" + DoFPDataObject.class.getName().replace(".", "-") + ".instance");
  18.206 +            assertNotNull("File found", fo);
  18.207 +
  18.208 +            assertEquals("Position Ok", 3565, fo.getAttribute("position"));
  18.209 +            assertEquals("Label Ok", "labeltest", fo.getAttribute("displayName"));
  18.210 +            assertEquals("MimeOk", "text/test1", fo.getAttribute("mimeType"));
  18.211 +            Object icon = fo.getAttribute("iconBase");
  18.212 +            assertEquals("Icon found", "org/openide/loaders/unknow.gif", icon);
  18.213 +            assertEquals("DataObjectClass found", DoFPDataObject.class.getName(), fo.getAttribute("dataObjectClass"));
  18.214 +
  18.215 +        }
  18.216 +
  18.217 +    }
  18.218 +
  18.219 +// use external DoFP* class and their registration to test if dataobject return is good
  18.220 +    public void testDataLoad() throws Exception {
  18.221 +        // be sure mime are correct
  18.222 +        {
  18.223 +            FileObject fo = createXmlFile("sdfsdf", ".tt1");
  18.224 +            assertEquals("text/test1", fo.getMIMEType());
  18.225 +            DataObject find = DataObject.find(fo);
  18.226 +            assertEquals("DataLoader type", DoFPDataObject.class, find.getClass());
  18.227 +        }
  18.228 +        {
  18.229 +            FileObject fo = createXmlFile("sdfsdf", ".tt2");
  18.230 +            assertEquals("text/test2", fo.getMIMEType());
  18.231 +            DataObject find = DataObject.find(fo);
  18.232 +            assertEquals("DataLoader type", DoFPDataObject.class, find.getClass());
  18.233 +        }
  18.234 +        {
  18.235 +            FileObject fo = createXmlFile("sdfsdf", ".tt3");
  18.236 +            assertEquals("text/test3", fo.getMIMEType());
  18.237 +            // XXX DoFPCustomLoader not loaded cannot assert for loader
  18.238 +        }
  18.239 +    }
  18.240 +
  18.241 +    // utility method inspired by FsMimeResolverTest
  18.242 +    private void createMIMEs() throws Exception {
  18.243 +// create  resolver to get tt1 extension resolve as test/test1 and do so for 3 different
  18.244 +        FileObject resolver = FileUtil.createData(FileUtil.getConfigRoot(), "Services/MIMEResolver/resolver.xml");
  18.245 +        OutputStream os = resolver.getOutputStream();
  18.246 +        PrintStream ps = new PrintStream(os);
  18.247 +        ps.println("<!DOCTYPE MIME-resolver PUBLIC '-//NetBeans//DTD MIME Resolver 1.0//EN' 'http://www.netbeans.org/dtds/mime-resolver-1_0.dtd'>");
  18.248 +        ps.println("<MIME-resolver>");
  18.249 +        for (int i = 1; i < 4; i++) {
  18.250 +            ps.println(" <file>");
  18.251 +            ps.println("  <ext name=\"tt" + i + "\"/>");
  18.252 +            ps.println("    <resolver mime=\"text/test" + i + "\"/>");
  18.253 +            ps.println(" </file>");
  18.254 +        }
  18.255 +        ps.println("</MIME-resolver>");
  18.256 +        os.close();
  18.257 +    }
  18.258 +
  18.259 +    private FileObject createXmlFile(String content, String ext) throws Exception {
  18.260 +        FileObject file = FileUtil.createMemoryFileSystem().getRoot().createData("file" + ext);
  18.261 +        FileLock lock = file.lock();
  18.262 +        try {
  18.263 +            OutputStream out = file.getOutputStream(lock);
  18.264 +            try {
  18.265 +                out.write(content.getBytes());
  18.266 +            } finally {
  18.267 +                out.close();
  18.268 +            }
  18.269 +        } finally {
  18.270 +            lock.releaseLock();
  18.271 +        }
  18.272 +        return file;
  18.273 +    }
  18.274 +    //---------------------- class text part DataObject
  18.275 +    String DUMMYCLASSIMPORTPART = "import java.io.IOException;"
  18.276 +            + "import org.openide.filesystems.FileObject;"
  18.277 +            + "import org.openide.loaders.DataFolder;"
  18.278 +            + "import org.openide.loaders.DataObject;"
  18.279 +            + "import org.openide.loaders.MultiFileLoader;"
  18.280 +            + "import org.openide.loaders.DataObjectExistsException;"
  18.281 +            + "import org.openide.loaders.DataLoader;"
  18.282 +            + "import org.openide.util.HelpCtx;";
  18.283 +    String DUMMYCLASSDEFPART = "public class B extends DataObject {";
  18.284 +    String OVERRIDE = "@Override\n";
  18.285 +    String DUMMYRUNTIMEEXCEPTION = " throw new RuntimeException(\"Not implemented yet.\");";
  18.286 +    String DUMMYCLASSOVERRIDEPART =
  18.287 +            ""
  18.288 +            + OVERRIDE + "public boolean isDeleteAllowed() {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.289 +            + OVERRIDE + "public boolean isCopyAllowed() {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.290 +            + OVERRIDE + "public boolean isMoveAllowed() {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.291 +            + OVERRIDE + "public boolean isRenameAllowed() {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.292 +            + OVERRIDE + "public HelpCtx getHelpCtx() {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.293 +            + OVERRIDE + "protected DataObject handleCopy(DataFolder f) throws IOException {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.294 +            + OVERRIDE + "protected void handleDelete() throws IOException {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.295 +            + OVERRIDE + "protected FileObject handleRename(String name) throws IOException {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.296 +            + OVERRIDE + "protected FileObject handleMove(DataFolder df) throws IOException {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.297 +            + OVERRIDE + "protected DataObject handleCreateFromTemplate(DataFolder df, String name) throws IOException {" + DUMMYRUNTIMEEXCEPTION + "}"
  18.298 +            + "}\n";
  18.299 +    // ---------------------- class text part DataObject.Factory
  18.300 +    String DUMMYFACTORYCLASSIMPORTPART = "   import java.io.IOException;"
  18.301 +            + "import org.openide.filesystems.FileObject;"
  18.302 +            + "import org.openide.loaders.DataObject;"
  18.303 +            + "import org.openide.loaders.MultiDataObject;"
  18.304 +            + "import org.openide.loaders.DataObjectExistsException;"
  18.305 +            + "import org.openide.loaders.UniFileLoader;";
  18.306 +//@DataObject.Registration(mimeType = "text/test3", position = 300)
  18.307 +    String DUMMYFACTORYCLASSDEFPART = "public class B extends UniFileLoader {";
  18.308 +
  18.309 +    /*
  18.310 +     * public DoFPCustomLoader() {
  18.311 +     * super("org.netbeans.modules.openide.loaders.DoFPDataObjectCustomLoader");
  18.312 +     * }
  18.313 +     */
  18.314 +    String DUMMYFACTORYCLASSOVERRIDEPART = OVERRIDE
  18.315 +            + "  protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {"
  18.316 +            + DUMMYRUNTIMEEXCEPTION
  18.317 +            + "   }"
  18.318 +            + "}";
  18.319 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPCustomLoader.java	Fri Feb 03 21:47:17 2012 +0100
    19.3 @@ -0,0 +1,66 @@
    19.4 +/*
    19.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    19.6 + *
    19.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
    19.8 + *
    19.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   19.10 + * Other names may be trademarks of their respective owners.
   19.11 + *
   19.12 + * The contents of this file are subject to the terms of either the GNU
   19.13 + * General Public License Version 2 only ("GPL") or the Common
   19.14 + * Development and Distribution License("CDDL") (collectively, the
   19.15 + * "License"). You may not use this file except in compliance with the
   19.16 + * License. You can obtain a copy of the License at
   19.17 + * http://www.netbeans.org/cddl-gplv2.html
   19.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   19.19 + * specific language governing permissions and limitations under the
   19.20 + * License.  When distributing the software, include this License Header
   19.21 + * Notice in each file and include the License file at
   19.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   19.23 + * particular file as subject to the "Classpath" exception as provided
   19.24 + * by Oracle in the GPL Version 2 section of the License file that
   19.25 + * accompanied this code. If applicable, add the following below the
   19.26 + * License Header, with the fields enclosed by brackets [] replaced by
   19.27 + * your own identifying information:
   19.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   19.29 + *
   19.30 + * If you wish your version of this file to be governed by only the CDDL
   19.31 + * or only the GPL Version 2, indicate your decision by adding
   19.32 + * "[Contributor] elects to include this software in this distribution
   19.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   19.34 + * single choice of license, a recipient has the option to distribute
   19.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   19.36 + * to extend the choice of license to its licensees as provided above.
   19.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   19.38 + * Version 2 license, then the option applies only if the new code is
   19.39 + * made subject to such option by the copyright holder.
   19.40 + *
   19.41 + * Contributor(s):
   19.42 + *
   19.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
   19.44 + */
   19.45 +package org.netbeans.modules.openide.loaders.data;
   19.46 +
   19.47 +import java.io.IOException;
   19.48 +import org.openide.filesystems.FileObject;
   19.49 +import org.openide.loaders.DataObject;
   19.50 +import org.openide.loaders.DataObjectExistsException;
   19.51 +import org.openide.loaders.UniFileLoader;
   19.52 +
   19.53 +/**
   19.54 + * @see DataObjectFactoryProcessorTest
   19.55 + * @author Eric Barboni <skygo@netbeans.org>
   19.56 + */
   19.57 +@DataObject.Registration(mimeType = "text/test3", position = 300)
   19.58 +public class DoFPCustomLoader extends UniFileLoader {
   19.59 +
   19.60 +    public DoFPCustomLoader() {
   19.61 +        super("org.netbeans.modules.openide.loaders.data.DoFPDataObjectCustomLoader");
   19.62 +    }
   19.63 +
   19.64 +    @Override
   19.65 +    protected DoFPDataObjectCustomLoader createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
   19.66 +        DoFPDataObjectCustomLoader obj = new DoFPDataObjectCustomLoader(primaryFile, this);
   19.67 +        return obj;
   19.68 +    }
   19.69 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPDataObject.java	Fri Feb 03 21:47:17 2012 +0100
    20.3 @@ -0,0 +1,113 @@
    20.4 +/*
    20.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    20.6 + *
    20.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
    20.8 + *
    20.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   20.10 + * Other names may be trademarks of their respective owners.
   20.11 + *
   20.12 + * The contents of this file are subject to the terms of either the GNU
   20.13 + * General Public License Version 2 only ("GPL") or the Common
   20.14 + * Development and Distribution License("CDDL") (collectively, the
   20.15 + * "License"). You may not use this file except in compliance with the
   20.16 + * License. You can obtain a copy of the License at
   20.17 + * http://www.netbeans.org/cddl-gplv2.html
   20.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   20.19 + * specific language governing permissions and limitations under the
   20.20 + * License.  When distributing the software, include this License Header
   20.21 + * Notice in each file and include the License file at
   20.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   20.23 + * particular file as subject to the "Classpath" exception as provided
   20.24 + * by Oracle in the GPL Version 2 section of the License file that
   20.25 + * accompanied this code. If applicable, add the following below the
   20.26 + * License Header, with the fields enclosed by brackets [] replaced by
   20.27 + * your own identifying information:
   20.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   20.29 + *
   20.30 + * If you wish your version of this file to be governed by only the CDDL
   20.31 + * or only the GPL Version 2, indicate your decision by adding
   20.32 + * "[Contributor] elects to include this software in this distribution
   20.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   20.34 + * single choice of license, a recipient has the option to distribute
   20.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   20.36 + * to extend the choice of license to its licensees as provided above.
   20.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   20.38 + * Version 2 license, then the option applies only if the new code is
   20.39 + * made subject to such option by the copyright holder.
   20.40 + *
   20.41 + * Contributor(s):
   20.42 + *
   20.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
   20.44 + */
   20.45 +package org.netbeans.modules.openide.loaders.data;
   20.46 +
   20.47 +import java.io.IOException;
   20.48 +import org.openide.filesystems.FileObject;
   20.49 +import org.openide.loaders.DataFolder;
   20.50 +import org.openide.loaders.DataObject;
   20.51 +import org.openide.loaders.DataObjectExistsException;
   20.52 +import org.openide.loaders.MultiFileLoader;
   20.53 +import org.openide.util.HelpCtx;
   20.54 +
   20.55 +/**
   20.56 + * @see DataObjectFactoryProcessorTest
   20.57 + * @author Eric Barboni <skygo@netbeans.org>
   20.58 + */
   20.59 +@DataObject.Registration(mimeType =  {"text/test1","text/test2"}, displayName = "labeltest", position = 3565, iconBase = "org/openide/loaders/unknow.gif")
   20.60 +public class DoFPDataObject extends DataObject {
   20.61 +
   20.62 +    public DoFPDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException {
   20.63 +        super(pf, loader);
   20.64 +    }
   20.65 +
   20.66 +    @Override
   20.67 +    public boolean isDeleteAllowed() {
   20.68 +        throw new UnsupportedOperationException("Not supported yet.");
   20.69 +    }
   20.70 +
   20.71 +    @Override
   20.72 +    public boolean isCopyAllowed() {
   20.73 +        throw new UnsupportedOperationException("Not supported yet.");
   20.74 +    }
   20.75 +
   20.76 +    @Override
   20.77 +    public boolean isMoveAllowed() {
   20.78 +        throw new UnsupportedOperationException("Not supported yet.");
   20.79 +    }
   20.80 +
   20.81 +    @Override
   20.82 +    public boolean isRenameAllowed() {
   20.83 +        throw new UnsupportedOperationException("Not supported yet.");
   20.84 +    }
   20.85 +
   20.86 +    @Override
   20.87 +    public HelpCtx getHelpCtx() {
   20.88 +        throw new UnsupportedOperationException("Not supported yet.");
   20.89 +    }
   20.90 +
   20.91 +    @Override
   20.92 +    protected DataObject handleCopy(DataFolder f) throws IOException {
   20.93 +        throw new UnsupportedOperationException("Not supported yet.");
   20.94 +    }
   20.95 +
   20.96 +    @Override
   20.97 +    protected void handleDelete() throws IOException {
   20.98 +        throw new UnsupportedOperationException("Not supported yet.");
   20.99 +    }
  20.100 +
  20.101 +    @Override
  20.102 +    protected FileObject handleRename(String name) throws IOException {
  20.103 +        throw new UnsupportedOperationException("Not supported yet.");
  20.104 +    }
  20.105 +
  20.106 +    @Override
  20.107 +    protected FileObject handleMove(DataFolder df) throws IOException {
  20.108 +        throw new UnsupportedOperationException("Not supported yet.");
  20.109 +    }
  20.110 +
  20.111 +    @Override
  20.112 +    protected DataObject handleCreateFromTemplate(DataFolder df, String name) throws IOException {
  20.113 +        throw new UnsupportedOperationException("Not supported yet.");
  20.114 +    }
  20.115 +    
  20.116 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/openide.loaders/test/unit/src/org/netbeans/modules/openide/loaders/data/DoFPDataObjectCustomLoader.java	Fri Feb 03 21:47:17 2012 +0100
    21.3 @@ -0,0 +1,59 @@
    21.4 +/*
    21.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    21.6 + *
    21.7 + * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
    21.8 + *
    21.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   21.10 + * Other names may be trademarks of their respective owners.
   21.11 + *
   21.12 + * The contents of this file are subject to the terms of either the GNU
   21.13 + * General Public License Version 2 only ("GPL") or the Common
   21.14 + * Development and Distribution License("CDDL") (collectively, the
   21.15 + * "License"). You may not use this file except in compliance with the
   21.16 + * License. You can obtain a copy of the License at
   21.17 + * http://www.netbeans.org/cddl-gplv2.html
   21.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   21.19 + * specific language governing permissions and limitations under the
   21.20 + * License.  When distributing the software, include this License Header
   21.21 + * Notice in each file and include the License file at
   21.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   21.23 + * particular file as subject to the "Classpath" exception as provided
   21.24 + * by Oracle in the GPL Version 2 section of the License file that
   21.25 + * accompanied this code. If applicable, add the following below the
   21.26 + * License Header, with the fields enclosed by brackets [] replaced by
   21.27 + * your own identifying information:
   21.28 + * "Portions Copyrighted [year] [name of copyright owner]"
   21.29 + *
   21.30 + * If you wish your version of this file to be governed by only the CDDL
   21.31 + * or only the GPL Version 2, indicate your decision by adding
   21.32 + * "[Contributor] elects to include this software in this distribution
   21.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
   21.34 + * single choice of license, a recipient has the option to distribute
   21.35 + * your version of this file under either the CDDL, the GPL Version 2 or
   21.36 + * to extend the choice of license to its licensees as provided above.
   21.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
   21.38 + * Version 2 license, then the option applies only if the new code is
   21.39 + * made subject to such option by the copyright holder.
   21.40 + *
   21.41 + * Contributor(s):
   21.42 + *
   21.43 + * Portions Copyrighted 2012 Sun Microsystems, Inc.
   21.44 + */
   21.45 +package org.netbeans.modules.openide.loaders.data;
   21.46 +
   21.47 +import org.netbeans.modules.openide.loaders.DataObjectFactoryProcessorTest;
   21.48 +import org.openide.filesystems.FileObject;
   21.49 +import org.openide.loaders.DataObjectExistsException;
   21.50 +import org.openide.loaders.MultiDataObject;
   21.51 +import org.openide.loaders.MultiFileLoader;
   21.52 +
   21.53 +/**
   21.54 + * @see DataObjectFactoryProcessorTest
   21.55 + * @author Eric Barboni <skygo@netbeans.org>
   21.56 + */
   21.57 +public class DoFPDataObjectCustomLoader extends MultiDataObject {
   21.58 +
   21.59 +    public DoFPDataObjectCustomLoader(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException {
   21.60 +        super(pf, loader);
   21.61 +    }
   21.62 +}