1 11 package org.eclipse.ui.internal.ide; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.jface.dialogs.ErrorDialog; 16 import org.eclipse.jface.dialogs.MessageDialog; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.ui.PartInitException; 20 21 28 public class DialogUtil { 29 30 33 private DialogUtil() { 34 } 35 36 41 public static void openError(Shell parent, String title, String message, 42 PartInitException exception) { 43 CoreException nestedException = null; 45 IStatus status = exception.getStatus(); 46 if (status != null && status.getException() instanceof CoreException) { 47 nestedException = (CoreException) status.getException(); 48 } 49 50 if (nestedException != null) { 51 ErrorDialog.openError(parent, title, message, nestedException 54 .getStatus()); 55 } else { 56 MessageDialog.openError(parent, title, message); 59 } 60 } 61 62 68 public static int availableRows(Composite parent) { 69 70 int fontHeight = (parent.getFont().getFontData())[0].getHeight(); 71 int displayHeight = parent.getDisplay().getClientArea().height; 72 73 return displayHeight / fontHeight; 74 } 75 76 85 public static boolean inRegularFontMode(Composite parent) { 86 87 return availableRows(parent) > 50; 88 } 89 } 90 | Popular Tags |