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