/** * Returns if a value has changed into the report. * * @return if a value has changed into the report. */ public boolean hasValueChanged() { if (ClientUtils.isEmpty(textAreas)) { return false; } for (final Entry<Integer, String> entry : oldContents.entrySet()) { final HasHTML textArea = textAreas.get(entry.getKey()); if (!ClientUtils.equals(textArea.getHTML(), entry.getValue())) { return true; } } return false; }
public void setText(String html) { if (iReadOnly == null) { iReadOnly = new P("label"); iReadOnly.setVisible(!getWidget().isVisible()); if (iPrint != null) iReadOnly.addStyleName("unitime-NoPrint"); insert(iReadOnly, 1); } if (iReadOnly instanceof HasHTML) { ((HasHTML)iReadOnly).setHTML(html); } else if (iReadOnly instanceof HasText) { ((HasText)iReadOnly).setText(html); } }
@Override public HasHTML getCaptionWidget() { if (captionWidget instanceof HasHTML) { return (HasHTML) captionWidget; } else { return null; } }
/** * {@inheritDoc} */ @Override public HasHTML addTextArea(final RichTextElementDTO richTextElement, final FoldPanel sectionPanel, final boolean draftMode) { if (draftMode) { final RichTextArea textArea = new RichTextArea(); textArea.setHTML(richTextElement.getText()); textArea.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { globalFormatterArray[0] = textArea.getFormatter(); } }); sectionPanel.add(textArea); return textArea; } else { final HTML html = new HTML(); final String value = richTextElement.getText(); if (ClientUtils.isBlank(value)) { html.setText(I18N.CONSTANTS.reportEmptySection()); html.addStyleName(STYLE_PROJECT_REPORT_FIELD_EMPTY); } else { html.setHTML(value); html.addStyleName(STYLE_PROJECT_REPORT_FIELD); } sectionPanel.add(html); return null; } }
/** * {@inheritDoc} */ @Override public HasHTML addKeyQuestion(final KeyQuestionDTO keyQuestion, final FoldPanel sectionPanel, final boolean draftMode) { keyQuestionState.increaseCount(); keyQuestion.setNumber(keyQuestionState.getCount()); // Rich text field. final RichTextArea textArea = new RichTextArea(); final RichTextElementDTO richTextElementDTO = keyQuestion.getRichTextElementDTO(); if (richTextElementDTO != null) { textArea.setHTML(richTextElementDTO.getText()); } // Compas icon. final ImageResource icon; if (ClientUtils.isBlank(textArea.getText())) { icon = ToolbarImages.IMAGES.compasRed(); } else { icon = ToolbarImages.IMAGES.compasGreen(); keyQuestionState.increaseValids(); } sectionPanel.addToolButton(icon, new ClickHandler() { @Override public void onClick(ClickEvent event) { KeyQuestionDialog.getDialog(keyQuestion, textArea, sectionPanel, sectionPanel.getToolButtonCount(), keyQuestionState, draftMode).show(); } }); return textArea; }
/** * Returns the report sections corresponding HTML changes map. * * @return The report sections corresponding HTML changes map. */ private Map<String, Object> getChanges() { final Map<String, Object> changes = new HashMap<String, Object>(); for (final Map.Entry<Integer, HasHTML> textArea : textAreas.entrySet()) { changes.put(textArea.getKey().toString(), textArea.getValue().getHTML()); } return changes; }
@Override public HasHTML getDetails() { return projectDetailsPanel; }
/** @return the existing HTML property of a widget. */ public static SafeHtml get(HasHTML t) { return new SafeHtmlString(t.getHTML()); }
/** Set the HTML property of a widget. */ public static <T extends HasHTML> T set(T e, SafeHtml str) { e.setHTML(str.asString()); return e; }
@Override public void setCaptionWidget(HasHTML aCaptionWidget) { window.setCaptionWidget(aCaptionWidget); }
@Override public HasHTML getCaptionWidget() { return window.getCaptionWidget(); }
@Override public HasHTML getTextField() { return valueField; }
/** * {@inheritDoc} */ @Override public HasHTML getNameLabel() { return usernameLabel; }
/** * {@inheritDoc} */ @Override public HasHTML getNameLabel() { return nameLabel; }
/** * Method executed on report save action. * * @param report * The current report. * @param changes * The changes. * @param loadingMask * Set to {@code true} to display a loading mask on the entire report during save action. Set to * {@code false} to ignore loading mask. */ private void onSaveReport(final ProjectReportDTO report, final Map<String, Object> changes, final boolean loadingMask) { changes.put(ProjectReportDTO.CURRENT_PHASE, phaseName); dispatch.execute(new UpdateEntity(ProjectReportDTO.ENTITY_NAME, report.getVersionId(), changes), new CommandResultHandler<VoidResult>() { @Override public void onCommandFailure(final Throwable caught) { N10N.error(I18N.CONSTANTS.projectTabReports(), I18N.CONSTANTS.reportSaveError()); } @Override public void onCommandSuccess(final VoidResult result) { N10N.infoNotif(I18N.CONSTANTS.projectTabReports(), I18N.CONSTANTS.reportSaveSuccess()); // -- // Updates store. // -- for (int index = 0; index < view.getReportsStore().getCount(); index++) { final ReportReference reference = view.getReportsStore().getAt(index); if (reference.getId().equals(report.getId())) { view.getReportsStore().remove(reference); reference.setEditorName(auth().getUserShortName()); reference.setPhaseName(phaseName); reference.setLastEditDate(new Date()); view.getReportsStore().add(reference); break; } } // -- // Updates changes. // -- if (ClientUtils.isEmpty(textAreas)) { return; } for (final Entry<Integer, String> entry : oldContents.entrySet()) { final HasHTML textArea = textAreas.get(entry.getKey()); oldContents.put(entry.getKey(), textArea.getHTML()); } // -- // Cancels timer. // -- autoSaveTimer.cancel(); autoSaveTimer.schedule(AUTO_SAVE_PERIOD); } }, loadingMask ? new LoadingMask(view.getMainPanel()) : null); }
/** * Adds a new rich textarea to the given {@code sectionPanel}. * * @param richTextElement * The rich text element data. * @param sectionPanel * The parent section panel. * @param draftMode * If the section is loaded in draft mode. * @return The {@link HasHTML} instance associated to the rich text element (if <em>draft</em> mode), or * {@code null}. */ HasHTML addTextArea(RichTextElementDTO richTextElement, FoldPanel sectionPanel, boolean draftMode);
/** * Adds a new key question to the given {@code sectionPanel}. * * @param keyQuestion * The key question element data. * @param sectionPanel * The parent section panel. * @param draftMode * If the section is loaded in draft mode. * @return The {@link HasHTML} instance associated to the key question. */ HasHTML addKeyQuestion(final KeyQuestionDTO keyQuestion, final FoldPanel sectionPanel, final boolean draftMode);
HasHTML getDetails();
public void setCaptionWidget(HasHTML aCaptionWidget);
public HasHTML getCaptionWidget();
public HasHTML getTextField();
HasHTML getNameLabel();