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.
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.
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.
> 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
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?).
- 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