List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder
public SafeHtmlBuilder()
From source file:com.sencha.gxt.widget.core.client.tree.Tree.java
License:sencha.com license
protected void onAfterFirstAttach() { SafeHtmlBuilder builder = new SafeHtmlBuilder(); this.appearance.renderContainer(builder); // TODO we should be asking appearance for the root container element rather // than assuming its the last child. rootContainer = getRootContainer();/* w w w. jav a2 s .c o m*/ rootContainer.setInnerSafeHtml(builder.toSafeHtml()); getElement().show(); getElement().getStyle().setProperty("overflow", "auto"); if (store.getRootItems().size() == 0 && loader != null) { loader.load(); } else { renderChildren(null); if (autoSelect) { getSelectionModel().select(0, false); } } // JAWS does not work when disabling text selection setAllowTextSelection(false); sinkEvents(Event.ONSCROLL | Event.ONCLICK | Event.ONDBLCLICK | Event.MOUSEEVENTS | Event.KEYEVENTS); }
From source file:com.sencha.gxt.widget.core.client.tree.Tree.java
License:sencha.com license
protected void renderChildren(M parent) { SafeHtmlBuilder markup = new SafeHtmlBuilder(); int depth = store.getDepth(parent); List<M> children = parent == null ? store.getRootItems() : store.getChildren(parent); if (children.size() == 0) { return;//from ww w. ja v a2 s . c om } for (M child : children) { register(child); } for (int i = 0; i < children.size(); i++) { TreeViewRenderMode mode = !bufferRender ? TreeViewRenderMode.ALL : TreeViewRenderMode.BUFFER_WRAP; markup.append(renderChild(parent, children.get(i), depth, mode)); } Element container = getContainer(parent); container.setInnerSafeHtml(markup.toSafeHtml()); for (int i = 0; i < children.size(); i++) { M child = children.get(i); TreeNode<M> node = findNode(child); if (autoExpand) { setExpanded(child, true); } else if (node.isExpand() && !isLeaf(node.getModel())) { node.setExpand(false); setExpanded(child, true); } else if (loader != null) { if (autoLoad) { if (store.isFiltered()) { renderChildren(child); } else { if (loader.hasChildren(child)) { loader.loadChildren(child); } } } } else if (autoLoad) { renderChildren(child); } } TreeNode<M> n = findNode(parent); if (n != null) { if (n.checked == CheckState.CHECKED) { switch (checkStyle) { case TRI: cascade = false; for (M child : store.getChildren(parent)) { setChecked(child, CheckState.CHECKED); } cascade = true; break; case CHILDREN: onCheckCascade(n.getModel(), n.checked); break; default: // empty } } n.setChildrenRendered(true); } if (parent == null) { ensureFocusElement(); } update(); }
From source file:com.sencha.gxt.widget.core.client.tree.TreeView.java
License:sencha.com license
public Element getContainer(TreeNode<M> node) { if (node.getContainerElement() == null) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); tree.getAppearance().renderContainer(sb); node.setContainerElement(getElement(node).appendChild(XDOM.create(sb.toSafeHtml()))); }//from www .ja v a 2s . c o m return node.getContainerElement(); }
From source file:com.sencha.gxt.widget.core.client.tree.TreeView.java
License:sencha.com license
public SafeHtml getTemplate(M m, String id, SafeHtml html, ImageResource icon, boolean checkable, CheckState checked, Joint joint, int level, TreeViewRenderMode renderMode) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); tree.getAppearance().renderNode(sb, id, html, tree.getStyle(), icon, checkable, checked, joint, level, renderMode);/*w w w. j a va 2 s . c o m*/ return sb.toSafeHtml(); }
From source file:com.sencha.gxt.widget.core.client.treegrid.TreeGrid.java
License:sencha.com license
/** * Creates a new tree grid./* w w w .j ava 2s. co m*/ * * @param store the tree store * @param cm the column model * @param treeColumn the tree column * @param appearance the grid appearance * @param treeAppearance the tree appearance */ public TreeGrid(TreeStore<M> store, ColumnModel<M> cm, ColumnConfig<M, ?> treeColumn, GridAppearance appearance, TreeAppearance treeAppearance) { this.appearance = appearance; this.treeAppearance = treeAppearance; disabledStyle = null; SafeHtmlBuilder builder = new SafeHtmlBuilder(); this.appearance.render(builder); setElement((Element) XDOM.create(builder.toSafeHtml())); getElement().makePositionable(); // Do not remove, this is being used in Grid.gss addStyleName("x-treegrid"); getElement().setTabIndex(0); getElement().setAttribute("hideFocus", "true"); this.cm = cm; setTreeColumn(treeColumn); this.treeStore = store; this.store = createListStore(); setSelectionModel(new TreeGridSelectionModel<M>()); disabledStyle = null; storeHandlerRegistration = treeStore.addStoreHandlers(storeHandler); setView(new TreeGridView<M>(appearance)); setAllowTextSelection(false); sinkCellEvents(); // use either long press or tap to select addGestureRecognizer(new LongPressOrTapGestureRecognizer() { @Override protected void onLongPress(TouchData touchData) { Event event = touchData.getLastNativeEvent().cast(); onMouseDown(event); onClick(event); super.onLongPress(touchData); } @Override protected void onEnd(List<TouchData> touches) { Event event = touches.get(0).getLastNativeEvent().cast(); onMouseDown(event); onClick(event); super.onEnd(touches); } }); }
From source file:com.sencha.gxt.widget.core.client.treegrid.TreeGridView.java
License:sencha.com license
/** * Returns the markup that is used to render a node. * /* ww w. j a va2 s . c om*/ * @param m the model * @param id the id of the node (store model key provider) * @param html the node html * @param icon the node icon or null * @param checkable true if the node is checked * @param joint the joint state * @param level the tree depth * @return the markup as safe html */ public SafeHtml getTemplate(M m, String id, SafeHtml html, ImageResource icon, boolean checkable, Joint joint, int level) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); tree.getTreeAppearance().renderNode(sb, id, html, tree.getStyle(), icon, checkable, CheckState.UNCHECKED, joint, level - 1, TreeViewRenderMode.ALL); return sb.toSafeHtml(); }
From source file:com.tasktop.c2c.server.scm.web.ui.client.view.ScmCommitView.java
License:Open Source License
private SafeHtml buildHtml(List<DiffEntry> changes) { SafeHtmlBuilder htmlBuilder = new SafeHtmlBuilder(); String fileName;// ww w. j a v a 2s .c om int i = 0; totalDiffLines = 0; for (DiffEntry diff : changes) { totalDiffLines = totalDiffLines + diff.getLinesAdded() + diff.getLinesRemoved(); String elId = computeElementId(i++); switch (diff.getChangeType()) { case ADD: case MODIFY: fileName = diff.getNewPath(); break; case DELETE: fileName = diff.getOldPath(); break; case RENAME: fileName = scmMessages.renamedTo(diff.getOldPath(), diff.getNewPath()); break; case COPY: fileName = scmMessages.copiedTo(diff.getOldPath(), diff.getNewPath()); break; default: fileName = diff.getNewPath(); break; } htmlBuilder .append(template.addFileChange(ScmResources.get.style().contentFileHeader(), elId, fileName)); if (diff.isBinary()) { htmlBuilder.append(template.binary("")); } else { for (Hunk hunk : diff.getHunks()) { htmlBuilder.append(template.hunk("", hunk.getAStartLine(), hunk.getAEndLine(), hunk.getBStartLine(), hunk.getBEndLine())); String style = null; char prefix = ' '; StringBuilder content = null; Hunk.LineChange.Type lt = null; for (Hunk.LineChange lc : hunk.getLineChanges()) { if (lc.getType() != lt) { if (content != null) { htmlBuilder.append(template.content(style, content.toString())); } content = new StringBuilder(); lt = lc.getType(); switch (lc.getType()) { case ADDED: style = ScmResources.get.style().contentAdded(); prefix = '+'; break; case REMOVED: prefix = '-'; style = ScmResources.get.style().contentRemoved(); break; default: prefix = ' '; style = ""; } } content.append(prefix + lc.getText() + "\n"); } htmlBuilder.append(template.content(style, content.toString())); } } } return htmlBuilder.toSafeHtml(); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.admin.products.ProjectAdminTasksDisplayView.java
License:Open Source License
public void setPresenter(ProjectAdminTasksDisplayPresenter presenter) { this.presenter = presenter; productName.setText(presenter.getProduct().getName()); productDescription.setText(presenter.getProduct().getDescription()); productDefaultRelease.setText(presenter.getProduct().getDefaultMilestone().toString()); SafeHtmlBuilder sb = new SafeHtmlBuilder(); for (Component component : presenter.getProduct().getComponents()) { if (component.getId() < 0) { continue; }//from w ww . j a va 2 s. c o m String name = component.getName() == null ? "" : component.getName(); String description = component.getDescription() == null ? "" : component.getDescription(); String owner = ""; if (component.getInitialOwner() != null) { owner = component.getInitialOwner().getRealname() == null ? "" : commonProfileMessages.parentheses(component.getInitialOwner().getRealname()); } sb.append(template.component(name, description, owner)); } components.setHTML(sb.toSafeHtml()); sb = new SafeHtmlBuilder(); for (Milestone milestone : presenter.getProduct().getMilestones()) { if (milestone.getId() < 0) { continue; } sb.append(template.release(milestone.getValue())); } releases.setHTML(sb.toSafeHtml()); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.TasksSummaryListView.java
License:Open Source License
private void createProductHeader(Product product) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<h2 class=\"task-summary-product-header\">"); sb.appendEscaped(tasksMessages.productWithName(product.getName())); sb.appendHtmlConstant("</h2>"); taskSummaryPanel.add(new HTML(sb.toSafeHtml())); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.TasksSummaryListView.java
License:Open Source License
private void createComponentSegment(String title, List<Component> componentList, Integer productId) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); if (title != null) { renderTitle(sb, title, ProjectTasksSummaryListPlace.createProductListPlace(appId, productId).getHref()); }// www .j a v a2 s. c om for (Component curComponent : componentList) { renderRow(sb, curComponent.getName(), ProjectTasksSummaryPlace .createPlaceForComponent(appId, productId, curComponent.getId()).getHref()); } taskSummaryPanel.add(new HTML(sb.toSafeHtml())); }