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

The following are top voted examples for showing how to use com.google.gwt.safehtml.shared.SafeHtmlBuilder. 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: 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 2
Project: sig-seguimiento-vehiculos   File: VehicleDialog.java   Source Code and License 6 votes vote down vote up
private RowExpander<VehicleJSO> createRowExpander() {
	
	return new RowExpander<VehicleJSO>(new AbstractCell<VehicleJSO>() {
		@Override
		public void render(Context context, VehicleJSO value,
				SafeHtmlBuilder sb) {
			
			String comment = value.getComments();
			if( comment == null) {
				comment = UISgfMessages.INSTANCE.noCommentLabel();
			}
			
			sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>"
					+ UISgfMessages.INSTANCE.commentColumn() + ":</b> "
					+ comment + "</p>");
			
		}
	});
}
 
Example 3
Project: optashift-employee-rostering   File: AbstractRosterViewPanel.java   Source Code and License 6 votes vote down vote up
protected void init() {
    buttonContent = new Span();
    buttonImage = new Span();
    buttonText = new Span();
    solveButton.getElement().setAttribute("class", "btn btn-success");
    buttonImage.getElement().setAttribute("class", "glyphicon glyphicon-play");
    buttonImage.getElement().setAttribute("aria-hidden", "true");
    buttonText.setHTML(new SafeHtmlBuilder()
            .appendEscaped(CONSTANTS.format("AbstractRosterViewPanel.solve"))
            .toSafeHtml().asString());
    buttonContent.add(buttonImage);
    buttonContent.add(buttonText);
    solveButton.add(buttonContent);
    solverObservable.addObserver(this);
}
 
Example 4
Project: optashift-employee-rostering   File: EmployeeEditForm.java   Source Code and License 6 votes vote down vote up
@PostConstruct
protected void initWidget() {
    employeeName.setValue(employee.getName());
    employeeSkills.removeAll();
    CollectionDataset<Skill> data = new CollectionDataset<Skill>(skills) {

        @Override
        public String getValue(Skill skill) {
            return (skill == null) ? "" : skill.getName();
        }
    };
    employeeSkills.setDatasets((Dataset<Skill>) data);
    employeeSkills.setItemValue(Skill::getName);
    employeeSkills.setItemText(Skill::getName);
    employeeSkills.reconfigure();
    employeeSkills.add(employee.getSkillProficiencyList().stream()
            .map((p) -> p.getSkill())
            .collect(Collectors.toList()));
    employee.getSkillProficiencyList().stream().map((p) -> p.getSkill())
            .forEach((s) -> employeeSkills.add(s));

    title.setInnerSafeHtml(new SafeHtmlBuilder().appendEscaped(employee.getName())
            .toSafeHtml());
    popup = FormPopup.getFormPopup(this);
    popup.center();
}
 
Example 5
Project: appinventor-extensions   File: TemplateUploadWizard.java   Source Code and License 6 votes vote down vote up
@Override
  public void render(Context context, TemplateInfo template, SafeHtmlBuilder sb) {
  if (template == null)
    return;
  sb.appendHtmlConstant("<table>");

  // Add the thumbnail image, if available, or a default image.
  sb.appendHtmlConstant("<tr><td rowspan='3'>");
  if ( !template.thumbStr.equals("") )   {
    String src = hostUrl + TEMPLATES_ROOT_DIRECTORY +   template.name + "/" + template.thumbStr;
    sb.appendHtmlConstant("<img style='width:32px' src='" + src + "'>");
  } else {
    ImageResource imgResource = Ode.getImageBundle().appInventorLogo();
    Image img = new Image(imgResource);
    String url = img.getUrl();
    sb.appendHtmlConstant("<img style='width:32px' src='" + url + "'>");
  }
  sb.appendHtmlConstant("</td>");

  // Add the name and description.
  sb.appendHtmlConstant("<td style='font-size:95%;'>");
  sb.appendEscaped(template.name);
  sb.appendHtmlConstant("</td></tr><tr><td>");
  sb.appendEscaped(template.subtitle);
  sb.appendHtmlConstant("</td></tr></table>");
}
 
Example 6
Project: essence   File: WrapStringColumnCell.java   Source Code and License 6 votes vote down vote up
/**
 * This method provides style for your wrap data
 * 
 */
