| package org.eclipse.cdt.managedbuilder.internal.ui; |
| |
| /********************************************************************** |
| * Copyright (c) 2002,2003 Rational Software Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v0.5 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v05.html |
| * |
| * Contributors: |
| * IBM Rational Software - Initial API and implementation |
| * **********************************************************************/ |
| |
| import java.text.MessageFormat; |
| import java.util.MissingResourceException; |
| import java.util.ResourceBundle; |
| |
| import org.eclipse.core.runtime.IPluginDescriptor; |
| import org.eclipse.core.runtime.Plugin; |
| |
| |
| public class ManagedBuilderUIPlugin extends Plugin { |
| //The shared instance. |
| private static ManagedBuilderUIPlugin plugin; |
| //Resource bundle. |
| private static ResourceBundle resourceBundle; |
| |
| /** |
| * @param descriptor |
| */ |
| public ManagedBuilderUIPlugin(IPluginDescriptor descriptor) { |
| super(descriptor); |
| plugin = this; |
| try { |
| resourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.managedbuilder.internal.ui.PluginResources"); //$NON-NLS-1$ |
| } catch (MissingResourceException x) { |
| resourceBundle = null; |
| } |
| } |
| |
| /** |
| * Returns the shared instance. |
| */ |
| public static ManagedBuilderUIPlugin getDefault() { |
| return plugin; |
| } |
| |
| public static String getResourceString(String key) { |
| try { |
| return resourceBundle.getString(key); |
| } catch (MissingResourceException e) { |
| return "!" + key + "!"; |
| } catch (NullPointerException e) { |
| return "#" + key + "#"; |
| } |
| } |
| |
| public static String getFormattedString(String key, String arg) { |
| return MessageFormat.format(getResourceString(key), new String[] { arg }); |
| } |
| |
| public static String getFormattedString(String key, String[] args) { |
| return MessageFormat.format(getResourceString(key), args); |
| } |
| |
| /** |
| * Convenience method which returns the unique identifier of this plugin. |
| */ |
| public static String getUniqueIdentifier() { |
| if (getDefault() == null) { |
| // If the default instance is not yet initialized, |
| // return a static identifier. This identifier must |
| // match the plugin id defined in plugin.xml |
| return "org.eclipse.cdt.managedbuilder.ui"; //$NON-NLS-1$ |
| } |
| return getDefault().getDescriptor().getUniqueIdentifier(); |
| } |
| |
| } |