01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.report.gui.action;
20:
21: import java.awt.event.ActionEvent;
22: import java.util.HashSet;
23: import java.util.Set;
24:
25: import javax.swing.SwingUtilities;
26: import javax.swing.UIManager;
27:
28: import org.apache.jmeter.gui.action.Command;
29: import org.apache.jmeter.gui.ReportGuiPackage;
30: import org.apache.jmeter.util.JMeterUtils;
31:
32: /**
33: * @author Brendan Burns
34: * @version $Revision: 493793 $
35: */
36: public class ReportLookAndFeelCommand implements Command {
37:
38: private static Set commands = new HashSet();
39: static {
40: UIManager.LookAndFeelInfo[] lfs = UIManager
41: .getInstalledLookAndFeels();
42: for (int i = 0; i < lfs.length; i++) {
43: commands.add("laf:" + lfs[i].getClassName());
44: }
45:
46: try {
47: String defaultUI = JMeterUtils.getPropDefault("jmeter.laf",
48: UIManager.getCrossPlatformLookAndFeelClassName());
49: UIManager.setLookAndFeel(defaultUI);
50: } catch (Exception e) {
51: }
52: }
53:
54: public ReportLookAndFeelCommand() {
55: }
56:
57: public void doAction(ActionEvent ev) {
58: try {
59: String className = ev.getActionCommand().substring(4)
60: .replace('/', '.');
61: UIManager.setLookAndFeel(className);
62: SwingUtilities.updateComponentTreeUI(ReportGuiPackage
63: .getInstance().getMainFrame());
64: } catch (javax.swing.UnsupportedLookAndFeelException e) {
65: JMeterUtils.reportErrorToUser("Look and Feel unavailable:"
66: + e.toString());
67: } catch (InstantiationException e) {
68: JMeterUtils.reportErrorToUser("Look and Feel unavailable:"
69: + e.toString());
70: } catch (ClassNotFoundException e) {
71: JMeterUtils.reportErrorToUser("Look and Feel unavailable:"
72: + e.toString());
73: } catch (IllegalAccessException e) {
74: JMeterUtils.reportErrorToUser("Look and Feel unavailable:"
75: + e.toString());
76: }
77: }
78:
79: public Set getActionNames() {
80: return commands;
81: }
82: }
|