public void render(Cell.Context context, WrapString value, SafeHtmlBuilder sb) {
	String longString = value.getLongString();
	@SuppressWarnings("unused")
    String row1Content = longString;
	@SuppressWarnings("unused")
    String row2Content = null;
	int LINE_SIZE = 60;
    sb.appendHtmlConstant("<div><table width='100%'>");
    while (longString != null && !longString.isEmpty()) {
    	if (longString.length() <= LINE_SIZE) {
	        sb.appendHtmlConstant("<tr><td><div>"+longString+"</div></td></tr>");
    		break;
    	} else {
 	    sb.appendHtmlConstant("<tr><td><div>"+longString.subSequence(0, LINE_SIZE)+"</div></td></tr>");
 	    longString = longString.substring(LINE_SIZE);
    	}
    }
    sb.appendHtmlConstant("</table></div>");
}
 
Example 7
Project: gwtmvp   File: PeoplePresenter.java   Source Code and License 6 votes vote down vote up
@Override
public void onViewLoaded() {
  personRowAdapter = new TableRowAdapter<Person>(view.getTable(), 4) {
    @Override
    protected Object getCellContent(int column, Person item) {
      switch (column) {
        case 0:
          return new SafeHtmlBuilder().appendHtmlConstant("<a href=\"#person/").append(item.id).appendHtmlConstant("\">")
              .appendEscaped(item.name).appendHtmlConstant("</a>").toSafeHtml();
        case 1:
          return item.email;
        case 2:
          return item.phone;
        case 3:
          return item.city;
      }
      return null;
    }
  };
}
 
Example 8
Project: kie-docker-ci   File: ButtonWithTitleCell.java   Source Code and License 6 votes vote down vote up
@Override
public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
    final ButtonType type = getType();
    final IconType icon = getIcon();
    final ButtonSize size = getSize();
    final String _title = this.title != null ? " title=\"" + this.title + "\" " : "";
    sb.appendHtmlConstant("<button " + _title + " type=\"button\" class=\"btn "
            + (type != null ? type.get() : "") + (size != null ? " " + size.get() : "") + "\" tabindex=\"-1\">");
    if (data != null) {
        if (icon != null) {
            sb.appendHtmlConstant("<i class=\"" + icon.get() + "\"></i> ");
        }
        sb.append(data);
    }
    sb.appendHtmlConstant("</button>");
}
 
Example 9
Project: kie-docker-ci   File: KieContainerTypesSafeHtmlRenderer.java   Source Code and License 6 votes vote down vote up
@Override
public SafeHtml render(KieContainer container) {
    final KieImageType type = container.getType();
    if (type != null) {
        final KieContainerTypeSafeHtmlRenderer r = KieContainerTypeSafeHtmlRenderer.getInstance();
        final SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder();
        final SafeHtml typeHtml = r.render(type);
        htmlBuilder.append(typeHtml);
        final List<KieImageType> subTypes = container.getSubTypes();
        if (subTypes != null && !subTypes.isEmpty()) {
            for (final KieImageType _suType : subTypes) {
                final SafeHtml sbuTypeHtml = r.render(_suType);
                htmlBuilder.append(sbuTypeHtml);
            }
        }
        return htmlBuilder.toSafeHtml();
    }
    
    return null;
}
 
Example 10
Project: dataworks-zeus   File: DataPreviewGrid.java   Source Code and License 6 votes vote down vote up
public DataPreviewGrid(TablePreviewModel result) {
	List<ColumnConfig<Tuple<Integer, List<String>>, ?>> list = new ArrayList<ColumnConfig<Tuple<Integer, List<String>>, ?>>();
	int count = 0;
	for (String col : result.getHeaders()) {
		ColumnConfig<Tuple<Integer, List<String>>, String> cc = new ColumnConfig<Tuple<Integer, List<String>>, String>(
				new MyValueProvider(count), 80, col);
		cc.setToolTip(new SafeHtmlBuilder().appendHtmlConstant(col)
				.toSafeHtml());
		cc.setCell(new TitledCell());
		list.add(cc);
		count++;
	}
	getListStore().addAll(result.getData());
	ColumnModel<Tuple<Integer, List<String>>> colModel = new ColumnModel<Tuple<Integer, List<String>>>(
			list);
	grid = new Grid<Tuple<Integer, List<String>>>(getListStore(), colModel);

	grid.setHeight(175);

	grid.setAllowTextSelection(true);

	grid.getView().setAdjustForHScroll(false);
	grid.getView().setEmptyText("没有数据!");
}
 
