/** * Create error message command. * * @return the remote message command */ protected RemoteMessageCommand createErrorMessageCommand() { RemoteMessageCommand errorMessageCommand = new RemoteMessageCommand(); errorMessageCommand.setTitle(getTranslation("error", getLocale())); errorMessageCommand.setTitleIcon(getIconFactory().getErrorIcon(getIconFactory().getTinyIconSize())); errorMessageCommand.setMessageIcon(getIconFactory().getErrorIcon(getIconFactory().getLargeIconSize())); return errorMessageCommand; }
/** * Handle duplicate session list. * * @param locale * the locale * @param controller * the controller * @return the list */ protected List<RemoteCommand> handleDuplicateSession(Locale locale, IFrontendController<RComponent, RIcon, RAction> controller) { RemoteMessageCommand errorMessage = createErrorMessageCommand(); errorMessage.setMessage(controller.getTranslation("session.dup", new Object[] { controller.getI18nName(controller, locale) }, locale)); // Do not return the singleton list directly since subclasses might add commands to it. return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage)); }
/** * {@inheritDoc} */ @Override public void popupInfo(RComponent sourceComponent, String title, String iconImageUrl, String message) { RemoteMessageCommand messageCommand = new RemoteMessageCommand(); messageCommand.setTitle(title); messageCommand.setMessage(message); messageCommand.setTitleIcon(getIconFactory().getInfoIcon(getIconFactory().getTinyIconSize())); if (iconImageUrl != null) { messageCommand.setMessageIcon(getIconFactory().getIcon(iconImageUrl, getIconFactory().getLargeIconSize())); } else { messageCommand.setMessageIcon(getIconFactory().getInfoIcon(getIconFactory().getLargeIconSize())); } registerCommand(messageCommand); }
/** * {@inheritDoc} */ @Override public boolean handleException(Throwable ex, Map<String, Object> context) { if (super.handleException(ex, context)) { return true; } RemoteMessageCommand errorMessageCommand; String userFriendlyExceptionMessage = computeUserFriendlyExceptionMessage(ex); if (userFriendlyExceptionMessage != null) { errorMessageCommand = createErrorMessageCommand(); errorMessageCommand.setMessage(userFriendlyExceptionMessage); } else { errorMessageCommand = createDetailedErrorMessageCommand(); traceUnexpectedException(ex); errorMessageCommand.setMessage(ex.getLocalizedMessage()); StringWriter stringWriter = new StringWriter(); ex.printStackTrace(new PrintWriter(stringWriter)); ((RemoteErrorMessageCommand) errorMessageCommand).setDetailMessage(stringWriter.toString()); // This is a very unexpected exception. Too risky to continue since there could be de-synchronizations // between client and server. stop(); } registerCommand(errorMessageCommand); return true; }
protected RemoteMessageCommand createErrorMessageCommand() { IIconFactory<RIcon> iconFactory = getFrontendController().getViewFactory() .getIconFactory(); RemoteMessageCommand messageCommand = new RemoteMessageCommand(); messageCommand.setTitle(getFrontendController().getTranslation("error", getFrontendController().getLocale())); messageCommand.setTitleIcon(iconFactory.getErrorIcon(iconFactory .getTinyIconSize())); messageCommand.setMessageIcon(iconFactory.getErrorIcon(iconFactory .getLargeIconSize())); return messageCommand; }
/** * Handle version incompatibility list. * * @param startCommand * the start command * @param controller * the controller * @param locale * the locale * @return the list */ protected List<RemoteCommand> handleVersionIncompatibility(RemoteStartCommand startCommand, IFrontendController<RComponent, RIcon, RAction> controller, Locale locale) { RemoteMessageCommand errorMessage = createErrorMessageCommand(); assert controller != null; errorMessage.setMessage(controller.getTranslation( "incompatible.client.version", new Object[] { startCommand.getVersion(), Build.getJspressoVersion() }, locale)); // Do not return the singleton list directly since subclasses might add commands to it. return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage)); }
/** * Callback after a failed login. */ protected void loginFailed() { RemoteMessageCommand errorMessageCommand = createErrorMessageCommand(); errorMessageCommand.setMessage(getTranslation(LoginUtils.LOGIN_FAILED, getLocale())); registerCommand(errorMessageCommand); }
RemoteMessageCommand errorMessage = createErrorMessageCommand(); errorMessage .setMessage("An unexpected error occurred while starting the server. Please contact the application manager.");