Example usage for com.google.gwt.user.client Element setInnerHTML

List of usage examples for com.google.gwt.user.client Element setInnerHTML

Introduction

In this page you can find the example usage for com.google.gwt.user.client Element setInnerHTML.

Prototype

@Override
    public void setInnerHTML(String html) 

Source Link

Usage

From source file:org.nsesa.editor.gwt.an.amendments.client.handler.common.content.AkomaNtoso20AmendmentBuilder.java

License:EUPL

public OverlayWidget build() {
    final Counter idGenerator = new Counter();

    final AkomaNtoso akomaNtoso = new AkomaNtoso();
    final Amendment root = akomaNtoso.setAmendment(new Amendment());

    // meta/*from  www.jav  a  2  s  .  c  om*/
    final Identification identification = new Identification();
    //        final String formattedDate = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.ISO_8601).format(new Date());
    final String formattedDate = DateTimeFormat.getFormat("yyyy-MM-dd").format(new Date());
    identification.setFRBRWork(new FRBRWork() {
        {
            setFRBRthis(new FRBRthis().valueAttr(s("TODO")));
            addFRBRuri(new FRBRuri().valueAttr(s("TODO")));
            addFRBRdate(new FRBRdate().dateAttr(d(formattedDate)).nameAttr(s("instantiation")));
            addFRBRauthor(new FRBRauthor().hrefAttr(u("#refTodo")));
            setFRBRcountry(new FRBRcountry().valueAttr(s("TODO")));
        }
    });

    identification.setFRBRExpression(new FRBRExpression() {
        {
            setFRBRthis(new FRBRthis().valueAttr(s("TODO")));
            addFRBRuri(new FRBRuri().valueAttr(s("TODO")));
            addFRBRdate(new FRBRdate().dateAttr(d(formattedDate)).nameAttr(s("instantiation")));
            addFRBRauthor(new FRBRauthor().hrefAttr(u("#refTodo")));
            addFRBRauthor(new FRBRauthor().hrefAttr(u("#refTodo")));
            addFRBRlanguage(new FRBRlanguage().languageAttr(l(languageIso)));
        }
    });

    identification.setFRBRManifestation(new FRBRManifestation() {
        {
            setFRBRthis(new FRBRthis().valueAttr(s("TODO")));
            addFRBRuri(new FRBRuri().valueAttr(s("TODO")));
            addFRBRdate(new FRBRdate().dateAttr(d(formattedDate)).nameAttr(s("instantiation")));
            addFRBRauthor(new FRBRauthor().hrefAttr(u("#refTodo")));
        }
    });

    final Meta meta = new Meta();
    root.setMeta(meta);
    meta.setIdentification(identification).sourceAttr(u("http://at4am.org/"));

    References references = new References();

    references.addTLCOrganization(new TLCOrganization().idAttr(id("ep-parliament"))
            .showAsAttr(s("European Parliament")).hrefAttr(u("http://www.europarl.europa.eu")));
    // keep a reference to the amended document
    if (documentController != null) {
        String documentId = documentController.getDocument().getDocumentID();
        final boolean isRemote = documentId.startsWith("http://") || documentId.startsWith("https://");
        if (isRemote) {
            references.addActiveRef(
                    new ActiveRef(u(documentId), id(documentId.substring(documentId.lastIndexOf("/") + 1)),
                            s(documentController.getDocument().getName())));
        } else {
            references.addActiveRef(new ActiveRef(u("http://at4am.org/xml/"), id(documentId),
                    s(documentController.getDocument().getName())));
        }
    }

    for (final PersonDTO authorial : authors) {
        final IDSimpleType idSimpleType = new IDSimpleType();
        idSimpleType.setValue("person-" + authorial.getPersonID());

        final StringSimpleType stringSimpleType = new StringSimpleType();
        stringSimpleType.setValue(authorial.getDisplayName());

        final AnyURISimpleType anyURISimpleType = new AnyURISimpleType();
        anyURISimpleType.setValue("urn:lex:eu:parliament:codict:person:" + authorial.getPersonID());

        references.addTLCPerson(
                new TLCPerson().idAttr(idSimpleType).showAsAttr(stringSimpleType).hrefAttr(anyURISimpleType));
    }

    meta.addReferences(references).sourceAttr(u("http://at4am.org/"));

    // preface;
    final P p = new P();
    for (final PersonDTO authorial : authors) {
        final DocProponent docProponent = new DocProponent()
                .refersToAttr(u("#person-" + authorial.getPersonID()));
        docProponent.html(authorial.getDisplayName());
        p.addDocProponent(docProponent);
    }
    root.setPreface(new Preface()).addContainer(
            new Container().idAttr(id("container-" + idGenerator.incrementAndGet())).nameAttr(s("authors")))
            .addP(p);

    // amendment body
    final AmendmentBody amendmentBody = root.setAmendmentBody(new AmendmentBody());

    amendmentBody.addAmendmentHeading(new AmendmentHeading()).addBlock(new Block()).nameAttr(s("heading"))
            .html(TextUtils.capitalize(location));

    // amendment content
    final AmendmentContent amendmentContent = amendmentBody.addAmendmentContent(new AmendmentContent());

    amendmentContent.addBlock(new Block()).nameAttr(s("versionTitle")).html("Text proposed");
    amendmentContent.addBlock(new Block()).nameAttr(s("versionTitle")).html("Amendment");

    final Mod mod = amendmentContent.addBlock(new Block()).nameAttr(s("changeBlock")).addMod(new Mod())
            .idAttr(id("mod-" + idGenerator.incrementAndGet()));

    // original content
    final QuotedStructure quotedStructureOriginal = mod.addQuotedStructure(new QuotedStructure())
            .idAttr(id("quotedStructure-" + idGenerator.incrementAndGet()));

    final com.google.gwt.user.client.Element cloneOriginal = DOM.clone(overlayWidget.asWidget().getElement(),
            false);
    cloneOriginal.setInnerHTML(originalText);
    final OverlayWidget overlayedOriginal = overlayFactory.getAmendableWidget(cloneOriginal);
    quotedStructureOriginal.addOverlayWidget(overlayedOriginal);

    // amendment content
    final QuotedStructure quotedStructureAmendment = mod.addQuotedStructure(new QuotedStructure())
            .idAttr(id("quotedStructure-" + idGenerator.incrementAndGet()));
    final com.google.gwt.user.client.Element clone = DOM.clone(overlayWidget.asWidget().getElement(), false);
    clone.setInnerHTML(amendmentText);
    final OverlayWidget overlayed = overlayFactory.getAmendableWidget(clone);
    if (modifyIds) {
        modifyIds(overlayed);
    }
    quotedStructureAmendment.addOverlayWidget(overlayed);

    // amendment notes
    mod.addAuthorialNote(new AuthorialNote()).idAttr(id("note-" + idGenerator.incrementAndGet())).addP(new P())
            .html(notes);

    // amendment justification

    if (justification != null && !"".equalsIgnoreCase(justification.trim())) {
        final AmendmentJustification amendmentJustification = new AmendmentJustification();
        amendmentJustification.addBlock(new Block()).nameAttr(s("justificationHeading")).html("Justification");
        amendmentJustification.addP(new P()).html(justification);
        amendmentBody.addAmendmentJustification(amendmentJustification);
    }

    akomaNtoso.addOverlayWidget(root);
    return akomaNtoso;
}

