List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:net.cristcost.study.gwt.client.list.ListTagsWidget.java
License:Apache License
/** * Instantiates a new list tags widget./*from w w w .j a v a 2 s . com*/ */ public ListTagsWidget() { initWidget(uiBinder.createAndBindUi(this)); TextColumn<Tag> usernameColumn = new TextColumn<Tag>() { @Override public String getValue(Tag tag) { return tag.getUsername(); } }; TextColumn<Tag> tagColumn = new TextColumn<Tag>() { @Override public String getValue(Tag tag) { return tag.getTag(); } }; TextColumn<Tag> publicCheckColumn = new TextColumn<Tag>() { @Override public String getValue(Tag tag) { return tag.isPublic() ? "public" : "private"; } }; Column<Tag, String> deleteButtonColumn = new Column<Tag, String>(new ButtonCell()) { @Override public String getValue(Tag object) { return "Delete"; } @Override public void render(Context context, Tag object, SafeHtmlBuilder sb) { if (object.getUsername() == currentUsername) { super.render(context, object, sb); } } }; deleteButtonColumn.setFieldUpdater(new FieldUpdater<Tag, String>() { @Override public void update(int index, Tag object, String value) { presenter.deleteTag(object.getUsername(), object.getTag()); } }); cellTable.addColumn(usernameColumn, "Name"); cellTable.addColumn(tagColumn, "Address"); cellTable.addColumn(publicCheckColumn, "Is Public?"); cellTable.addColumn(deleteButtonColumn, "Delete"); cellTable.setRowCount(0, true); }
From source file:net.exclaimindustries.paste.braket.client.ui.Leaderboard.java
License:Open Source License
/** * Add a column with a header./* w w w. j a v a 2 s . c o m*/ * * @param <C> * the cell type * @param cell * the cell used to render the column * @param headerText * the header string * @param getter * the value getter for the cell */ private <C> Column<SelectionInfo, C> addColumn(Cell<C> cell, String headerText, final GetValue<C> getter, FieldUpdater<SelectionInfo, C> fieldUpdater) { Column<SelectionInfo, C> column = new Column<SelectionInfo, C>(cell) { @Override public C getValue(SelectionInfo object) { return getter.getValue(object); } }; column.setFieldUpdater(fieldUpdater); dataGrid.addColumn(column, headerText); return column; }
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);/* w w w .j ava 2s .c om*/ 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.apache.oozie.tools.workflowgenerator.client.property.action.FSPropertyTable.java
License:Apache License
/** * Create a table showing fs operations// w ww . ja va2 s .c o m * * @param data * @return */ protected CellTable<FSActionData> createFSActionTable(List<FSActionData> data) { final CellTable<FSActionData> table = new CellTable<FSActionData>(); final ListDataProvider<FSActionData> dataProvider = new ListDataProvider<FSActionData>(); dataProvider.setList(data); dataProvider.addDataDisplay(table); // Add Name column Column<FSActionData, String> nameCol = null; nameCol = new Column<FSActionData, String>( new SelectionCell(Arrays.asList("", "delete", "mkdir", "move", "chmod", "touchz"))) { @Override public String getValue(FSActionData object) { return object.getOp(); } }; // set event for updating value nameCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); d.setOp(value); table.redraw(); } }); table.addColumn(nameCol, "operation"); Column<FSActionData, String> label1Col = new Column<FSActionData, String>(new TextCell()) { @Override public String getValue(FSActionData object) { String rel = "Path"; String op = object.getOp(); if (op.equals("move")) { rel = "Source Path"; } return rel; } }; table.addColumn(label1Col); // Add Column for 1st parameter of delete/mkdir/chmod/move/touchz Column<FSActionData, String> param1Col = new Column<FSActionData, String>(new TextInputCell()) { @Override public String getValue(FSActionData object) { String op = object.getOp(); if (op.equals("delete") || op.equals("mkdir") || op.equals("chmod") || op.equals("touchz")) { if (object.getParams().containsKey("path") && object.getParams().get("path") != null) return object.getParams().get("path"); } else if (op.equals("move")) { if (object.getParams().containsKey("source") && object.getParams().get("source") != null) return object.getParams().get("source"); } return ""; } }; param1Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); String op = d.getOp(); if (op.equals("delete") || op.equals("mkdir") || op.equals("chmod") || op.equals("touchz")) { d.getParams().put("path", value); } else if (op.equals("move")) { d.getParams().put("source", value); } } }); table.addColumn(param1Col, ""); // Add Label for 2rd parameter of move and chmod Column<FSActionData, String> label2Col = new Column<FSActionData, String>(new TextCell()) { public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { FSActionData data = (FSActionData) context.getKey(); if (data.getOp().equals("move") || data.getOp().equals("chmod")) sb.append(value); } } @Override public String getValue(FSActionData object) { String rel = null; String op = object.getOp(); if (op.equals("move")) { rel = "Target Path"; } else if (op.equals("chmod")) { rel = "Permissions"; } return rel; } }; table.addColumn(label2Col); // Add Column for 2nd parameter of move and chmod Column<FSActionData, String> param2Col = new Column<FSActionData, String>(new CustomEditTextCell()) { @Override public String getValue(FSActionData object) { String op = object.getOp(); if (op.equals("move")) { if (object.getParams().containsKey("target") && object.getParams().get("target") != null) return object.getParams().get("target"); } else if (op.equals("chmod")) { if (object.getParams().containsKey("permissions") && object.getParams().get("permissions") != null) return object.getParams().get("permissions"); } return ""; } }; param2Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); String op = d.getOp(); if (op.equals("move")) { d.getParams().put("target", value); } else if (op.equals("chmod")) { d.getParams().put("permissions", value); } } }); table.addColumn(param2Col, ""); // Add Label for 3rd parameter of chmod Column<FSActionData, String> label3Col = new Column<FSActionData, String>(new TextCell()) { public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { FSActionData data = (FSActionData) context.getKey(); if (data.getOp().equals("chmod")) sb.append(value); } } @Override public String getValue(FSActionData object) { String rel = null; String op = object.getOp(); if (op.equals("chmod")) rel = "Chmod files within directory?(dir-files)"; return rel; } }; table.addColumn(label3Col); // Add Column for 3rd parameter of chmod // ( Recursive option not implemented in this version. need to add // another column for that. ) Column<FSActionData, String> param3Col = new Column<FSActionData, String>( new CustomSelectionCell(Arrays.asList("true", "false"))) { @Override public String getValue(FSActionData object) { String rel = null; String op = object.getOp(); if (op.equals("chmod")) rel = object.getParams().get("dir-files"); return rel; } }; param3Col.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { FSActionData d = dataProvider.getList().get(index); String op = d.getOp(); if (op.equals("chmod")) { d.getParams().put("dir-files", value); } } }); table.addColumn(param3Col, ""); // Button to add row Column<FSActionData, String> addCol = new Column<FSActionData, String>(new ButtonCell()) { @Override public String getValue(FSActionData object) { return " + "; } }; addCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { dataProvider.getList().add(index + 1, new FSActionData()); } }); table.addColumn(addCol, ""); // Button to delete row Column<FSActionData, String> delCol = new Column<FSActionData, String>(new ButtonCell()) { @Override public String getValue(FSActionData object) { return " - "; } }; delCol.setFieldUpdater(new FieldUpdater<FSActionData, String>() { @Override public void update(int index, FSActionData object, String value) { List<FSActionData> li = dataProvider.getList(); if (li.size() == 1) { FSActionData p = li.get(0); p.clear(); table.redraw(); } else { dataProvider.getList().remove(index); } } }); table.addColumn(delCol, ""); return table; }
From source file:org.apache.oozie.tools.workflowgenerator.client.property.action.SSHPropertyTable.java
License:Apache License
/** * Create a table showing list of arguments added by a user * * @param data/*w w w.jav a 2 s .c o m*/ * @return */ protected CellTable<String> createArgsTable(List<String> data) { final CellTable<String> table = new CellTable<String>(); final ListDataProvider<String> dataProvider = new ListDataProvider<String>(); dataProvider.setList(data); dataProvider.addDataDisplay(table); // Add Name column Column<String, String> argCol = null; // when editText is used for name column argCol = new Column<String, String>(new TextInputCell()) { @Override public String getValue(String object) { return object; } }; // set event for updating value argCol.setFieldUpdater(new FieldUpdater<String, String>() { @Override public void update(int index, String object, String value) { List<String> li = dataProvider.getList(); li.remove(index); li.add(index, value); } }); table.addColumn(argCol, ""); // Button to add row Column<String, String> addCol = new Column<String, String>(new ButtonCell()) { @Override public String getValue(String object) { return " + "; } }; addCol.setFieldUpdater(new FieldUpdater<String, String>() { @Override public void update(int index, String object, String value) { List<String> li = dataProvider.getList(); li.add(index + 1, new String(" ")); } }); table.addColumn(addCol, ""); // Button to delete row Column<String, String> delCol = new Column<String, String>(new ButtonCell()) { @Override public String getValue(String object) { return " - "; } }; delCol.setFieldUpdater(new FieldUpdater<String, String>() { @Override public void update(int index, String object, String value) { List<String> li = dataProvider.getList(); li.remove(index); if (li.size() == 0) { li.add(" "); table.redraw(); } } }); table.addColumn(delCol, ""); return table; }
From source file:org.apache.oozie.tools.workflowgenerator.client.property.control.DecisionPropertyTable.java
License:Apache License
/** * Create an expandable table to show switch cases * * @return//from ww w . j av a 2s .c om */ protected CellTable<SwitchCase> createCaseTable() { final CellTable<SwitchCase> table = new CellTable<SwitchCase>(); dataProvider.addDataDisplay(table); // Add Case column Column<SwitchCase, String> caseCol = null; caseCol = new Column<SwitchCase, String>(new TextCell()) { @Override public String getValue(SwitchCase object) { return prettyItemString(object.getWidget()); } }; table.addColumn(caseCol, "To"); // Add Predicate column Column<SwitchCase, String> predicateCol = null; predicateCol = new Column<SwitchCase, String>(new CustomTextCell()) { @Override public String getValue(SwitchCase object) { return object.getPreDicate(); } }; predicateCol.setFieldUpdater(new FieldUpdater<SwitchCase, String>() { @Override public void update(int index, SwitchCase object, String value) { object.setPredicate(value); } }); table.addColumn(predicateCol, "Predicate"); // Button to delete row Column<SwitchCase, String> defaultCol = new Column<SwitchCase, String>(new ButtonCell()) { @Override public String getValue(SwitchCase object) { Connection c = object.getConnection(); DecorationShape ds = c.getDecoration(); String rel = "Change to Default"; if (ds != null) rel = "Default"; return rel; } }; defaultCol.setFieldUpdater(new FieldUpdater<SwitchCase, String>() { @Override public void update(int index, SwitchCase object, String value) { initializeDefault(dataProvider.getList()); Connection c = object.getConnection(); addDecorationDefaultLabel(c); table.redraw(); } }); table.addColumn(defaultCol, ""); // Button to delete row Column<SwitchCase, String> delCol = new Column<SwitchCase, String>(new ButtonCell()) { @Override public String getValue(SwitchCase object) { return " - "; } }; delCol.setFieldUpdater(new FieldUpdater<SwitchCase, String>() { @Override public void update(int index, SwitchCase object, String value) { dataProvider.getList().remove(index); OozieDiagramController controller = (OozieDiagramController) current.getGenerator() .getDiagramController(); controller.removeConnection(current, object.getWidget()); } }); table.addColumn(delCol, ""); return table; }
From source file:org.apache.oozie.tools.workflowgenerator.client.property.control.ForkPropertyTable.java
License:Apache License
/** * Create a expandable table listing paths that this fork node has * * @return/*w ww . j ava2 s.co m*/ */ protected CellTable<NodeWidget> createPathTable() { CellTable<NodeWidget> table = new CellTable<NodeWidget>(); dataProvider.addDataDisplay(table); // Add Name column Column<NodeWidget, String> nameCol = null; nameCol = new Column<NodeWidget, String>(new TextCell()) { @Override public String getValue(NodeWidget object) { return prettyItemString(object); } }; table.addColumn(nameCol, "To"); // Button to delete row Column<NodeWidget, String> delCol = new Column<NodeWidget, String>(new ButtonCell()) { @Override public String getValue(NodeWidget object) { return " - "; } }; delCol.setFieldUpdater(new FieldUpdater<NodeWidget, String>() { @Override public void update(int index, NodeWidget object, String value) { List<NodeWidget> li = (List<NodeWidget>) dataProvider.getList(); dataProvider.getList().remove(index); OozieDiagramController controller = current.getController(); controller.removeConnection(current, object); } }); table.addColumn(delCol, ""); return table; }
From source file:org.apache.oozie.tools.workflowgenerator.client.property.PropertyTable.java
License:Apache License
/** * Create an expandable sub table as a part of property table * * @param colname1 1st column name// w w w . jav a 2s . co m * @param colname2 2nd column name * @param data data list * @param options listbox options, if null, text input cell used * @return */ protected CellTable<Property> createSubTable(String colname1, String colname2, List<Property> data, List<String> options) { final CellTable<Property> table = new CellTable<Property>(); final ListDataProvider<Property> dataProvider = new ListDataProvider<Property>(); dataProvider.setList(data); dataProvider.addDataDisplay(table); // add Name column Column<Property, String> nameCol = null; if (options == null) { nameCol = new Column<Property, String>(new TextInputCell()) { @Override public String getValue(Property object) { return object.getName(); } }; } else { nameCol = new Column<Property, String>(new SelectionCell(options)) { @Override public String getValue(Property object) { return object.getName(); } }; } // set event for updating value nameCol.setFieldUpdater(new FieldUpdater<Property, String>() { @Override public void update(int index, Property object, String value) { object.setName(value); } }); table.addColumn(nameCol, colname1); // Add Value column Column<Property, String> valueCol = new Column<Property, String>(new TextInputCell()) { @Override public String getValue(Property object) { return object.getValue(); } }; valueCol.setFieldUpdater(new FieldUpdater<Property, String>() { @Override public void update(int index, Property object, String value) { object.setValue(value); } }); table.addColumn(valueCol, colname2); // Button to add row Column<Property, String> addCol = new Column<Property, String>(new ButtonCell()) { @Override public String getValue(Property object) { return " + "; } }; addCol.setFieldUpdater(new FieldUpdater<Property, String>() { @Override public void update(int index, Property object, String value) { dataProvider.getList().add(index + 1, new Property("", "")); } }); table.addColumn(addCol, ""); // Button to delete row Column<Property, String> delCol = new Column<Property, String>(new ButtonCell()) { @Override public String getValue(Property object) { return " - "; } }; delCol.setFieldUpdater(new FieldUpdater<Property, String>() { @Override public void update(int index, Property object, String value) { List<Property> li = dataProvider.getList(); if (li.size() == 1) { Property p = li.get(0); p.setName(""); p.setValue(""); table.redraw(); } else dataProvider.getList().remove(index); } }); table.addColumn(delCol, ""); return table; }
From source file:org.cee.webreader.client.ui.NewSiteWizard.java
License:Apache License
public NewSiteWizard() { cellTableFeeds = new CellTable<FeedData>(); Column<FeedData, Boolean> columnActive = new Column<FeedData, Boolean>(new CheckboxCell()) { @Override//from w w w. ja v a 2 s. com public Boolean getValue(FeedData feed) { return feed.getIsActive(); } }; columnActive.setFieldUpdater(new FieldUpdater<FeedData, Boolean>() { @Override public void update(int index, FeedData feed, Boolean active) { feed.setIsActive(active); cellTableFeeds.redraw(); } }); cellTableFeeds.addColumn(columnActive, "Active"); TextColumn<FeedData> columnTitle = new TextColumn<FeedData>() { @Override public String getValue(FeedData feed) { return feed.getTitle(); } }; cellTableFeeds.addColumn(columnTitle, "Title"); TextColumn<FeedData> columnLanguage = new TextColumn<FeedData>() { @Override public String getValue(FeedData feed) { EntityKey languageKey = feed.getLanguage(); if (languageKey == null) { return "unknown"; } else { return languageKey.getName(); } } }; cellTableFeeds.addColumn(columnLanguage, "Language"); listBoxLanguage = new ValueListBox<EntityKey>(new EntityKeyRenderer(), new EntityKeyProvider()); setWidget(uiBinder.createAndBindUi(this)); setGlassEnabled(true); setStyleName(resources.styles().popupPanel()); labelLoadingMessage.setVisible(false); }
From source file:org.drools.guvnor.client.asseteditor.drools.enums.EnumEditor.java
License:Apache License
public EnumEditor(Asset a, int visibleLines) { data = (RuleContentText) a.getContent(); if (data.content == null) { data.content = ""; }//from w w w . j a va 2 s . c o m cellTable = new CellTable<EnumRow>(); cellTable.setWidth("100%"); panel = new VerticalPanel(); String[] array = data.content.split("\n"); for (String line : array) { EnumRow enumRow = new EnumRow(line); dataProvider.getList().add(enumRow); } DeleteButtonCell deleteButton = new DeleteButtonCell(); Column<EnumRow, String> delete = new Column<EnumRow, String>(deleteButton) { @Override public String getValue(EnumRow enumRow1) { return ""; } }; Column<EnumRow, String> columnFirst = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(EnumRow enumRow) { return enumRow.getFactName(); } }; Column<EnumRow, String> columnSecond = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(EnumRow enumRow) { return enumRow.getFieldName(); } }; Column<EnumRow, String> columnThird = new Column<EnumRow, String>(new EditTextCell()) { @Override public String getValue(EnumRow enumRow) { return enumRow.getContext(); } }; columnFirst.setFieldUpdater(new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { object.setFactName(value); } }); columnSecond.setFieldUpdater(new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { object.setFieldName(value); } }); columnThird.setFieldUpdater(new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { object.setContext(value); } }); cellTable.addColumn(delete); cellTable.addColumn(columnFirst, "Fact"); cellTable.addColumn(columnSecond, "Field"); cellTable.addColumn(columnThird, "Context"); // Connect the table to the data provider. dataProvider.addDataDisplay(cellTable); delete.setFieldUpdater(new FieldUpdater<EnumRow, String>() { public void update(int index, EnumRow object, String value) { dataProvider.getList().remove(object); } }); Button addButton = new Button("+", new ClickHandler() { public void onClick(ClickEvent clickEvent) { EnumRow enumRow = new EnumRow(""); dataProvider.getList().add(enumRow); } }); panel.add(cellTable); panel.add(addButton); initWidget(panel); }