01: /*
02: * MCS Media Computer Software Copyright (c) 2006 by MCS
03: * -------------------------------------- Created on 07.08.2006 by w.klaas
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License. You may obtain a copy of
07: * 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, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package de.mcs.jmeasurement.gui;
18:
19: import java.util.MissingResourceException;
20: import java.util.ResourceBundle;
21:
22: import javax.swing.Icon;
23: import javax.swing.ImageIcon;
24:
25: /**
26: * resource bundle class generated by eclipse.
27: *
28: * @author w.klaas
29: *
30: */
31: public final class Messages {
32: /** the bundle to use. */
33: private static final String BUNDLE_NAME = "de.mcs.jmeasurement.gui.messages"; //$NON-NLS-1$
34:
35: /** getting a resource bundle. */
36: private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
37: .getBundle(BUNDLE_NAME);
38:
39: /**
40: * prevent instancing.
41: */
42: private Messages() {
43: }
44:
45: /**
46: * Getting a language string.
47: *
48: * @param key
49: * key to search for
50: * @return String the language depending string.
51: */
52: public static String getString(final String key) {
53: try {
54: return RESOURCE_BUNDLE.getString(key);
55: } catch (MissingResourceException e) {
56: return '!' + key + '!';
57: }
58: }
59:
60: /**
61: * getting an image. the image file will be constructed with the actual fil
62: * epath for images and if the active or passive gif should be used.
63: *
64: * @param name
65: * name of the image (without extension and "_act" or "_pas" and
66: * path
67: * @param active
68: * the active variant.
69: * @return Icon the icon to display.
70: */
71: public static Icon getImage(final String name, final boolean active) {
72: StringBuffer buf = new StringBuffer();
73: buf.append("/de/mcs/jmeasurement/gui/images/");
74: buf.append(name);
75: if (active) {
76: buf.append("_act");
77: } else {
78: buf.append("_pas");
79: }
80: buf.append(".gif");
81: Icon exitIcon = new ImageIcon(name.getClass().getResource(
82: buf.toString()));
83: return exitIcon;
84: }
85: }
|