From source file:org.nsesa.editor.gwt.an.amendments.client.ui.amendment.action.AkomaNtoso20AmendmentActionPanelController.java

License:EUPL

@Inject
public AkomaNtoso20AmendmentActionPanelController(final AmendmentActionPanelView amendmentActionPanelView,
        final CoreMessages coreMessages, final Constants constants) {
    super(amendmentActionPanelView, coreMessages);
    this.exportPopupPanel.setWidget(mainPanel);

    this.mainPanel.setHeight("600px");
    this.mainPanel.setWidth("800px");
    this.mainPanel.add(scrollPanel);
    buttonPanel.setWidth("800px");
    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    this.mainPanel.add(buttonPanel);
    buttonPanel.add(closeButton);//  w  ww.j  a  va 2 s . c o  m
    this.scrollPanel.setHeight("570px");
    this.scrollPanel.setWidth("100%");
    this.scrollPanel.setWidget(content);
    this.content.setHeight("100%");
    this.content.setWidth("100%");

    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            exportPopupPanel.hide();
        }
    });

    final Anchor history = new Anchor(constants.amendmentActionHistory());
    history.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            final ServiceFactory serviceFactory = amendmentController.getDocumentController()
                    .getServiceFactory();
            final ClientFactory clientFactory = amendmentController.getDocumentController().getClientFactory();

            final ComparisonProvider comparisonProvider = new ComparisonProvider() {
                @Override
                public void getRevisionContent(final String revisionID,
                        final AsyncCallback<String> asyncCallback) {
                    serviceFactory.getGwtAmendmentService().getAmendmentContainerRevision(
                            clientFactory.getClientContext(), revisionID,
                            new AsyncCallback<AmendmentContainerDTO>() {
                                @Override
                                public void onFailure(final Throwable caught) {
                                    asyncCallback.onFailure(caught);
                                }

                                @Override
                                public void onSuccess(final AmendmentContainerDTO result) {
                                    // wrap in a span to correct the rendering via amendment.css
                                    final Element span = DOM.createSpan();
                                    span.setInnerHTML(result.getBody());
                                    final String body = "<div class='amendmentHolder'><div>"
                                            + span.getFirstChildElement() + "</div></div>";
                                    asyncCallback.onSuccess(body);
                                }
                            });
                }

                @Override
                public void getRevisions(final AsyncCallback<List<RevisionDTO>> asyncCallback) {
                    serviceFactory.getGwtAmendmentService().getRevisions(clientFactory.getClientContext(),
                            amendmentController.getModel().getId(),
                            new AsyncCallback<ArrayList<RevisionDTO>>() {
                                @Override
                                public void onFailure(final Throwable caught) {
                                    asyncCallback.onFailure(caught);
                                }

                                @Override
                                public void onSuccess(final ArrayList<RevisionDTO> result) {
                                    asyncCallback.onSuccess(result);
                                }
                            });
                }

                @Override
                public void rollback(final String revisionID) {
                    serviceFactory.getGwtAmendmentService().getAmendmentContainerRevision(
                            clientFactory.getClientContext(), revisionID,
                            new AsyncCallback<AmendmentContainerDTO>() {
                                @Override
                                public void onFailure(Throwable caught) {
                                    clientFactory.getEventBus().fireEvent(new CriticalErrorEvent(
                                            "Could not rollback revision: " + caught.getMessage(), caught));
                                }

                                @Override
                                public void onSuccess(AmendmentContainerDTO result) {
                                    // force an update of the revision ID to let the backend know we're aware of the latest version
                                    result.setRevisionID(amendmentController.getModel().getRevisionID());
                                    amendmentController.getDocumentController().getDocumentEventBus()
                                            .fireEvent(new AmendmentContainerSaveEvent(result));
                                    popupPanel.hide();
                                }
                            });
                }
            };

            amendmentController.getDocumentController().getClientFactory().getEventBus().fireEvent(
                    new ShowComparePanelEvent(amendmentController.getDocumentController(), comparisonProvider));
            popupPanel.hide();
        }
    });
    //        TODO not finished yet (needs extraction of the amendment text).
    addSeparator();
    addWidget(history);

    final Anchor xmlExport = new Anchor(constants.amendmentActionExportXml());
    xmlExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/xml/"
                    + amendmentController.getModel().getId();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    final Anchor pdfExport = new Anchor(constants.amendmentActionExportPdf());
    pdfExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/pdf/"
                    + amendmentController.getModel().getId();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    final Anchor wordExport = new Anchor(constants.amendmentActionExportWord());
    wordExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/word/"
                    + amendmentController.getModel().getId();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    final Anchor htmlExport = new Anchor(constants.amendmentActionExportHtml());
    htmlExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/html/"
                    + amendmentController.getModel().getId();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    addSeparator();
    addWidget(xmlExport);
    addWidget(pdfExport);
    addWidget(wordExport);
    addWidget(htmlExport);

}

