if (root!=null) {
root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
*/
final JRadioButtonMenuItem rb = (JRadioButtonMenuItem) e.getSource();
final String newLFClassName = rb.getActionCommand();
final String newLFName = rb.getText();
final String currentLFClassName = UIManager.getLookAndFeel().getName();
LookAndFeel cLF = (LookAndFeel)lfManager.customLF.get(newLFClassName);
if(cLF != null) { // First, check if it any of the custom LFs
try {
Activator.log.debug("set custom LF classloader to" + cLF.getClass().getClassLoader());
UIManager.getLookAndFeelDefaults().put("ClassLoader", cLF.getClass().getClassLoader());
Activator.log.debug("set custom LF " + newLFClassName);
UIManager.setLookAndFeel(cLF);
for(Iterator it = roots.iterator(); it.hasNext();) {
Component root = (Component)it.next();
SwingUtilities.updateComponentTreeUI( root );
}
} catch (Exception ex) {
Activator.log.error("Failed to set LF " + newLFClassName, ex);
}
} else { // Otherwise, go for one of the installed LFs
if (newLFClassName!=null && !newLFClassName.equals(currentLFClassName)) {
try {
Activator.log.debug("set installed LF " + newLFClassName);
UIManager.setLookAndFeel(newLFClassName);
try {
for(Iterator it = roots.iterator(); it.hasNext();) {
Component root = (Component)it.next();
SwingUtilities.updateComponentTreeUI( root );
}
} catch (NullPointerException npe) {
Activator.log.error
( "Unexpected error while applying new look and feel", npe);
}
} catch (UnsupportedLookAndFeelException exc) {
rb.setEnabled( false );
Activator.log.error( "Unsupported LookAndFeel: " + newLFName
+" ("+newLFClassName+")", exc );
// Fallback: Set L&F to cross platform L&F
Activator.log.error( "Reverting to the cross platform LookAndFeel." );
final String cpLFcn = UIManager.getCrossPlatformLookAndFeelClassName();
// Find the menu item with the cross platform L&F and select it
for (Enumeration lfBEnum = lfGroup.getElements();
lfBEnum.hasMoreElements(); ) {
final AbstractButton ab =(AbstractButton)lfBEnum.nextElement();
if (cpLFcn.equals( ab.getActionCommand() )) {
SwingUtilities.invokeLater( new Runnable(){
public void run() { ab.setSelected(true); }} );
break;
}
}
} catch (Exception exc) {
rb.setEnabled(false);
Activator.log.error("Could not load LookAndFeel: " +rb.getText(), exc);
}
} else {
// Selected current LF, noop
}
}