本文整理匯總了Java中com.google.gwt.safehtml.shared.SafeHtml類的典型用法代碼示例。如果您正苦於以下問題:Java SafeHtml類的具體用法?Java SafeHtml怎麽用?Java SafeHtml使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SafeHtml類屬於com.google.gwt.safehtml.shared包,在下文中一共展示了SafeHtml類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: VertexStyleComboBox
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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());
}
示例2: getImageHtml
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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);
}
}
示例3: testShowError
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
@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();
}
示例4: testShowErrors
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
@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());
}
示例5: getHTML
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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;
}
示例6: setHTML
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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);
}
}
示例7: assertViewNotUsed
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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();
}
示例8: testOnSubmitComplete
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
@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));
}
示例9: setMultiRowDragDecoration
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
/**
* 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();
}
}
}
示例10: testShowErrors
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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());
}
示例11: testShowErrors
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
@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());
}
示例12: assertSetViewValue
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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());
}
示例13: testConfigure
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
@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();
}
示例14: MenuButton
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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);
}
示例15: MainButton
import com.google.gwt.safehtml.shared.SafeHtml; //導入依賴的package包/類
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();
}
});
}