Bug 227345 - @annotation to register paletteitem
@annotation to register paletteitem
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Palette
7.4
PC Other
: P3 (vote)
: 8.0
Assigned To: Stanislav Aubrecht
issues@platform
: API, API_REVIEW, API_REVIEW_FAST
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-12 10:11 UTC by skygo
Modified: 2013-12-10 08:40 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Proposed patch to handle annotation (25.97 KB, application/octet-stream)
2013-03-12 10:12 UTC, skygo
Details
Proposed Patch with Updated manifest (25.97 KB, patch)
2013-12-05 16:09 UTC, skygo
Details | Diff
Proposed Patch with Updated manifest (29.57 KB, patch)
2013-12-07 01:28 UTC, skygo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description skygo 2013-03-12 10:11:48 UTC
Draft for annotation to register paletteitem.

At package level or for class extending activeeditordrop.
Comment 1 skygo 2013-03-12 10:12:56 UTC
Created attachment 132505 [details]
Proposed patch to handle annotation
Comment 2 skygo 2013-12-03 10:36:27 UTC
Sorry for the delay provinding some more details API proposal. I choose to register to NetCAT :p and I was very busy there, so before NetCAT 8 start, 
I find some time to present. 

According to wiki pages [1] and [2] there is a potential for using annotation to describe palette item.

This may help simplifying ressources management at the time Netbeans Platform Users need to create basic palette item. 
Current process involve icon + layer modification + palette file xml edit. With help of annotations only icons need to be managed, 
others parts are done with annotation in java files.

The API consists of two new annotations:

PaletteItemRegistrations for allowing multiple annotation of PaletteItemRegistration

PaletteItemRegistration to handle palette item

The differents elements for the annotation, 

// Coordinate for layer 
    String paletteid();
    String category();
    String itemid();

// Optionnal body for alternate palette
    String body() default "";

// Visualisation icons, name and tooltip

    String icon16();
    String icon32();

    String name();
    String tooltip();
 
Example of usage in a class that extends ActiveEditorDrop
@PaletteItemRegistration(paletteid = "JavaPalette", category = "dummycat", itemid = "myitem",
    "icon16 = "org/netbeans/modules/palette/resources/unknown16.gif", 
    "icon32 = "org/netbeans/modules/palette/resources/unknown32.gif", tooltip = "this is a tooltip", name = "my name for myitem")

Example of usage in a package info
@PaletteItemRegistration(paletteid = "JavaPalette", category = "dummycat", itemid = "myitem",
    "icon16 = "org/netbeans/modules/palette/resources/unknown16.gif", +
    "icon32 = "org/netbeans/modules/palette/resources/unknown32.gif", tooltip = "this is a tooltip", name = "my name for myitem",body ="my body")

Best Regards

skygo
PS: 
 I hope I respect process of fast review.

[1] http://wiki.netbeans.org/MoreDeclarativeRegistrationUsingAnnotations
[2] http://wiki.netbeans.org/DeclarativeRegistrationUsingAnnotations
Comment 3 Stanislav Aubrecht 2013-12-03 10:57:32 UTC
Looks good to me.
Comment 4 skygo 2013-12-05 16:09:54 UTC
Created attachment 142871 [details]
Proposed Patch with Updated manifest

The initial diff was made long time ago and 7.4 was released with new manifest version. Now patch can be imported with no error.
Comment 5 Jaroslav Tulach 2013-12-06 16:49:05 UTC
Y01 Javadoc of PaletteItemRegistration might contain few samples that use it.

Otherwise go on. Add it, imho.
Comment 6 skygo 2013-12-07 01:28:39 UTC
Created attachment 142927 [details]
Proposed Patch with Updated manifest

Y01:
 Added example on Registration Javadoc.

I revise the processor, a uncauch exeception was thrown in case of wrong resource file.
Change processor to source_7.
Added Test to check for invalid resource for icons.
Comment 7 Stanislav Aubrecht 2013-12-09 07:49:37 UTC
If there are no objections I'll integrate the changes tomorrow.
Comment 8 Stanislav Aubrecht 2013-12-10 08:40:54 UTC
core-main 226ec9ff52fb

Thanks for the patch!


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