findInstance() not generated, what is the "new" way of doing this ?
"bruehlicke" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <[email protected]> |
Thanx Geertjan, though this guy could return null. Hence in "old days" aka before introduction of annotations (i guess before 7.0) the TopComponent creation Wizard created code with the "findInstance" method like :
Code:
/**
* Obtain the MyTopComponent instance. Never call {@link #getDefault} directly!
*/
public static synchronized MyTopComponent findInstance() {
TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
if (win == null) {
Logger.getLogger(MyTopComponent.class.getName()).warning(
"Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
return getDefault();
}
if (win instanceof MyTopComponent) {
return (MyTopComponent) win;
}
Logger.getLogger(MyTopComponent.class.getName()).warning(
"There seem to be multiple components with the '" + PREFERRED_ID +
"' ID. That is a potential source of errors and unexpected behavior.");
return getDefault();
}
Of course this assumed each TopComponent is a Singleton. So I guess that the "findInstance" method is hereby grand-fathered and not "standard" anymore and up to each developer to create or not - fair enough. It was anyhow never in the TopComponent interface. (same as getDefault()).
Bests and Thanx again for all the effort being but into the move to Apache.