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

The following are top voted examples for showing how to use com.google.gwt.safehtml.shared.SafeHtmlUtils. 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: unitimes   File: FilterBox.java   Source Code and License 6 votes vote down vote up
private SuggestionMenuItem(final Suggestion suggestion) {
	super(suggestion.getDisplayString() == null
			? suggestion.getChip().getLabel() + " <span class='item-command'>" + suggestion.getChip().getTranslatedCommand() + "</span>"
			: SafeHtmlUtils.htmlEscape(suggestion.getDisplayString()) + (suggestion.getHint() == null ? "" : " " + suggestion.getHint()),
		true,
		new Command() {
			@Override
			public void execute() {
				hideSuggestions();
				setStatus(ARIA.suggestionSelected(suggestion.toAriaString(FilterBox.this)));
				applySuggestion(suggestion);
				iLastValue = getValue();
				setAriaLabel(toAriaString());
				fireSelectionEvent(suggestion);
				ValueChangeEvent.fire(FilterBox.this, getValue());
			}
		});
	setStyleName("item");
	getElement().setAttribute("whiteSpace", "nowrap");
	iSuggestion = suggestion;
}
 
Example 2
Project: sig-seguimiento-vehiculos   File: LayerCatalogDialog.java   Source Code and License 6 votes vote down vote up
private ColumnModel<LayerDef> createColumnList(LayerDefProperties props, 
		RowExpander<LayerDef> rowExpander) {
	
	rowExpander.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
	rowExpander.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
	
	ColumnConfig<LayerDef, String> nameColumn = new ColumnConfig<LayerDef, String>(
			props.name(), 200, SafeHtmlUtils.fromTrustedString("<b>"
					+ UIMessages.INSTANCE.layerManagerToolText() + "</b>"));
	nameColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);		
	
	ColumnConfig<LayerDef, String> typeColumn = new ColumnConfig<LayerDef, String>(
			props.type(), 75, UICatalogMessages.INSTANCE.type());
	typeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
	typeColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);		
	
	ColumnConfig<LayerDef, ImageResource> iconColumn = new ColumnConfig<LayerDef, ImageResource>(
			props.icon(), 32, "");
	iconColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
	iconColumn.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
	iconColumn.setCell(new ImageResourceCell() {
		@Override
		public void render(Context context, ImageResource value, SafeHtmlBuilder sb) {
			super.render(context, value, sb);
		}
	});
			
	List<ColumnConfig<LayerDef, ?>> columns = new ArrayList<ColumnConfig<LayerDef, ?>>();
	columns.add(rowExpander);
	columns.add(iconColumn);		
	columns.add(nameColumn);
	columns.add(typeColumn);		
	
	return new ColumnModel<LayerDef>(columns);
}
 
Example 3
Project: dangchat-sdk   File: HtmlMarkdownUtils.java   Source Code and License 6 votes vote down vote up
public static String renderText(MDText[] texts) {
    StringBuilder builder = new StringBuilder();

    for (MDText text : texts) {
        if (text instanceof MDRawText) {
            final MDRawText rawText = (MDRawText) text;
            builder.append(SafeHtmlUtils.htmlEscape(rawText.getRawText()).replace("\n", "<br/>"));
        } else if (text instanceof MDSpan) {
            final MDSpan span = (MDSpan) text;
            builder.append(spanElement(span.getSpanType(), renderText(span.getChild())));
        } else if (text instanceof MDUrl) {
            final MDUrl url = (MDUrl) text;
            builder.append(urlElement(url));
        }
    }

    return builder.toString();
}
 
Example 4
Project: dangchat-sdk   File: HtmlMarkdownUtils.java   Source Code and License 6 votes vote down vote up
private static String urlElement(MDUrl url) {
    // Sanitizing URL
    String href = UriUtils.sanitizeUri(url.getUrl());

    // "DeSanitize" custom url scheme
    if (url.getUrl().startsWith("send:")) {
        href = UriUtils.encodeAllowEscapes(url.getUrl());
    } else {
        // HotFixing url without prefix
        if (!href.equals("#") && !href.contains("://")) {
            href = "http://" + href;
        }
    }

    return "<a " +
            "target=\"_blank\" " +
            "onClick=\"window.messenger.handleLinkClick(event)\" " +
            "href=\"" + href + "\">" +
            SafeHtmlUtils.htmlEscape(url.getUrlTitle()) +
            "</a>";
}
 
