private void render() {
   PerfTimer timer = PerfTimer.get(this, "render");
   SafeHtmlBuilder builder = new SafeHtmlBuilder();
   if (data != null) {
     for (Contact c : data) {
       builder.append(
           TEMPLATE.item(
               "",
               AppResources.INSTANCE.css().profilePic(),
               c.getPicURL(),
               AppResources.INSTANCE.css().detailBlock(),
               c.getName(),
               c.getEmail(),
               c.getPhone()));
     }
   } else {
     builder.append(
         TEMPLATE.loading(
             AppResources.INSTANCE.css().loading(),
             AppResources.INSTANCE.loadingImage().getURL(),
             Messages.INSTANCE.listLoading()));
   }
   getElement().setInnerHTML(builder.toSafeHtml().asString());
   timer.end();
 }
  private void buildDOM(AbstractImagePrototype thumbImage) {
    final Element leftDiv = getElement(LEFT);
    final Element rightDiv = getElement(RIGHT);
    final Element splitDiv = getSplitElement();

    DOM.appendChild(getElement(), container);

    DOM.appendChild(container, leftDiv);
    DOM.appendChild(container, splitDiv);
    DOM.appendChild(container, rightDiv);

    /*
     * Sadly, this is the only way I've found to get vertical centering in this
     * case. The usually CSS hacks (display: table-cell, vertical-align: middle)
     * don't work in an absolute positioned DIV.
     */
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    sb.appendHtmlConstant(
        "<table class='hsplitter' height='100%' cellpadding='0' "
            + "cellspacing='0'><tr><td align='center' valign='middle'>");
    sb.append(thumbImage.getSafeHtml());
    splitDiv.setInnerSafeHtml(sb.toSafeHtml());

    addScrolling(leftDiv);
    addScrolling(rightDiv);
  }
Пример #3
0
  @Override
  public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {

    ObjectProperty property = (ObjectProperty) context.getKey();
    if (navigable && property != null && !property.isBaseType()) {
      SafeHtml startAnchor = null;
      SafeHtml endAnchor = null;
      startAnchor =
          new SafeHtml() {
            @Override
            public String asString() {
              return "<div style=\"cursor: pointer;\">";
            }
          };

      endAnchor =
          new SafeHtml() {
            @Override
            public String asString() {
              return "</div>";
            }
          };

      sb.append(startAnchor);
      sb.append(value);
      sb.append(endAnchor);

    } else {
      super.render(context, value, sb);
    }
  }
Пример #4
0
  public void updateDetailData(AnnotationInfo annotationInfo) {
    // updates the detail section (3' and 5' coordinates) when user clicks on any of the types in
    // the table.
    // mRNA information is not available
    this.internalAnnotationInfo = annotationInfo;
    GWT.log("updating exon detail panel");
    //        GWT.log(internalData.toString());
    //        nameField.setText(internalData.get("name").isString().stringValue());

    //        JSONObject locationObject = this.internalData.get("location").isObject();
    coordinatesToPrime(annotationInfo.getMin(), annotationInfo.getMax());
    if (internalAnnotationInfo.getStrand() > 0) {
      positiveStrandValue.setType(ButtonType.PRIMARY);
      negativeStrandValue.setType(ButtonType.DEFAULT);
    } else {
      positiveStrandValue.setType(ButtonType.DEFAULT);
      negativeStrandValue.setType(ButtonType.PRIMARY);
    }

    //        phaseButton.setText(internalAnnotationInfo.getPhase());

    SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
    for (String note : annotationInfo.getNoteList()) {
      safeHtmlBuilder.appendHtmlConstant("<div class='label label-warning'>" + note + "</div>");
    }
    notePanel.setHTML(safeHtmlBuilder.toSafeHtml());

    //        safeHtmlBuilder.appendHtmlConstant("<div class='label
    // label-warning'>"+error+"</div>");

    setVisible(true);
  }
 /* (non-Javadoc)
  * @see com.google.gwt.cell.client.AbstractCell#render(com.google.gwt.cell.client.Cell.Context, java.lang.Object, com.google.gwt.safehtml.shared.SafeHtmlBuilder)
  */
 @Override
 public void render(Context context, CellTreeNode cellTreeNode, SafeHtmlBuilder sb) {
   if (cellTreeNode == null) {
     return;
   }
   // TODO :  We can add classes based on the NodeType with the specified image.
   // The classes will be picked up from Mat.css
   if ((cellTreeNode.getNodeType() == CellTreeNode.MASTER_ROOT_NODE)
       || (cellTreeNode.getNodeType() == CellTreeNode.ROOT_NODE)) {
     sb.append(
         template.outerDiv(
             getStyleClass(cellTreeNode),
             cellTreeNode.getTitle(),
             cellTreeNode.getLabel() != null
                 ? cellTreeNode.getLabel()
                 : cellTreeNode.getName()));
   } else {
     sb.append(
         template.outerDivItem(
             getStyleClass(cellTreeNode),
             cellTreeNode.getTitle(),
             cellTreeNode.getLabel() != null
                 ? cellTreeNode.getLabel()
                 : cellTreeNode.getName()));
   }
 }
