<?xml version="1.0" encoding="UTF-8"?>
<!--
The contents of this file are subject to the terms of the Common Development
and Distribution License (the License). You may not use this file except in
compliance with the License.

You can obtain a copy of the License at http://www.netbeans.org/cddl.html
or http://www.netbeans.org/cddl.txt.

When distributing Covered Code, include this CDDL Header Notice in each file
and include the License file at http://www.netbeans.org/cddl.txt.
If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"

The Original Software is NetBeans. The Initial Developer of the Original
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
Microsystems, Inc. All Rights Reserved.
-->
<!DOCTYPE api-answers PUBLIC "-//NetBeans//DTD Arch Answers//EN" "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd" [
  <!ENTITY api-questions SYSTEM "../../nbbuild/antsrc/org/netbeans/nbbuild/Arch-api-questions.xml">
]>

<api-answers
  question-version="1.13"
  module="Loaders"
  author="dstrupl@netbeans.org"
>

  &api-questions;



<!--
        <question id="arch-what">
            What is this project good for?
            <hint>
            Please provide here a few lines describing the project, 
            what problem it should solve, provide links to documentation, 
            specifications, etc.
            </hint>
        </question>
-->
<answer id="arch-what">
    In summary, the <api name="LoadersAPI" group="java" type="export" category="official" url="@TOP@org/openide/loaders/doc-files/api.html" />
    is responsible for scanning files in a directory on disk, 
    weeding out irrelevant files of no interest to the IDE, 
    and grouping the rest into logical chunks, or just determining 
    what type of data each represents. It does this scanning by asking each registered 
    data loader whether or not the given file(s) should be handled. The first 
    loader to recognize a file takes ownership of it, and creates a matching data object to represent it to the rest of the IDE.
</answer>

<answer id="arch-usecases" >
    A lot of usecases is described <a href="@TOP@/org/openide/loaders/doc-files/api.html" >in the javadoc</a>. Here 
    is the list of some faqs:
    
    <usecase id="add-action-to-folder" name="How to add action to folder's popup menu?" >
    <api name="Loaders-folder-any-Actions" category="stable" group="layer" type="export" >
    The actions that the default folder loader shows in its popup menu are read from
    a layer folder <code>Loaders/folder/any/Actions</code>
    so if any module wishes
    to extend, hide or reorder some of them it can just register its actions there.</api> 
    As code like this does:
    <pre>
    &lt;folder name="Loaders" &gt;
        &lt;folder name="folder" &gt;
            &lt;folder name="any" &gt;
                &lt;folder name="Actions" &gt;
                    &lt;file name="org-mymodule-MyAction.instance" &gt;
                        &lt;attr name="instanceCreate" stringvalue="org.mymodule.MyAction" /&gt;
                    &lt;/file&gt;
                &lt;/folder&gt;
            &lt;/folder&gt;
        &lt;/folder&gt;
    &lt;/folder&gt;
    </pre>
    As described in general <a href="@org-openide-actions@/org/openide/actions/doc-files/api.html#adv-install">
    actions registration tutorial</a>. 
    <p/>
    This functionality is available since version 5.0 of the loaders module. Please use
    <code>OpenIDE-Module-Module-Dependencies: org.openide.loaders > 5.0</code> in your
    module dependencies. 
    <p>
        In version 5.8 all the standard loaders were changed to read actions
        from layer:
    </p>
    <ul>
        <li><api name="Loaders-text-xml-Actions" category="stable" group="layer" type="export" >
        The actions that the standard XML loader shows in its popup menu are read from
        a layer folder <code>Loaders/text/xml/Actions</code></api></li>
        
        <li><api name="Loaders-content-unknown-Actions" category="stable" group="layer" type="export" >
        The actions that the loader for unrecognized files shows in its popup menu are read from
        a layer folder <code>Loaders/content/unknown/Actions</code></api></li>
        
        <li><api name="Loaders-application-x-nbsettings-Actions" category="stable" group="layer" type="export" >
        The actions that the loader for instance and settings files shows in its popup menu are read from
        a layer folder <code>Loaders/application/x-nbsettings/Actions</code></api></li>
    </ul>
    </usecase>

    <usecase id="let-others-to-add-actions-to-loader" name="How to allow others to enhance actions of your loader?" >
    If you want other modules to enhance or modify actions that are visible on 
    <code>DataObject</code>s produced by your <code>DataLoader</code> and you
    are either using <code>DataNode</code> or its subclass, you can just override
    <code>protected String actionsContext()</code> method to return non-null
    location of context in layers from where to read the actions.
    <p/>
    The usual value should match <code>Loaders/mime/type/Actions</code> scheme, 
    for example java is using <code>Loaders/text/x-java/Actions</code>, but 
    the name can be arbitrary.
    <p/>
    This functionality is available since version 5.0 of the loaders module. Please use
    <code>OpenIDE-Module-Module-Dependencies: org.openide.loaders > 5.0</code> in your
    module dependencies.
    </usecase>
