loganddisplaysaferunnable.java

来自「配置文件」· Java 代码 · 共 58 行

JAVA
58
字号
/**
 * Copyright (c) 2003-2005 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package eclipseme.ui.internal.utils;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.widgets.Shell;

import eclipseme.core.internal.EclipseMECorePlugin;
import eclipseme.core.internal.utils.LoggingSafeRunnable;

/**
 * Simple implementation of the ISafeRunnable interface that logs and displays
 * the exception.
 * <p />
 * Copyright (c) 2003-2005 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.3 $
 * <br>
 * $Date: 2005/07/07 02:36:26 $
 * <br>
 * @author Craig Setera
 */
public abstract class LogAndDisplaySafeRunnable extends LoggingSafeRunnable {
	private Shell shell;
	private String action;
	
	public LogAndDisplaySafeRunnable(Shell shell, String action) {
		this.shell = shell;
		this.action = action;
	}
	
	/**
	 * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
	 */
	public void handleException(Throwable exception) {
		super.handleException(exception);
		
		IStatus status = EclipseMECorePlugin.newStatus(
				IStatus.ERROR, 
				-999, 
				exception.getMessage(),
				exception);
		
		ErrorDialog.openError(
			shell,
			"Error Occurred",
			"An error occurred during " + action,
			status);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?