com.google.gwt.safehtml.shared.SafeHtml Java Examples

The following examples show how to use com.google.gwt.safehtml.shared.SafeHtml. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapEditorTest.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Test
public void testShowErrors() throws Exception {
    EditorError e1 = mockEditorError(presenter, "m1");
    EditorError e2 = mockEditorError(presenter, "m2");
    List<EditorError> errors = new ArrayList<EditorError>(2);
    errors.add(e1);
    errors.add(e2);
    presenter.showErrors(errors);
    final ArgumentCaptor<SafeHtml> errorSafeHtmlCaptor =  ArgumentCaptor.forClass(SafeHtml.class);
    verify(view, times(1)).showError(errorSafeHtmlCaptor.capture());
    verify(view, times(0)).clearError();
    verify(view, times(0)).init(presenter);
    verify(view, times(0)).setAddText(anyString());
    verify(view, times(0)).setEmptyText(anyString());
    verify(view, times(0)).addButtonColumn(anyInt(), anyString(), anyInt());
    verify(view, times(0)).addTextColumn(anyInt(), anyString(), anyBoolean(), anyInt());
    verify(view, times(0)).setData(anyList());
    verify(view, times(0)).setRowCount(anyInt());
    verify(view, times(0)).removeColumn(anyInt());
    final SafeHtml value = errorSafeHtmlCaptor.getValue();
    Assert.assertEquals("m1\nm2", value.asString());
}
 
Example #2
Source File: ColumnProfileView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void setPreview(final SafeHtml html) {

    if(locked) return;

    if (
            (contentCanvas.getWidgetCount()>0  && !contentCanvas.getElement().hasAttribute("presenter-view"))
                    || (contentCanvas.getWidgetCount() ==0)
            ) {

            contentCanvas.clear();
            contentCanvas.add(new ScrollPanel(new HTML(html)));
            contentCanvas.getElement().removeAttribute("presenter-view");

    }
}
 
Example #3
Source File: ImageListEditorTest.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
public void testShowErrors() throws Exception {
    EditorError e1 = mockEditorError(presenter, "m1");
    EditorError e2 = mockEditorError(presenter, "m2");
    List<EditorError> errors = new ArrayList<EditorError>(2);
    errors.add(e1);
    errors.add(e2);
    
    presenter.showErrors(errors);
    final ArgumentCaptor<SafeHtml> errorSafeHtmlCaptor =  ArgumentCaptor.forClass(SafeHtml.class);
    verify(view, times(0)).clear();
    verify(view, times(0)).init(any(ImageListEditor.class));
    verify(view, times(0)).clearError();
    verify(view, times(0)).add(any(SafeUri.class), anyString(), anyString(), any(SafeHtml.class),
            any(SafeHtml.class), anyBoolean(), any(Command.class));
    verify(view, times(1)).showError(errorSafeHtmlCaptor.capture());
    final SafeHtml value = errorSafeHtmlCaptor.getValue();
    Assert.assertEquals("m1\nm2", value.asString());
}
 
Example #4
Source File: FileUploadEditorTest.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Test
public void testOnSubmitComplete() throws Exception {
    when(view.getFileName()).thenReturn("ff");
    presenter.onSubmitComplete("OK");
    assertEquals("ff", presenter.value);
    verify(view, times(0)).addHelpContent(anyString(), anyString(), any(Placement.class));
    verify(view, times(0)).init(presenter);
    verify(view, times(0)).setFileUploadName(anyString());
    verify(view, times(1)).setFileUploadVisible(true);
    verify(view, times(0)).setFileLabelText(anyString());
    verify(view, times(0)).setFileLabelVisible(anyBoolean());
    verify(view, times(1)).setLoadingImageVisible(false);
    verify(view, times(1)).getFileName();
    verify(view, times(0)).setFormAction(anyString());
    verify(view, times(0)).submit();
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(2)).clearError();
    verify( workbenchNotificationEvent, times( 1 ) ).fire(any(NotificationEvent.class));
    verify( valueChangeEvent, times( 1 ) ).fire(any(ValueChangeEvent.class));
}
 
