Skip to content

Commit

Permalink
[NETBEANS-1402] Added nb.laf.norestart system property to prevent res…
Browse files Browse the repository at this point in the history
…tart on LaF changes
  • Loading branch information
lkishalmi committed Feb 10, 2019
1 parent d1cef0a commit 5a865cf
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import org.netbeans.api.options.OptionsDisplayer;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.LifecycleManager;
Expand All @@ -48,6 +49,7 @@
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
import org.openide.windows.WindowManager;

@OptionsPanelController.Keywords(keywords={"#KW_LafOptions"}, location="Appearance", tabTitle="#Laf_DisplayName")
public class LafPanel extends javax.swing.JPanel {
Expand All @@ -57,7 +59,7 @@ public class LafPanel extends javax.swing.JPanel {
private final Preferences prefs = NbPreferences.forModule(LafPanel.class);

private final boolean isAquaLaF = "Aqua".equals(UIManager.getLookAndFeel().getID()); //NOI18N

private static final boolean NO_RESTART_ON_LAF_CHANGE = Boolean.getBoolean("nb.laf.norestart"); //NOI18N
private int defaultLookAndFeelIndex;
private final ArrayList<LookAndFeelInfo> lafs = new ArrayList<LookAndFeelInfo>( 10 );

Expand All @@ -73,6 +75,7 @@ public void itemStateChanged(ItemEvent e) {
}
});
initLookAndFeel();
lblRestart.setVisible(!NO_RESTART_ON_LAF_CHANGE);
DefaultComboBoxModel model = new DefaultComboBoxModel();
for( LookAndFeelInfo li : lafs ) {
model.addElement( li.getName() );
Expand Down Expand Up @@ -165,7 +168,17 @@ protected boolean store() {
if( selLaFIndex != defaultLookAndFeelIndex && !isForcedLaF() ) {
LookAndFeelInfo li = lafs.get( comboLaf.getSelectedIndex() );
NbPreferences.root().node( "laf" ).put( "laf", li.getClassName() ); //NOI18N
askForRestart();
if (NO_RESTART_ON_LAF_CHANGE) {
try {
UIManager.setLookAndFeel(li.getClassName());
WindowManager wmgr = Lookup.getDefault().lookup(WindowManager.class);
wmgr.updateUI();
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException ex) {
askForRestart();
}
} else {
askForRestart();
}
}

return false;
Expand Down

0 comments on commit 5a865cf

Please sign in to comment.