/** * Handles core exceptions. This implementation logs the exceptions * with the workbench plug-in and shows an error dialog. * * @param exception the exception to be handled * @param message the message to be logged with the given exception */ protected void handleCoreException(CoreException exception, String message) { Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID); ILog log= Platform.getLog(bundle); if (message != null) log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, exception)); else log.log(exception.getStatus()); Shell shell= getTextEditor().getSite().getShell(); String title= getString(fBundle, fPrefix + "error.dialog.title", fPrefix + "error.dialog.title"); //$NON-NLS-2$ //$NON-NLS-1$ String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$ ErrorDialog.openError(shell, title, msg, exception.getStatus()); }
/** * Handles core exceptions. This implementation logs the exceptions * with the workbench plug-in and shows an error dialog. * * @param exception the exception to be handled * @param message the message to be logged with the given exception */ protected void handleCoreException(CoreException exception, String message) { Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID); ILog log= Platform.getLog(bundle); if (message != null) log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, exception)); else log.log(exception.getStatus()); Shell shell= getTextEditor().getSite().getShell(); String title= getString(fBundle, fPrefix + "error.dialog.title", fPrefix + "error.dialog.title"); //$NON-NLS-2$ //$NON-NLS-1$ String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$ ErrorDialog.openError(shell, title, msg, exception.getStatus()); }
/** * Execute the specified undoable operation. * * @param operation the operation to execute * @since 3.3 */ private void execute(IUndoableOperation operation) { final Shell shell= getTextEditor().getSite().getShell(); IAdaptable context= new IAdaptable() { public Object getAdapter(Class adapter) { if (adapter == Shell.class) return shell; return null; } }; IOperationHistory operationHistory= PlatformUI.getWorkbench().getOperationSupport().getOperationHistory(); try { operationHistory.execute(operation, null, context); } catch (ExecutionException e) { Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID); ILog log= Platform.getLog(bundle); String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$ log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, e)); } } }
/** * Execute the specified undoable operation. * * @param operation the operation to execute * @since 3.3 */ private void execute(IUndoableOperation operation) { final Shell shell= getTextEditor().getSite().getShell(); IAdaptable context= new IAdaptable() { @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> adapter) { if (adapter == Shell.class) return (T) shell; return null; } }; IOperationHistory operationHistory= PlatformUI.getWorkbench().getOperationSupport().getOperationHistory(); try { operationHistory.execute(operation, null, context); } catch (ExecutionException e) { Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID); ILog log= Platform.getLog(bundle); String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$ log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, e)); } } }