Hello,

in the meantime I've found out what to do:

1. Besides registering the MultiViewElement with PERSISTENCE_ONLY_OPENED
(or PERSISTENCE_ALWAYS, if You need to), the JPanel (or probably other
type of component) implementing MultiViewElement must be serializable.
But be aware of the pitfalls!

2. If Your component has a GroupLayout (i.e. created with "Free
design"), this will fail, at least if You're using Java 8: The layout
does not implement Serializable. I don't see any sense in persisting the
component, either, so better implement Externalizable and do the
serialization on Your own.

3. You save every state of Your MultiViewElements separately; probably
it'd be possible to make one of them the "master" and look for it using
TopComponent.getSubComponents().

4. Also, the MultiViewTopComponent tries to save the provided Lookup, at
least if You create Your views from mime. So be careful what You put
into Your lookup, it has to be serializable (You can implement
Externalizable on its elements, of course, so You have full control)!

5. If You don't want a "History" tab, it's probably better to not use
mime, as the tab is appended then automatically. I've done some strange
coding to just create my MultiViewElements from mime-type, though this
type is already "synthetic", as I'm using some un-typed web resource
(i.e. it isn't usually stored anywhere in the file-system). I'll change
it to an interface definition, so I can use my own lookup, or I'll use
an XML layer - there're many better possibilities.

Kind regards

Peter




Am 01.12.20 um 06:47 schrieb P.N.:
Thank You, Ernie. Yes, the VM bulldozer might be an option, but only as a last 
resort, as the IDE registers its own shutdown hooks, AFAIK, and these may 
probably interfere. But this took me to some other possibility: using @OnStop 
is NetBeans' way to register such hooks - and that will probably fit perfectly.

However, some better support for persistence would be very nice ... probably 
some methods could be added to MultiViewCallback?

Kind regards
Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to