</answer>  

<!-- Question: compat-i18n

     <question id="compat-i18n">
            Is your module correctly internationalized?
        </question>
-->
<answer id="compat-i18n">
Yes.
</answer>



<!-- Question: compat-standards

     <question id="compat-standards">
            Does the module implements or defines any standards? Is the 
            implementation exact or it deviates somehow?
        </question>
-->
<answer id="compat-standards">
No.
</answer>



<!-- Question: compat-version

     <question id="compat-version">
            Does your module properly coexists with earlier and future
            versions? Can you correctly read settings? Will future
            versions be able to read settings?
            
            <hint>
            Very helpful for reading settings is to store version number
            there, so future versions can decide whether how to read/convert
            the settings and older versions can ignore the new ones.
            </hint>
        </question>
-->
<answer id="compat-version">
No answer
</answer>



<!-- Question: dep-jre

     <question id="dep-jre">
            Which version of JRE you need (1.2, 1.3, 1.4, etc.)?
        </question>
-->
<answer id="dep-jre">
JRE 1.3.
</answer>



<!-- Question: dep-jrejdk

     <question id="dep-jrejdk">
            Do you require JDK or is JRE enough?
        </question>
-->
<answer id="dep-jrejdk">
JRE is enough.
</answer>



<!-- Question: dep-nb

     <question id="dep-nb">
            What other NetBeans projects this one depends on?
        </question>
-->
<answer id="dep-nb">
It depends on 
    <api name="FilesystemsAPI" type="import" url="@org-openide-filesystems@/org/openide/filesystems/doc-files/api.html" category="official" group="java" />, 
    <api name="LookupAPI" type="import" url="@org-openide-util@/org/openide/util/doc-files/api.html#lookup" category="official" group="java" />, 
    <api name="UtilitiesAPI" type="import" url="@org-openide-util@/org/openide/util/doc-files/api.html" category="official" group="java" />.
</answer>



<!-- Question: dep-non-nb

     <question id="dep-non-nb">
            What other non-NetBeans projects this one depends on?
            
            <hint>
            Some non-NetBeans projects are packaged as NetBeans modules
            and
            it is prefered to use this approach when more modules may
            depend on such third-party library.
            </hint>
        </question>
-->
<answer id="dep-non-nb">
It does not depend on any external library.
</answer>



<!-- Question: dep-platform

     <question id="dep-platform">
            On which platforms your module run? Any? Does it run in the same
            way?
        </question>
-->
<answer id="dep-platform">
It runs on any platform.
</answer>



<!-- Question: deploy-jar

     <question id="deploy-jar">
            Do you deploy just module JAR file(s) or some other files?
        </question>
-->
<answer id="deploy-jar">
Data Systems are integral part of openide.jar.
</answer>



<!-- Question: deploy-nbm

     <question id="deploy-nbm">
            Can you deploy NBM via AutoUpdate center?
        </question>
-->
<answer id="deploy-nbm">
Yes. openide.jar can be deployed via AutoUpdate.
</answer>



<!-- Question: deploy-packages

     <question id="deploy-packages">
            Are packages of your module made inaccessible by not declaring them
            public?
            
            <hint>
            NetBeans module system allows restriction of access rights to
            public classes of your module from other modules. This prevents
            unwanted dependencies of others on your code and should be used
            public packages
            </a>). 
            </hint>
        </question>
