1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-22 15:53:58 +02:00

Removing unused ResourceBundle code. All function has migrated to the new properties initialization introduced in Eclipse 3.0.

This commit is contained in:
David Dykstal 2006-04-28 00:37:05 +00:00
parent ddb85dadad
commit a0151c0b62
2 changed files with 152 additions and 162 deletions

View file

@ -529,7 +529,7 @@ public class RSEUIPlugin extends SystemBasePlugin
svraf.registerWithManager(manager); svraf.registerWithManager(manager);
getInstallLocation(); // getInstallLocation();
//org.eclipse.rse.core.ui.uda.UserDefinedActionAdapterFactory udaaf = new org.eclipse.rse.core.ui.uda.UserDefinedActionAdapterFactory(); //org.eclipse.rse.core.ui.uda.UserDefinedActionAdapterFactory udaaf = new org.eclipse.rse.core.ui.uda.UserDefinedActionAdapterFactory();
//udaaf.registerWithManager(manager); //udaaf.registerWithManager(manager);

View file

@ -16,23 +16,18 @@
package org.eclipse.rse.core; package org.eclipse.rse.core;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.PropertyResourceBundle; import java.util.PropertyResourceBundle;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Stack; import java.util.Stack;
import java.util.Vector;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.resource.ImageRegistry;
@ -40,7 +35,6 @@ import org.eclipse.rse.logging.Logger;
import org.eclipse.rse.logging.LoggerFactory; import org.eclipse.rse.logging.LoggerFactory;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile; import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.messages.SystemUIMessageFile; import org.eclipse.rse.ui.messages.SystemUIMessageFile;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
@ -189,52 +183,54 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
* @param name of .properties file, without the '.properties' specified * @param name of .properties file, without the '.properties' specified
* @return ResourceBundle if loaded successfully, null if not. * @return ResourceBundle if loaded successfully, null if not.
*/ */
public static final ResourceBundle loadResourceBundle(Bundle bundle, String fileName) // public static final ResourceBundle loadResourceBundle(Bundle bundle, String fileName)
{ // {
ResourceBundle rb = null; // ResourceBundle rb = null;
boolean ok = false; // boolean ok = false;
try // try
{ // {
IPath path = new Path("$nl$/"+fileName+".properties"); // URL url = resolveBundleNameNL(bundle, fileName+".properties");
URL url = Platform.find(bundle, path); // logDebugMessage("SystemBasePlugin", "Trying this now: " + url.toString());
logDebugMessage("SystemBasePlugin", "Trying this now: " + url.toString()); // InputStream in = url.openStream();
rb = new PropertyResourceBundle(url.openStream()); // rb = new PropertyResourceBundle(in);
ok = true; // in.close();
} // ok = true;
catch (Exception exc) //
{ // }
logError("SystemBasePlugin - try for resource bundle " + fileName + " not successful!",exc); // catch (Exception exc)
} // {
// logError("SystemBasePlugin - try for resource bundle " + fileName + " not successful!",exc);
if (!ok) // }
{ //
Shell s = getActiveWorkbenchShell(); // if (!ok)
// {
if (s == null) { // Shell s = getActiveWorkbenchShell();
Display d = Display.getCurrent(); //
// if (s == null) {
if (d != null) { // Display d = Display.getCurrent();
s = d.getActiveShell(); //
} // if (d != null) {
else { // s = d.getActiveShell();
d = Display.getDefault(); // }
// else {
if (d != null) { // d = Display.getDefault();
s = d.getActiveShell(); //
} // if (d != null) {
} // s = d.getActiveShell();
} // }
// }
if (s != null) { // }
org.eclipse.swt.widgets.MessageBox mb = new org.eclipse.swt.widgets.MessageBox(s); //
mb.setText("Unexcepted Error"); // if (s != null) {
mb.setMessage("Unable to load resource file " + fileName + ".properties"); // org.eclipse.swt.widgets.MessageBox mb = new org.eclipse.swt.widgets.MessageBox(s);
mb.open(); // mb.setText("Unexcepted Error");
} // mb.setMessage("Unable to load resource file " + fileName + ".properties");
} // mb.open();
// }
return rb; // }
} //
// return rb;
// }
/** /**
* Returns the plugin.properties resource bundle associated with the specified plugin descriptor * Returns the plugin.properties resource bundle associated with the specified plugin descriptor
@ -242,20 +238,20 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
* @param descriptor for the plugin where the file is * @param descriptor for the plugin where the file is
* @return ResourceBundle if loaded successfully, null if not. * @return ResourceBundle if loaded successfully, null if not.
*/ */
public static final ResourceBundle loadPluginResourceBundle(Bundle bundle) // public static final ResourceBundle loadPluginResourceBundle(Bundle bundle)
{ // {
ResourceBundle rb = null; // ResourceBundle rb = null;
try // try
{ // {
rb = Platform.getResourceBundle(bundle); // rb = Platform.getResourceBundle(bundle);
} // }
catch (Exception exc) // catch (Exception exc)
{ // {
logInfo("try for resource bundle plugin.properties not successful!"); // logInfo("try for resource bundle plugin.properties not successful!");
} // }
//
return rb; // return rb;
} // }
/** /**
* Sets the default resource bundle for handling cases where strings aren't translated. Called by child class in their * Sets the default resource bundle for handling cases where strings aren't translated. Called by child class in their
@ -266,72 +262,74 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
* @param name of .properties file, without the '.properties' specified * @param name of .properties file, without the '.properties' specified
* @return ResourceBundle if loaded successfully, null if not. * @return ResourceBundle if loaded successfully, null if not.
*/ */
public static final ResourceBundle loadDefaultResourceBundle(Bundle bundle, // public static final ResourceBundle loadDefaultResourceBundle(Bundle bundle,
String fileName) // String fileName)
{ // {
ResourceBundle rb = null; // ResourceBundle rb = null;
boolean ok = false; // boolean ok = false;
try // try
{ // {
IPath path = new Path(fileName+".properties"); // String name = fileName+".properties";
URL url = Platform.find(bundle, path); // URL url = bundle.getEntry("/"+name);
logDebugMessage("SystemBasePlugin", "Trying this now: " + url.toString()); // logDebugMessage("SystemBasePlugin", "Trying this now: " + url.toString());
rb = new PropertyResourceBundle(url.openStream()); // InputStream in = url.openStream();
ok = true; // rb = new PropertyResourceBundle(in);
} // in.close();
catch (Exception exc) // ok = true;
{ // }
logError("SystemBasePlugin - try for resource bundle " + fileName + " not successful!",exc); // catch (Exception exc)
} // {
// logError("SystemBasePlugin - try for resource bundle " + fileName + " not successful!",exc);
if (!ok) // }
{ //
// if (!ok)
Shell s = getActiveWorkbenchShell(); // {
//
if (s == null) { // Shell s = getActiveWorkbenchShell();
Display d = Display.getCurrent(); //
// if (s == null) {
if (d != null) { // Display d = Display.getCurrent();
s = d.getActiveShell(); //
} // if (d != null) {
else { // s = d.getActiveShell();
d = Display.getDefault(); // }
// else {
if (d != null) { // d = Display.getDefault();
s = d.getActiveShell(); //
} // if (d != null) {
} // s = d.getActiveShell();
} // }
// }
if (s != null) { // }
org.eclipse.swt.widgets.MessageBox mb = new org.eclipse.swt.widgets.MessageBox(s); //
mb.setText("Unexcepted Error"); // if (s != null) {
mb.setMessage("Unable to load resource file " + fileName + ".properties"); // org.eclipse.swt.widgets.MessageBox mb = new org.eclipse.swt.widgets.MessageBox(s);
mb.open(); // mb.setText("Unexcepted Error");
} // mb.setMessage("Unable to load resource file " + fileName + ".properties");
} // mb.open();
// }
return rb; // }
} //
// return rb;
// }
/** /**
* Get a string from a given resource bundle. * Get a string from a given resource bundle.
* If not found, stack trace info is placed in the * If not found, stack trace info is placed in the
* plugin's log file to help pinpoint the offending code. * plugin's log file to help pinpoint the offending code.
*/ */
public static String getString(ResourceBundle resourceBundle, String key) // public static String getString(ResourceBundle resourceBundle, String key)
{ // {
try // try
{ // {
return resourceBundle.getString(key); // return resourceBundle.getString(key);
} // }
catch (MissingResourceException exc) // catch (MissingResourceException exc)
{ // {
SystemBasePlugin.logError("Missing resource: " + key, exc); // SystemBasePlugin.logError("Missing resource: " + key, exc);
} // }
return null; // return null;
} // }
/** /**
* Get a string from a given resource bundle, with an english string to * Get a string from a given resource bundle, with an english string to
@ -340,19 +338,19 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
* If not found, stack trace info is placed in the * If not found, stack trace info is placed in the
* plugin's log file to help pinpoint the offending code. * plugin's log file to help pinpoint the offending code.
*/ */
public static String getString(ResourceBundle resourceBundle, String key, String defaultString) // public static String getString(ResourceBundle resourceBundle, String key, String defaultString)
{ // {
String s = defaultString; // String s = defaultString;
try // try
{ // {
s = resourceBundle.getString(key); // s = resourceBundle.getString(key);
} // }
catch (MissingResourceException exc) // catch (MissingResourceException exc)
{ // {
SystemBasePlugin.logError("Missing resource: " + key, exc); // SystemBasePlugin.logError("Missing resource: " + key, exc);
} // }
return s; // return s;
} // }
// ------------------ // ------------------
// MESSAGE METHODS... // MESSAGE METHODS...
@ -404,10 +402,6 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
try { try {
URL url = resolveBundleNameNL(bundle, fileName); URL url = resolveBundleNameNL(bundle, fileName);
if (url != null) { if (url != null) {
// url = Platform.resolve(url);
// URL temp = Platform.getBundle(RSEUIPlugin.PLUGIN_ID).getEntry("/");
// temp = Platform.resolve(temp);
// url = Platform.resolve(url);
InputStream messageFileStream = url.openStream(); InputStream messageFileStream = url.openStream();
mf = SystemUIMessageFile.getMessageFile(fileName, messageFileStream); mf = SystemUIMessageFile.getMessageFile(fileName, messageFileStream);
messageFileStream.close(); messageFileStream.close();
@ -450,12 +444,8 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
SystemMessageFile mf = null; SystemMessageFile mf = null;
boolean ok = false; boolean ok = false;
try { try {
URL url = bundle.getEntry(fileName); URL url = bundle.getEntry("/"+fileName);
// IPath path = new Path(fileName);
// URL url = Platform.find(bundle, path);
// URL url = new URL(descriptor.getInstallURL(), fileName);
if (url != null) { if (url != null) {
// url = Platform.resolve(url);
InputStream messageFileStream = url.openStream(); InputStream messageFileStream = url.openStream();
mf = SystemUIMessageFile.getMessageFile(fileName, messageFileStream); mf = SystemUIMessageFile.getMessageFile(fileName, messageFileStream);
messageFileStream.close(); messageFileStream.close();
@ -705,19 +695,19 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin
/** /**
* Return the fully qualified install directory for this plugin. * Return the fully qualified install directory for this plugin.
*/ */
protected IPath getInstallLocation() { // protected IPath getInstallLocation() {
IPath prefix = null; // IPath prefix = null;
try // try
{ // {
String filePath = Platform.resolve(getBundle().getEntry("/")).getPath(); // String filePath = Platform.resolve(getBundle().getEntry("/")).getPath();
prefix = new Path(filePath); // prefix = new Path(filePath);
} // }
catch (Exception e) // catch (Exception e)
{ // {
prefix = new Path(getBundle().getEntry("/").getFile()); // prefix = new Path(getBundle().getEntry("/").getFile());
} // }
return prefix; // return prefix;
} // }
// ------------------------------------- // -------------------------------------
// ABSTRACTUIPLUGIN LIFECYCLE METHODS... // ABSTRACTUIPLUGIN LIFECYCLE METHODS...