Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIUtils.java')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIUtils.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIUtils.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIUtils.java
new file mode 100644
index 000000000..c6ab08c97
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIUtils.java
@@ -0,0 +1,74 @@
+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();
+ }
+ }
+}
+

Back to the top