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

The following are top voted examples for showing how to use com.google.gwt.safehtml.shared.SafeHtml. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: sig-seguimiento-vehiculos   File: VertexStyleComboBox.java   Source Code and License 6 votes vote down vote up
public VertexStyleComboBox(String width) {
	super(new ListStore<VertexStyleDef>(
			((VertexStyleDefProperties)GWT.create(VertexStyleDefProperties.class)).key()),
			((VertexStyleDefProperties)GWT.create(VertexStyleDefProperties.class)).name(),
			new AbstractSafeHtmlRenderer<VertexStyleDef>() {
				final VertexStyleComboTemplates comboBoxTemplates = GWT
						.create(VertexStyleComboTemplates.class);

				public SafeHtml render(VertexStyleDef item) {
					return comboBoxTemplates.vertexStyle(item.getImage()
							.getSafeUri(), item.getName());
				}
			});
	
	setWidth(width);
	setTypeAhead(true);
	setEmptyText(UIMessages.INSTANCE.sbLayerComboEmptyText());
	setTriggerAction(TriggerAction.ALL);
	setForceSelection(true);
	setEditable(false);
	enableEvents();
	
	getStore().addAll(VertexStyles.getAll());
}
 
Example 2
Project: ontobrowser   File: ActionIconCellDecorator.java   Source Code and License 6 votes vote down vote up
private SafeHtml getImageHtml(ImageResource res, VerticalAlignmentConstant valign) {
	AbstractImagePrototype proto = AbstractImagePrototype.create(res);
	SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML());

	// Create the wrapper based on the vertical alignment.
	SafeStylesBuilder cssStyles =
			new SafeStylesBuilder().appendTrustedString(direction + ":0px;");
	if (HasVerticalAlignment.ALIGN_TOP == valign) {
		return templates.imageWrapperTop(cssStyles.toSafeStyles(), image);
	} else if (HasVerticalAlignment.ALIGN_BOTTOM == valign) {
		return templates.imageWrapperBottom(cssStyles.toSafeStyles(), image);
	} else {
		int halfHeight = (int) Math.round(res.getHeight() / 2.0);
		cssStyles.appendTrustedString("margin-top:-" + halfHeight + "px;");
		return templates.imageWrapperMiddle(cssStyles.toSafeStyles(), image);
	}
}
 
Example 3
Project: appformer   File: DataSetEditorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testShowError() {
    final ClientRuntimeError error = mock(ClientRuntimeError.class);
    when(error.getCause()).thenReturn("errorCause");
    presenter.afterPreviewCommand = mock(Command.class);
    presenter.showError(error);
    verify(loadingBox, times(1)).hide();
    verify(view, times(1)).showErrorNotification(any(SafeHtml.class));
    verify(errorEvent, times(1)).fire(any(ErrorEvent.class));
    verify(presenter.afterPreviewCommand, times(1)).execute();
    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)).clearErrorNotification();
}
 
Example 4
Project: appformer   File: ValueBoxEditorTest.java   Source Code and License 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)).init(presenter);
    verify(view, times(0)).clearError();
    verify(view, times(0)).setValue(anyString());
    final SafeHtml value = errorSafeHtmlCaptor.getValue();
    Assert.assertEquals("m1\nm2", value.asString());
}
 
Example 5
Project: hftinymce-gwt   File: HFRichTextEditor.java   Source Code and License 6 votes vote down vote up
public SafeHtml getHTML() {
    SafeHtml result = null;
    if (libraryLoaded && initialized) {
        try {
            String contentHtml = getContentHtml(elementId); // TinyMCE takes care of the sanitization.
            if (contentHtml == null || contentHtml.trim().isEmpty()) {
                return SafeHtmlUtils.fromSafeConstant("");
            }
            // Remove the root block <p></p> that gets added automatically by TinyMCE
            if (contentHtml.startsWith("<p>") && contentHtml.endsWith("</p>")) {
                contentHtml = contentHtml.substring(3, contentHtml.length() - 4);
            }
            result = SafeHtmlUtils.fromTrustedString(contentHtml); 
        } catch (JavaScriptException e) {
            GWT.log("Unable to get the content from the TinyMCE editor.", e);
        }
    } else {
        String text = super.getText();
        if (text == null || text.trim().isEmpty()) {
            return SafeHtmlUtils.fromSafeConstant("");
        } else {
            return SafeHtmlUtils.fromString(text);
        }
    }
    return result;        
}
 