Example 5
Project: gwt-cs   File: ShowcaseTopPanel.java   Source Code and License 6 votes vote down vote up
@Inject
public ShowcaseTopPanel(Image logo, ShowcaseSearchPanel searchPanel) {
    super.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    super.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    super.setStyleName("top");
    
    super.setSpacing(1);

    logo.setSize("32px", "32px");
    super.add(logo);
    Anchor anchor = new Anchor();
    String text = "<div class=\"brand\"><a href=\"http://cesiumjs.org\">Cesium</a> on GWT Examples</div>";
    anchor.setHTML(SafeHtmlUtils.fromTrustedString(text));
    super.add(anchor);
    super.add(searchPanel);

    super.setCellWidth(logo, "10px");
}
 
Example 6
Project: gwt-olcs   File: ShowcaseTopPanel.java   Source Code and License 6 votes vote down vote up
@Inject
public ShowcaseTopPanel(Image logo, ShowcaseSearchPanel searchPanel) {
    super.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    super.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    super.setStyleName("top");
    
    super.setSpacing(1);

    logo.setSize("32px", "32px");
    super.add(logo);
    Anchor anchor = new Anchor();
    String text = "<div class=\"brand\"><a href=\"http://cesiumjs.org\">Cesium</a> on GWT Examples</div>";
    anchor.setHTML(SafeHtmlUtils.fromTrustedString(text));
    super.add(anchor);
    super.add(searchPanel);

    super.setCellWidth(logo, "10px");
}
 
Example 7
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 8
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 9
Project: hftinymce-gwt   File: HFRichTextEditor.java   Source Code and License 6 votes vote down vote up
public String getText()
{
    String result = "";
    if (libraryLoaded && initialized) {
        try {
            String contentText = getContentText(elementId);
            if (contentText == null) {
                contentText = "";
            }
            result = SafeHtmlUtils.fromString(contentText).asString(); // requested as text, so we need to escape the string
        } catch (JavaScriptException e) {
            GWT.log("Unable to get the content from the TinyMCE editor.", e);
        }
    } else {
        result = super.getText();
        if (result == null || result.trim().isEmpty()) {
            result = "";
        } else {
            result = SafeHtmlUtils.fromString(result).asString();
        }
    }
    return result;
}
 
Example 10
Project: synergynet3.1   File: ExpressionView.java   Source Code and License 6 votes vote down vote up
/**
 * Load participant items.
 */
private void loadParticipantItems()
{
	NumberNetService.Util.getInstance().getAllParticipants(new AsyncCallback<List<Participant>>()
	{

		@Override
		public void onFailure(Throwable caught)
		{
			new MessageDialogBox(caught.getMessage()).show();
		}

		@Override
		public void onSuccess(List<Participant> result)
		{
			trtmByPerson.removeItems();
			for (Participant p : result)
			{
				TreeItem person = new TreeItem(SafeHtmlUtils.fromString(p.getName()));
				person.setUserObject("person");
				trtmByPerson.addItem(person);
			}
		}
	});
}
 
Example 11
Project: aggregate   File: AggregateUI.java   Source Code and License 6 votes vote down vote up
/***********************************
 ****** HELP STUFF ******
 ***********************************/

private void changeHelpPanel(SubTabs subMenu) {
  // change root item
  rootItem.setText(subMenu + " Help");
  rootItem.removeItems();
  SubTabInterface subTabObj = getSubTab(subMenu);
  if (subTabObj != null) {
    HelpSliderConsts[] helpVals = subTabObj.getHelpSliderContent();
    if (helpVals != null) {
      for (int i = 0; i < helpVals.length; i++) {
        TreeItem helpItem = new TreeItem(SafeHtmlUtils.fromString(helpVals[i].getTitle()));
        TreeItem content = new TreeItem(SafeHtmlUtils.fromString(helpVals[i].getContent()));
        helpItem.setState(false);
        helpItem.addItem(content);
        rootItem.addItem(helpItem);
      }
    }
  }
  rootItem.setState(true);
  resize();
}
 
