use of com.github.bordertech.wcomponents.WImageEditor in project wcomponents by BorderTech.
the class WImageEditorRenderer method doRender.
/**
* Paints the given {@link WImageEditor}.
*
* @param component the WImageEditor to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WImageEditor editorComponent = (WImageEditor) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("wc-imageedit");
xml.appendAttribute("id", editorComponent.getId());
xml.appendOptionalAttribute("class", editorComponent.getHtmlClass());
xml.appendOptionalUrlAttribute("overlay", editorComponent.getOverlayUrl());
xml.appendOptionalAttribute("camera", editorComponent.getUseCamera());
xml.appendOptionalAttribute("face", editorComponent.getIsFace());
xml.appendOptionalAttribute("inline", editorComponent.getRenderInline());
// Check for size information on the image
Dimension size = editorComponent.getSize();
if (size != null) {
if (size.getHeight() >= 0) {
xml.appendAttribute("height", size.height);
}
if (size.getWidth() >= 0) {
xml.appendAttribute("width", size.width);
}
}
xml.appendEnd();
}
use of com.github.bordertech.wcomponents.WImageEditor in project wcomponents by BorderTech.
the class WMultiFileWidgetRenderer method doRender.
/**
* Paints the given WMultiFileWidget.
*
* @param component the WMultiFileWidget to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WMultiFileWidget widget = (WMultiFileWidget) component;
XmlStringBuilder xml = renderContext.getWriter();
// Check if rendering a file upload response
String uploadId = widget.getFileUploadRequestId();
if (uploadId != null) {
handleFileUploadRequest(widget, xml, uploadId);
return;
}
boolean readOnly = widget.isReadOnly();
xml.appendTagOpen(TAG_NAME);
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("hidden", widget.isHidden(), "true");
if (readOnly) {
xml.appendAttribute("readOnly", "true");
} else {
long maxFileSize = widget.getMaxFileSize();
int maxFiles = widget.getMaxFiles();
WComponent dropzone = widget.getDropzone();
WImageEditor editor = widget.getEditor();
xml.appendOptionalAttribute("disabled", widget.isDisabled(), "true");
xml.appendOptionalAttribute("required", widget.isMandatory(), "true");
xml.appendOptionalAttribute("toolTip", widget.getToolTip());
xml.appendOptionalAttribute("accessibleText", widget.getAccessibleText());
xml.appendOptionalAttribute("acceptedMimeTypes", typesToString(widget.getFileTypes()));
xml.appendOptionalAttribute("maxFileSize", maxFileSize > 0, maxFileSize);
xml.appendOptionalAttribute("maxFiles", maxFiles > 0, maxFiles);
if (dropzone != null) {
xml.appendAttribute("dropzone", dropzone.getId());
}
if (editor != null) {
xml.appendAttribute("editor", editor.getId());
if (editor.getUseCamera()) {
xml.appendAttribute("camera", true);
}
}
}
if (widget.getColumns() != null) {
xml.appendAttribute("cols", widget.getColumns());
}
if (widget.getFileAjaxAction() != null) {
xml.appendAttribute("ajax", "true");
}
List<Diagnostic> diags = readOnly ? null : widget.getDiagnostics(Diagnostic.ERROR);
if (widget.getFiles().isEmpty()) {
if (readOnly || diags == null || diags.isEmpty()) {
xml.appendEnd();
return;
}
xml.appendClose();
} else {
xml.appendClose();
// Render files
int i = 0;
for (FileWidgetUpload file : widget.getFiles()) {
FileWidgetRendererUtil.renderFileElement(widget, xml, file, i++);
}
}
if (!readOnly && diags != null && !diags.isEmpty()) {
DiagnosticRenderUtil.renderDiagnostics(widget, renderContext);
}
xml.appendEndTag(TAG_NAME);
}
Aggregations