Example 11
Project: gwt-modular-webapp-archetype   File: GreetingView.java   Source Code and License 6 votes vote down vote up
public void onResponse(String greet, String info, String agent) {

		SafeHtmlBuilder builder = new SafeHtmlBuilder();
		builder.appendEscaped(greet);
		builder.appendHtmlConstant("<br><br>I am running ");
		builder.appendEscaped(info);
		builder.appendHtmlConstant(".<br><br>It looks like you are using:<br>");
		builder.appendEscaped(agent);

		dialogBox.setText("Remote Procedure Call");
		dialogBox.center();

		serverResponseLabel.removeStyleName(greetingCss.error());
		serverResponseLabel.setHTML(builder.toSafeHtml());

		closeButton.setFocus(true);
	}
 
Example 12
Project: gwt-modular-webapp-archetype   File: GreetingView.java   Source Code and License 6 votes vote down vote up
public void onResponse(String greet, String info, String agent) {

		SafeHtmlBuilder builder = new SafeHtmlBuilder();
		builder.appendEscaped(greet);
		builder.appendHtmlConstant("<br><br>I am running ");
		builder.appendEscaped(info);
		builder.appendHtmlConstant(".<br><br>It looks like you are using:<br>");
		builder.appendEscaped(agent);

		dialogBox.setText("Remote Procedure Call");
		dialogBox.center();

		serverResponseLabel.removeStyleName(greetingCss.error());
		serverResponseLabel.setHTML(builder.toSafeHtml());

		closeButton.setFocus(true);
	}
 
Example 13
Project: aggregate   File: UIEnabledActionCell.java   Source Code and License 6 votes vote down vote up
public UIEnabledActionCell(SafeHtml text, UIVisiblePredicate<T> isVisiblePredicate,
    UIEnabledPredicate<T> isEnabledPredicate,
    UIEnabledActionCell.Delegate<T> delegate) {
  super("click", "keydown");
  this.isEnabledPredicate = isEnabledPredicate;
  this.isVisiblePredicate = isVisiblePredicate;
  this.delegate = delegate;
  htmlEnabled = new SafeHtmlBuilder()
      .appendHtmlConstant(
          "<button class=\"gwt-Button\" type=\"button\" tabindex=\"-1\">").append(text)
      .appendHtmlConstant("</button>").toSafeHtml();
  htmlDisabled = new SafeHtmlBuilder()
      .appendHtmlConstant(
          "<button class=\"gwt-Button\" type=\"button\" tabindex=\"-1\" disabled>").append(text)
      .appendHtmlConstant("</button>").toSafeHtml();
}
 
Example 14
Project: che   File: ProcessWidget.java   Source Code and License 6 votes vote down vote up
private ActionButton createStopButton(Process process, StopProcessHandler handler) {
  final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
  safeHtmlBuilder.appendHtmlConstant(FontAwesome.STOP);

  final ActionButton button = new ActionButton(safeHtmlBuilder.toSafeHtml());
  button.addClickHandler(
      event -> {
        event.stopPropagation(); // prevent dropdown list from opening/closing
        handler.onStopProcess(process);
      });
  button.ensureDebugId("dropdown-processes-stop");

  Tooltip.create((Element) button.getElement(), BOTTOM, MIDDLE, "Stop");

  return button;
}
 
Example 15
Project: che   File: ProcessWidget.java   Source Code and License 6 votes vote down vote up
private ActionButton createRerunButton(Process process, RerunProcessHandler handler) {
  final SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
  safeHtmlBuilder.appendHtmlConstant(FontAwesome.REPEAT);

  final ActionButton button = new ActionButton(safeHtmlBuilder.toSafeHtml());
  button.addClickHandler(
      event -> {
        event.stopPropagation(); // prevent dropdown list from opening/closing
        handler.onRerunProcess(process);
      });
  button.ensureDebugId("dropdown-processes-rerun");

  Tooltip.create((Element) button.getElement(), BOTTOM, MIDDLE, "Re-run");

  return button;
}
 