Example 6
Project: hftinymce-gwt   File: HFRichTextEditor.java   Source Code and License 6 votes vote down vote up
public void setHTML(SafeHtml html) {
    String text = html == null ? null: html.asString();
    if (libraryLoaded && (isInitialized() || isInitializing())) {
        if (isInitializing()) {
            pendingSetHtmlText = html;
            addPendingSetHtml();
            return;
        }
        try {
            setContent(elementId, text);
        } catch (JavaScriptException e) {
            // Don't do anything, just allow it to return.
            GWT.log("Unable to set the content on the TinyMCE editor.", e);
        }
        return;
    } else {
        super.setText(text);
    }
}
 
Example 7
Project: appformer   File: DataSetEditorTest.java   Source Code and License 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 8
Project: appformer   File: FileUploadEditorTest.java   Source Code and License 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 9
Project: hawkbit   File: ViewClientCriterion.java   Source Code and License 6 votes vote down vote up
/**
 * Styles a multi-row selection with the number of elements.
 *
 * @param drag
 *            the current drag event holding the context.
 */
void setMultiRowDragDecoration(VDragEvent drag) {
    Widget widget = drag.getTransferable().getDragSource().getWidget();

    if (widget instanceof VScrollTable) {
        VScrollTable table = (VScrollTable) widget;
        int rowCount = table.selectedRowKeys.size();

        Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT);
        if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) {
            if (dragCountElement == null) {
                dragCountElement = Document.get().createStyleElement();
                dragCountElement.setId(SP_DRAG_COUNT);
                HeadElement head = HeadElement.as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0));
                head.appendChild(dragCountElement);
            }
            SafeHtml formattedCssStyle = getDraggableTemplate().multiSelectionStyle(determineActiveTheme(drag),
                    String.valueOf(rowCount));
            StyleElement dragCountStyleElement = StyleElement.as(dragCountElement);
            dragCountStyleElement.setInnerSafeHtml(formattedCssStyle);
        } else if (dragCountElement != null) {
            dragCountElement.removeFromParent();
        }
    }
}
 
Example 10
Project: appformer   File: ImageListEditorTest.java   Source Code and License 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 11
Project: appformer   File: ToggleSwitchEditorTest.java   Source Code and License 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)).init(presenter);
    verify(view, times(0)).clearError();
    verify(view, times(0)).setValue(anyBoolean());
    final SafeHtml value = errorSafeHtmlCaptor.getValue();
    Assert.assertEquals("m1\nm2", value.asString());
}
 
Example 12
Project: appformer   File: MapEditorTest.java   Source Code and License 6 votes vote down vote up
protected void assertSetViewValue(final int size) {
    verify(view, times(3)).removeColumn(0);
    verify(view, times(1)).clearError();
    verify(view, times(1)).addButtonColumn(anyInt(), anyString(), anyInt());
    verify(view, times(2)).addTextColumn(anyInt(), anyString(), anyBoolean(), anyInt());
    verify(view, times(1)).setEmptyText(anyString());
    verify(view, times(1)).setRowCount(size);
    final ArgumentCaptor<List> dataCaptor =  ArgumentCaptor.forClass(List.class);
    verify(view, times(1)).setData(dataCaptor.capture());
    final List dataValue = dataCaptor.getValue();
    assertNotNull(dataValue);
    assertEquals(size, dataValue.size());
    verify(view, times(0)).init(presenter);
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).setAddText(anyString());
}
 
