MoreDeclarativeRegistrationUsingAnnotations

(Difference between revisions)
(Navigator panels)
m (Palette items)
 
(10 intermediate revisions not shown)
Line 5: Line 5:
=MIME resolvers=
=MIME resolvers=
-
Easy: link to an XML file in the current DTD, similar to @HelpSetRegistration.
+
[http://netbeans.org/bugzilla/show_bug.cgi?id=191777#c10 bug #191777]
-
 
+
-
Trickier: provide similar functionality entirely in annotations.
+
-
 
+
-
Should be possible to register also on a nondeclarative resolver.
+
-
 
+
-
 
+
-
 
+
-
(To JGlick, I'am not very confident with the way to handle the wiki, please fill free to "optimize". (EBarboni)
+
-
 
+
-
The easy part may be handled this way:
+
-
 
+
-
<pre>
+
-
@ServiceMimeRegistration(id = "resolver-id", label = "#mylabel", position = XXX, resource = "myresolver.xml")
+
-
</pre>
+
-
 
+
-
This annotation is not related to a class but may be a good things to be able to allow it in the user DataLoader where the mimetype is handled.
+
-
 
+
-
 
+
-
I was thinking of the trickiest generator but there is lots subpart to deals with.
+
-
<pre>
+
-
 
+
-
8 annotations instead of 75 lines
+
-
/*
+
-
for the php resolver
+
-
*/
+
-
 
+
-
@MimeResolverPattern(id="lookforphpin4000",value="&lt;?php",range=4000)
+
-
 
+
-
@ServiceMimeRegistration(mimetype="text/x-php5",entry={
+
-
 
+
-
@ServiceMimeRegistrationEntry(extensions={"php","phtml"}),
+
-
@ServiceMimeRegistrationEntry(extensions={"java","rb","rhtml"},ignore=true),
+
-
@ServiceMimeRegistrationEntry(patterns={
+
-
  @MimeResolverPattern(value="&lt;?php",range=255),
+
-
  @MimeResolverPattern(value="&lt;HTML&gt;",range=255,ignorecase=true,subpattern="#lookforphpin4000"),
+
-
  @MimeResolverPattern(value="&lt;!DOCTYPE HTML",range=255,ignorecase=true,subpattern="#lookforphpin4000")
+
-
})
+
-
+
-
})
+
-
 
+
-
five annotations instead of 69 lines
+
-
/*
+
-
for editor codetemplate
+
-
*/
+
-
@XMLResolver(id="publicidforcodetemplate",publicID="-//NetBeans//DTD Editor Code Templates settings 1.0//EN")
+
-
@XMLResolver(id="rootforcodetemplate",element="codetemplates")
+
-
 
+
-
@ServiceMimeRegistration(mimetype="text/x-nbeditor-codetemplatesettings",entry={
+
-
@ServiceMimeRegistrationEntry(extensions={"xml"},xmlresolver="publicidforcodetemplate"),
+
-
@ServiceMimeRegistrationEntry(extensions={"xml"},xmlresolver="rootforcodetemplate")
+
-
})
+
-
</pre>
+
-
)
+
=Data loaders=
=Data loaders=
-
For traditional <tt>DataLoader</tt>-extending modules:
+
[http://netbeans.org/bugzilla/show_bug.cgi?id=207219 bug #207219]
-
<pre>
+
[[DeclarativeRegistrationUsingAnnotationsDataObjectMigration]]
-
@DataObject.Factory.Registration(mimeTypes="text/html", label="#PROP_HtmlLoader_Name",
+
-
                                icon="org/netbeans/modules/html/htmlObject.png")
+
-
public class HtmlLoader extends UniFileLoader {...}
+
-
</pre>
+
-
For those skipping the loader and using <tt>DataLoaderPool.factory</tt>:
 
-
 
-
<pre>
 
-
@DataObject.Factory.Registration(mimeTypes="text/html", label="#PROP_HtmlLoader_Name",
 
-
                                icon="org/netbeans/modules/html/htmlObject.png")
 
-
public class HtmlDataObject extends MultiDataObject {...}
 
-
</pre>
 
-
 
-
(
 
-
 
-
Does the plural form (mimeTypes) means that this annoation may register several factories?
 
-
 
-
May a notion of position be usefull like in other part of layer?
 
-
 
-
)
 
==Loader actions==
==Loader actions==
-
TBD how to handle context menu actions. See [[DeclarativeRegistrationUsingAnnotations#Problems_with_actions]] for discussion.
+
Tricky to handle context menu actions. See [[DeclarativeRegistrationUsingAnnotations#Problems_with_actions]] for discussion.
=Startup tasks=
=Startup tasks=
Line 93: Line 21:
Most simply: an annotation to register ModuleInstall implementations.
Most simply: an annotation to register ModuleInstall implementations.
-
More ambitiously, an annotation to cover parallelizable startup tasks, perhaps replacing ModuleInstall as well as other hooks: #200636.
+
More ambitiously, an annotation to cover parallelizable startup tasks, perhaps replacing ModuleInstall as well as other hooks: #200636. ''done''
Either would supersede #163937 (refactoring hook).
Either would supersede #163937 (refactoring hook).
Line 104: Line 32:
Two kinds of provider, both should be simple to register.
Two kinds of provider, both should be simple to register.
 +
 +
Need to eliminate nonmodular registration of filters in TypesFilter.enabledProviders (see c6e3e159fc1b for example).
=Quick search providers=
=Quick search providers=
Line 112: Line 42:
Probably straightforward as package annotations.
Probably straightforward as package annotations.
 +
See [http://netbeans.org/bugzilla/show_bug.cgi?id=227345 #227345]
=XML catalogs, schemas, DTDs=
=XML catalogs, schemas, DTDs=

Current revision as of 16:25, 10 July 2013

Background: DeclarativeRegistrationUsingAnnotations#Potential_Layer_Annotations

In addition to new annotations, we need more editor hints to replace old layer.xml registrations - only a few cases (actions, templates) are currently covered, and even then not fully.

Contents

MIME resolvers

bug #191777

Data loaders

bug #207219

DeclarativeRegistrationUsingAnnotationsDataObjectMigration

Loader actions

Tricky to handle context menu actions. See DeclarativeRegistrationUsingAnnotations#Problems_with_actions for discussion.

Startup tasks

Most simply: an annotation to register ModuleInstall implementations.

More ambitiously, an annotation to cover parallelizable startup tasks, perhaps replacing ModuleInstall as well as other hooks: #200636. done

Either would supersede #163937 (refactoring hook).

Navigator panels

bug #206954 done

Task list providers

Two kinds of provider, both should be simple to register.

Need to eliminate nonmodular registration of filters in TypesFilter.enabledProviders (see c6e3e159fc1b for example).

Quick search providers

Should be simple.

Palette items

Probably straightforward as package annotations. See #227345

XML catalogs, schemas, DTDs

May be tricky. See #192595 for discussion.

Project type registration

See #193549.

Repeating annotations

JEP 120 proposes repeating annotations, which would allow us to write the more natural

@ActionID(...)
@ActionRegistration(...)
@ActionReference(path="Menu/File")
@ActionReference(path="Toolbars/File")
public class A implements ActionListener {...}

rather than the current awkward

@ActionID(...)
@ActionRegistration(...)
@ActionReferences({
  @ActionReference(path="Menu/File")
  @ActionReference(path="Toolbars/File")
}
public class A implements ActionListener {...}

Of course this has to wait for JDK 8 (or whenever the JEP is implemented).

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo