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 100172 - API for adding privileged templates
Summary: API for adding privileged templates
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks: 98440
  Show dependency tree
 
Reported: 2007-04-05 23:45 UTC by _ potingwu
Modified: 2007-05-23 18:35 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ potingwu 2007-04-05 23:45:00 UTC
Currently the privileged templates are hard-coded in
org.netbeans.modules.web.project.WebProject.PRIVILEGED_NAMES. There is no API
for framework to add more privileged templates into the list.

This feature is now becoming more important for the users because of the
increased framework implementations.

I use 'DEFECT' instead of 'ENHANCEMENT' because many users feel it's a serious
bug when they don't find their expected items listed.
Comment 1 Mark Dey 2007-04-17 20:56:11 UTC
I feel this is a serious usability issue for visual web, and likely for other
frameworks as well. Please commit this for NB 6.
Comment 2 Petr Pisl 2007-04-18 10:31:21 UTC
I'm going to do it on branch.
Comment 3 Petr Pisl 2007-04-18 21:24:41 UTC
The functionality is commited to the branch frameworksupport60. If you want to
try it you have to checkout/update from this branch Web API and Web Projects.

There is one new method in WebFrameworkProvider class:
public String[] getPrivilegedTemplates(WebModule webModule){
        return new String[0];
}

Your web framework has to overwrite this method.

The web project asks to the frameworks during opening project or adding
framework to the project for the privileged templates. The  templates are added
at the beginning of the list of privileged templates. The number of the
templates is not limited, which means that if we will have 5 frameworks and
every framework will add 5 templates, then there can be 35 templates(5*5 + 10
templates from web project itself) offered in the context menu.  I'm not sure
whether this is real problem, but it can be limited for the certain number of
templates.

The good think is that the functionality doesn't influence performance during
creating the context menu at all. The wrong thing is that I wasn't able to test
the functionality during adding a framework to the already existing project due
to the issue #10650.

It will be merged to the trunk after M9 stabilization phase.
Comment 4 Pavel Buzek 2007-04-18 22:43:02 UTC
We definitely have to limit the number of items in the popup New> menu. I think
the limit should be 10 + the "Other..." item. If there are too many items the
list should be cut off. Framework templates should be given priority over the
templates offered by the standard web project so up to 10 framework's preferred
templates can be displayed.

If there are multiple frameworks I would take first 3 from each framework. If
there are more then 3 frameworks I would do the same, i.e. the list would just
be cut off after 10 items no matter what. We could in theory do 5+5 for 2
frameworks, 4+3+3 for 3, etc., but I would not thinker about it too much as we
will not get it absolutely right by any algorithm. A user who uses many
frameworks will hopefully figure out how to use Other and the preferred list
will get populated later.
Comment 5 Petr Pisl 2007-04-18 23:28:46 UTC
I definitely agree that there has to be an limit. Probably 10. On the other hand
now the JavaEE5 Web projects has more than 10 by default. 
Comment 6 Petr Pisl 2007-04-18 23:32:38 UTC
I'm sorry, the issue, which I mentioined in my previous comment is #101650
Comment 7 Petr Pisl 2007-05-16 14:22:03 UTC
I partially change the api for privileged templates. It's not a part of
WebFrameworkProvider class. Instead there is a new interface

public interface WebPrivilegedTemplates {
    public String[] getPrivilegedTemplates(WebModule webModule);
}

An instance should be placed in j2ee/webtier/templates folder in a module XML
layer file. The reason for these change was to separate it from the frameworks.
Now the functionality is independent on the framework.

From the framework implementation side the FrameworkProvider can implement this
interface and then can be registered in both folders (j2ee/webtier/templates and
j2ee/webtier/framework) through a factory method.

The change is done at  the branch frameworksupport60. If there will not be any
objections, I'm going to commit this to the trunk on Friday.
Comment 8 Petr Pisl 2007-05-18 13:36:40 UTC
The new version of the api is in the trunk now.