Example 16
Project: che   File: MacroCompletionProposal.java   Source Code and License 6 votes vote down vote up
@Override
public String getDisplayString() {
  SafeHtmlBuilder builder = new SafeHtmlBuilder();

  String label = macro.getName();
  int pos = 0;
  for (Match highlight : matches) {
    if (highlight.getStart() == highlight.getEnd()) {
      continue;
    }

    if (pos < highlight.getStart()) {
      appendPlain(builder, label.substring(pos, highlight.getStart()));
    }

    appendHighlighted(builder, label.substring(highlight.getStart(), highlight.getEnd()));
    pos = highlight.getEnd();
  }

  if (pos < label.length()) {
    appendPlain(builder, label.substring(pos));
  }

  return builder.toSafeHtml().asString();
}
 
Example 17
Project: che   File: FrameItemRender.java   Source Code and License 6 votes vote down vote up
@Override
public void render(Element itemElement, StackFrameDump itemData) {
  TableCellElement label = Elements.createTDElement();

  SafeHtmlBuilder sb = new SafeHtmlBuilder();
  sb.appendEscaped(itemData.getLocation().getMethod().getName());
  sb.appendEscaped("(");

  List<? extends Variable> arguments = itemData.getLocation().getMethod().getArguments();
  for (int i = 0; i < arguments.size(); i++) {
    String type = arguments.get(i).getType();
    sb.appendEscaped(type.substring(type.lastIndexOf(".") + 1));

    if (i != arguments.size() - 1) {
      sb.appendEscaped(", ");
    }
  }

  sb.appendEscaped("):");
  sb.append(itemData.getLocation().getLineNumber());
  sb.appendEscaped(", ");

  Path path = Path.valueOf(itemData.getLocation().getTarget());

  String className;
  if (path.isAbsolute()) {
    className = path.removeFileExtension().lastSegment();
  } else {
    className = path.lastSegment();
  }

  sb.appendEscaped(className);

  label.setInnerHTML(sb.toSafeHtml().asString());
  itemElement.appendChild(label);
}
 
Example 18
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 19
Project: gerrit   File: HighlightSuggestion.java   Source Code and License 6 votes vote down vote up
@Override
public String getDisplayString() {
  int start = 0;
  int keyLen = keyword.length();
  SafeHtmlBuilder builder = new SafeHtmlBuilder();
  for (; ; ) {
    int index = value.indexOf(keyword, start);
    if (index == -1) {
      builder.appendEscaped(value.substring(start));
      break;
    }
    builder.appendEscaped(value.substring(start, index));
    builder.appendHtmlConstant("<strong>");
    start = index + keyLen;
    builder.appendEscaped(value.substring(index, start));
    builder.appendHtmlConstant("</strong>");
  }
  return builder.toSafeHtml().asString();
}
 
Example 20
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 21
Project: appformer   File: NewFilterPopup.java   Source Code and License 6 votes vote down vote up
public RemoveActionHasCell(String text,
                           ActionCell.Delegate<DataGridFilterSummary> delegate) {
    cell = new ActionCell<DataGridFilterSummary>(text,
                                                 delegate) {
        @Override
        public void render(Cell.Context context,
                           final DataGridFilterSummary value,
                           SafeHtmlBuilder sb) {
            AbstractImagePrototype imageProto = AbstractImagePrototype.create(images.close());
            SafeHtmlBuilder mysb = new SafeHtmlBuilder();
            mysb.appendHtmlConstant("<span title='" + CommonConstants.INSTANCE.RemoveFilter() + " " + value.getFilterName() + "' style='margin-right:5px;'>");
            mysb.append(imageProto.getSafeHtml());
            mysb.appendHtmlConstant("</span>");
            sb.append(mysb.toSafeHtml());
        }
    };
}
 
Example 22
Project: appformer   File: CheckboxCellImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void render(Context context,
                   Boolean value,
                   SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    Boolean viewData = getViewData(key);
    if (viewData != null && viewData.equals(value)) {
        clearViewData(key);
        viewData = null;
    }

    if (value != null && ((viewData != null) ? viewData : value)) {
        if (isReadOnly) {
            sb.append(READ_ONLY_INPUT_CHECKED);
        } else {
            sb.append(INPUT_CHECKED);
        }
    } else {
        if (isReadOnly) {
            sb.append(READ_ONLY_INPUT_UNCHECKED);
        } else {
            sb.append(INPUT_UNCHECKED);
        }
    }
}
 