Пример #6
0
      @SuppressWarnings("unchecked")
      @Override
      public void render(
          com.google.gwt.cell.client.Cell.Context context, Boolean value, SafeHtmlBuilder sb) {
        // Get the view data.
        Object key = context.getKey();
        E keyValue = (E) key;
        if (disabledSet.contains(keyValue)) {
          // disabled
          Boolean viewData = getViewData(key);
          if (viewData != null && viewData.equals(value)) {
            clearViewData(key);
            viewData = null;
          }

          if (value != null && ((viewData != null) ? viewData : value)) {
            sb.append(INPUT_CHECKED_DISABLED);
          } else {
            sb.append(INPUT_UNCHECKED_DISABLED);
          }
        } else {
          // enabled
          super.render(context, value, sb);
        }
      }
Пример #7
0
 /** Test rendering the cell with a null value and no view data. */
 public void testRenderNull() {
   Cell<T> cell = createCell();
   SafeHtmlBuilder sb = new SafeHtmlBuilder();
   Context context = new Context(0, 0, null);
   cell.render(context, null, sb);
   assertEquals(getExpectedInnerHtmlNull(), sb.toSafeHtml().asString());
 }
 @Override
 protected <X> void render(
     Context context, T value, SafeHtmlBuilder sb, HasCell<T, X> hasCell, String id) {
   Cell<X> cell = hasCell.getCell();
   sb.appendHtmlConstant("<td>"); // $NON-NLS-1$
   cell.render(context, hasCell.getValue(value), sb);
   sb.appendHtmlConstant("</td>"); // $NON-NLS-1$
 }
Пример #9
0
 /** Test rendering the cell with a negative index is handled. */
 public void testRenderNegativeIndex() {
   Cell<T> cell = createCell();
   T value = createCellValue();
   SafeHtmlBuilder sb = new SafeHtmlBuilder();
   Context context = new Context(-1, -1, null);
   cell.render(context, value, sb);
   assertEquals(getExpectedInnerHtml(), sb.toSafeHtml().asString());
 }
 public void showErrors(List<EditorError> errors) {
   SafeHtmlBuilder b = new SafeHtmlBuilder();
   for (EditorError error : errors) {
     b.appendEscaped(error.getPath()).appendEscaped(": ");
     b.appendEscaped(error.getMessage()).appendHtmlConstant("<br>");
   }
   this.errors.setInnerHTML(b.toSafeHtml().asString());
 }
 @Override
 protected <X> void render(
     Context context, RoleProxy value, SafeHtmlBuilder sb, HasCell<RoleProxy, X> hasCell) {
   Cell<X> cell = hasCell.getCell();
   sb.appendHtmlConstant("<td>");
   cell.render(context, hasCell.getValue(value), sb);
   sb.appendHtmlConstant("</td>");
 }
Пример #12
0
 static SafeHtml replace() {
   // TODO I18n or take from DMR
   SafeHtmlBuilder builder = new SafeHtmlBuilder();
   builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
   addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
   addHelpTextRow(builder, "Runtime Name:", Console.CONSTANTS.deploymentRuntimeNameDescription());
   return builder.toSafeHtml();
 }
Пример #13
0
 @Override
 public void render(Context context, InputItem rec, SafeHtmlBuilder sb) {
   boolean changed = changedRecs.containsKey(rec.getId());
   String style =
       changed ? "color: red; font-weight: bold;" : "color: black; font-weight: normal";
   sb.appendHtmlConstant("<span style=\"" + style + "\">");
   sb.append(SafeHtmlUtils.fromString("" + rec.getId()));
   sb.appendHtmlConstant("</span>");
 }
