]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/workbench/WorkbenchResources.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / WorkbenchResources.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.ui.workbench;\r
13 \r
14 import java.text.MessageFormat;\r
15 import java.util.MissingResourceException;\r
16 import java.util.ResourceBundle;\r
17 \r
18 public final class WorkbenchResources {\r
19 \r
20     private static final ResourceBundle bundle = ResourceBundle.getBundle("org.simantics.ui.workbench.messages"); //$NON-NLS-1$\r
21 \r
22     /**\r
23      * Returns the resource object with the given key in the Workbench resource\r
24      * bundle. If there isn't any value under the given key, the key is\r
25      * returned.\r
26      * \r
27      * @param key the resource name\r
28      * @return the string\r
29      */\r
30     public static final String getString(String key) {\r
31         try {\r
32             return bundle.getString(key);\r
33         } catch (MissingResourceException e) {\r
34             return key;\r
35         }\r
36     }\r
37 \r
38     /**\r
39      * Returns the formatted message for the given key in the Workbench resource\r
40      * bundle.\r
41      * \r
42      * @param key the resource name\r
43      * @param args the message arguments\r
44      * @return the string\r
45      */\r
46     public static String format(String key, Object[] args) {\r
47         return MessageFormat.format(getString(key), args);\r
48     }\r
49 \r
50 }\r