KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > junit > runtime > PdeJUnitPlugin


1 /*******************************************************************************
2  * Copyright (c) 2003, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.junit.runtime;
12
13 import java.util.*;
14
15 import org.eclipse.core.runtime.*;
16
17 /**
18  * @author melhem
19  *
20  */

21 public class PdeJUnitPlugin extends Plugin {
22     
23     private static PdeJUnitPlugin inst;
24     private ResourceBundle resourceBundle;
25     
26     public PdeJUnitPlugin(IPluginDescriptor descriptor) {
27         super(descriptor);
28         inst = this;
29         try {
30             resourceBundle =
31                 ResourceBundle.getBundle(
32                 "org.eclipse.pde.internal.junit.runtime.junitresources"); //$NON-NLS-1$
33
} catch (MissingResourceException x) {
34             resourceBundle = null;
35         }
36     }
37     
38     public static PdeJUnitPlugin getDefault() {
39         return inst;
40     }
41     
42     public static String JavaDoc getFormattedMessage(String JavaDoc key, String JavaDoc arg) {
43         String JavaDoc text = getResourceString(key);
44         return java.text.MessageFormat.format(text, new Object JavaDoc[] { arg });
45     }
46     
47     public static String JavaDoc getFormattedMessage(String JavaDoc key, String JavaDoc[] args) {
48         String JavaDoc text = getResourceString(key);
49         return java.text.MessageFormat.format(text, args);
50     }
51     
52     static IPath getInstallLocation() {
53         return new Path(inst.getDescriptor().getInstallURL().getFile());
54     }
55     
56     public static String JavaDoc getPluginId() {
57         return inst.getDescriptor().getUniqueIdentifier();
58     }
59     
60     public static String JavaDoc getResourceString(String JavaDoc key) {
61         ResourceBundle bundle = inst.getResourceBundle();
62         if (bundle != null) {
63             try {
64                 String JavaDoc bundleString = bundle.getString(key);
65                 return bundleString;
66             } catch (MissingResourceException e) {
67             }
68         }
69         return key;
70     }
71     
72     public ResourceBundle getResourceBundle() {
73         return resourceBundle;
74     }
75     
76     
77 }
78
Popular Tags