Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETBEANS-1402] Added nb.laf.norestart system property to prevent restart on LaF changes #1056

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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