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 56870 - New > Java Class doesn't open new file in Editor
Summary: New > Java Class doesn't open new file in Editor
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Pokorsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-23 14:21 UTC by Adam Sotona
Modified: 2007-09-26 09:14 UTC (History)
1 user (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 Adam Sotona 2005-03-23 14:21:09 UTC
New > ...  new created document isn't opened in editor for all java templates in
j2me project. 

The root cause is that j2me project introduces J2MEDataObject as a child of
JavaDataObject that is recognized by J2MEDataLoader within j2me projects only.
All java template data objects are still instances of JavaDataObject.
JavaDataObject.handleCreateFromTemplate(...) assumes no differnce between
template and new data object type and returns a direct instance of
JavaDataObject. This instance is then invalidated and a new instance of
J2MEDataObject is created. At the same time the file is beeing opened in editor
and it fails with following message: "Can not open
org.netbeans.modules.java.JavaEditor$JavaEditorComponent ... component, its
support environment is not valid..." 

After discussion with Yarda Tulach we found a possible fix for this problem in
JavaDataObject. In case the method handleCreateFromTemplate will return instance
s of the correct data object types, there would be no further invalidations. The
solution is to do not ask directly JavaDataLoader to create a new JavaDataObject
but to ask the pool of all loaders, or even better (if possible) to ask a subset
of loaders that produce subclasses of JavaDataObject.


I know that this solution is not very nice but other ways are out of the time
scope for release 4.1. For next release we need to define exact requirements for
JavaDataObject to avoid such nasty subclassing.
Comment 1 Jan Pokorsky 2005-03-23 15:49:46 UTC
IMO the right place to fix this is MultiDataObject.createMultiObject since the
same may be the case of others than JDO.

To workaround this in the java module I will have to invalidate DO obtained from
MDO.handleCreateFromTemplate inside JDO.handleCreateFromTemplate which seems to
be really ugly.
Comment 2 Jaroslav Tulach 2005-03-24 07:58:41 UTC
> To workaround this in the java module I will have to invalidate DO 
> obtained from MDO.handleCreateFromTemplate 

Or not call MDO.handleCreateFromTemplate at all.

> IMO the right place to fix this is MultiDataObject.createMultiObject

It is one of the places where it would be possible to fix this, but also one of
the most dangerous as a lot of things could go wrong.

In my discussion with Adam I wanted to say two things:
1. the fact that somebody has to subclass JDO is flaw in the design and should
be replaced
2. if we have to do it, there is a way

Comment 3 Jan Pokorsky 2005-03-24 13:25:37 UTC
fixed in

/cvs/java/src/org/netbeans/modules/java/JavaDataObject.java
new revision: 1.203; previous revision: 1.202

I wanted to be sure you do not consider this as a defect of MDO.

I agree that the design is not good. The java module api would deserve redesign
in some future release. It would be great if Adam or someone from the mobility
team could list their requirements so they do not need to subclass JDO or
possibly other classes (JavaEditor?).
Comment 4 ericarseneau 2005-10-14 00:29:09 UTC
- FYI: we also subclass JavaDataObject in Creator, in order to allow the Java
editor to be opened as a sub-tab of a page in designer
- we should see if there is a better way to do this