Example 23
Project: appformer   File: ToggleSwitchEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example 24
Project: appformer   File: MapEditor.java   Source Code and License 6 votes vote down vote up
/*************************************************************
 ** GWT EDITOR CONTRACT METHODS **
 *************************************************************/

@Override
public void showErrors(final List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example 25
Project: appformer   File: DropDownEditor.java   Source Code and License 6 votes vote down vote up
/*************************************************************
 ** GWT EDITOR CONTRACT METHODS **
 *************************************************************/

@Override
public void showErrors(final List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        if (error.getEditor().equals(this)) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example 26
Project: appformer   File: ImageListEditor.java   Source Code and License 6 votes vote down vote up
/*************************************************************
 ** GWT EDITOR CONTRACT METHODS **
 *************************************************************/

@Override
public void showErrors(final List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        if (error.getEditor().equals(this)) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example 27
Project: appformer   File: FileUploadEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example 28
Project: appformer   File: ValueBoxEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (final EditorError error : errors) {

        if (error.getEditor() == this) {
            sb.append("\n").append(error.getMessage());
        }
    }

    boolean hasErrors = sb.length() > 0;
    if (!hasErrors) {
        view.clearError();
        return;
    }

    // Show the errors.
    view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml());
}
 
Example 29
Project: Charba   File: BaseOptions.java   Source Code and License 5 votes vote down vote up
/**
 * Called to generate an HTML legend.
 * 
 * @return an HTML string which represents the legend.
 */
protected String generateLegend() {
	// checks if legend callback is set
	if (legendCallBack != null) {
		// creates the safe html to be sure about the right HTML to send back
		SafeHtmlBuilder builder = new SafeHtmlBuilder();
		// calls callback
		legendCallBack.generateLegend(getChart(), builder);
		// returns safe html
		return builder.toSafeHtml().asString();
	}
	return LEGEND_CALLBACK_ERROR;
}
 
Example 30
Project: sig-seguimiento-vehiculos   File: LayerCatalogDialog.java   Source Code and License 5 votes vote down vote up
private RowExpander<LayerDef> createRowExpander() {
	return new RowExpander<LayerDef>(new AbstractCell<LayerDef>() {
		@Override
		public void render(Context context, LayerDef value,
				SafeHtmlBuilder sb) {
			sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>"
					+ UICatalogMessages.INSTANCE.description() + ":</b> "
					+ value.getDescription() + "</p>");
		}
	});
}
 
Example 31
Project: optashift-employee-rostering   File: SpotEditForm.java   Source Code and License 5 votes vote down vote up
@PostConstruct
protected void initWidget() {
    spotName.setValue(spot.getName());
    skills.forEach((s) -> requiredSkill.addItem(s.getName()));
    requiredSkill.setItemSelected(skills.indexOf(spot.getRequiredSkill()), true);
    title.setInnerSafeHtml(new SafeHtmlBuilder().appendEscaped(spot.getName())
            .toSafeHtml());
    popup = FormPopup.getFormPopup(this);
    popup.center();
}
 
Example 32
Project: optashift-employee-rostering   File: SpotShiftEditForm.java   Source Code and License 5 votes vote down vote up
@PostConstruct
protected void initWidget() {
    isLocked.setValue(spot.getData().isLocked());
    title.setInnerSafeHtml(new SafeHtmlBuilder().appendEscaped(spot.getData().getSpot().getName())
            .appendEscaped(" - ")
            .appendEscaped(spot.getData().getStartTime().toLocalTime().toString())
            .appendEscaped("-")
            .appendEscaped(spot.getData().getEndTime().toLocalTime().toString())
            .toSafeHtml());
    SpotShiftEditForm form = this;
    EmployeeRestServiceBuilder.getEmployeeList(spot.getData().getShift().getTenantId(),
            new FailureShownRestCallback<List<
                    Employee>>() {

                @Override
                public void onSuccess(List<Employee> tenantEmployeeList) {
                    employeeList = tenantEmployeeList;
                    employeeList.forEach((e) -> assignedEmployee.addItem(e.getName()));
                    if (!spot.getData().isLocked()) {
                        assignedEmployee.setEnabled(false);
                    } else {
                        assignedEmployee.setSelectedIndex(employeeList.indexOf(spot.getData()
                                .getAssignedEmployee()));
                    }
                    isLocked.addValueChangeHandler((v) -> assignedEmployee.setEnabled(v.getValue()));

                    popup = FormPopup.getFormPopup(form);
                    popup.center();
                }
            });
}
 