Example 12
Project: actor-platform   File: HtmlMarkdownUtils.java   Source Code and License 6 votes vote down vote up
public static String renderText(MDText[] texts) {
    StringBuilder builder = new StringBuilder();

    for (MDText text : texts) {
        if (text instanceof MDRawText) {
            final MDRawText rawText = (MDRawText) text;
            builder.append(SafeHtmlUtils.htmlEscape(rawText.getRawText()).replace("\n", "<br/>"));
        } else if (text instanceof MDSpan) {
            final MDSpan span = (MDSpan) text;
            builder.append(spanElement(span.getSpanType(), renderText(span.getChild())));
        } else if (text instanceof MDUrl) {
            final MDUrl url = (MDUrl) text;
            builder.append(urlElement(url));
        }
    }

    return builder.toString();
}
 
Example 13
Project: actor-platform   File: HtmlMarkdownUtils.java   Source Code and License 6 votes vote down vote up
private static String urlElement(MDUrl url) {
    // Sanitizing URL
    String href = UriUtils.sanitizeUri(url.getUrl());

    // "DeSanitize" custom url scheme
    if (url.getUrl().startsWith("send:")) {
        href = UriUtils.encodeAllowEscapes(url.getUrl());
    } else {
        // HotFixing url without prefix
        if (!href.equals("#") && !href.contains("://")) {
            href = "http://" + href;
        }
    }

    return "<a " +
            "target=\"_blank\" " +
            "onClick=\"window.messenger.handleLinkClick(event)\" " +
            "href=\"" + href + "\">" +
            SafeHtmlUtils.htmlEscape(url.getUrlTitle()) +
            "</a>";
}
 
Example 14
Project: unitime   File: FilterBox.java   Source Code and License 6 votes vote down vote up
private SuggestionMenuItem(final Suggestion suggestion) {
	super(suggestion.getDisplayString() == null
			? suggestion.getChip().getLabel() + " <span class='item-command'>" + suggestion.getChip().getTranslatedCommand() + "</span>"
			: SafeHtmlUtils.htmlEscape(suggestion.getDisplayString()) + (suggestion.getHint() == null ? "" : " " + suggestion.getHint()),
		true,
		new Command() {
			@Override
			public void execute() {
				hideSuggestions();
				setStatus(ARIA.suggestionSelected(suggestion.toAriaString(FilterBox.this)));
				applySuggestion(suggestion);
				iLastValue = getValue();
				setAriaLabel(toAriaString());
				fireSelectionEvent(suggestion);
				ValueChangeEvent.fire(FilterBox.this, getValue());
			}
		});
	setStyleName("item");
	getElement().setAttribute("whiteSpace", "nowrap");
	iSuggestion = suggestion;
}
 
Example 15
Project: fullmetalgalaxy   File: MAppChat.java   Source Code and License 6 votes vote down vote up
@Override
public void onChannelMessage(Object p_message)
{
  if( p_message instanceof ChatMessage )
  {
    ChatMessage p_msg = (ChatMessage)p_message;
    if( !p_msg.isEmpty() )
    {
      String text = SafeHtmlUtils.htmlEscape( p_msg.getText() );
      text = SmileyCollection.INSTANCE.replace( text );
      text = text.replace( "\n", "<br/>" );
      HTML label = new HTML( "<b>[" + p_msg.getFromPseudo() + "]</b> " + text );
      m_msgList.add( label );
      scrollPanel.ensureVisible( label );
    }
  }
}
 
Example 16
Project: blogwt   File: GalleryPart.java   Source Code and License 6 votes vote down vote up
/**
 * @param line
 */
public void addImageWithLine (String line) {
	if (line.length() > 0) {
		ConfigLine config = parseConfigLine(line);

		if (config.url != null && config.url.length() > 0) {
			Image image = new Image(config.url);

			if (config.name != null) {
				image.setTitle(config.name);
				image.setAltText(config.caption);
			}

			((HTMLPanel) this.getWidget()).add(image);

			if (config.caption != null) {
				((HTMLPanel) this.getWidget())
						.add(new HTMLPanel(SafeHtmlUtils.fromTrustedString(
								PostHelper.makeMarkup(config.caption))));
			}
		}
	}
}
 
