List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant
public SafeHtmlBuilder appendHtmlConstant(String html)
From source file:org.aksw.TripleCheckMate.client.widgets.EvaluationTable.java
License:Apache License
private void createTable() { // Link to data provider dataProvider.addDataDisplay(tblEvalTriples); // Table properties tblEvalTriples.setPageSize(arrPagerSizes[0]); // Set Pagers (add both bottom and top) pgrTop.setDisplay(tblEvalTriples);//from w ww . jav a2 s . c o m pgrBottom.setDisplay(tblEvalTriples); // Table columns final SafeHtmlCell cellP = new SafeHtmlCell(); Column<EvaluateItem, SafeHtml> colPred = new Column<EvaluateItem, SafeHtml>(cellP) { public SafeHtml getValue(EvaluateItem item) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant(item.P.toHTMLString()); return sb.toSafeHtml(); } }; tblEvalTriples.addColumn(colPred, "Predicate"); final SafeHtmlCell cellO = new SafeHtmlCell(); Column<EvaluateItem, SafeHtml> colObj = new Column<EvaluateItem, SafeHtml>(cellO) { public SafeHtml getValue(EvaluateItem item) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant(item.O.toHTMLString()); return sb.toSafeHtml(); } }; tblEvalTriples.addColumn(colObj, "Object"); Column<EvaluateItem, Boolean> colIsValid = new Column<EvaluateItem, Boolean>( new CheckboxCell(true, false)) { public Boolean getValue(EvaluateItem item) { return item.isWrong; } }; tblEvalTriples.addColumn(colIsValid, "Is Wrong"); // Add a field updater to be notified when the user enters a new name. colIsValid.setFieldUpdater(new FieldUpdater<EvaluateItem, Boolean>() { public void update(int index, EvaluateItem object, Boolean value) { dataProvider.getList().get(index).isWrong = value; if (value == false) { dataProvider.getList().get(index).errorTittle = ""; tblEvalTriples.redraw(); } else { dlgEdit.setEvaluateItem(dataProvider.getList().get(index), true); dlgEdit.center(); dlgEdit.show(); } } }); tblEvalTriples.addCellPreviewHandler(new CellPreviewEvent.Handler<EvaluateItem>() { long lastClick = -1000; public void onCellPreview(CellPreviewEvent<EvaluateItem> event) { long clictAt = System.currentTimeMillis(); if (event.getNativeEvent().getType().contains("click")) { if (clictAt - lastClick < 600) { // dblclick on 2 clicks detected within 300 ms int index = event.getIndex(); dlgEdit.setEvaluateItem(dataProvider.getList().get(index), false); dlgEdit.center(); dlgEdit.show(); } lastClick = System.currentTimeMillis(); } } }); final SafeHtmlCell cellError = new SafeHtmlCell(); Column<EvaluateItem, SafeHtml> colError = new Column<EvaluateItem, SafeHtml>(cellError) { public SafeHtml getValue(EvaluateItem item) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant(item.errorTittle); return sb.toSafeHtml(); } }; tblEvalTriples.addColumn(colError, "Error"); // Setup sorting colPred.setSortable(true); sortHandler.setComparator(colPred, new Comparator<EvaluateItem>() { public int compare(EvaluateItem o1, EvaluateItem o2) { return o1.P.toString().compareTo(o2.P.toString()); } }); colObj.setSortable(true); sortHandler.setComparator(colObj, new Comparator<EvaluateItem>() { public int compare(EvaluateItem o1, EvaluateItem o2) { return o1.P.toString().compareTo(o2.P.toString()); } }); colIsValid.setSortable(true); sortHandler.setComparator(colIsValid, new Comparator<EvaluateItem>() { public int compare(EvaluateItem o1, EvaluateItem o2) { if (o1.isWrong == o2.isWrong) return 0; else return (o1.isWrong ? 1 : -1); } }); colError.setSortable(true); sortHandler.setComparator(colError, new Comparator<EvaluateItem>() { public int compare(EvaluateItem o1, EvaluateItem o2) { return o1.errorTittle.compareTo(o2.errorTittle); } }); tblEvalTriples.addColumnSortHandler(sortHandler); tblEvalTriples.getColumnSortList().push(colObj); tblEvalTriples.getColumnSortList().push(colPred); for (int i = 0; i < arrPagerSizes.length; i++) { lstPager.addItem("" + arrPagerSizes[i]); } lstPager.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { tblEvalTriples.setPageSize(arrPagerSizes[lstPager.getSelectedIndex()]); } }); }
From source file:org.aksw.TripleCheckMate.client.widgets.UserStatisticsTable.java
License:Apache License
private void createTable() { // Link to data provider dataProvider.addDataDisplay(tblUserStats); // Table properties tblUserStats.setWidth("100%"); tblUserStats.setPageSize(50);// ww w . ja va 2 s.c o m // Table columns Column<UserRecord, SafeHtml> colUserName = new Column<UserRecord, SafeHtml>(new SafeHtmlCell()) { public SafeHtml getValue(UserRecord item) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant(item.toHTMLString()); return sb.toSafeHtml(); } }; tblUserStats.addColumn(colUserName, "User"); colUserName.setSortable(true); sortHandler.setComparator(colUserName, new Comparator<UserRecord>() { public int compare(UserRecord o1, UserRecord o2) { return o1.name.compareTo(o2.name); } }); Column<UserRecord, String> colRes = new Column<UserRecord, String>(new TextCell()) { public String getValue(UserRecord object) { // TODO Auto-generated method stub return "" + object.recordCount; } }; tblUserStats.addColumn(colRes, "Resources"); colRes.setSortable(true); sortHandler.setComparator(colRes, new Comparator<UserRecord>() { public int compare(UserRecord o1, UserRecord o2) { Integer a1 = new Integer(o1.recordCount); Integer a2 = new Integer(o2.recordCount); return a1.compareTo(a2); } }); Column<UserRecord, String> colTriples = new Column<UserRecord, String>(new TextCell()) { public String getValue(UserRecord object) { // TODO Auto-generated method stub return "" + object.errorCount; } }; tblUserStats.addColumn(colTriples, "Wrong Triples"); colTriples.setSortable(true); sortHandler.setComparator(colTriples, new Comparator<UserRecord>() { public int compare(UserRecord o1, UserRecord o2) { Integer a1 = new Integer(o1.errorCount); Integer a2 = new Integer(o2.errorCount); return a1.compareTo(a2); } }); Column<UserRecord, String> colErrorTypes = new Column<UserRecord, String>(new TextCell()) { public String getValue(UserRecord object) { // TODO Auto-generated method stub return "" + object.distinctErrorCount; } }; tblUserStats.addColumn(colErrorTypes, "Error Types"); colErrorTypes.setSortable(true); sortHandler.setComparator(colErrorTypes, new Comparator<UserRecord>() { public int compare(UserRecord o1, UserRecord o2) { Integer a1 = new Integer(o1.distinctErrorCount); Integer a2 = new Integer(o2.distinctErrorCount); return a1.compareTo(a2); } }); tblUserStats.addColumnSortHandler(sortHandler); tblUserStats.getColumnSortList().push(colTriples); tblUserStats.getColumnSortList().push(colRes); }
From source file:org.appverse.web.framework.frontend.gwt.theme.bluetouch.client.button.AppverseWebButtonCellDefaultAppearance.java
License:sencha.com license
@Override public void render(final ButtonCell<C> cell, Context context, C value, SafeHtmlBuilder sb) { String constantHtml = cell.getHTML(); boolean hasConstantHtml = constantHtml != null && constantHtml.length() != 0; boolean isBoolean = value != null && value instanceof Boolean; // is a boolean always a toggle button? String text = hasConstantHtml ? cell.getText() : (value != null && !isBoolean) ? SafeHtmlUtils.htmlEscape(value.toString()) : ""; ImageResource icon = cell.getIcon(); IconAlign iconAlign = cell.getIconAlign(); String cls = style.button();/* w w w.java 2s.co m*/ String arrowCls = ""; if (cell.getMenu() != null) { if (cell instanceof SplitButtonCell) { switch (cell.getArrowAlign()) { case RIGHT: arrowCls = style.split(); break; case BOTTOM: arrowCls = style.splitBottom(); break; } } else { switch (cell.getArrowAlign()) { case RIGHT: arrowCls = style.arrow(); break; case BOTTOM: arrowCls = style.arrowBottom(); break; } } } ButtonScale scale = cell.getScale(); switch (scale) { case SMALL: cls += " " + style.small(); break; case MEDIUM: cls += " " + style.medium(); break; case LARGE: cls += " " + style.large(); break; } SafeStylesBuilder stylesBuilder = new SafeStylesBuilder(); int width = -1; if (cell.getWidth() != -1) { int w = cell.getWidth(); if (w < cell.getMinWidth()) { w = cell.getMinWidth(); } stylesBuilder.appendTrustedString("width:" + w + "px;"); cls += " " + style.hasWidth() + " x-has-width"; width = w; } else { if (cell.getMinWidth() != -1) { TextMetrics.get().bind(style.text()); int length = TextMetrics.get().getWidth(text); length += 6; // frames if (icon != null) { switch (iconAlign) { case LEFT: case RIGHT: length += icon.getWidth(); break; } } if (cell.getMinWidth() > length) { stylesBuilder.appendTrustedString("width:" + cell.getMinWidth() + "px;"); cls += " " + style.hasWidth() + " x-has-width"; width = cell.getMinWidth(); } } } final int height = cell.getHeight(); if (height != -1) { stylesBuilder.appendTrustedString("height:" + height + "px;"); } if (icon != null) { switch (iconAlign) { case TOP: arrowCls += " " + style.iconTop(); break; case BOTTOM: arrowCls += " " + style.iconBottom(); break; case LEFT: arrowCls += " " + style.iconLeft(); break; case RIGHT: arrowCls += " " + style.iconRight(); break; } } else { arrowCls += " " + style.noIcon(); } // toggle button if (value == Boolean.TRUE) { cls += " " + frame.pressedClass(); } sb.append(templates.outer(cls, new SafeStylesBuilder().toSafeStyles())); SafeHtmlBuilder inside = new SafeHtmlBuilder(); String innerWrap = arrowCls; if (GXT.isIE6() || GXT.isIE7()) { arrowCls += " " + CommonStyles.get().inlineBlock(); } inside.appendHtmlConstant("<div class='" + innerWrap + "'>"); inside.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class='" + style.mainTable() + "'>"); if (icon != null) { switch (iconAlign) { case LEFT: inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); if (text != null) { int w = width - (icon != null ? icon.getWidth() : 0) - 4; writeText(inside, text, w, height); } inside.appendHtmlConstant("</tr>"); break; case RIGHT: inside.appendHtmlConstant("<tr>"); if (text != null) { int w = width - (icon != null ? icon.getWidth() : 0) - 4; writeText(inside, text, w, height); } writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); break; case TOP: inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); if (text != null) { inside.appendHtmlConstant("<tr>"); writeText(inside, text, width, height); inside.appendHtmlConstant("</tr>"); } break; case BOTTOM: if (text != null) { inside.appendHtmlConstant("<tr>"); writeText(inside, text, width, height); inside.appendHtmlConstant("</tr>"); } inside.appendHtmlConstant("<tr>"); writeIcon(inside, icon, height); inside.appendHtmlConstant("</tr>"); break; } } else { inside.appendHtmlConstant("<tr>"); if (text != null) { writeText(inside, text, width, height); } inside.appendHtmlConstant("</tr>"); } inside.appendHtmlConstant("</table>"); inside.appendHtmlConstant("</div>"); frame.render(sb, new Frame.FrameOptions(0, CommonStyles.get().noFocusOutline(), stylesBuilder.toSafeStyles()), inside.toSafeHtml()); sb.appendHtmlConstant("</div>"); }
From source file:org.appverse.web.framework.frontend.gwt.theme.bluetouch.client.field.AppverseWebTextFieldAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb, String type, String value, FieldAppearanceOptions options) { String inputStyles = ""; String wrapStyles = ""; int width = options.getWidth(); String name = options.getName() != null ? " name='" + options.getName() + "' " : ""; String disabled = options.isDisabled() ? "disabled=true" : ""; boolean empty = false; if ((value == null || value.equals("")) && options.getEmptyText() != null) { value = options.getEmptyText();/*ww w.j a va 2 s .c o m*/ empty = true; } if (width != -1) { wrapStyles += "width:" + width + "px;"; // 6px margin, 2px border width -= 8; inputStyles += "width:" + width + "px;"; } String cls = style.text() + " " + style.field(); if (empty) { cls += " " + style.empty(); } String ro = options.isReadonly() ? " readonly" : ""; value = SafeHtmlUtils.htmlEscape(value); sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>"); sb.appendHtmlConstant("<input " + name + disabled + " value='" + value + "' style='" + inputStyles + "' type='" + type + "' class='" + cls + "'" + ro + ">"); }
From source file:org.appverse.web.framework.frontend.gwt.theme.bluetouch.client.field.AppverseWebTriggerFieldAppearance.java
License:sencha.com license
@Override public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) { int width = options.getWidth(); boolean hideTrigger = options.isHideTrigger(); if (width == -1) { width = 150;/*from w w w . j a va 2 s.c o m*/ } SafeStyles inputStyles = null; String wrapStyles = ""; if (width != -1) { wrapStyles += "width:" + width + "px;"; // 6px margin, 2px border width -= 8; if (!hideTrigger) { width -= resources.triggerArrow().getWidth(); } inputStyles = SafeStylesUtils.fromTrustedString("width:" + width + "px;"); } sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>"); if (!hideTrigger) { sb.appendHtmlConstant("<table cellpadding=0 cellspacing=0><tr><td>"); renderInput(sb, value, inputStyles, options); sb.appendHtmlConstant("</td>"); sb.appendHtmlConstant("<td><div class='" + style.trigger() + "' /></td>"); sb.appendHtmlConstant("</table>"); } else { renderInput(sb, value, inputStyles, options); } sb.appendHtmlConstant("</div>"); }
From source file:org.datacleaner.monitor.scheduling.widgets.ExecutionIdentifierCell.java
License:Open Source License
@Override public void render(com.google.gwt.cell.client.Cell.Context context, ExecutionIdentifier executionIdentifier, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div class=\"ExecutionIdentifier\">"); final Date beginDate = executionIdentifier.getJobBeginDate(); final String dateString; if (beginDate == null) { dateString = "(n/a)"; } else {//from ww w. j a v a 2s . co m dateString = _format.format(beginDate); } // date sb.appendHtmlConstant("<span class=\"beginDate\">"); sb.appendEscaped(dateString); sb.appendHtmlConstant("</span>"); // trigger type sb.appendHtmlConstant("<span class=\"triggerTypes\">"); final TriggerType triggerType = executionIdentifier.getTriggerType(); if (triggerType == null) { sb.appendEscaped("(n/a)"); } else { sb.appendEscaped(triggerType.toString()); } sb.appendHtmlConstant("</span>"); // execution status sb.appendHtmlConstant("<span class=\"executionStatus\">"); final ExecutionStatus executionStatus = executionIdentifier.getExecutionStatus(); if (executionStatus == null) { sb.appendEscaped("(n/a)"); } else { sb.appendEscaped(executionStatus.toString()); } sb.appendHtmlConstant("</span>"); sb.appendHtmlConstant("</div>"); }
From source file:org.dataconservancy.dcs.access.client.model.CollectionTreeViewModel.java
License:Apache License
public CollectionTreeViewModel(final SelectionModel<CollectionNode> selectionModel, final DatasetRelation relations, String root) { this.selectionModel = selectionModel; this.dusMap = relations.getDuAttrMap(); this.parentMap = relations.getParentMap(); this.root = root; // Construct a composite cell for contacts that includes a checkbox. //adding/*from www. j a v a 2 s . c om*/ List<HasCell<CollectionNode, ?>> hasCells = new ArrayList<HasCell<CollectionNode, ?>>(); hasCells.add(new HasCell<CollectionNode, Boolean>() { private CheckboxCell cell = new CheckboxCell(true, false); public Cell<Boolean> getCell() { return cell; } public Boolean getValue(CollectionNode object) { return selectionModel.isSelected(object); } private void updateChildNodes(CollectionNode object, Boolean value) { List<String> subCollections = object.getSub().get(SubType.Collection); if (subCollections != null)//why is this running twice? { for (int i = 0; i < subCollections.size(); i++) { selectionModel.setSelected((CollectionNode) dusMap.get(subCollections.get(i)), value); MediciIngestPresenter.EVENT_BUS.fireEvent(new CollectionPassiveSelectEvent( (CollectionNode) dusMap.get(subCollections.get(i)), value)); updateChildNodes((CollectionNode) dusMap.get(subCollections.get(i)), value); } } } @Override public FieldUpdater<CollectionNode, Boolean> getFieldUpdater() { // TODO Auto-generated method stub //return null; return new FieldUpdater<CollectionNode, Boolean>() { public void update(int index, CollectionNode object, Boolean value) { //Update child Nodes /* List<String> subCollections = object.getSub().get(SubType.Collection); if(subCollections!=null)//why is this running twice? { for(int i=0;i<subCollections.size();i++) selectionModel.setSelected((CollectionNode)dusMap.get(subCollections.get(i)), value); }*/ //Update child collection nodes updateChildNodes(object, value); //update the Parent Node String parentCollection = parentMap.get(object.getId()); if (parentCollection != null) { List<String> siblingCollections = dusMap.get(parentCollection).getSub() .get(SubType.Collection); int allSelected = 1; if (value) { for (String sibling : siblingCollections) { if (!selectionModel.isSelected(dusMap.get(sibling))) { allSelected = 0; break; } } } if (allSelected == 1 && value) { //set parent true selectionModel.setSelected((CollectionNode) dusMap.get(parentCollection), true); } else { //set parent false selectionModel.setSelected((CollectionNode) dusMap.get(parentCollection), false); } } MediciIngestPresenter.EVENT_BUS.fireEvent(new CollectionSelectEvent(object, value)); } }; } }); hasCells.add(new HasCell<CollectionNode, CollectionNode>() { private CollectionCell cell = new CollectionCell(); public Cell<CollectionNode> getCell() { return cell; } public FieldUpdater<CollectionNode, CollectionNode> getFieldUpdater() { return null; } public CollectionNode getValue(CollectionNode object) { return object; } }); collectionCell = new CompositeCell<CollectionNode>(hasCells) { @Override public void render(Context context, CollectionNode value, SafeHtmlBuilder sb) { if (value == null) return; sb.appendHtmlConstant("<table><tbody><tr>"); super.render(context, value, sb); sb.appendHtmlConstant("</tr></tbody></table>"); } @Override protected Element getContainerElement(Element parent) { // Return the first TR element in the table. return parent.getFirstChildElement().getFirstChildElement().getFirstChildElement(); } @Override protected <X> void render(Context context, CollectionNode value, SafeHtmlBuilder sb, HasCell<CollectionNode, X> hasCell) { if (value != null) { Cell<X> cell = hasCell.getCell(); sb.appendHtmlConstant("<td>"); cell.render(context, hasCell.getValue(value), sb); sb.appendHtmlConstant("</td>"); } } }; }
From source file:org.daxplore.presenter.client.ui.PerspectiveQuestionsPanel.java
License:Open Source License
private PerspectiveQuestionsPanel(QuestionMetadata questions, Perspectives perspectives, UITexts uiTexts, PrefixProperties prefixProperties) { Label header = new Label(uiTexts.pickSelectionGroupHeader()); header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); header.addStyleName("daxplore-PerspectiveQuestionList-header"); this.add(header); perspectiveList = new Tree(); for (String questionID : perspectives.getQuestionIDs()) { SafeHtmlBuilder html = new SafeHtmlBuilder(); html.appendEscaped(questions.getShortText(questionID)); if (questions.hasSecondary(questionID)) { html.appendHtmlConstant(" <span class=\"super\">"); html.appendEscaped(prefixProperties.getSecondaryFlagText()); html.appendHtmlConstant("</span>"); }//from w w w . ja va 2s . com QuestionTreeItem item = new QuestionTreeItem(html.toSafeHtml(), questionID); perspectiveList.addItem(item); } this.add(perspectiveList); setWidth("100%"); setPerspective(perspectives.getQuestionIDs().get(0), false); }
From source file:org.daxplore.presenter.client.ui.QuestionPanel.java
License:Open Source License
@Inject protected QuestionPanel(QuestionMetadata questions, Groups groups, EventBus eventBus, UITexts uiTexts, UIResources uiResources, PrefixProperties prefixProperties) { this.eventBus = eventBus; treeRoot = new Tree(uiResources, false); Label header = new Label(uiTexts.pickAQuestionHeader()); header.addStyleName("daxplore-QuestionPanel-header"); vp.add(header);//from w ww. ja va2 s. com vp.setCellHeight(header, "30px"); // Set up questiontree treeRoot.addSelectionHandler(new QuestionSelectionHandler()); treeRoot.addOpenHandler(new GroupOpenHandler()); for (int i = 0; i < groups.getGroupCount(); i++) { String txt = groups.getGroupName(i); SafeHtmlBuilder html = new SafeHtmlBuilder(); html.appendHtmlConstant("<span class=\"daxplore-QuestionPanel-branch\"> "); html.appendEscaped(txt); html.appendHtmlConstant(" </span>"); GroupItem gr = new GroupItem(html.toSafeHtml()); List<String> qlist = groups.getQuestionIDs(i); for (String q : qlist) { html = new SafeHtmlBuilder(); html.appendHtmlConstant(" "); html.appendEscaped(questions.getShortText(q)); if (questions.hasSecondary(q)) { html.appendHtmlConstant(" <span class=\"super\">"); html.appendEscaped(prefixProperties.getSecondaryFlagText()); html.appendHtmlConstant("</span>"); } html.appendHtmlConstant(" "); QuestionTreeItem qi = new QuestionTreeItem(html.toSafeHtml(), q); qi.setTitle(questions.getFullText(q)); gr.addItem(qi); } treeRoot.addItem(gr); } vp.add(treeRoot); vp.setCellVerticalAlignment(treeRoot, HasVerticalAlignment.ALIGN_TOP); vp.setWidth("100%"); initWidget(vp); QueryUpdateEvent.register(eventBus, this); }
From source file:org.drools.guvnor.client.asseteditor.drools.enums.DeleteButtonCell.java
License:Apache License
@Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { ImageResource imageResource = DroolsGuvnorImageResources.INSTANCE.itemImages().deleteItemSmall(); sb.appendHtmlConstant("<input type=\"image\" src=\"" + imageResource.getURL() + "\" tabindex=\"-1\">"); sb.appendHtmlConstant("</input>"); }