Пример #14
0
 public static String getError(String message) {
   SafeHtmlBuilder builder = new SafeHtmlBuilder();
   builder.append(
       SafeHtmlUtils.fromTrustedString(
           "<html><title>Getting credentials failed</title><body><div align=\"center\"><p><h1>Getting credentails failed</h1></p><p><img src=\"themes/active/logo.png\" /></p><p><h3 style=\"font-color: red;\">"));
   builder.appendEscaped(message);
   builder.append(SafeHtmlUtils.fromTrustedString("</h3></p></div></body></html>"));
   return builder.toSafeHtml().asString();
 }
    @Override
    public void render(Context context, SummaryDTO value, SafeHtmlBuilder sb) {
      if (value == null) {
        return;
      }

      sb.appendHtmlConstant("<table style=\"padding:5px;text-align:justify;\">");
      sb.appendHtmlConstant("<tr><td><span style=\"font-weight:bold;\">");
      sb.appendHtmlConstant(value.getResourceTitle());
      sb.appendHtmlConstant("</b></td></tr>");
      sb.appendHtmlConstant("<tr><td>");
      sb.appendHtmlConstant(value.getResourceAbstract());
      sb.appendHtmlConstant("</td></tr>");
      sb.appendHtmlConstant(
          "<tr><td><span id=\""
              + SEE_METADATA
              + "-"
              + value.getUuid()
              + "\" class=\"small-button\">VOIR</span><span class=\"small-button\" id=\""
              + PDF_METADATA
              + "-"
              + value.getUuid()
              + "\">PDF</span><span class=\"small-button\" id=\""
              + DIPLAY_METADATA_QUICKLOOKS
              + "-"
              + value.getUuid()
              + "\">APERCUS</span><span class=\"small-button\" id=\""
              + DIPLAY_METADATA_LINKS
              + "-"
              + value.getUuid()
              + "\">LIENS</span></td></tr>");
      sb.appendHtmlConstant("</table>");
    }
Пример #16
0
  private void resultsBuild() {

    selectItems = new SelectParser().parse(selectElement);

    if (isMultiple && choices > 0) {
      searchChoices.find("li." + css.searchChoice()).remove();
      choices = 0;
    } else if (!isMultiple) {
      selectedItem.addClass(css.chznDefault()).find("span").text(defaultText);

      if (selectElement.getOptions().getLength() <= options.getDisableSearchThreshold()) {
        container.addClass(css.chznContainerSingleNoSearch());
      } else {
        container.removeClass(css.chznContainerSingleNoSearch());
      }
    }

    SafeHtmlBuilder content = new SafeHtmlBuilder();

    for (int i = 0; i < selectItems.length(); i++) {
      SelectItem item = selectItems.get(i);

      if (item.isGroup()) {
        SafeHtml result = resultAddGroup((GroupItem) item);
        if (result != null) {
          content.append(result);
        }
      } else {
        OptionItem optionItem = (OptionItem) item;

        if (optionItem.isEmpty()) {
          continue;
        }

        SafeHtml optionHtml = resultAddOption(optionItem);
        if (optionHtml != null) {
          content.append(optionHtml);
        }

        if (optionItem.isSelected() && isMultiple) {
          choiceBuild(optionItem);
        } else if (optionItem.isSelected() && !isMultiple) {
          selectedItem.removeClass(css.chznDefault()).find("span").text(optionItem.getText());
          if (allowSingleDeselect) {
            singleDeselectControlBuild();
          }
        }
      }
    }
    searchFieldDisabled();
    showSearchFieldDefault();
    searchFieldScale();

    searchResults.html(content.toSafeHtml().asString());
  }
  public void render(Context context, Semesterverband value, SafeHtmlBuilder sb) {

    if (value == null) {
      return;
    }

    sb.appendHtmlConstant("<div>");
    sb.appendEscaped(value.getStudiengang().getKuerzel() + " ");
    sb.appendEscaped(value.getJahrgang());
    sb.appendHtmlConstant("</div>");
  }
  @Override
  public void onUncaughtException(Throwable exception) {
    Throwable e = unwrapUmbrellaException(exception);
    Log.fatal("uncaught exception", e);

    String stackTrace = buildStackTraceMessages(e);
    /*    disable server side logging for now to avoid email bombing

          RemoteLoggingAction action = new RemoteLoggingAction(stackTrace);
          action.addContextInfo("selected Doc", appPresenter.getSelectedDocumentInfoOrNull());
          action.addContextInfo("selected TransUnitId", targetContentsPresenter.getCurrentTransUnitIdOrNull());
          action.addContextInfo("editor contents", targetContentsPresenter.getNewTargets());
          dispatcher.execute(action, new NoOpAsyncCallback<NoOpResult>());
    */

    if (!configHolder.getState().isShowError()) {
      return;
    }
    globalPopup
        .getCaption()
        .setHTML("<div class=\"globalPopupCaption\">ERROR: " + e.getMessage() + "</div>");

    VerticalPanel popupContent = new VerticalPanel();

    // description text
    SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder();
    // @formatter:off
    htmlBuilder
        .appendHtmlConstant("<h3>You may close this window and continue with your work</h3>")
        .appendHtmlConstant(
            "<div>If you want to let us know the error, Please recall your actions and take one of the following steps:</div>")
        .appendHtmlConstant("<ul>")
        .appendHtmlConstant("<li>Email administration; Or</li>")
        .appendHtmlConstant(
            "<li>Check if it's a <a href=\"https://bugzilla.redhat.com/buglist.cgi?product=Zanata&bug_status=__open__\" target=\"_blank\">known issue</a>; Or</li>")
        .appendHtmlConstant(
            "<li><a href=\"https://bugzilla.redhat.com/enter_bug.cgi?format=guided&product=Zanata\" target=\"_blank\">Report a problem</a>; Or</li>")
        .appendHtmlConstant(
            "<li>Email <a href=\"mailto:[email protected]\">Zanata users mailing list</a></li>")
        .appendHtmlConstant("</ul>")
    // @formatter:on
    ;

    // stack trace
    DisclosurePanel disclosurePanel = buildStackTraceDisclosurePanel(stackTrace);

    // send stack trace log to server

    popupContent.add(new HTMLPanel(htmlBuilder.toSafeHtml()));
    popupContent.add(disclosurePanel);
    popupContent.add(closeButton);
    globalPopup.setWidget(popupContent);
    globalPopup.center();
  }