Example 17
Project: blogwt   File: UserSummaryCell.java   Source Code and License 6 votes vote down vote up
@Override
public void render (com.google.gwt.cell.client.Cell.Context context,
		User user, SafeHtmlBuilder sb) {

	String summary;
	if (user.summary != null) {
		summary = PostHelper.makeMarkup(user.summary);
	} else {
		summary = "<p class=\"text-muted text-justify\">"
				+ SafeHtmlUtils.fromString(UserHelper.name(user)).asString()
				+ " has not entered a user summary.</p>";
	}

	RENDERER.render(sb, SafeHtmlUtils.fromString(UserHelper.name(user)),
			SafeHtmlUtils.fromString("@" + user.username),
			UriUtils.fromString(user.avatar + "?s=80&default=retro"),
			SafeHtmlUtils.fromTrustedString(summary));

}
 
Example 18
Project: appformer   File: AbstractConcurrentChangePopup.java   Source Code and License 6 votes vote down vote up
protected AbstractConcurrentChangePopup(final String content,
                                        final Command onIgnore,
                                        final Command onAction,
                                        final String buttonText) {
    setTitle(CommonConstants.INSTANCE.Error());

    add(new ModalBody() {{
        add(uiBinder.createAndBindUi(AbstractConcurrentChangePopup.this));
    }});
    add(new ModalFooterReOpenIgnoreButtons(this,
                                           onAction,
                                           onIgnore,
                                           buttonText));

    message.setHTML(SafeHtmlUtils.fromTrustedString(content));
}
 
Example 19
Project: appformer   File: AbstractConcurrentChangePopup.java   Source Code and License 6 votes vote down vote up
protected AbstractConcurrentChangePopup(final String content,
                                        final Command onForceSave,
                                        final Command onIgnore,
                                        final Command onReOpen) {
    setTitle(CommonConstants.INSTANCE.Error());

    add(new ModalBody() {{
        add(uiBinder.createAndBindUi(AbstractConcurrentChangePopup.this));
    }});
    add(new ModalFooterForceSaveReOpenCancelButtons(this,
                                                    onForceSave,
                                                    onReOpen,
                                                    onIgnore));

    message.setHTML(SafeHtmlUtils.fromTrustedString(content));
}
 
Example 20
Project: ns2gather   File: VoteResultPanel.java   Source Code and License 6 votes vote down vote up
@Override
public void render(Context context, PlayerDTO value, SafeHtmlBuilder sb) {
    String playerClass = "";
    if (comms.contains(value.getId())) {
        playerClass = "participant captain";
    } else {
        playerClass = "participant " + baseClass;
    }
    sb.appendHtmlConstant("<span class=\"" + playerClass + "\" title=\"" + SafeHtmlUtils.fromString(value.getName()).asString()
            + "\">");
    value.buildInfo(sb);
    if (value.getSide() == Side.MERC) {
        sb.appendEscaped(" [MERC]");
    }
    sb.appendHtmlConstant("</span>");
}
 
Example 21
Project: zico   File: UserManagementPanel.java   Source Code and License 6 votes vote down vote up
@Override
public void render(Context context, UserInfo value, SafeHtmlBuilder sb) {
    if (value.isAdmin()) {
        sb.appendHtmlConstant(
            "<span style=\"color: gray;\"> ** all hosts visible due to administrator privileges ** </span>");
    } else {
        List<String> hosts = value.getAllowedHosts();
        if (hosts != null) {
            for (int i = 0; i < hosts.size(); i++) {
                if (i > 0) {
                    sb.appendHtmlConstant(",");
                }
                sb.append(SafeHtmlUtils.fromString(hosts.get(i)));
            }
        }
    }
}
 