Example 13
Project: appformer   File: FileUploadEditorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testConfigure() throws Exception {
    FileUploadEditor.FileUploadEditorCallback callback = mock(FileUploadEditor.FileUploadEditorCallback.class);
    presenter.configure("f1", callback);
    assertEquals(view.asWidget(), presenter.asWidget());
    assertEquals(callback, presenter.callback);
    verify(view, times(0)).init(presenter);
    verify(view, times(0)).addHelpContent(anyString(), anyString(), any(Placement.class));
    verify(view, times(1)).setFileUploadName("f1");
    verify(view, times(0)).setFileUploadVisible(anyBoolean());
    verify(view, times(0)).setFileLabelText(anyString());
    verify(view, times(0)).setFileLabelVisible(anyBoolean());
    verify(view, times(0)).setLoadingImageVisible(false);
    verify(view, times(0)).getFileName();
    verify(view, times(0)).setFormAction(anyString());
    verify(view, times(0)).submit();
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).clearError();
}
 
Example 14
Project: che   File: MenuButton.java   Source Code and License 6 votes vote down vote up
public MenuButton(SafeHtml content, ItemsProvider itemsProvider) {
  super();

  this.itemsProvider = itemsProvider;

  addStyleName(RESOURCES.css().menuButton());

  showMenuTimer =
      new Timer() {
        @Override
        public void run() {
          showMenu();
        }
      };

  final FocusWidget mainButton = new MainButton(content);
  final FocusWidget dropButton = new DropButton();

  add(mainButton);
  add(dropButton);

  attachMouseEventHandlers(mainButton);
  attachMouseEventHandlers(dropButton);
}
 
Example 15
Project: che   File: MenuButton.java   Source Code and License 6 votes vote down vote up
MainButton(SafeHtml content) {
  super(Document.get().createDivElement());

  getElement().setInnerSafeHtml(content);

  addStyleName(RESOURCES.css().button());
  addStyleName(RESOURCES.css().mainButton());

  addClickHandler(
      event -> {
        if (menu != null && menu.isShowing()) {
          return;
        }

        final Optional<MenuItem> defaultItem = itemsProvider.getDefaultItem();

        if (defaultItem.isPresent()) {
          getActionHandler()
              .ifPresent(actionHandler -> actionHandler.onAction(defaultItem.get()));
        } else {
          showMenu();
        }
      });
}
 
Example 16
Project: TreeGridGWT   File: ExpandableCell.java   Source Code and License 6 votes vote down vote up
private void createClosedArrowAndFolderSafeHtml(SafeHtmlBuilder sb,
		SafeStyles imgStyle) {
	SafeHtml rendered;
	if (currentRow.getChildren().size() != 0) {
		rendered = nodeImageTemplate.cell("ICON_ARROW__CLOSE", imgStyle,
				ICON_ARROW_CLOSE);
	} else {
		SafeStyles imageWidthStyle = SafeStylesUtils
				.fromTrustedString("float:left;width:16.0px;");
		rendered = nodeImageTemplate.cell("ICON_ARROW__CLOSE",
				imageWidthStyle, ICON_CLEAR);
	}
	sb.append(rendered);
	if (treeGrid.isSelectable()) {
		createCheckBoxImg(sb, imgStyle);
	}
	rendered = nodeImageTemplate.cell("ICON_FOLDER__CLOSE", imgStyle,
			ICON_FOLDER_CLOSE);
	sb.append(rendered);
}
 
Example 17
Project: riscoss-corporate   File: DomainList.java   Source Code and License 6 votes vote down vote up
public DomainList() {
	
	table = new CellTable<>(15, (Resources) GWT.create(TableResources.class));
	
	table.addColumn( new Column<String,SafeHtml>(new SafeHtmlCell() ) {
		@Override
		public SafeHtml getValue(String domain) {
			return new LinkHtml( domain, "javascript:selectDomain(\"" + domain + "\")" ); };
	}, "Domain");
	
	dataProvider = new ListDataProvider<String>();
	dataProvider.addDataDisplay( table );
	
	SimplePager pager = new SimplePager();
    pager.setDisplay( table );
    
    table.setWidth("100%");
	tablePanel.add( table );
	tablePanel.add( pager );
	tablePanel.setWidth("100%");
	
	
}
 
