blob: a671aea851101dd8ac151d5590d4eb35a3bb3379 [file] [log] [blame]
package org.eclipse.cdt.managedbuilder.core;
/**********************************************************************
* 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 ManagedBuilderCorePlugin extends Plugin {
//The shared instance.
private static ManagedBuilderCorePlugin plugin;
//Resource bundle.
private static ResourceBundle resourceBundle;
/**
* @param descriptor
*/
public ManagedBuilderCorePlugin(IPluginDescriptor descriptor) {
super(descriptor);
plugin = this;
try {
resourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.managedbuilder.internal.core.PluginResources"); //$NON-NLS-1$
} catch (MissingResourceException x) {
resourceBundle = null;
}
}
/**
* Returns the shared instance.
*/
public static ManagedBuilderCorePlugin 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.core"; //$NON-NLS-1$
}
return getDefault().getDescriptor().getUniqueIdentifier();
}
}