Example 22
Project: zico   File: TraceCallTreePanel.java   Source Code and License 6 votes vote down vote up
@Override
public void render(Context context, TraceRecordInfo tr, SafeHtmlBuilder sb) {
    String path = tr.getPath();
    int offs = path != null && path.length() > 0 ? (path.split("/").length) * 24 : 0;
    String color = tr.getExceptionInfo() != null ? "red" : tr.getAttributes() != null ? "blue" : "black";

    sb.appendHtmlConstant("<div style=\"margin-left: " + offs + "px; color: " + color + ";margin-top: 3px;\">");
    if (tr.getChildren() > 0) {
        sb.appendHtmlConstant("<span style=\"cursor: pointer;\">");
        sb.appendHtmlConstant(isExpanded(context.getIndex()) ? MINUS_HTML : PLUS_HTML);
        sb.appendHtmlConstant("</span>");
    }
    sb.appendHtmlConstant("<span style=\"vertical-align: top;\">");
    sb.append(SafeHtmlUtils.fromString(tr.getMethod()));
    sb.appendHtmlConstant("</span></div>");
}
 
Example 23
Project: avro-ui   File: AbstractGrid.java   Source Code and License 6 votes vote down vote up
protected float constructBooleanColumn(DataGrid<T> table, String title,
        final BooleanValueProvider<T> valueProvider, 
        Comparator<T> comparator, Boolean isSortAscending, float prefWidth) {
    Header<SafeHtml> header = new SafeHtmlHeader(
            SafeHtmlUtils.fromSafeConstant(title));
    Column<T, Boolean> column = new Column<T, Boolean>(new UneditableCheckboxCell()) {
        @Override
        public Boolean getValue(T item) {
            return valueProvider.getValue(item);
        }
    };
    column.setFieldUpdater(new FieldUpdater<T,Boolean>() {
        @Override
        public void update(int index, T object, Boolean value) {
            onRowClicked(getObjectId(object));
        }
    });
    table.addColumn(column, header);
    table.setColumnWidth(column, prefWidth, Unit.PX);
    processColumnSort(table, column, comparator, isSortAscending);
    return prefWidth;
}
 
Example 24
Project: avro-ui   File: AbstractGrid.java   Source Code and License 6 votes vote down vote up
protected float constructActions(DataGrid<T> table, float prefWidth) {
    if (enableActions) {
        if (deleteColumn == null || table.getColumnIndex(deleteColumn) == -1) {
            Header<SafeHtml> deleteHeader = new SafeHtmlHeader(
                    SafeHtmlUtils.fromSafeConstant(Utils.constants.delete()));

            deleteColumn = constructDeleteColumn("");
            table.addColumn(deleteColumn, deleteHeader);
            table.setColumnWidth(deleteColumn, ACTION_COLUMN_WIDTH, Unit.PX);
            return ACTION_COLUMN_WIDTH;
        }
        else {
            return 0;
        }
    }
    else {
        return 0;
    }
}
 
Example 25
Project: avro-ui   File: ArrayFieldWidget.java   Source Code and License 6 votes vote down vote up
@Override
protected float constructActions(DataGrid<FormField> table, float prefWidth) {
    if (enableActions) {
        if (deleteColumn == null || table.getColumnIndex(deleteColumn) == -1) {
            Header<SafeHtml> deleteHeader = new SafeHtmlHeader(
                    SafeHtmlUtils.fromSafeConstant(Utils.constants.delete()));

            deleteColumn = constructDeleteColumn("");
            table.addColumn(deleteColumn, deleteHeader);
            table.setColumnWidth(deleteColumn, DELETE_COLUMN_WIDTH, Unit.PX);
            return DELETE_COLUMN_WIDTH;
        }
        else {
            return 0;
        }
    }
    else {
        return 0;
    }
}
 
Example 26
Project: kaa   File: BasePluginGrid.java   Source Code and License 6 votes vote down vote up
@Override
protected float constructActions(DataGrid<T> table, float prefWidth) {

  float result = 0;
  if (!embedded
      && (downloadPropsColumn == null || table.getColumnIndex(downloadPropsColumn) == -1)) {
    Header<SafeHtml> downloadRecordSchemaHeader = new SafeHtmlHeader(
        SafeHtmlUtils.fromSafeConstant(Utils.constants.configuration()));
    downloadPropsColumn = constructDownloadSchemaColumn("");
    table.addColumn(downloadPropsColumn, downloadRecordSchemaHeader);
    table.setColumnWidth(downloadPropsColumn, ACTION_COLUMN_WIDTH, Unit.PX);
    result += ACTION_COLUMN_WIDTH;
  }
  result += super.constructActions(table, prefWidth);
  return result;
}
 