Example 18
Project: appformer   File: FileUploadEditorTest.java   Source Code and License 6 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)).init(presenter);
    verify(view, times(0)).setFileUploadName(anyString());
    verify(view, times(0)).setFileUploadVisible(anyBoolean());
    verify(view, times(0)).setFileLabelText(anyString());
    verify(view, times(0)).setFileLabelVisible(anyBoolean());
    verify(view, times(0)).setLoadingImageVisible(anyBoolean());
    verify(view, times(0)).getFileName();
    verify(view, times(0)).setFormAction(anyString());
    verify(view, times(0)).submit();
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).clearError();
}
 
Example 19
Project: geowe-core   File: VertexStyleComboBox.java   Source Code and License 6 votes vote down vote up
public VertexStyleComboBox(String width) {
	super(new ListStore<VertexStyleDef>(
			((VertexStyleDefProperties)GWT.create(VertexStyleDefProperties.class)).key()),
			((VertexStyleDefProperties)GWT.create(VertexStyleDefProperties.class)).name(),
			new AbstractSafeHtmlRenderer<VertexStyleDef>() {
				final VertexStyleComboTemplates comboBoxTemplates = GWT
						.create(VertexStyleComboTemplates.class);

				public SafeHtml render(VertexStyleDef item) {
					return comboBoxTemplates.vertexStyle(item.getImage()
							.getSafeUri(), item.getName());
				}
			});
	
	setWidth(width);
	setTypeAhead(true);
	setEmptyText(UIMessages.INSTANCE.sbLayerComboEmptyText());
	setTriggerAction(TriggerAction.ALL);
	setForceSelection(true);
	setEditable(false);
	enableEvents();
	
	getStore().addAll(VertexStyles.getAll());
}
 
Example 20
Project: appformer   File: FileUploadEditorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testValueUnset() throws Exception {
    final String newValue = "newValue";
    when(view.getFileName()).thenReturn(null);
    presenter.setValue(newValue);
    assertEquals(newValue, presenter.getValue());
    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(0)).setFileUploadVisible(anyBoolean());
    verify(view, times(1)).setFileLabelText(newValue);
    verify(view, times(1)).setFileLabelVisible(true);
    verify(view, times(0)).setLoadingImageVisible(anyBoolean());
    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(0)).clearError();
}
 
Example 21
Project: gwt-promptly   File: StyledBlock.java   Source Code and License 5 votes vote down vote up
SafeHtml toSafeHtml(boolean withFormatting) {

      // NOTE :: Embedded operations are LOST using this method .... 
      
      StringBuilder sb = new StringBuilder();
      
      for (StyledParagraphItem i : _items) {
         final String text = i.getText();
         final String style = i.getStyle();
         
         if (withFormatting && style != null) {
            sb.append("<span style=\"");
            sb.append(SafeHtmlUtils.htmlEscape(style));
            sb.append("\">");
            if (text != null && " ".equals(text)) {
               sb.append("&nbsp;");
            } else {
               sb.append(SafeHtmlUtils.htmlEscape(text));
            }
            sb.append("</span>");
         } else {
            sb.append(SafeHtmlUtils.htmlEscape(text));
         }
      }
      
      final SafeHtml safeHtml = SafeHtmlUtils.fromTrustedString(sb.toString());
      return safeHtml;
   }
 
Example 22
Project: essence   File: ClickableTextCellRuleID.java   Source Code and License 5 votes vote down vote up
@Override
protected void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
 if (!value.asString().equals("none")) {
	  sb.appendHtmlConstant("<div class=\""+style+"\">");
      sb.append(value);
      sb.appendHtmlConstant("</div>");
  }
 else
	 sb.append(value);
}
 
Example 23
Project: essence   File: VOOBDetailClickableCellText.java   Source Code and License 5 votes vote down vote up
@Override
protected void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
  // Make the details clickable for VOOB rule
  if (value != null && !value.asString().isEmpty()) {
	  sb.appendHtmlConstant("<div class=\""+style+"\">");
      sb.append(value);
      sb.appendHtmlConstant("</div>");
  }
}
 