Example 33
Project: optashift-employee-rostering   File: SkillEditForm.java   Source Code and License 5 votes vote down vote up
@PostConstruct
protected void initWidget() {
    skillName.setValue(skill.getName());
    title.setInnerSafeHtml(new SafeHtmlBuilder().appendEscaped(skill.getName())
            .toSafeHtml());
    popup = FormPopup.getFormPopup(this);
    popup.center();
}
 
Example 34
Project: optashift-employee-rostering   File: AbstractRosterViewPanel.java   Source Code and License 5 votes vote down vote up
public void update(Observable observable, Object arg) {
    if (solverObservable == observable) {
        if (arg instanceof StartSolvingEvent) {
            solveButton.getElement().setAttribute("class", "btn btn-danger");
            buttonImage.getElement().setAttribute("class", "glyphicon glyphicon-stop");
            buttonImage.getElement().setAttribute("aria-hidden", "true");
            buttonText.setHTML(new SafeHtmlBuilder()
                    .appendEscaped(CONSTANTS.format("AbstractRosterViewPanel.terminateEarly"))
                    .toSafeHtml().asString());
            isSolving = true;
        } else if (arg instanceof TerminateSolvingEvent) {
            solveButton.getElement().setAttribute("class", "btn btn-success");
            buttonImage.getElement().setAttribute("class", "glyphicon glyphicon-play");
            buttonImage.getElement().setAttribute("aria-hidden", "true");
            buttonText.setHTML(new SafeHtmlBuilder()
                    .appendEscaped(CONSTANTS.format("AbstractRosterViewPanel.solve"))
                    .toSafeHtml().asString());
            isSolving = false;
            solveStatus.setHTML(new SafeHtmlBuilder()
                    .appendHtmlConstant(CONSTANTS.format(AbstractRosterViewPanel_finishedSolving) + ".")
                    .toSafeHtml().asString());
        } else if (arg instanceof SetSolvingTimeEvent) {
            SetSolvingTimeEvent event = (SetSolvingTimeEvent) arg;
            solveStatus.setHTML(new SafeHtmlBuilder()
                    .appendHtmlConstant(CONSTANTS.format(AbstractRosterViewPanel_solvingFor, event
                            .getSecondsRemaining()))
                    .toSafeHtml().asString());
        }
    }
}
 
Example 35
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 36
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 37
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 38
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 39
Project: LAS   File: ThumbnailPropProp.java   Source Code and License 5 votes vote down vote up
private void showMetadata() {
    int index = 0;
    for (Iterator metaIt = metadata.keySet().iterator(); metaIt.hasNext();) {
        String name = (String) metaIt.next();
        String value = metadata.get(name);
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        builder.appendHtmlConstant("<strong>").append(HtmlSanitizerUtil.sanitizeHtml(name)).appendHtmlConstant(":</strong>&nbsp;&nbsp;&nbsp;").append(HtmlSanitizerUtil.sanitizeHtml(value));
        metadataTable.setWidget(0, index, new HTML(builder.toSafeHtml()));
        index++;
    }
}
 
Example 40
Project: mentor   File: ImageUnitWidget.java   Source Code and License 5 votes vote down vote up
public void setUnit(ImageUnit unit) {

		super.setUnit(unit);
		
		image.setUrl(GWT.getHostPageBaseURL() + "api/units/" + unit.getId() + "/content");

		if (unit.getAttributes().getCaption() != null) {
			caption.setHTML(new SafeHtmlBuilder().appendEscapedLines(unit.getAttributes().getCaption()).toSafeHtml());
			captionColumn.setVisible(true);
		} else {
			captionColumn.setVisible(false);
		}
		
	}