Example 27
Project: kaa   File: ConfigSchemaGrid.java   Source Code and License 6 votes vote down vote up
@Override
protected float constructActions(DataGrid<ConfigurationSchemaDto> table, float prefWidth) {
  float result = super.constructActions(table, prefWidth);
  if (!embedded && (downloadBaseSchemaColumn == null
      || table.getColumnIndex(downloadBaseSchemaColumn) == -1)) {
    Header<SafeHtml> downloadBaseSchemaHeader = new SafeHtmlHeader(
        SafeHtmlUtils.fromSafeConstant(Utils.constants.downloadBaseSchema()));

    downloadBaseSchemaColumn = constructDownloadBaseSchemaColumnColumn("");
    table.addColumn(downloadBaseSchemaColumn, downloadBaseSchemaHeader);
    table.setColumnWidth(downloadBaseSchemaColumn, ACTION_COLUMN_WIDTH, Style.Unit.PX);
    result += ACTION_COLUMN_WIDTH;
  }

  if (!embedded && (downloadOverrideSchemaColumn == null
      || table.getColumnIndex(downloadOverrideSchemaColumn) == -1)) {
    Header<SafeHtml> downloadOverrideSchemaHeader = new SafeHtmlHeader(
        SafeHtmlUtils.fromSafeConstant(Utils.constants.downloadOverrideSchema()));

    downloadOverrideSchemaColumn = constructDownloadOverrideSchemaColumnColumn("");
    table.addColumn(downloadOverrideSchemaColumn, downloadOverrideSchemaHeader);
    table.setColumnWidth(downloadOverrideSchemaColumn, ACTION_COLUMN_WIDTH, Style.Unit.PX);
    result += ACTION_COLUMN_WIDTH;
  }
  return result;
}
 
Example 28
Project: kaa   File: EndpointProfileGrid.java   Source Code and License 6 votes vote down vote up
@Override
protected float constructActions(DataGrid<EndpointProfileDto> table, float prefWidth) {
  if (enableActions) {
    float result = 0;

    if (deleteColumn == null || table.getColumnIndex(deleteColumn) == -1) {
      Header<SafeHtml> deleteHeader = new SafeHtmlHeader(
          SafeHtmlUtils.fromSafeConstant(
              embedded ? Utils.constants.remove() : Utils.constants.delete()));

      deleteColumn = constructDeleteColumn("");
      table.addColumn(deleteColumn, deleteHeader);
      table.setColumnWidth(deleteColumn, 40, Style.Unit.PX);
      result += 40;
    }

    return result;
  } else {
    return 0;
  }
}
 
Example 29
Project: opennmszh   File: AlarmView.java   Source Code and License 6 votes vote down vote up
/** {@inheritDoc} */
protected void setRow(FlexTable table, int row, int elementIndex) {
	Alarm alarm = m_alarms[elementIndex];
	if (alarm.getIsDashboardRole()) {
        table.setText(row, 0, alarm.getNodeLabel());
	} else {
        table.setHTML(row, 0, "<a href=\"element/node.jsp?node=" + alarm.getNodeId() + "\">" + alarm.getNodeLabel() + "</a>");
	}
	
    HTML label = new HTML();
    label.setTitle(stripHtmlTags(alarm.getDescrption()));
    label.setHTML(SafeHtmlUtils.fromTrustedString(alarm.getLogMsg()));
    table.setWidget(row, 1, label);
    table.setText(row, 2, ""+alarm.getCount());
    table.setText(row, 3, alarm.getFirstEventTime().toString());
    table.setText(row, 4, alarm.getLastEventTime().toString());
    table.getRowFormatter().setStyleName(row, alarm.getSeverity());
}
 
