站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

Overview (Datasystems API) - NetBeans API Javadoc (Current Development Version)

org.openide.loaders 6.4

Datasystems API
Official

See:
          Description

Datasystems API
org.openide.actions  
org.openide.awt  
org.openide.loaders Datasystems are the logical layer between a filesystem and higher-level file-oriented operations.
org.openide.text  

 

This module provides API that works on top of file objects and gives each file a logical behaviour - icon, name, operations, etc.

What is New (see all changes)?

Use Cases

A lot of usecases is described in the javadoc. Here is the list of some faqs:
Using Scripting and Templating Languages

Often many people require ability to create a "clever" template - e.g. write piece of simple text and at the time of its processing do some advanced changes to it using either scripting or templating languages.

This traditionally used to be a bit complicated task, however since version 6.1 there are new interfaces can be registered as a services in a lookup and it is reponsible for handling the whole copy of the template file(s) to the destination folder. and can be registered as a services in a lookup and it is reponsible for providing "hints" - e.g. map mapping strings to various objects. and these interfaces allow anyone to extend the behaviour during creation of new files without writing new DataLoader and co.

Smart Templating Quick How-To
First of all create a file in your module layer located somewhere under the Templates/ folder. Make it a template by adding <attr name="template" boolvalue="true"/>. Associate this template with a scripting language, for example by <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>. Now make sure that the scripting language integration is also available by requesting a token in standard format, for freemarker just put OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker in your manifest. Also create a runtime dependency on org.netbeans.modules.templates - the module providing the templates/scripting languages integration. This tells the NetBeans module system that a module providing integration with such scripting engine has to be enabled. Now you can use regular script language tags inside of your template file. When you write your instantiate method in your wizard, you can create a Map<String,Object> and fill it with parameters collected from your wizard and then pass it to CreateFromTemplate(targetFolder, targetName, mapWithParameters) . This will invoke the scripting language and make the mapWithParameters values available to it. Beyond this there is few standard parameters predefined including name, user, date and time and also additional parameters are collected from all registered CreateFromTemplateAttributesProviders.

Moreover there is a built in support for scripting languages in the standard NetBeans IDE. If a template is annotated with a property that can be associated to templates that either should return real instance of ScriptEngine interface or a String name of the engine that is then used to search for it in the javax.script.ScriptEngineManager. Usually the freemarker engine is the one that is supported by the NetBeans IDE - if your module wants to use it then include a token dependency OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker in your manifest file (also accessible through project customizer GUI) to indicate to the system that you need it. then the scripting engine is then used to process the template and generate the output file. While running the engine one can rely on few predefined properties:

  • contains the name of the DataObject that is being created
  • contains String representing the current day like 23. 3. 2007
  • contains String the current time like 17:18:30

Other properties can indeed be provided by CreateFromTemplateAttributesProviders. After processing, the output is also sent to appropriate org.openide.text.IndentEngine associated with the mime type of the template, for formating.

How to add action to folder's popup menu?
The actions that the default folder loader shows in its popup menu are read from a layer folder Loaders/folder/any/Actions so if any module wishes to extend, hide or reorder some of them it can just register its actions there. As code like this does:
    <folder name="Loaders" >
        <folder name="folder" >
            <folder name="any" >
                <folder name="Actions" >
                    <file name="org-mymodule-MyAction.instance" >
                        <attr name="instanceCreate" stringvalue="org.mymodule.MyAction" />
                    </file>
                </folder>
            </folder>
        </folder>
    </folder>
    
As described in general actions registration tutorial.

This functionality is available since version 5.0 of the loaders module. Please use OpenIDE-Module-Module-Dependencies: org.openide.loaders > 5.0 in your module dependencies.

In version 5.8 all the standard loaders were changed to read actions from layer:

  • The actions that the standard XML loader shows in its popup menu are read from a layer folder Loaders/text/xml/Actions
  • The actions that the loader for unrecognized files shows in its popup menu are read from a layer folder Loaders/content/unknown/Actions
  • The actions that the loader for instance and settings files shows in its popup menu are read from a layer folder Loaders/application/x-nbsettings/Actions
How to allow others to enhance actions of your loader?
If you want other modules to enhance or modify actions that are visible on DataObjects produced by your DataLoader and you are either using DataNode or its subclass, you can just override protected String actionsContext() method to return non-null location of context in layers from where to read the actions.

The usual value should match Loaders/mime/type/Actions scheme, for example java is using Loaders/text/x-java/Actions, but the name can be arbitrary.

This functionality is available since version 5.0 of the loaders module. Please use OpenIDE-Module-Module-Dependencies: org.openide.loaders > 5.0 in your module dependencies.

Exported Interfaces

This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...
Group of java interfaces
Interface NameIn/OutStabilitySpecified in What Document?
LoadersAPIExportedOfficial .../openide/loaders/doc-files/api.html

Group of lookup interfaces
Interface NameIn/OutStabilitySpecified in What Document?
org.openide.loaders.CreateFromTemplateHandlerExportedOfficial .../loaders/CreateFromTemplateHandler.html