Example 24
Project: essence   File: MyClickableCellTextDecision.java   Source Code and License 5 votes vote down vote up
@Override
protected void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
  if (value != null && !value.asString().equals("Select Action")) {
      sb.append(value);
  }
  // if the value is assign, then we need to make the cell clickable with underline
  // otherwise, not.
  if (value.asString().equals("Select Action")) {
	  sb.appendHtmlConstant("<div class=\""+style+"\">");
      sb.append(value);
      sb.appendHtmlConstant("</div>");
  }
}
 
Example 25
Project: essence   File: DecisionTypeButtonOrTextCell.java   Source Code and License 5 votes vote down vote up
@Override
public void render(Context arg0, Object arg1, SafeHtmlBuilder arg2) {
	// TODO Auto-generated method stub
       if (arg1 != null && arg1.equals(DecisionTypeDTO.MANUAL_ACTION.toString())) {
       	buttonCell.render(arg0, (SafeHtml)arg1, arg2);
       } else {
           textCell.render(arg0,(SafeHtml) arg1, arg2);
       }		
}
 
Example 26
Project: gwtmvp   File: TableRowAdapter.java   Source Code and License 5 votes vote down vote up
/**
 * Default implementation that populates the table cells with a return value of {@link #getCellContent(int, Object)}.
 * Override this method if you need to perform more complex operation on a table cell.
 * @param column The column index of the table cell (0-based)
 * @param elem The DOM element of the table cell
 * @param item The item for this row
 */
protected void setTableCell(int column, TableCellElement elem, T item) {
  Object content = getCellContent(column, item);
  if (content instanceof SafeHtml) {
    elem.setInnerSafeHtml((SafeHtml) content);
  } else {
    elem.setInnerText(content != null ? content.toString() : "");
  }
}
 
Example 27
Project: appformer   File: ValueBoxEditorTest.java   Source Code and License 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)).showError(any(SafeHtml.class));
    verify(view, times(0)).init(presenter);
    verify(view, times(0)).setValue(anyString());
}
 
Example 28
Project: wte4j   File: GenerateDocumentPanel.java   Source Code and License 5 votes vote down vote up
private Column<OrderDataDto, SafeHtml> createAddressColumn() {
	return new Column<OrderDataDto, SafeHtml>(new SafeHtmlCell()) {

		@Override
		public SafeHtml getValue(OrderDataDto orderData) {
			SafeHtmlBuilder builder = new SafeHtmlBuilder();
			builder.appendEscapedLines(orderData.getAddress());
			return builder.toSafeHtml();
		}
	};
}
 
Example 29
Project: appformer   File: ToggleSwitchEditorTest.java   Source Code and License 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)).showError(any(SafeHtml.class));
    verify(view, times(0)).init(presenter);
    verify(view, times(0)).setValue(anyBoolean());
}
 
Example 30
Project: blogwt   File: PrettyButtonCell.java   Source Code and License 5 votes vote down vote up
@Override
public void render (Context context, SafeHtml data, SafeHtmlBuilder sb) {
	if (data != null) {
		String buttonStyle = null, glyph = null;

		Button b = buttons.get(data.asString());

		if (b != null) {
			buttonStyle = b.style;
			glyph = b.glyph;
		} else {
			buttonStyle = "btn-default";
		}

		sb.appendHtmlConstant(
				"<button type=\"button\" class=\"btn btn-xs "
						+ (buttonStyle == null || buttonStyle.length() == 0
								? "" : buttonStyle)
						+ "\" tabindex=\"-1\">");

		if (glyph != null && glyph.length() > 0) {
			sb.appendHtmlConstant(
					"<span class=\"glyphicon " + glyph + "\"></span> ");
		}

		sb.append(data);
		sb.appendHtmlConstant("</button>");
	}
}
 