-->
<answer id="deploy-packages">
No. 
</answer>



<!-- Question: deploy-shared

     <question id="deploy-shared">
            Do you need to be installed in shared location or only in user directory?
        </question>
-->
<answer id="deploy-shared">
openide.jar needs to be in the system directory. 
</answer>



<!-- Question: exec-classloader

     <question id="exec-classloader">
            Does your code uses own classloader?
        </question>
-->
<answer id="exec-classloader">
No.
</answer>



<!-- Question: exec-component

     <question id="exec-component">
            Is execution of your code influenced by (string) property
            of any of your components?
        </question>
-->
<answer id="exec-component">
The data system stores some of its vital information in file attributes. Those
attributes are accessible via calls to 
org.openide.filesystems.FileObject.getAttribute(name)
org.openide.filesystems.FileObject.setAttribute(name, value)
They can also be stored in the module layer. Please see filesystems
for more information about this.

    <api type="export" group="property" name="NetBeansAttrAssignedLoader" category="stable" >
        Extended attribute for holding the class of the loader that should
        be used to recognize a file object before the normal processing takes
        place.
    </api>
  
    <api type="export" group="property" name="NetBeansAttrAssignedLoaderModule" category="private" >
        Extended attribute which may be used in addition to EA_ASSIGNED_LOADER
        which indicates the code name base of the module that installed that preferred
        loader. If the indicated module is not installed, ignore the loader request.
        See #13816.     
    </api>
       
    <api type="export" group="property" name="template" category="stable" >
        If set to Boolean.TRUE the file is recognized as template and
        its instantiation is allowed.
    </api>
  
<!-- TemplateWizard: -->
     
    <api type="export" group="property" name="isRemoteAndSlow" category="private" >
        <p>NewObjectWizardPanel: The Attribute "isRemoteAndSlow" will be checked for on the targetFolder,
        and if it is found and <b>true</b>, then 
        targetFolder.getPrimaryFile().getFileObject will NOT be called.</p>
    </api>
  
  
    <api type="export" group="property" name="templateWizardURL" category="stable" >
        Attribute that defines a template wizard description page (type <code>URL</code> to HTML).
    </api>
    
    <api type="export" group="property" name="templateWizardIterator" category="stable" >
        Attribute that defines a custom template wizard iterator (type <code>TemplateWizard.Iterator</code>).
    </api>
  
    
<!-- DataShadow: -->

    <api type="export" group="property" name="originalFile" category="stable" >
        Path to the target file in its filesystem (type <code>String</code>).
    </api>

    <api type="export" group="property" name="originalFileSystem" category="stable" >
        System name of filesystem of target file (type <code>String</code>; default is same as that of shadow).
    </api>

    <api type="export" group="property" name="UseOwnName" category="private" >
        if true, the DataShadow name is used instead of original's name, 
        affects DataShadows of filesystem roots only
    </api>
    
<!-- FolderOrder: -->
    <api type="export" group="property" name="PartialOrders" category="stable" >
        Read the list of intended partial orders from disk.
        Each element is a string of the form <samp>a/b</samp> for <samp>a</samp>, <samp>b</samp> filenames
        with extension, where <samp>a</samp> should come before <samp>b</samp>.
        The value of the attribute must be of type <code>Boolean</code>; ignored unless <code>true</code>.
    </api>
     
<!-- DataFolder: -->
    <api type="export" group="property" name="OpenIDE-Folder-SortMode" category="private" >
        Extended attribute for order of children. The values
        are "F", "N", "C", "0" (type <code>String</code>).
    </api>
        
    <api type="export" group="property" name="OpenIDE-Folder-Order" category="private" >
        Extended attribute for order of children - stores list
        of file names separated by '/' (type <code>String</code>).
    </api>
    
     
<!-- ConnectionSupport: -->
    <api type="export" group="property" name="EA-OpenIDE-Connection" category="private" >
        Extended attribute to store (ArrayList of Type and Node.Handle).
        Used by Java synchronization feature at least; generally, <code>ConnectionCookie</code>.
    </api>
    
    <api type="export" group="property" name="DataFolder.Index.reorderable" category="friend">
        If set to <code>Boolean.TRUE</code> on a folder not in the system filesystem, make its node reorderable.
    </api>
