public void onTestConnectionError(Object message, Throwable throwable) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestFailedMessage) + "\n"); builder.appendEscapedLines(throwable.getMessage()); popupsUtil.showErrorPopup(builder.toSafeHtml().asString()); }
public void onTestConnectionSuccess(TestResult response) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (response.isTestPassed()) { builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestSuccessfulMessage) + "\n"); } else { builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestFailedMessage) + "\n"); } builder.appendEscapedLines(response.getMessage()); popupsUtil.showInformationPopup(builder.toSafeHtml().asString()); }
private void refreshAssociatedEntities(Map<String, String[]> entities) { view.setUsersGroupsListBox(""); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (entities.keySet().isEmpty()) { safeHtmlBuilder .appendEscapedLines(constants.NoUserOrGroupUsedInThisProcess()); view.setUsersGroupsListBox(safeHtmlBuilder.toSafeHtml().asString()); } else { for (String key : entities.keySet()) { StringBuffer names = new StringBuffer(); String[] entityNames = entities.get(key); if (entityNames != null) { for (String entity : entityNames) { names.append("'" + entity + "' "); } } safeHtmlBuilder.appendEscapedLines(names + " - " + key + "\n"); } view.setUsersGroupsListBox(safeHtmlBuilder.toSafeHtml().asString()); } }
private void refreshRequiredInputData(Map<String, String> inputs) { view.setProcessDataListBox(""); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (inputs.keySet().isEmpty()) { safeHtmlBuilder.appendEscapedLines(constants.NoProcessVariablesDefinedForThisProcess()); view.setProcessDataListBox(safeHtmlBuilder.toSafeHtml().asString()); } else { for (String key : inputs.keySet()) { safeHtmlBuilder.appendEscapedLines(key + " - " + inputs.get(key) + "\n"); } view.setProcessDataListBox(safeHtmlBuilder.toSafeHtml().asString()); } }
private static String buildHtmlEscapedText(final String message) { return new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().asString(); } }
private static String buildHtmlEscapedText(final String message) { return new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().asString(); }
@Override public void callback(final List<TaskDefSummary> userTaskSummaries) { view.setNumberOfHumanTasksText(String.valueOf(userTaskSummaries.size())); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (userTaskSummaries.isEmpty()) { safeHtmlBuilder.appendEscapedLines(constants.NoUserTasksDefinedInThisProcess()); view.setHumanTasksListBox(safeHtmlBuilder.toSafeHtml().asString()); } else { for (TaskDefSummary t : userTaskSummaries) { safeHtmlBuilder.appendEscapedLines(t.getName() + "\n"); } view.setHumanTasksListBox(safeHtmlBuilder.toSafeHtml().asString()); } } }).getProcessUserTasks(serverTemplateId,
private void refreshReusableSubProcesses(Collection<String> subprocesses) { view.setSubProcessListBox(""); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (subprocesses.isEmpty()) { safeHtmlBuilder.appendEscapedLines(constants.NoSubprocessesRequiredByThisProcess()); view.setSubProcessListBox(safeHtmlBuilder.toSafeHtml().asString()); } else { for (String key : subprocesses) { safeHtmlBuilder.appendEscapedLines(key + "\n"); } view.setSubProcessListBox(safeHtmlBuilder.toSafeHtml().asString()); } }
private void refreshServiceTasks(Map<String, String> services) { view.setProcessServicesListBox(""); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (services.keySet().isEmpty()) { safeHtmlBuilder.appendEscaped(constants.NoServicesRequiredForThisProcess()); view.setProcessServicesListBox(safeHtmlBuilder.toSafeHtml().asString()); } else { for (String key : services.keySet()) { safeHtmlBuilder.appendEscapedLines(key + " - " + services.get(key) + "\n"); } view.setProcessServicesListBox(safeHtmlBuilder.toSafeHtml().asString()); } }
@Override public void callback( Map<String, String> inputs ) { view.getProcessDataListBox().setText( "" ); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (inputs.keySet().isEmpty()) { safeHtmlBuilder.appendEscapedLines(constants.NoProcessVariablesDefinedForThisProcess()); view.getProcessDataListBox().setStyleName( "muted" ); view.getProcessDataListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } else { for (String key : inputs.keySet()) { safeHtmlBuilder.appendEscapedLines( key + " - " + inputs.get( key ) + "\n" ); } view.getProcessDataListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } } }, new ErrorCallback<Message>() {
@Override public void callback( Map<String, Collection<String>> entities ) { view.getUsersGroupsListBox().setText( "" ); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (entities.keySet().isEmpty()) { safeHtmlBuilder .appendEscapedLines(constants.NoUserOrGroupUsedInThisProcess()); view.getUsersGroupsListBox().setStyleName( "muted" ); view.getUsersGroupsListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } else { for (String key : entities.keySet()) { StringBuffer names = new StringBuffer(); Collection<String> entityNames = entities .get( key ); if (entityNames != null) { for (String entity : entityNames) { names.append( "'" + entity + "' " ); } } safeHtmlBuilder.appendEscapedLines( names + " - " + key + "\n" ); } view.getUsersGroupsListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } } }, new ErrorCallback<Message>() {
@Override public void callback( List<TaskDefSummary> tasks ) { view.getNroOfHumanTasksText().setText( String.valueOf( tasks.size() ) ); view.getHumanTasksListBox().setText( "" ); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (tasks.isEmpty()) { safeHtmlBuilder.appendEscapedLines(constants.NoUserTasksDefinedInThisProcess()); view.getHumanTasksListBox().setStyleName( "muted" ); view.getHumanTasksListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } else { for (TaskDefSummary t : tasks) { safeHtmlBuilder.appendEscapedLines( t.getName() + "\n" ); } view.getHumanTasksListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } } }, new ErrorCallback<Message>() {
@Override public void callback( Collection<String> subprocesses ) { view.getSubprocessListBox().setText( "" ); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (subprocesses.isEmpty()) { safeHtmlBuilder.appendEscapedLines(constants.NoSubprocessesRequiredByThisProcess()); view.getSubprocessListBox().setStyleName( "muted" ); view.getSubprocessListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } else { for (String key : subprocesses) { safeHtmlBuilder.appendEscapedLines( key + "\n" ); } view.getSubprocessListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } } }, new ErrorCallback<Message>() {
@Override public void callback( Map<String, String> services ) { view.getProcessServicesListBox().setText( "" ); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); if (services.keySet().isEmpty()) { safeHtmlBuilder.appendEscaped(constants.NoServicesRequiredForThisProcess()); view.getProcessServicesListBox().setStyleName( "muted" ); view.getProcessServicesListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } else { for (String key : services.keySet()) { safeHtmlBuilder.appendEscapedLines( key + " - " + services.get( key ) + "\n" ); } view.getProcessServicesListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } } }, new ErrorCallback<Message>() {
private void testConnection(boolean isValid) { TestResult result = new TestResult(isValid); result.setMessage("Message"); when(editorService.testConnection(any(DataSourceDef.class))).thenReturn(result); when(translationService.getTranslation( DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestFailedMessage)).thenReturn(ERROR); when(translationService.getTranslation( DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestSuccessfulMessage)).thenReturn("OK"); editorHelper.onTestConnection(); if (isValid) { verify(popupsUtil, times(1)).showInformationPopup( new SafeHtmlBuilder().appendEscapedLines("OK" + "\n" + "Message").toSafeHtml().asString()); } else { verify(popupsUtil, times(1)).showInformationPopup( new SafeHtmlBuilder().appendEscapedLines(ERROR + "\n" + "Message").toSafeHtml().asString()); } } }
@Test @SuppressWarnings("unchecked") public void testDiagramValidationMessage() { final ConstraintViolation<?> rootViolation = mock(ConstraintViolation.class); final Path propertyPath = mock(Path.class); when(propertyPath.toString()).thenReturn("path1"); when(rootViolation.getPropertyPath()).thenReturn(propertyPath); when(rootViolation.getMessage()).thenReturn("message1"); final ModelBeanViolation beanViolation = ModelBeanViolationImpl.Builder.build(rootViolation); final RuleViolation ruleViolation = mock(RuleViolation.class); final DiagramElementViolation<RuleViolation> diagramViolation = mock(DiagramElementViolation.class); when(diagramViolation.getUUID()).thenReturn("uuid1"); when(diagramViolation.getModelViolations()).thenReturn(Collections.singletonList(beanViolation)); when(diagramViolation.getGraphViolations()).thenReturn(Collections.singletonList(ruleViolation)); when(ruleViolation.getViolationType()).thenReturn(Violation.Type.WARNING); when(translationService.getViolationMessage(eq(ruleViolation))).thenReturn("rv1"); when(translationService.getValue(eq("aKey"))).thenReturn("aValue"); String message = CoreTranslationMessages.getDiagramValidationsErrorMessage(translationService, "aKey", Collections.singleton(diagramViolation)); message = new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().asString(); assertEquals("aValue." + HTML_NEW_LINE + "R" + COLON + HTML_NEW_LINE + OPEN_BRA + "E" + COLON + "uuid1" + CLOSE_BRA + HTML_NEW_LINE + "(WARNING) " + HTML_OPEN_COMMENT + "path1" + HTML_CLOSE_COMMENT + "message1" + HTML_NEW_LINE + "(WARNING) rv1" + HTML_NEW_LINE, message); } }
@Test public void testCanvasValidationMessage() { final RuleViolation ruleViolation = mock(RuleViolation.class); final CanvasViolation canvasViolation = mock(CanvasViolation.class); when(canvasViolation.getViolationType()).thenReturn(Violation.Type.ERROR); when(canvasViolation.getRuleViolation()).thenReturn(ruleViolation); when(ruleViolation.getViolationType()).thenReturn(Violation.Type.ERROR); when(ruleViolation.getViolationType()).thenReturn(Violation.Type.ERROR); final Iterable<CanvasViolation> violations = Collections.singletonList(canvasViolation); when(translationService.getValue(eq("aKey"))).thenReturn("aValue"); when(translationService.getViolationMessage(eq(canvasViolation))).thenReturn("cv1"); String message = CoreTranslationMessages.getCanvasValidationsErrorMessage(translationService, "aKey", violations); message = new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().asString(); assertEquals("aValue." + HTML_NEW_LINE + "R" + COLON + HTML_NEW_LINE + OPEN_BRA + "1" + CLOSE_BRA + "(ERROR) " + "cv1" + HTML_NEW_LINE, message); }
public void show() { clear(); stackPanel.setHTML(new SafeHtmlBuilder().appendEscapedLines(stack).toSafeHtml()); messageLabel.setText(message); messageLabel.setWordWrap(true); exceptionDialog.setPopupPositionAndShow(new PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { exceptionDialog.center(); } }); exceptionDialog.center(); }
@Override public void callback( List<NodeInstanceSummary> details ) { view.setCurrentActiveNodes( details ); view.getCurrentActivitiesListBox().setText( "" ); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); for ( NodeInstanceSummary nis : details ) { safeHtmlBuilder.appendEscapedLines( nis.getTimestamp() + ": " + nis.getId() + " - " + nis.getNodeName() + " (" + nis.getType() + ") \n" ); } view.getCurrentActivitiesListBox().setHTML( safeHtmlBuilder.toSafeHtml() ); } }, new ErrorCallback<Message>() {
protected String formatValue(IndicatorDTO indicator, Object value) { if(indicator.getType() == FieldTypeClass.QUANTITY) { if (value instanceof Double) { return indicatorValueFormatter.format((Double) value); } } else if(indicator.getType() == FieldTypeClass.FREE_TEXT) { if (value instanceof String) { return htmlEscape((String) value); } } else if(indicator.getType() == FieldTypeClass.NARRATIVE) { if (value instanceof String) { SafeHtmlBuilder html = new SafeHtmlBuilder(); html.appendEscapedLines((String)value); return html.toSafeHtml().asString(); } } return "-"; }