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.gui.action;
20:
21: import java.awt.Component;
22: import java.awt.event.ActionEvent;
23: import java.util.HashSet;
24: import java.util.Locale;
25: import java.util.Set;
26:
27: import org.apache.jmeter.util.JMeterUtils;
28: import org.apache.jorphan.logging.LoggingManager;
29: import org.apache.log.Logger;
30:
31: /**
32: * @version $Revision: 493779 $
33: */
34: public class ChangeLanguage implements Command {
35: private static final Set commands = new HashSet();
36:
37: private static final Logger log = LoggingManager
38: .getLoggerForClass();
39:
40: static {
41: commands.add(ActionNames.CHANGE_LANGUAGE);
42: }
43:
44: /**
45: * @see org.apache.jmeter.gui.action.Command#doAction(ActionEvent)
46: */
47: public void doAction(ActionEvent e) {
48: String locale = ((Component) e.getSource()).getName();
49: Locale loc;
50:
51: int sep = locale.indexOf('_');
52: if (sep > 0) {
53: loc = new Locale(locale.substring(0, sep), locale
54: .substring(sep + 1));
55: } else {
56: loc = new Locale(locale, "");
57: }
58: log.debug("Changing locale to " + loc.toString());
59: JMeterUtils.setLocale(loc);
60: }
61:
62: /**
63: * @see org.apache.jmeter.gui.action.Command#getActionNames()
64: */
65: public Set getActionNames() {
66: return commands;
67: }
68: }
|