can be registered as a services in a lookup and it is reponsible for handling the whole copy of the template file(s) to the destination folder.

org.openide.loaders.CreateFromTemplateAttributesProviderExportedOfficial .../

can be registered as a services in a lookup and it is reponsible for providing "hints" - e.g. map mapping strings to various objects.

Group of property interfaces
Interface NameIn/OutStabilitySpecified in What Document?
javax.script.ScriptEngineExportedOfficial

a property that can be associated to templates that either should return real instance of ScriptEngine interface or a String name of the engine that is then used to search for it in the javax.script.ScriptEngineManager. Usually the
freemarker engine is the one that is supported by the NetBeans IDE - if your module wants to use it then include a token dependency OpenIDE-Module-Needs: javax.script.ScriptEngine.freemarker in your manifest file (also accessible through project customizer GUI) to indicate to the system that you need it.

nameExportedStable

contains the name of the
DataObject that is being created

dateExportedStable

contains String representing the current day like 23. 3. 2007

timeExportedStable

contains String the current time like 17:18:30

NetBeansAttrAssignedLoaderExportedStable

Extended attribute for holding the class of the loader that should be used to recognize a file object before the normal processing takes place.

NetBeansAttrAssignedLoaderModuleExportedPrivate

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.

templateExportedStable

If set to Boolean.TRUE the file is recognized as template and its instantiation is allowed.

isRemoteAndSlowExportedPrivate

NewObjectWizardPanel: The Attribute "isRemoteAndSlow" will be checked for on the targetFolder, and if it is found and true, then targetFolder.getPrimaryFile().getFileObject will NOT be called.

templateWizardURLExportedStable

Attribute that defines a template wizard description page (type URL to HTML).

templateWizardIteratorExportedStable

Attribute that defines a custom template wizard iterator (type TemplateWizard.Iterator).

originalFileExportedStable

Path to the target file in its filesystem (type String).

originalFileSystemExportedStable

System name of filesystem of target file (type String; default is same as that of shadow).

UseOwnNameExportedPrivate

if true, the DataShadow name is used instead of original's name, affects DataShadows of filesystem roots only

simpleExportedStable

templates and folders under Templates/ folder can be annotated with <attr name="simple" boolvalue="false"< if they are supposed to be hidden in Template Manager. If a folder is annotated with this attribute, it is also hidden in standard New File wizard.

PartialOrdersExportedStable

Read the list of intended partial orders from disk. Each element is a string of the form a/b for a, b filenames with extension, where a should come before b. The value of the attribute must be of type Boolean; ignored unless true.

OpenIDE-Folder-SortModeExportedPrivate

Extended attribute for order of children. The values are "F", "N", "C", "0" (type String).

OpenIDE-Folder-OrderExportedPrivate

Extended attribute for order of children - stores list of file names separated by '/' (type String).

EA-OpenIDE-ConnectionExportedPrivate

Extended attribute to store (ArrayList of Type and Node.Handle). Used by Java synchronization feature at least; generally, ConnectionCookie.

DataFolder.Index.reorderableExportedFriend

If set to Boolean.TRUE on a folder not in the system filesystem, make its node reorderable.

org.openide.loaders.FolderList.refresh.intervalExportedPrivate

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.

netbeans.dataobject.insecure.operationExportedFriend

If set to true, the DataObject.copy, move, createFromTemplate 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.

Group of layer interfaces
Interface NameIn/OutStabilitySpecified in What Document?
Loaders-folder-any-ActionsExportedStable

The actions that the default folder loader shows in its popup menu are read from a layer folder Loaders/folder/any/Actions so if any module wishes to extend, hide or reorder some of them it can just register its actions there.

Loaders-text-xml-ActionsExportedStable

The actions that the standard XML loader shows in its popup menu are read from a layer folder Loaders/text/xml/Actions

Loaders-content-unknown-ActionsExportedStable

The actions that the loader for unrecognized files shows in its popup menu are read from a layer folder Loaders/content/unknown/Actions

Loaders-application-x-nbsettings-ActionsExportedStable

The actions that the loader for instance and settings files shows in its popup menu are read from a layer folder Loaders/application/x-nbsettings/Actions

PrivilegedTemplatesExportedUnder Development

A folder Privileged offers to other module possibility add own templates.

RecentTemplatesExportedPrivate

A folder Recent stores a set of recently used templates, it's not open to other module.

Group of javax.swing.UIManager interfaces
Interface NameIn/OutStabilitySpecified in What Document?
Nb.Explorer.Folder.iconExportedUnder Development

Icon or Image for closed folder.

Nb.Explorer.Folder.openedIconExportedUnder Development

Icon or Image for opened folder.

Tree.openedIconExportedUnder Development

Fallback Icon or Image for opened folder.

Tree.closedIconExportedUnder Development

Fallback Icon or Image for folder.

Implementation Details

Where are the sources for the module?

The sources for the module are in NetBeans CVS in openide/loaders directory.

What do other modules need to do to declare a dependency on this one, in addition to or instead of a plain module dependency?

XXX no answer for deploy-dependencies

Read more about the implementation in the answers to architecture questions.


org.openide.loaders 6.4

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.