Example #5
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml unmanaged() {
    // TODO I18n or take from DMR
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
    addHelpTextRow(builder, "Path:",
            Console.CONSTANTS.unmanagedDeploymentPathDescription());
    addHelpTextRow(builder, "Relative To:",
            Console.CONSTANTS.unmanagedDeploymentRelativeToDescription());
    addHelpTextRow(builder, "Is Archive?:",
            Console.CONSTANTS.unmanagedDeploymentArchiveDescription());
    addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
    addHelpTextRow(builder, "Runtime Name:",
            Console.CONSTANTS.deploymentRuntimeNameDescription());
    if (Console.getBootstrapContext().isStandalone()) {
        addHelpTextRow(builder, "Enable:",
                Console.CONSTANTS.deploymentEnabledDescription());
    }
    return builder.toSafeHtml();
}
 
Example #6
Source File: ContentBox.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ContentBox(final String id, final String title, final SafeHtml body, final String linkTitle,
                  final String linkTarget) {

    dp = new DisclosurePanel();
    dp.setHeader(new HTML(TEMPLATES.header(IdHelper.asId(id + "_", getClass(), "_" + "header"), title)));
    dp.addOpenHandler(this);
    dp.addCloseHandler(this);
    dp.setOpen(true);

    String linkId = IdHelper.asId(id + "_", getClass(), "_" + "link");
    HTMLPanel panel = new HTMLPanel(TEMPLATES.body(body, linkId));
    panel.addStyleName("homepage-content-box-body");
    InlineHyperlink hyperlink = new InlineHyperlink(linkTitle, linkTarget);
    hyperlink.addStyleName("homepage-link");
    panel.add(hyperlink, linkId);
    dp.add(panel);

    initWidget(dp);
    setStyleName("homepage-content-box");
}
 
Example #7
Source File: CellBrowser.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Get the HTML representation of an image.
 *
 * @param res the {@link ImageResource} to render as HTML
 * @return the rendered HTML
 */
private SafeHtml getImageHtml(ImageResource res) {
  // Right-justify image if LTR, left-justify if RTL
  AbstractImagePrototype proto = AbstractImagePrototype.create(res);
  SafeHtml image = proto.getSafeHtml();

  SafeStylesBuilder cssBuilder = new SafeStylesBuilder();
  if (LocaleInfo.getCurrentLocale().isRTL()) {
    cssBuilder.appendTrustedString("left:0px;");
  } else {
    cssBuilder.appendTrustedString("right:0px;");
  }
  cssBuilder.appendTrustedString("width: " + res.getWidth() + "px;");
  cssBuilder.appendTrustedString("height: " + res.getHeight() + "px;");
  return template.imageWrapper(cssBuilder.toSafeStyles(), image);
}
 
Example #8
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml contentPreview(final Content content) {
    String managed = "No";
    String archive = "Yes";
    
    if (content.get("managed").asBoolean()) 
        managed = "Yes";
    
    if (content.get("content").get(0).hasDefined("archive") && !content.get("content").get(0).get("archive").asBoolean()) {
        archive = "No";
    }
    if (content.getAssignments().isEmpty()) {
        return PREVIEWS.unassignedContent(content.getName(), managed, archive);
    } else {
        SafeHtmlBuilder details = new SafeHtmlBuilder();
        details.appendHtmlConstant("<ul>");
        for (Assignment assignment : content.getAssignments()) {
            details.appendHtmlConstant("<li>")
                    .appendEscaped(assignment.getServerGroup())
                    .appendHtmlConstant("</li>");
        }
        details.appendHtmlConstant("</ul>");
        return PREVIEWS.content(content.getName(), details.toSafeHtml(), managed, archive);
    }
}
 
