If it’s not a feature – WindowSystem Persistence

Sometimes in your specific application you want to turn off a feature of the NetBeans Platform. E.g. your application is supposed to ignore all changes a user makes to the WindowSystem. So how do you turn WindowSystem persistence off? There are different ways for doing this. Some more complicated than others. Setting persistence type of your TopComponents to PERSISTENCE_NEVER would be a start, but it doesn’t really change the Modes layout. You can call the “Reset Windows” Action programatically (doing some tricks with the layer). But for this you will need to start the application and then reset it, which causes the Window to show up and vanish, just to show up again in a different layout. You can even provide your own System FileSystem to do it.  But the simplest one is probably this:


public class Installer extends ModuleInstall {

@Override
 public void restored() {
 try {
 FileUtil.getConfigFile("Windows2Local").delete();
 } catch (IOException ex) {
 Exceptions.printStackTrace(ex);
 }
 }
}

Beware, this also throws away all the settings files, so it’s a real “clean” start :-).

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>