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 69660 - [multiview] Missing API to access the multiview instance from client elements
Summary: [multiview] Missing API to access the multiview instance from client elements
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: issues@platform
Keywords: API
Depends on:
Reported: 2005-11-30 22:39 UTC by Peter Zavadsky
Modified: 2013-10-17 08:53 UTC (History)
1 user (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Peter Zavadsky 2005-11-30 22:39:55 UTC
There is missing convenient API to access the multiview TopComponent instance
from its client implementations. Either you implement MultiViewElement,
MultiViewDescription you have no API to access the enclosing multiview
TopComponent instance.
Comment 1 Milos Kleint 2005-12-01 13:16:24 UTC
The MultiViewElement implementation is passed the MultiViewCallback that does
have the getTopComponent() method for accessing the enclosing TC. 
The MVDescriptions should be just simple lazy placeholders for elements.

closing as worksforme because such API is there already.
Comment 2 Peter Zavadsky 2005-12-01 18:58:19 UTC
That works only after the element was first time selected (just then the
callback is initiated), but up to that point (until is selected), there is no
such API. We need such a cawe when element needs to change the display name of
the multiview, but it wasn't selected yet. Also keep in mind that all the
elements could be implemented in different modules, so there is no way to access
the selected element and get the info from it.
Comment 3 Milos Kleint 2005-12-02 07:15:48 UTC
I don't see a solution for your scenario. The element that was not selected yet,
was not even created yet. That happens only when you select it (both
instantiation and the callback instance injection)
that's as designed, the only reason why there is MVDescription and MVElement
split is the performance issue with creating multiple full blown view instances
at startup.

can you describe in more details what the actual usecase is?
Comment 4 Peter Zavadsky 2005-12-02 17:08:39 UTC
I think I described it already. In sum there is missing conveniet API to
retrieve enclosing multiview component for a component which is an element of
the multiview and vice versa, something like this:

TopComponent MultiViews.findEnclosingMultiViewTopComponent(JComponent element);
which would return enclosing multiview topcomponent for provided element or null
if there is no such.

JComponent[] MultiViews.getElements(TopComponent multiView); which would return
element components for specified multiview TopComponent or null if the specified
topcomponent is not a multiview.

JComponent MultiViews.getSelectedElement(TopComponent multiView); which would
return selected element for specified multiview TopComponent or null if the
specified top component is not a multiview.

Also useful could be:
boolean MultiViews.isMultiView(TopComponent tc);

Missing those basic API's causes a lot of problems for implementors. I.e. such a
basic task like setting display name and tooltip on the multiview according
changes in the elements (or surrounding implementation, typically editor
support) top component becomes extremelly difficult task.

As an example. Have a look at the implementation of form multiview
(FormEditorSupport) and the presence of the 'multiviewTC' variable, .. that hack
is needed due to absence of that API.

And now imagine you implement the elements of the same multiview in different
(independent) modules, then you need to hack it even more, and the code becomes
very clumsy.

I don't understand why don't you provide that API (which I would expect will be
there at the beginning and before all the others). It is like providing an API
for a List whithout any possibility to retrieve the elements it contains.
Comment 5 David Simonek 2008-10-22 13:09:57 UTC
pzavadsky, this is still valid am I right?