|
org.openide.loaders 6.4 | |||||||||
PREV NEXT | FRAMES NO FRAMES |
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.
The DataEditorSupport adds default implementation of SaveAsCapable interface to the CookieSet of DataObjects created by UniFileLoaders. The default implementation calls copyRename method on the DataObject.
The DataEditorSupport overides the loadFromStreamToKit and saveFromKitToStream methods. In these methods it uses FileEncodingQuery to find out the encoding of the file, creates the Reader or Writer with obtained encoding and calls EditorKit.read or EditorKit.write.
Two new interfaces - CreateFromTemplateHandler
and
CreateFromTemplateAttributesProvider
to enhance the abilities
of data object to be created with parametrized values. Also new method
createFromTemplate
taking extra map of named arguments
has been added, so users can pass the data object additional info
that can be processed during instantiation of the template.
This is particallary useful when using scripting and templating languages during create from template operation.
Since now, each DataNode constructed without using own lookup,
shall have FileObject
(s) associated with its
DataObject
available in its own lookup.
Also a
DataObject
has been retrofitted to implement a
Lookup.Provider
interface and thus have its
getLookup
method that can be used instead of the old getCookie
one.
Class DataNode
add additional DataFlavor
s
to its Transferable
which means that any file or folder
can be dragged from the IDE and dropped to any external application
that supports file drag and drop operations. The same functionality
applies to Copy/Cut and Paste operations.
Class DataFolder.FolderNode
now supports file-type
DataFlavor
s so when a file(s) is dropped to a folder node
in the IDE then the file is copied into that folder. If the file is
a Java source file then the appropriate refactoring will fire up as well.
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
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
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.
String
representing the current day like 23. 3. 2007
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.
Loaders/folder/any/Actions
so if any module wishes
to extend, hide or reorder some of them it can just register its actions there.<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:
Loaders/text/xml/Actions
Loaders/content/unknown/Actions
Loaders/application/x-nbsettings/Actions
DataObject
s 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.
|
|
|
|
The sources for the module are in NetBeans CVS in openide/loaders directory.
XXX no answer for deploy-dependencies
Read more about the implementation in the answers to architecture questions.
|
org.openide.loaders 6.4 | |||||||||
PREV NEXT | FRAMES NO FRAMES |