Example 30
Project: QMAClone   File: WidgetLinkData.java   Source Code and License 6 votes vote down vote up
public WidgetLinkData(PacketLinkData linkData, PanelLink panelLink) {
	this.linkData = linkData;
	this.panelLink = panelLink;
	add(new HTML(TEMPLATE.messageWithLink(UriUtils.fromString(linkData.url),
			linkData.homePageName, linkData.authorName,
			Utility.toDateFormat(new Date(linkData.lastUpdate)))));

	{
		final HorizontalPanel panel = new HorizontalPanel();
		panel.setVerticalAlignment(ALIGN_MIDDLE);
		panel.add(new HTML(
				TEMPLATE.image(UriUtils.fromString(linkData.url), linkData.bannerUrl)));
		panel.add(new HTML(SafeHtmlUtils.fromString(linkData.description)));

		{
			final VerticalPanel panelButtons = new VerticalPanel();
			panelButtons.add(buttonUpdate);
			panelButtons.add(buttonRemove);
			panel.add(panelButtons);
		}

		add(panel);
	}
}
 
Example 31
Project: QMAClone   File: CreationUi.java   Source Code and License 6 votes vote down vote up
private void showRepeatedPostWarning() {
  final DialogBox dialogBox = new DialogBox(true);

  VerticalPanel panel = new VerticalPanel();
  panel.add(new HTML(new SafeHtmlBuilder().appendEscapedLines(
      "現在アニメジャンルにおいて連続投稿制限中です。\n" + "送信した問題が受け付けられない場合があります。\n" + "その他のジャンルは通常通り投稿できます。")
      .toSafeHtml()));
  panel.add(new Button("OK", new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      dialogBox.hide();
    }
  }));
  dialogBox.setWidget(panel);
  dialogBox.setAnimationEnabled(true);
  dialogBox.setGlassEnabled(true);
  dialogBox.setHTML(SafeHtmlUtils.fromString("連続投稿制限"));
  dialogBox.setPopupPosition(100, 100);
  dialogBox.show();
}
 
Example 32
Project: QMAClone   File: PanelThread.java   Source Code and License 6 votes vote down vote up
private void setPanels() {
  HTML titleHtml = new HTML(SafeHtmlUtils.fromString(title));
  titleHtml.addStyleDependentName("bbsThreadTitle");
  add(titleHtml);

  add(bodyPanel);

  {
    HorizontalPanel panel = new HorizontalPanel();
    panel.add(buttonAll);
    panel.add(buttonWrite);
    add(panel);
  }

  add(responseForm);
}
 
Example 33
Project: unitimes   File: FilterBox.java   Source Code and License 5 votes vote down vote up
public String toAriaString(FilterBox box) {
	if (getChipToAdd() != null) {
		if (getChipToRemove() != null)
			return ARIA.chipReplace(getChipToAdd().getTranslatedCommand(), getChipToAdd().getLabel());
		else {
			if (box.hasChip(getChipToAdd()))
				return ARIA.chipDelete(getChipToAdd().getTranslatedCommand(), getChipToAdd().getLabel());
			else
				return ARIA.chipAdd(getChipToAdd().getTranslatedCommand(), getChipToAdd().getLabel());
		}
	} else if (getChipToRemove() != null) {
		return ARIA.chipDelete(getChipToRemove().getTranslatedCommand(), getChipToRemove().getLabel());
	}
	return SafeHtmlUtils.htmlEscape(getDisplayString()) + (getHint() == null ? "" : " " + getHint());
}
 
Example 34
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 35
Project: social-analytics   File: SearchView.java   Source Code and License 5 votes vote down vote up
public void getSuggestions(String searchText) {
    String url = JSON_URL_SUGGESTION;
    String searchString = SafeHtmlUtils.htmlEscape(searchText.trim().replace("'", ""));

    // Append the name of the callback function to the JSON URL.
    url += searchString;
    url = URL.encode(url);
    JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
    // Set timeout for 30 seconds (30000 milliseconds)
    jsonp.setTimeout(30000);
    jsonp.requestObject(url, new AsyncCallback<Words>() {

        @Override
        public void onFailure(Throwable caught) {
            // Just fail silently here.
        }

        @Override
        public void onSuccess(Words words) {
            if (words.getWords() != null) {

                List<SearchObject> searchHints = new ArrayList<SearchObject>();

                for (int i = 0; i < words.getWords().length(); i++){
                    SearchObject search = new SearchObject();
                    search.setKeyword(words.getWords().get(i));
                    searchHints.add(search);
                }

                updateSuggestions(searchHints);
            }
        }
    });
}
 