Example #9
Source File: DataSetEditorTest.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
protected void assertViewNotUsed() {
    verify(view, times(0)).init(any(DataSetEditor.class));
    verify(view, times(0)).initWidgets(
            any(DataSetDefBasicAttributesEditor.View.class),
            any(IsWidget.class),
            any(DataSetDefColumnsFilterEditor.View.class),
            any(DataSetDefPreviewTable.View.class),
            any(DataSetDefCacheAttributesEditorView.class),
            any(DataSetDefCacheAttributesEditorView.class),
            any(DataSetDefRefreshAttributesEditor.View.class)
    );
    verify(view, times(0)).addConfigurationTabItemClickHandler(any(Command.class));
    verify(view, times(0)).addPreviewTabItemClickHandler(any(Command.class));
    verify(view, times(0)).addAdvancedTabItemClickHandler(any(Command.class));
    verify(view, times(0)).showConfigurationTab();
    verify(view, times(0)).showPreviewTab();
    verify(view, times(0)).showAdvancedTab();
    verify(view, times(0)).openColumnsFilterPanel(anyString());
    verify(view, times(0)).closeColumnsFilterPanel(anyString());
    verify(view, times(0)).showErrorNotification(any(SafeHtml.class));
    verify(view, times(0)).clearErrorNotification();
}
 
Example #10
Source File: StandaloneRuntimeView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setPreview(final SafeHtml html) {

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            previewCanvas.clear();
            previewCanvas.add(new ScrollPanel(new HTML(html)));
        }
    });

}
 
Example #11
Source File: ImageListEditorTest.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
public void testInit() throws Exception {
    presenter.init();
    verify(view, times(1)).init(presenter);
    verify(view, times(0)).clear();
    verify(view, times(0)).clearError();
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).add(any(SafeUri.class), anyString(), anyString(), any(SafeHtml.class),
            any(SafeHtml.class), anyBoolean(), any(Command.class));
    
}
 
Example #12
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Update the image based on the current state.
 *
 * @param isLoading true if still loading data
 */
private void updateImage(boolean isLoading) {
  // Early out if this is a root node.
  if (isRootNode()) {
    return;
  }

  // Replace the image element with a new one.
  boolean isTopLevel = parentNode.isRootNode();
  SafeHtml html = tree.getClosedImageHtml(isTopLevel);
  if (open) {
    html = isLoading ? tree.getLoadingImageHtml() : tree.getOpenImageHtml(isTopLevel);
  }
  if (nodeInfoLoaded && nodeInfo == null) {
    html = LEAF_IMAGE;
  }
  Element tmp = Document.get().createDivElement();
  tmp.setInnerSafeHtml(html);
  Element imageElem = tmp.getFirstChildElement();

  Element oldImg = getImageElement();
  oldImg.getParentElement().replaceChild(imageElem, oldImg);

  // Set 'aria-expanded' state
  // don't set aria-expanded on the leaf nodes
  if (isLeaf()) {
    Roles.getTreeitemRole().removeAriaExpandedState(getElement());
  }
  else {
    Roles.getTreeitemRole().setAriaExpandedState(getElement(), ExpandedValue.of(open));
  }
}
 
Example #13
Source File: PicketLinkFinderView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startupContent(PreviewContentFactory contentFactory) {
    contentFactory.createContent(PreviewContent.INSTANCE.picketlink_federations(),
            new SimpleCallback<SafeHtml>() {
                @Override
                public void onSuccess(SafeHtml previewContent) {
                    setPreview(previewContent);
                }
            }
    );
}
 
Example #14
Source File: MapEditorTest.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void testClearErrors() throws Exception {
    List<EditorError> errors = new ArrayList<EditorError>();
    presenter.showErrors(errors);
    verify(view, times(1)).clearError();
    verify(view, times(0)).init(presenter);
    verify(view, times(0)).setAddText(anyString());
    verify(view, times(0)).setEmptyText(anyString());
    verify(view, times(0)).addButtonColumn(anyInt(), anyString(), anyInt());
    verify(view, times(0)).addTextColumn(anyInt(), anyString(), anyBoolean(), anyInt());
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).setData(anyList());
    verify(view, times(0)).setRowCount(anyInt());
    verify(view, times(0)).removeColumn(anyInt());
}
 
Example #15
Source File: DomainRuntimeView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setPreview(final SafeHtml html) {

    if (presenter.getPlaceManager().getCurrentPlaceRequest().getNameToken().equals(serverColumn.getToken())) {
        Scheduler.get().scheduleDeferred(() -> {
            contentCanvas.clear();
            contentCanvas.add(new ScrollPanel(new HTML(html)));
        });
    }

}
 
Example #16
Source File: StandaloneDeploymentFinderView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setPreview(final SafeHtml html) {
    Scheduler.get().scheduleDeferred(() -> {
        contentCanvas.clear();
        contentCanvas.add(new ScrollPanel(new HTML(html)));
    });
}
 