From source file:org.nsesa.editor.gwt.an.amendments.client.ui.amendment.action.AkomaNtosoAmendmentActionPanelController.java

License:EUPL

@Inject
public AkomaNtosoAmendmentActionPanelController(final AmendmentActionPanelView amendmentActionPanelView,
        final CoreMessages coreMessages, final SharePanelController sharePanelController,
        final Constants constants) {
    super(amendmentActionPanelView, coreMessages, sharePanelController);
    this.exportPopupPanel.setWidget(mainPanel);

    this.mainPanel.setHeight("600px");
    this.mainPanel.setWidth("800px");
    this.mainPanel.add(scrollPanel);
    buttonPanel.setWidth("800px");
    buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    this.mainPanel.add(buttonPanel);
    closeButton.setText(constants.amendmentActionClose());
    buttonPanel.add(closeButton);/*from ww  w  .j a  va 2 s  .c o m*/
    this.scrollPanel.setHeight("570px");
    this.scrollPanel.setWidth("100%");
    this.scrollPanel.setWidget(content);
    this.content.setHeight("100%");
    this.content.setWidth("100%");

    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            exportPopupPanel.hide();
        }
    });

    final Anchor history = new Anchor(constants.amendmentActionHistory());
    history.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            final ServiceFactory serviceFactory = amendmentController.getDocumentController()
                    .getServiceFactory();
            final ClientFactory clientFactory = amendmentController.getDocumentController().getClientFactory();

            final ComparisonProvider comparisonProvider = new ComparisonProvider() {
                @Override
                public void getRevisionContent(final String revisionID,
                        final AsyncCallback<String> asyncCallback) {
                    serviceFactory.getGwtAmendmentService().getAmendmentContainerRevision(
                            clientFactory.getClientContext(), revisionID,
                            new AsyncCallback<AmendmentContainerDTO>() {
                                @Override
                                public void onFailure(final Throwable caught) {
                                    asyncCallback.onFailure(caught);
                                }

                                @Override
                                public void onSuccess(final AmendmentContainerDTO result) {
                                    // wrap in a span to correct the rendering via amendment.css
                                    final Element span = DOM.createSpan();
                                    span.setInnerHTML(result.getBody());
                                    final String body = "<div class='amendmentHolder'><div>"
                                            + DOM.toString((Element) span.getFirstChildElement())
                                            + "</div></div>";
                                    asyncCallback.onSuccess(body);
                                }
                            });
                }

                @Override
                public void getRevisions(final AsyncCallback<List<RevisionDTO>> asyncCallback) {
                    serviceFactory.getGwtAmendmentService().getRevisions(clientFactory.getClientContext(),
                            amendmentController.getModel().getAmendmentContainerID(),
                            new AsyncCallback<ArrayList<RevisionDTO>>() {
                                @Override
                                public void onFailure(final Throwable caught) {
                                    asyncCallback.onFailure(caught);
                                }

                                @Override
                                public void onSuccess(final ArrayList<RevisionDTO> result) {
                                    asyncCallback.onSuccess(result);
                                }
                            });
                }

                @Override
                public void rollback(final String revisionID) {
                    serviceFactory.getGwtAmendmentService().getAmendmentContainerRevision(
                            clientFactory.getClientContext(), revisionID,
                            new AsyncCallback<AmendmentContainerDTO>() {
                                @Override
                                public void onFailure(Throwable caught) {
                                    clientFactory.getEventBus().fireEvent(new CriticalErrorEvent(
                                            "Could not rollback revision: " + caught.getMessage(), caught));
                                }

                                @Override
                                public void onSuccess(AmendmentContainerDTO result) {
                                    // force an update of the revision ID to let the backend know we're aware of the latest version
                                    result.setRevisionID(amendmentController.getModel().getRevisionID());
                                    amendmentController.getDocumentController().getDocumentEventBus()
                                            .fireEvent(new AmendmentContainerSaveEvent(result));
                                    popupPanel.hide();
                                }
                            });
                }
            };

            amendmentController.getDocumentController().getClientFactory().getEventBus().fireEvent(
                    new ShowComparePanelEvent(amendmentController.getDocumentController(), comparisonProvider));
            popupPanel.hide();
        }
    });
    //        TODO not finished yet (needs extraction of the amendment text).
    addSeparator();
    addWidget(history);

    final Anchor xmlExport = new Anchor(constants.amendmentActionExportXml());
    xmlExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/xml/"
                    + amendmentController.getModel().getAmendmentContainerID();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    final Anchor pdfExport = new Anchor(constants.amendmentActionExportPdf());
    pdfExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/pdf/"
                    + amendmentController.getModel().getAmendmentContainerID();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    final Anchor wordExport = new Anchor(constants.amendmentActionExportWord());
    wordExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/word/"
                    + amendmentController.getModel().getAmendmentContainerID();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    final Anchor openOfficeExport = new Anchor(constants.amendmentActionExportOo());
    openOfficeExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/odt/"
                    + amendmentController.getModel().getAmendmentContainerID();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    final Anchor htmlExport = new Anchor(constants.amendmentActionExportHtml());
    htmlExport.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final String url = GWT.getModuleBaseURL() + "download/amendment/html/"
                    + amendmentController.getModel().getAmendmentContainerID();
            Window.open(URL.encode(url), "download", "");
            popupPanel.hide();
        }
    });
    addSeparator();
    addWidget(xmlExport);
    addWidget(pdfExport);
    addWidget(wordExport);
    addWidget(openOfficeExport);
    addWidget(htmlExport);

}