Пример #19
0
 public void render(final Cell.Context context, final T value, final SafeHtmlBuilder sb) {
   final SafeHtmlBuilder mysb = new SafeHtmlBuilder();
   final Button btn = GWT.create(Button.class);
   btn.setText(getText(value));
   btn.setTitle(getText(value));
   btn.setType(ButtonType.DEFAULT);
   btn.setSize(ButtonSize.SMALL);
   btn.getElement().getStyle().setMarginRight(5, Style.Unit.PX);
   mysb.appendHtmlConstant(btn.getElement().getString());
   sb.append(mysb.toSafeHtml());
 }
 @Override
 public void render(
     com.google.gwt.cell.client.Cell.Context context, SafeHtml data, SafeHtmlBuilder sb) {
   if (data != null) {
     sb.appendHtmlConstant(
         "<button type=\"button\" style=\"height:24px;\" tabindex=\"-1\">"); //$NON-NLS-1$
     if (data != null) {
       sb.append(data);
     }
     sb.appendHtmlConstant("</button>"); // $NON-NLS-1$
   }
 }
 private static DisclosurePanel buildStackTraceDisclosurePanel(String stackTrace) {
   DisclosurePanel disclosurePanel =
       new DisclosurePanel("Stack trace of the exception (helpful to us)");
   disclosurePanel.getHeader().getParent().setStyleName(""); // conflict style from menu.css
   SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder();
   htmlBuilder.appendHtmlConstant("<pre>");
   htmlBuilder.appendHtmlConstant(stackTrace);
   htmlBuilder.appendHtmlConstant("</pre>");
   disclosurePanel.setContent(new HTMLPanel(htmlBuilder.toSafeHtml()));
   disclosurePanel.setOpen(false);
   return disclosurePanel;
 }
Пример #22
0
 @Override
 public void updateSearchLabel(String query, String path) {
   SafeHtmlBuilder builder = new SafeHtmlBuilder();
   builder
       .appendEscaped("Results for ")
       .appendHtmlConstant("<strong>")
       .appendEscaped(query)
       .appendHtmlConstant("</strong>")
       .appendEscaped(" in ")
       .appendEscaped(path);
   searchLabel_.getElement().setInnerHTML(builder.toSafeHtml().asString());
 }
  private void setNick(UserDataProxy userData) {
    if (userData == null) {
      return;
    }

    String nick = userData.getGoogleNickname();

    // This is a must, always clean before draw
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendEscaped(nick);

    htmlNick.setHTML(builder.toSafeHtml());
  }
  @Override
  public void render(Context context, T value, SafeHtmlBuilder sb, String id) {
    if (!isVisible(value)) {
      return;
    }

    sb.appendHtmlConstant(
        "<table id=\"" + id + "\" style=\"margin:0 auto\"><tr>"); // $NON-NLS-1$ //$NON-NLS-2$
    Iterator<HasCell<T, ?>> iterator = hasCells.iterator();
    while (iterator.hasNext()) {
      render(context, value, sb, iterator.next(), id);
    }
    sb.appendHtmlConstant("</tr></table>"); // $NON-NLS-1$
  }
