This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 189848 - Annotation to register separators
Summary: Annotation to register separators
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 7.0
Hardware: Other Linux
: P3 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on: 189558 193263
Blocks:
  Show dependency tree
 
Reported: 2010-08-25 14:00 UTC by Jaroslav Tulach
Modified: 2011-03-03 18:40 UTC (History)
2 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
separatorBefore() and separatorAfter() (18.52 KB, patch)
2010-08-29 16:03 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2010-08-25 14:00:05 UTC
While implementing bug 189558, we realized the need to allow registration of separators via annotations as well. This is especially important for users of 6.10 FCS, so they don't need to migrate from current layer based registration to new way of registering separators later.

One option is to add into @ActionReference

boolean separatorAfter() default false;
boolean separatorBefore() default false;

but the problem is that when generating the layer one does not have overall view of the layer and can hardlly place separators properly (into position in middle of the action and its predecessor/successor).

Other option is to try to align with other IDEs and rather than separators specify some kind of @ActionReference:

String group() default "none";

If there is a sequence of actions after each other with same group they would have no separator among themselves. But this is slightly tricky, the primary sorting criteria should naturally be the group, the position shall be secondary. This is hard to do compatibly.

Last option I can think of is to provide @ActionReference with

int[] separators() default {}

an array of positions where one wants to place separators. This is easy to implement as it just means to create JSeparator-position.instance file(s) by the processor without knowing the surroundings. The wizard can properly compute these positions (as it knows the whole layer). This options seems powerful enough, compatible, yet slightly hacky.
Comment 1 Jesse Glick 2010-08-25 14:59:44 UTC
(In reply to comment #0)
> String group() default "none";
> 
> If there is a sequence of actions after each other with same group they would
> have no separator among themselves. But this is slightly tricky, the primary
> sorting criteria should naturally be the group, the position shall be
> secondary. This is hard to do compatibly.

Also hard to make work with Lookup-based menu interpretation such as Actions.forPath; currently the position attributes simply order the lookup result, but a group ID would complicate this system.

> Last option I can think of is to provide @ActionReference with
> 
> int[] separators() default {}

I would actually suggest

int separatorBefore() default Integer.MAX_VALUE;
int separatorAfter() default Integer.MAX_VALUE;

where the processor verifies that these attrs, if set, are less (resp. greater) than position(), which must in that case also be set. Basically matches what the wizard already generates, and the basename of the separator instance file can be taken from the reference name, e.g.

  com-mycom-MyAction-separatorBefore.instance
Comment 2 Jaroslav Tulach 2010-08-29 16:02:18 UTC
OK, as you wish my lord.
Comment 3 Jaroslav Tulach 2010-08-29 16:03:55 UTC
Created attachment 101737 [details]
separatorBefore() and separatorAfter()
Comment 4 Jaroslav Tulach 2010-09-03 08:06:16 UTC
I'll integrate the change over weekend.
Comment 5 Jaroslav Tulach 2010-09-04 12:48:22 UTC
core-main#960db7e78a68
Comment 6 Quality Engineering 2010-09-05 02:53:24 UTC
Integrated into 'main-golden', will be available in build *201009050000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/960db7e78a68
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #189848: ActionReference.separatorBefore and After
Comment 7 Quality Engineering 2010-09-18 03:43:37 UTC
Integrated into 'main-golden', will be available in build *201009180000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/d8cc05b87cd5
User: Jesse Glick <jglick@netbeans.org>
Log: #189848: again, Integer.MAX_VALUE is the customary default value for "no specified position". -1 is a legal position value between -2 and 0.