1 11 package org.eclipse.help.ui.internal.util; 12 13 import org.eclipse.help.internal.base.util.IErrorUtil; 14 import org.eclipse.help.ui.internal.Messages; 15 import org.eclipse.jface.dialogs.MessageDialog; 16 import org.eclipse.swt.widgets.Display; 17 import org.eclipse.swt.widgets.Shell; 18 import org.eclipse.ui.IWorkbenchWindow; 19 import org.eclipse.ui.PlatformUI; 20 21 24 public class ErrorUtil implements IErrorUtil { 25 26 public void displayError(String msg) { 27 displayErrorDialog(msg); 28 } 29 30 public void displayError(final String msg, Thread uiThread) { 31 try { 32 Display.findDisplay(uiThread).asyncExec(new Runnable () { 33 34 public void run() { 35 displayErrorDialog(msg); 36 } 37 }); 38 } catch (Exception e2) { 39 } 40 } 41 42 48 public static void displayErrorDialog(String msg) { 49 String title = Messages.Help_Error; 50 IWorkbenchWindow workbenchWindow = getActiveWorkbenchWindow(); 51 Shell shell; 52 if (workbenchWindow != null) { 53 shell = workbenchWindow.getShell(); 54 } else { 55 shell = new Shell(); 56 } 57 MessageDialog.openError(shell, title, msg); 58 } 59 60 66 public static void displayInfoDialog(String msg) { 67 String title = Messages.Help_Info; 68 IWorkbenchWindow workbenchWindow = getActiveWorkbenchWindow(); 69 Shell shell; 70 if (workbenchWindow != null) { 71 shell = workbenchWindow.getShell(); 72 } else { 73 shell = new Shell(); 74 } 75 MessageDialog.openInformation(shell, title, msg); 76 } 77 78 83 public static boolean displayQuestionDialog(String msg) { 84 String title = Messages.Help_Question; 85 IWorkbenchWindow workbenchWindow = getActiveWorkbenchWindow(); 86 Shell shell; 87 if (workbenchWindow != null) { 88 shell = workbenchWindow.getShell(); 89 } else { 90 shell = new Shell(); 91 } 92 return MessageDialog.openQuestion(shell, title, msg); 93 } 94 95 protected static IWorkbenchWindow getActiveWorkbenchWindow() { 96 return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); 97 } 98 } 99 | Popular Tags |