blob: d6d5c907be28d617f97bff70ac6015908b8764b1 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010, 2011 Mia-Software.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nicolas Bros (Mia-Software)
*******************************************************************************/
package org.eclipse.gmt.modisco.infra.common.ui.internal.util;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public final class DialogUtils {
private DialogUtils() {
// not instantiable
}
public static void openErrorDialog(final Shell shell, final Throwable e, final String title) {
StackTraceElement[] stackTrace = e.getStackTrace();
final String stack;
if (stackTrace.length > 0) {
stack = "\n" + stackTrace[0].toString(); //$NON-NLS-1$
} else {
stack = ""; //$NON-NLS-1$
}
final String message;
if (e.getMessage() != null) {
message = " : " + e.getMessage(); //$NON-NLS-1$
} else {
message = ""; //$NON-NLS-1$
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
MessageDialog.openError(shell, title, e.getClass().getSimpleName() + message
+ stack);
}
});
}
}