Example #17
Source File: WebServiceDescriptions.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static SafeHtml getEndpointDescription()
{
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<ul>");
    html.appendHtmlConstant("<li>");
    html.appendEscaped("context: Webservice endpoint context.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("class: Webservice implementation class.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("type: Webservice endpoint type.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("wsdl-url:Webservice endpoint WSDL URL.") ;
    html.appendHtmlConstant("</ul>");
    return html.toSafeHtml();
}
 
Example #18
Source File: HorizImageListEditorView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Override
public ImageListEditorView<T> showError(SafeHtml message) {
    errorTooltip.setTitle(message.asString());
    errorPanel.removeStyleName(style.errorPanel());
    errorPanel.addStyleName(style.errorPanelWithError());
    return null;
}
 
Example #19
Source File: ResourceAdapterFinderView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setPreview(final SafeHtml html) {

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            previewCanvas.clear();
            previewCanvas.add(new ScrollPanel(new HTML(html)));
        }
    });

}
 
Example #20
Source File: MailFinderView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setPreview(final SafeHtml html) {

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            previewCanvas.clear();
            previewCanvas.add(new ScrollPanel(new HTML(html)));
        }
    });

}
 
Example #21
Source File: StandaloneDeploymentFinderView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startupContent(PreviewContentFactory contentFactory) {
    contentFactory.createContent(PreviewContent.INSTANCE.deployments_empty(),
            new SimpleCallback<SafeHtml>() {
                @Override
                public void onSuccess(SafeHtml previewContent) {
                    setPreview(previewContent);
                }
            }
    );
}
 
Example #22
Source File: DomainDeploymentFinderView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startupContent(PreviewContentFactory contentFactory) {
    contentFactory.createContent(PreviewContent.INSTANCE.deployments_empty(),
            new SimpleCallback<SafeHtml>() {
                @Override
                public void onSuccess(SafeHtml previewContent) {
                    setPreview(previewContent);
                }
            }
    );
}
 
Example #23
Source File: ValueBoxEditorTest.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void testInit() throws Exception {
    presenter.init();
    verify(view, times(1)).init(presenter);
    verify(view, times(0)).clearError();
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).setValue(anyString());
}
 
Example #24
Source File: CacheFinder.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setPreview(final SafeHtml html) {
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            previewCanvas.clear();
            previewCanvas.add(new ScrollPanel(new HTML(html)));
        }
    });
}
 
Example #25
Source File: ValueBoxEditorTest.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddHelpContent() throws Exception {
    final String title = "title";
    final String content = "content";
    final Placement p = Placement.BOTTOM;
    presenter.addHelpContent(title, content, p);
    verify(view, times(1)).addHelpContent(title, content, p);
    verify(view, times(0)).setValue(anyString());
    verify(view, times(0)).clearError();
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).init(presenter);
}
 
Example #26
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static SafeHtml principalItem(final String css, final Principal principal) {
    return principal.getRealm() == null ?
            ITEMS.item(css, principal.getName(), principal.getName()) :
            ITEMS.principalWithRealm(css, principal.getName(),
                    principal.getName() + " (at) " + principal.getRealm(), principal.getRealm());
}
 
Example #27
Source File: Code.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void setValue(final SafeHtml value) {
    element.removeClassName("prettyprinted");
    element.setInnerSafeHtml(value);
    prettyPrint();
}
 
Example #28
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Template("<div style=\"{0}position:relative;\"" + " class=\"{1}\">{2}<div class=\"{3}\">{4}</div></div>")
SafeHtml innerDiv(SafeStyles cssString, String classes, SafeHtml image, String itemValueStyle, SafeHtml cellContents);
 
Example #29
Source File: DataSourceFinderView.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Template("<div class=\"preview-content\"><h1>{0}</h1><p>The datasource is {1} and bound to {2}.</p></div>")
SafeHtml datasourcePreview(String name, String enabledDisabled, String JNDI);
 
Example #30
Source File: PatchManagementTemplates.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Template("<div class=\"patch-error-panel\"><i class=\"icon-exclamation-sign icon-large\"></i> {0}</div>")
SafeHtml errorPanel(String message);