</answer>



<!-- Question: exec-property

     <question id="exec-property">
            Is execution of your code influenced by any environment of
            system (<code>System.getProperty</code>) property?
        </question>
-->
<answer id="exec-property">
<!-- XMLDataObject: -->
    <api type="import" group="property" name="org.xml.sax.driver" category="private" > 
        This is a standard way to find a class of a SAX2 driver. See
        <a href="http://www.saxproject.org/"> SAX2 documentation </a>
    </api>

    <api type="import" group="property" name="netbeans.profile.memory" category="private" > 
        Boolean.TRUE means to dettach from shared impl of parser, it is static!?
    </api>
    
    <api type="export" group="property" name="org.openide.loaders.FolderList.refresh.interval" category="private" > 
        The value of type integer determines the number of milliseconds
        between successive refreshes of contents of a folder. Can be used to tweak
        performance of folder refresh. Defaults to 10.
    </api>
    
    <api group="property" category="friend" name="netbeans.dataobject.insecure.operation" type="export" >
        If set to <b>true</b>, the <code>DataObject.copy, move, createFromTemplate</code> 
        are executed in insecure way. That means that other threads can access the
        products of such operation before it finishes. This is a friend contract
        with projects, that need to do such strange things. Will be removed when they
        fix it.
    </api>
</answer>



<!-- Question: format-clipboard

     <question id="format-clipboard">
            Which protocols your code reads/inserts when communicating with
            clipboard?
        </question>
-->
<answer id="format-clipboard">
We use following MIME type:
application/x-java-openide-dataobjectdnd;class=org.openide.loaders.DataObject;mask={0}
</answer>



<!-- Question: format-dnd

     <question id="format-dnd">
            Which protocols your code understands during drag-n-drop?
        </question>
-->
<answer id="format-dnd">
We use following MIME type:
application/x-java-openide-dataobjectdnd;class=org.openide.loaders.DataObject;mask={0}
</answer>



<!-- Question: format-types

     <question id="format-types">
            Which file formats your code reads or writes on disk?
        </question>
-->
<answer id="format-types">
Any file format.
</answer>



<!-- Question: lookup-lookup

     <question id="lookup-lookup">
            Does your module used <code>org.openide.util.Lookup</code>
            to find any components to communicate to? Which ones?
        </question>
-->
<answer id="lookup-lookup">
<ul>
<li>DataLoaderPool.class </li>
<li>ActionManager.class</li>
<li>(in XMLDataObject) Node.Cookie.class</li>
<li>RepositoryNodeFactory.class</li>
<li>ModuleInfo.class</li>
<li>ClassLoader.class</li>
</ul>
        <p>
            If there is no <code>DataLoaderPool</code> available in default
            lookup, the fallback is to use a simple loader pool that contains
            just the fixed <q>system</q> loaders, and any
            <code>DataLoader</code>s that can be found in default lookup.
        </p>
DataFolder.FolderNode.setName() looks for one instance of org.openide.loaders.FolderRenameHandler.        
</answer>



<!-- Question: lookup-register

     <question id="lookup-register">
            Do you register anything into the lookup for other to find? Who are 
            the others?
        </question>
-->
<answer id="lookup-register">
Registration of
<ul>
<li>DataLoaderPool.class</li>
<li>Environment.Provider.class</li>
<li>RepositoryNodeFactory.class</li>
</ul>
is done in core in META-INF/services.
</answer>



<!-- Question: lookup-remove

     <question id="lookup-remove">
            Are removing entries of other modules from the lookup? Why?
        </question>
-->
<answer id="lookup-remove">
No.
</answer>



<!-- Question: perf-exit

     <question id="perf-exit">
            Does your module executes anything on exit?
        </question>
-->
<answer id="perf-exit">
No.
</answer>



<!-- Question: perf-huge_dialogs

     <question id="perf-huge_dialogs">
            Does your module contain any dialogs or wizards with huge
            amount of GUI controls like combo boxes, lists, trees, text
            areas?
        </question>