Example 31
Project: appformer   File: ValueBoxEditorTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testValue() throws Exception {
    final String newValue = "newValue";  
    presenter.setValue(newValue);
    assertEquals(newValue, presenter.getValue());
    verify(view, times(1)).setValue(newValue);
    verify(view, times(0)).clearError();
    verify(view, times(0)).showError(any(SafeHtml.class));
    verify(view, times(0)).init(presenter);
}
 
Example 32
Project: appformer   File: ImageListEditorTest.java   Source Code and License 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 33
Project: appformer   File: ValueBoxEditorTest.java   Source Code and License 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 34
Project: appformer   File: MessageTableWidget.java   Source Code and License 5 votes vote down vote up
public SafeHtml createDivStart(String title,
                               String defaultValue,
                               String cssClasses) {
    if (title == null || "".equals(title)) {
        title = defaultValue;
    }

    final String css = cssClasses == null ? "" : "class=\"" + cssClasses + "\"";
    return SafeHtmlUtils.fromTrustedString("<div title=\"" + SafeHtmlUtils.htmlEscape(title.trim()) + "\" " + css + " >");
}
 
Example 35
Project: appformer   File: IconCell.java   Source Code and License 5 votes vote down vote up
@Override
protected void render(Context context,
                      SafeHtml data,
                      SafeHtmlBuilder sb) {
    Icon icon = GWT.create(Icon.class);
    if (tooltip != null) {
        icon.setTitle(tooltip);
    }
    icon.setSize(iconSize);
    icon.setType(iconType);
    sb.appendHtmlConstant(icon.getElement().getString());
}
 
Example 36
Project: appformer   File: ToggleSwitchEditorTest.java   Source Code and License 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(anyBoolean());
}
 
Example 37
Project: appformer   File: DataSetEditorTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testInit() {
    presenter.init();
    verify(view, times(1)).init(presenter);
    verify(view, times(1)).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(1)).addConfigurationTabItemClickHandler(any(Command.class));
    verify(view, times(1)).addPreviewTabItemClickHandler(any(Command.class));
    verify(view, times(1)).addAdvancedTabItemClickHandler(any(Command.class));
    verify(columnsAndFilterEditor, times(1)).setMaxHeight(anyString());
    verify(backendCacheAttributesEditor, times(1)).setRange(anyDouble(), anyDouble());
    verify(clientCacheAttributesEditor, times(1)).setRange(anyDouble(), anyDouble());
    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 38
Project: aggregate   File: UIEnabledActionColumn.java   Source Code and License 5 votes vote down vote up
public UIEnabledActionColumn(SafeHtml html, 
        UIVisiblePredicate<T> isVisiblePredicate,
        UIEnabledPredicate<T> isEnabledPredicate,
        UIEnabledActionCell.Delegate<T> action) {
    super(new UIEnabledActionCell<T>(html, 
                isVisiblePredicate, isEnabledPredicate,
                action));
}
 
Example 39
Project: appformer   File: ImageListEditorTest.java   Source Code and License 5 votes vote down vote up
protected static ImageListEditor<DataSetProviderType>.Entry mockEntry(DataSetProviderType type) {
    final String name = type.getName();
    final SafeUri uri = mock(SafeUri.class);
    final SafeHtml safeHtml = mock(SafeHtml.class);
    doReturn(name).when(safeHtml).asString();
    ImageListEditor<DataSetProviderType>.Entry entry = mock(ImageListEditor.Entry.class);
    doReturn(type).when(entry).getValue();
    doReturn(safeHtml).when(entry).getHeading();
    doReturn(safeHtml).when(entry).getText();
    doReturn(uri).when(entry).getUri();
    return entry;
}
 
Example 40
Project: appformer   File: DropDownEditorView.java   Source Code and License 5 votes vote down vote up
@Override
public DropDownEditorView showError(SafeHtml message) {
    errorTooltip.setTitle(message.asString());
    errorPanel.removeStyleName(style.errorPanel());
    errorPanel.addStyleName(style.errorPanelWithError());
    return this;
}