From source file:org.nsesa.editor.gwt.dialog.client.ui.handler.create.AmendmentDialogCreateController.java

License:EUPL

/**
 * Validates the content before saving/*from  w w  w . j a va 2s .co  m*/
 *
 * @return True if the content is valid
 */
protected boolean validate() {
    //validate the overlay
    String content = view.getAmendmentContent();
    //replace all validation-error class names with empty
    content = content.replaceAll("validation-error", "");
    final com.google.gwt.user.client.Element clone = DOM
            .clone(dialogContext.getOverlayWidget().asWidget().getElement(), false);
    clone.setInnerHTML(content);
    OverlayWidget overlayWidget = overlayFactory.getAmendableWidget(clone);
    ValidationResult validationResult = overlayWidgetValidator.validate(overlayWidget);
    boolean isValid = validationResult.isSuccessful();
    if (!isValid) {
        OverlayWidget invalidWidget = validationResult.getInvalidWidget();
        if (invalidWidget != null) {
            //mark the widget as invalid
            invalidWidget.getOverlayElement().addClassName("validation-error");

            invalidWidget.getOverlayElement().setAttribute("error", validationResult.getErrorMessage());
        } else {
            overlayWidget.getOverlayElement().addClassName("validation-error");
            overlayWidget.getOverlayElement().setAttribute("error", validationResult.getErrorMessage());
        }
        view.setAmendmentContent(overlayWidget.getOverlayElement().getInnerHTML());
    }
    return isValid;
}

