blob: c6ab08c971cb31a0f9c73c034f1928fc8272a20b [file] [log] [blame]
package org.eclipse.debug.internal.ui;
/*
* Licensed Materials - Property of IBM,
* WebSphere Studio Workbench
* (c) Copyright IBM Corp 2001
*/
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* This class serves as a location for utility methods for the debug UI.
*/
public class DebugUIUtils {
private static ResourceBundle fgResourceBundle;
/**
* Utility method with conventions
*/
public static void errorDialog(Shell shell, String resourcePrefix, IStatus s) {
String message= getResourceString(resourcePrefix + "message");
// if the 'message' resource string and the IStatus' message are the same,
// don't show both in the dialog
if (s != null && message.equals(s.getMessage())) {
message= null;
}
String title= getResourceString(resourcePrefix + "title");
ErrorDialog.openError(shell, title, message, s);
}
/**
* Utility method
*/
public static String getResourceString(String key) {
if (fgResourceBundle == null) {
fgResourceBundle= getResourceBundle();
}
if (fgResourceBundle != null) {
return fgResourceBundle.getString(key);
} else {
return "!" + key + "!";
}
}
/**
* Returns the resource bundle used by all parts of the debug ui package.
*/
public static ResourceBundle getResourceBundle() {
try {
return ResourceBundle.getBundle("org.eclipse.debug.internal.ui.DebugUIResources");
} catch (MissingResourceException e) {
MessageDialog.openError(DebugUIPlugin.getActiveWorkbenchWindow().getShell(), "Error", e.toString());
}
return null;
}
/**
* Convenience method to log internal UI errors
*/
public static void logError(Exception e) {
if (DebugUIPlugin.getDefault().isDebugging()) {
System.out.println("Internal error logged from UI: ");
e.printStackTrace();
System.out.println();
}
}
}