-->
<answer id="perf-huge_dialogs">
This module contains infrastructure for creating "New" functionality
wizards.
</answer>



<!-- Question: perf-limit

     <question id="perf-limit">
            Are there any limits in number/size of elements your code
            can handle?
        </question>
-->
<answer id="perf-limit">
No.
</answer>



<!-- Question: perf-mem

     <question id="perf-mem">
            What is the amount of memory your component occupies? Estimate
            with a relaction to the number of windows, etc.
        </question>
-->
<answer id="perf-mem">
Unknown.
</answer>



<!-- Question: perf-menus

     <question id="perf-menus">
            Does your module use dynamically changing context menus or
            context sensitive actions with complicated logic for enable/disable?
        </question>
-->
<answer id="perf-menus">
No.
</answer>

<!-- Question: perf-progress

     <question id="perf-progress">
            Does your module executes some long running task?
            <hint>Typically they are tasks like connecting over
            network, computing huge amount of data, compilation.
            Such communication should be done asynchronously (for example
            using <code>RequestProcessor</code>), definitively it should 
            not block AWT thread.
            </hint>
        </question>
-->
<answer id="perf-progress">
The module uses its own RequestProcessors to handle long running
tasks.
</answer>



<!-- Question: perf-scale

     <question id="perf-scale">
            Which external criteria influence the performance of your
            program (size of file in editor, number of files in menu, 
            in source directory, etc.) and how well your code scales?
            Please include some estimates.
        </question>
-->
<answer id="perf-scale">
Performance of some operations
is lineary proportional to number of files in a given
folder times number of registered data loaders in
the pool.

</answer>



<!-- Question: perf-startup

     <question id="perf-startup">
            Does your module executes anything on startup?
        </question>
-->
<answer id="perf-startup">
Yes. The list of loaders is read from the disk to memory.
</answer>



<!-- Question: perf-wakeup

     <question id="perf-wakeup">
            Is any piece of your code waking up periodically?
        </question>
-->
<answer id="perf-wakeup">
No.
</answer>



<!-- Question: resources-file

     <question id="resources-file">
            Does your module use <code>java.io.File</code> directly?
            
            <hint>
            NetBeans provide a logical wrapper over plain files called 
            <code>org.openide.filesystems.FileObject</code> that
            provides uniform access to such resources and is the prefered
            way that should be used. But of course there can be situations when
            this is not suitable.
            </hint>
        </question>
-->
<answer id="resources-file">
No.
</answer>



<!-- Question: resources-layer

     <question id="resources-layer">
            Does your module provide own layer? Does it create some files or
            folders on it? What it is trying to communicate by that and with which 
            component?
            
            <hint>
            NetBeans allows automatic and declarative installation of resources 
            by module layers. Module register files into appropriate places
            and other components use that information to perform their task
            (build menu, toolbar, window layout, list of templates, set of
            options, etc.). 
            </hint>
        </question>
-->
<answer id="resources-layer">
Yes, module creates the folders in layer <samp>org/netbeans/core/ui/resources/layer.xml</samp>
in <samp>core-ui.jar</samp>. The folders are instrumental to store information
about used templates.
<b>Provided folderes: </b>
<ul>
<li>
    <api name="PrivilegedTemplates" group="layer" type="export" category="devel">
    A folder Privileged offers to other module possibility add own templates.
    </api><p></p>
</li>
<li>
    <api name="RecentTemplates" group="layer" type="export" category="private">
    A folder Recent stores a set of recently used templates, it's not open to other module. 
    </api><p></p>
</li>
</ul>
None of them is forced to found.
</answer>

<!-- Question: resources-mask

     <question id="resources-mask">
            Does your module read any resource provided by another one in
            module layer? Why?
        </question>
-->
<answer id="resources-mask">
No.
</answer>



<!-- Question: resources-read

     <question id="resources-read">
            Does your module read any resources from layers? For what purpose?
        </question>
-->
<answer id="resources-read">
Module reads a list of templates from folders Privileged and Recent from core/ui layer. 
This list is exposed in a popup menu.
</answer>

</api-answers>