Пример #25
0
 @Override
 public void render(Context context, SafeHtmlBuilder sb) {
   if (!isEnabled()) {
     if (getValue()) {
       sb.append(INPUT_CHECKED_DISABLED);
     } else {
       sb.append(INPUT_UNCHECKED_DISABLED);
     }
     if (getLabel() != null && !StringUtils.isEmpty(getLabel())) {
       sb.append(SafeHtmlUtils.fromString(getLabel()));
     }
   } else {
     super.render(context, sb);
   }
 }
Пример #26
0
 @Override
 protected void render(Context context, String value, String viewData, SafeHtmlBuilder sb) {
   if (viewData != null) {
     if (isMultilineStyle()) {
       sb.append(TEMPLATE.html(getCellStyleName(), SafeHtmlUtils.fromSafeConstant(viewData)));
     } else {
       sb.append(TEMPLATE.text(getCellStyleName(), Utils.getTextFromHtml(viewData)));
     }
   } else if (value != null) {
     if (isMultilineStyle()) {
       sb.append(TEMPLATE.html(getCellStyleName(), SafeHtmlUtils.fromSafeConstant(value)));
     } else {
       sb.append(TEMPLATE.text(getCellStyleName(), Utils.getTextFromHtml(value)));
     }
   }
 }
 @Override
 public void render(Context context, Boolean value, SafeHtmlBuilder sb) {
   if (value) {
     SafeHtml html = SafeHtmlUtils.fromTrustedString(image.toString());
     sb.append(html);
   }
 }
Пример #28
0
  @Override
  public void render(
      com.google.gwt.cell.client.Cell.Context context, FeedEntry value, SafeHtmlBuilder sb) {
    if (value == null) return;

    final FeedEntry fe = value;
    SafeHtml rendered =
        new SafeHtml() {

          private static final long serialVersionUID = 1L;

          @Override
          public String asString() {
            return "<div id=\"rssEntry\">"
                + "<div id=\"rssTitle\"><a target=\"_blank\" href=\""
                + fe.link
                + "\">"
                + fe.title
                + "</a></div>"
                + "<div id=\"rssDetails\">"
                + fe.date.toString()
                + " - "
                + fe.author
                + "</div>"
                + "<div id=\"rssDescription\">"
                + fe.getDescription()
                + "</div>"
                + "</div>";
          }
        };

    sb.append(rendered);
  }
Пример #29
0
 @Override
 public void render(Context context, T value, SafeHtmlBuilder sb) {
   lastContext = context;
   if (value != null) {
     sb.appendEscaped(String.valueOf(value));
   }
 }
Пример #30
0
  public void render(Context context, Document value, SafeHtmlBuilder sb) {
    SafeHtml formatedDate = SafeHtmlUtils.fromString(dateParser.parseDate(value.getCreated()));
    SafeHtml author = SafeHtmlUtils.fromString(value.getFullPrimaryAuthorName());
    if (Strings.isNullOrEmpty(value.getFullPrimaryAuthorName())) {
      author = SafeHtmlUtils.fromString("anonymous");
    }

    String note = value.getOnlyContent();
    int linkStart = note.indexOf("http");
    if (linkStart > 0 && note.charAt(linkStart - 1) != ' ') {
      String firstPart = note.substring(0, linkStart);
      String lastPart = note.substring(linkStart, note.length());
      note = firstPart + " " + lastPart;
    }

    String[] words = note.split(" ");
    StringBuilder builder = new StringBuilder();
    for (String word : words) {
      if (isValidLink(word)) {
        builder.append(prepareLink(word));
      } else {
        word = textSanitizerUtil.sanitize(word).asString();
        builder.append(word);
      }

      builder.append(" ");
    }

    SafeHtml noteText = SafeHtmlUtils.fromTrustedString(builder.toString());
    sb.append(template.noteTemplate(noteText, author, formatedDate));
  }