From source file:org.nsesa.editor.gwt.dialog.client.ui.handler.modify.AmendmentDialogModifyController.java

License:EUPL

/**
 * Validates the content before saving/*from   w w  w . jav a2s.c  om*/
 *
 * @return True if content is valid
 */
protected boolean validate() {
    //validate the overlay
    String content = view.getAmendmentContent();
    //replace all validation-error class names with empty string
    content = content.replaceAll("validation-error", "");
    final com.google.gwt.user.client.Element clone = DOM
            .clone(dialogContext.getOverlayWidget().asWidget().getElement(), false);
    clone.setInnerHTML(content);
    OverlayWidget clonedOverlayWidgetToValidate = overlayFactory.getAmendableWidget(clone);
    ValidationResult validationResult = overlayWidgetValidator.validate(clonedOverlayWidgetToValidate);
    boolean isValid = validationResult.isSuccessful();
    if (!isValid) {
        OverlayWidget invalidWidget = validationResult.getInvalidWidget();
        if (invalidWidget != null) {
            //mark the widget as invalid
            invalidWidget.getOverlayElement().addClassName("validation-error");

            invalidWidget.getOverlayElement().setAttribute("error", validationResult.getErrorMessage());
        } else {
            clonedOverlayWidgetToValidate.getOverlayElement().addClassName("validation-error");
            clonedOverlayWidgetToValidate.getOverlayElement().setAttribute("error",
                    validationResult.getErrorMessage());
        }
        view.setAmendmentContent(clonedOverlayWidgetToValidate.getOverlayElement().getInnerHTML());
        //            view.getRichTextEditor().setOverlayWidget(clonedOverlayWidgetToValidate);
    }
    return isValid;
}