Example 36
Project: gwt-bean-validators-example   File: MyNavigationStructure.java   Source Code and License 5 votes vote down vote up
@Override
protected final List<NavigationEntryInterface> buildNavigation() {
  final List<NavigationEntryInterface> navigationEntries = new ArrayList<>();
  final NavigationConstants navigationConstants = GWT.create(NavigationConstants.class);

  navigationEntries
      .add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuPostalAddress()),
          NameTokens.ADDRESS, null));
  navigationEntries.add(new NavigationEntry(
      SafeHtmlUtils.fromString(navigationConstants.menuSepa()), NameTokens.SEPA, null));
  navigationEntries
      .add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuPhoneNumber()),
          NameTokens.PHONE_NUMBER, null));
  navigationEntries
      .add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuEmailList()),
          NameTokens.EMAIL_LIST, null));

  navigationEntries.add(new NavigationEntry(
      SafeHtmlUtils.fromString(navigationConstants.menuSettings()), NameTokens.SETTINGS, null));

  navigationEntries
      .add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuLogin()),
          NameTokens.SECRET, this.loggedOutGatekeeper));
  navigationEntries
      .add(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuLogout()),
          NameTokens.LOGOUT, this.loggedInGatekeeper));

  final NavigationEntryFolder testFolder = new NavigationEntryFolder(
      SafeHtmlUtils.fromString(navigationConstants.menuTestFolder()), true);
  testFolder
      .addSubEntry(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuSecret()),
          NameTokens.SECRET, this.loggedInGatekeeper));
  testFolder
      .addSubEntry(new NavigationEntry(SafeHtmlUtils.fromString(navigationConstants.menuPerson()),
          NameTokens.PERSON, this.loggedInGatekeeper));
  navigationEntries.add(testFolder);

  return navigationEntries;
}
 
Example 37
Project: wte4j   File: MyMenuItem.java   Source Code and License 5 votes vote down vote up
@UiConstructor
public MyMenuItem(String text, ImageResource res) {
    super(SafeHtmlUtils.fromString(text));

    ImageResourceRenderer renderer = new ImageResourceRenderer();
    setHTML(renderer.render(res).asString() + "&nbsp;" + text);
}
 
Example 38
Project: synergynet3.1   File: ExpressionView.java   Source Code and License 5 votes vote down vote up
/**
 * Instantiates a new expression view.
 */
public ExpressionView()
{
	super();
	setSpacing(5);

	Button btnRefresh = new Button("Refresh");
	btnRefresh.addClickHandler(new ClickHandler()
	{
		@Override
		public void onClick(ClickEvent event)
		{
			refreshButtonPressed();
		}
	});
	add(btnRefresh);

	HorizontalPanel horizontalPanel = new HorizontalPanel();
	horizontalPanel.setSpacing(10);
	add(horizontalPanel);
	horizontalPanel.setSize("517px", "279px");

	Tree tree = new Tree();
	tree.addSelectionHandler(this);
	horizontalPanel.add(tree);

	trtmByPerson = new TreeItem(SafeHtmlUtils.fromString("By Person"));
	tree.addItem(trtmByPerson);

	trtmByTable = new TreeItem(SafeHtmlUtils.fromString("By Table"));
	tree.addItem(trtmByTable);

	trtmByTarget = new TreeItem(SafeHtmlUtils.fromString("By Target"));
	tree.addItem(trtmByTarget);

	verticalPanel = new VerticalPanel();
	horizontalPanel.add(verticalPanel);
}
 
Example 39
Project: markdown4j-gwt-demo   File: MarkdownDemoPage.java   Source Code and License 5 votes vote down vote up
@UiHandler("another")
void onAnotherClicked (ClickEvent ce) {
	if (markdown.getText().length() > 0) {
		process();
		converted.add(new HTMLPanel(SafeHtmlUtils.EMPTY_SAFE_HTML));
		markdown.setText("");
	}
}
 
Example 40
Project: grid-renderers-collection-addon   File: RowIndexRendererConnector.java   Source Code and License 5 votes vote down vote up
@Override
public void render(RendererCellReference cell, String htmlString) {
	int rowIndex = cell.getRowIndex();
	String content = ""+rowIndex;
    cell.getElement()
            .setInnerSafeHtml(SafeHtmlUtils.fromSafeConstant(content));
}