Author: sebb
Date: Fri Apr 24 16:56:19 2009
New Revision: 768367
URL: http://svn.apache.org/viewvc?rev=768367&view=rev
Log:
Allow LAF override based on OS name
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/LookAndFeelCommand.java
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/LookAndFeelCommand.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/LookAndFeelCommand.java?rev=768367&r1=768366&r2=768367&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/LookAndFeelCommand.java
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/action/LookAndFeelCommand.java
Fri Apr 24 16:56:19 2009
@@ -20,6 +20,7 @@
import java.awt.event.ActionEvent;
import java.util.HashSet;
+import java.util.Locale;
import java.util.Set;
import javax.swing.SwingUtilities;
@@ -34,6 +35,8 @@
*/
public class LookAndFeelCommand implements Command {
+ private static final String JMETER_LAF = "jmeter.laf"; // $NON-NLS-1$
+
private static final Set commands = new HashSet();
static {
@@ -43,9 +46,7 @@
}
try {
- String defaultUI = JMeterUtils.getPropDefault("jmeter.laf",
UIManager
- .getCrossPlatformLookAndFeelClassName());
- UIManager.setLookAndFeel(defaultUI);
+ UIManager.setLookAndFeel(getJMeterLaf());
} catch (IllegalAccessException e) {
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) {
@@ -53,6 +54,37 @@
}
}
+ /**
+ * Get LookAndFeel classname from the following properties:
+ * <ul>
+ * <li>jmeter.laf.<os.name> - lowercased; spaces replaced by '_'</li>
+ * <li>jmeter.laf.<os.family> - lowercased.</li>
+ * <li>jmeter.laf</li>
+ * <li>UIManager.getCrossPlatformLookAndFeelClassName()</li>
+ * </ul>
+ * @return LAF classname
+ */
+ private static String getJMeterLaf(){
+ String osName = System.getProperty("os.name") // $NON-NLS-1$
+ .toLowerCase(Locale.ENGLISH);
+ String laf;
+ // Spaces are not allowed in property names read from files
+ laf = JMeterUtils.getProperty(JMETER_LAF+"."+osName.replace(' ', '_'));
+ if (laf != null) {
+ return laf;
+ }
+ String osFamily = osName.substring(0, osName.indexOf(' '));// e.g.
windows xp => windows
+ laf = JMeterUtils.getProperty(JMETER_LAF+"."+osFamily);
+ if (laf != null) {
+ return laf;
+ }
+ laf = JMeterUtils.getProperty(JMETER_LAF);
+ if (laf != null) {
+ return laf;
+ }
+ return UIManager.getCrossPlatformLookAndFeelClassName();
+ }
+
public LookAndFeelCommand() {
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]