From source file:org.opencms.ui.client.CmsLoadingIndicator.java

License:Open Source License

/**
 * @see com.vaadin.client.VLoadingIndicator#getElement()
 *///from   w ww. j av a2  s. co m
@Override
public Element getElement() {

    Element element = super.getElement();
    if (element.getChildCount() == 0) {
        element.setInnerHTML(CmsVaadinConstants.LOADING_INDICATOR_HTML);
    }
    return element;
}

From source file:org.pentaho.pac.client.common.ui.ExternalHyperlink.java

License:Open Source License

public ExternalHyperlink(String label, String link, boolean isOpenInNewWindow) {
    super();/*from www .  jav a 2  s .com*/

    Element a = DOM.createAnchor();

    a.setAttribute("href", link); //$NON-NLS-1$

    if (isOpenInNewWindow) {
        a.setAttribute("target", "_blank"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    a.setInnerHTML(label);

    this.setElement(a);
}

From source file:org.raccoon.hit.client.ui.player.skin.AviaVolumeControl.java

License:Apache License

/**
 * Constructs <code>VolumeControl</code>.  This constructor is provided for complete CSS styling
 * support.  An horizontal slider of height {@code sliderHeight} is
 * displayed when this control is clicked on.
 *
 * <p>The slider popup panel has a fixed width of 50px.
 *
 * @param sliderHeight the height of the volume slider control.
 * @since 1.2//from ww  w . j  a  v a2 s  .  co m
 */
public @UiConstructor AviaVolumeControl(int sliderHeight) {

    liElements = new Element[VOLUME_COUNT];
    aElements = new Element[VOLUME_COUNT];

    final Element divElement = DOM.createDiv();
    divElement.setClassName("gwt-AviaVolume");

    final Element ulElement = DOM.createElement("ul");
    divElement.appendChild(ulElement);

    final Element spanTrick = DOM.createSpan();
    spanTrick.getStyle().setProperty("display", "block");
    spanTrick.getStyle().setProperty("clear", "both");
    spanTrick.setInnerHTML("<!-- -->");
    divElement.appendChild(spanTrick);

    value = 0;

    // Set volume element
    Element li = DOM.createElement("li");
    Element a = DOM.createAnchor();
    a.setAttribute("href", "javascript:;");
    li.appendChild(a);
    volumeElement = li;
    volumeElement.getStyle().setProperty("background", "url(\"img/music/volume.png\")");
    DOM.sinkEvents(a, Event.ONCLICK);
    ulElement.appendChild(li);

    setElement(divElement);

    // Set volume level
    for (int i = 0; i < VOLUME_COUNT; i++) {
        li = DOM.createElement("li");
        a = DOM.createAnchor();
        a.setAttribute("href", "javascript:;");
        li.appendChild(a);
        liElements[i] = li;
        aElements[i] = a;
        DOM.sinkEvents(a, Event.ONCLICK);
        ulElement.appendChild(li);
    }

    render();
    initVolumeControl(sliderHeight);
}

From source file:org.rhq.coregui.client.LoginView.java

License:Open Source License

private void setLoginError(String error) {
    Element errorDiv = DOM.getElementById(LOGIN_ERROR_DIV_ID);
    Element feedbackDiv = DOM.getElementById(ERROR_FEEDBACK_DIV_ID);
    if (errorDiv != null && feedbackDiv != null) {
        errorDiv.setInnerHTML(error);
        feedbackDiv.setClassName(error != null ? "showError" : "hideError");
    }// w  ww. j  av  a 2  s  .  c o  m
}

From source file:org.talend.mdm.webapp.stagingarea.control.client.view.StagingContainerSummaryView.java

License:Open Source License

@Override
public void onModelEvent(ModelEvent e) {
    GwtEvent.Type<ModelEventHandler> type = e.getAssociatedType();
    if (type == ModelEvent.Types.CONTAINER_MODEL_CHANGED.getType()) {
        StagingContainerModel stagingContainerModel = e.getModel();
        // Updates summary
        int waiting = stagingContainerModel.getWaitingValidationRecords();
        int valid = stagingContainerModel.getValidRecords();
        int invalid = stagingContainerModel.getInvalidRecords();
        Element titleEl = detailPanel.getElementById(STAGING_AREA_TITLE);
        titleEl.setInnerHTML(messages.total_desc("<b>" + stagingContainerModel.getTotalRecords() + "</b>")); //$NON-NLS-1$ //$NON-NLS-2$
        Element waitingEl = detailPanel.getElementById(STAGING_AREA_WAITING);
        waitingEl.setInnerHTML(messages.waiting_desc("<b>" + waiting + "</b>")); //$NON-NLS-1$ //$NON-NLS-2$
        Element invalidEl = detailPanel.getElementById(STAGING_AREA_INVALID);
        invalidEl.setInnerHTML(messages.invalid_desc(
                "<span id=\"open_invalid_record\" style=\"color:red; text-decoration:underline; cursor:pointer;\">", //$NON-NLS-1$
                "<b>" + invalid + "</b>", "</span>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        Element open_invalid_record = detailPanel.getElementById("open_invalid_record"); //$NON-NLS-1$
        addClickForRecord(2, open_invalid_record);
        Element validEl = detailPanel.getElementById(STAGING_AREA_VALID);
        validEl.setInnerHTML(messages.valid_desc(
                "<span id=\"open_valid_record\" style=\"color:green; text-decoration:underline; cursor:pointer;\">", //$NON-NLS-1$
                "<b>" + valid + "</b>", "</span>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        Element open_valid_record = detailPanel.getElementById("open_valid_record"); //$NON-NLS-1$
        addClickForRecord(3, open_valid_record);
        // Update gauge bar
        int total = valid + invalid + waiting;
        if (total == 0) {
            gaugeBar.reset();/* ww w.java 2 s.  c o m*/
            return;
        }
        double percentage = valid * 1D / total;
        NumberFormat format = NumberFormat.getFormat("#0.00"); //$NON-NLS-1$
        final double validPercentage = format.parse(format.format(valid * 100D / total));
        if (gaugeBar.getValue() < 1.0 || totalRecordCount != total) {
            gaugeBar.updateProgress(percentage, messages.percentage(valid, total, validPercentage));
        }
        totalRecordCount = total;
    } else if (type == ModelEvent.Types.VALIDATION_END.getType()
            || type == ModelEvent.Types.VALIDATION_CANCEL.getType()) {
        startValidate.enable();
    } else if (type == ModelEvent.Types.VALIDATION_START.getType()) {
        startValidate.disable();
    }
}