List of usage examples for com.google.gwt.user.cellview.client CellTable CellTable
public CellTable()
From source file:org.drools.guvnor.client.scorecards.GuidedScorecardWidget.java
License:Apache License
private Widget addAttributeCellTable(final DirtyableFlexTable cGrid, final Characteristic characteristic) { final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>(); List<String> operators = new ArrayList<String>(); String dataType;//from ww w. j a v a 2 s . c o m if (characteristic == null) { dataType = "String"; } else { dataType = characteristic.getDataType(); } if ("String".equalsIgnoreCase(dataType)) { operators.addAll(Arrays.asList(stringOperators)); } else if ("boolean".equalsIgnoreCase(dataType)) { operators.addAll(Arrays.asList(booleanOperators)); } else { operators.addAll(Arrays.asList(numericOperators)); } DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators); Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) { public String getValue(Attribute object) { return object.getOperator(); } }; Column<Attribute, String> valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) { public String getValue(Attribute attribute) { return attribute.getValue(); } }; final EditTextCell partialScoreCell = new EditTextCell(); Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) { public String getValue(Attribute attribute) { return "" + attribute.getPartialScore(); } }; Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) { public String getValue(Attribute attribute) { return attribute.getReasonCode(); } }; ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() { public void execute(Attribute attribute) { if (Window.confirm("Remove this attribute?")) { List<Attribute> list = characteristicsAttrMap.get(cGrid).getList(); list.remove(attribute); ((EnumDropDown) cGrid.getWidget(2, 0)).setEnabled(list.size() == 0); ((EnumDropDown) cGrid.getWidget(2, 1)).setEnabled(list.size() == 0); ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2); attributeCellTable.redraw(); } } }; Cell<Attribute> actionCell = new ActionCell<Attribute>("Remove", delegate); Column<Attribute, String> actionColumn = new IdentityColumn(actionCell); reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setReasonCode(value); attributeCellTable.redraw(); } }); operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setOperator(value); attributeCellTable.redraw(); } }); valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setValue(value); attributeCellTable.redraw(); } }); partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { try { double d = Double.parseDouble(value); object.setPartialScore(d); } catch (Exception e1) { partialScoreCell.clearViewData(object); } attributeCellTable.redraw(); } }); // Add the columns. attributeCellTable.addColumn(operatorColumn, "Operator"); attributeCellTable.addColumn(valueColumn, "Value"); attributeCellTable.addColumn(partialScoreColumn, "Partial Score"); attributeCellTable.addColumn(reasonCodeColumn, "Reason Code"); attributeCellTable.addColumn(actionColumn, "Actions"); attributeCellTable.setWidth("100%", true); attributeCellTable.setColumnWidth(operatorColumn, 5.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(valueColumn, 10.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(partialScoreColumn, 10.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(reasonCodeColumn, 10.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(actionColumn, 5.0, Style.Unit.PCT); ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>(); dataProvider.addDataDisplay(attributeCellTable); characteristicsAttrMap.put(cGrid, dataProvider); return (attributeCellTable); }
From source file:org.drools.guvnor.client.widgets.tables.AbstractPagedTable.java
License:Apache License
/** * Set up table with zero columns. Additional columns can be appended by * overriding <code>addAncillaryColumns()</code> *//*from w ww .j ava 2s .c om*/ protected void doCellTable() { cellTable = new CellTable<T>(); ColumnPicker<T> columnPicker = new ColumnPicker<T>(cellTable); SortableHeaderGroup<T> sortableHeaderGroup = new SortableHeaderGroup<T>(cellTable); // Add any additional columns addAncillaryColumns(columnPicker, sortableHeaderGroup); cellTable.setWidth("100%"); columnPickerButton = columnPicker.createToggleButton(); }
From source file:org.drools.guvnor.client.widgets.tables.AbstractSimpleTable.java
License:Apache License
/** * Set up table with zero columns. Additional columns can be appended by * overriding <code>addAncillaryColumns()</code> *//*from w w w. java 2s.c om*/ protected void doCellTable() { cellTable = new CellTable<T>(); ColumnPicker<T> columnPicker = new ColumnPicker<T>(cellTable); SortableHeaderGroup<T> sortableHeaderGroup = new SortableHeaderGroup<T>(cellTable); // Add any additional columns addAncillaryColumns(columnPicker, sortableHeaderGroup); cellTable.setWidth("100%"); columnPickerButton = columnPicker.createToggleButton(); }
From source file:org.drools.workbench.screens.guided.dtable.client.widget.auditlog.AuditLogViewImpl.java
License:Apache License
public void setup() { // BZ-996917: Use a the gwtboostrap style "row-fluid" to allow display some events in the same row. eventTypes.setStyleName(Constants.ROW_FLUID); // Fill panel with available events. for (Map.Entry<String, Boolean> e : auditLog.getAuditLogFilter().getAcceptedTypes().entrySet()) { eventTypes.add(makeEventTypeCheckBox(e.getKey(), e.getValue())); }/*w w w . j a va 2 s .c o m*/ // Create the GWT Cell Table as events container. // BZ-996942: Set custom width and table css style. events = new CellTable<AuditLogEntry>(); events.setWidth("100%"); events.addStyleName(Constants.TABLE); final ListDataProvider<AuditLogEntry> dlp = new ListDataProvider<AuditLogEntry>( filterDeletedEntries(auditLog)); dlp.addDataDisplay(events); AuditLogEntrySummaryColumn summaryColumn = new AuditLogEntrySummaryColumn(style.auditLogDetailLabel(), style.auditLogDetailValue()); AuditLogEntryCommentColumn commentColumn = new AuditLogEntryCommentColumn(); events.addColumn(summaryColumn); events.addColumn(commentColumn); events.setColumnWidth(summaryColumn, 60.0, Unit.PCT); events.setColumnWidth(commentColumn, 40.0, Unit.PCT); //If the current user is not an Administrator include the delete comment column if (identity.getRoles().contains(new RoleImpl(AppRoles.ADMIN.getName()))) { AuditLogEntryDeleteCommentColumn deleteCommentColumn = new AuditLogEntryDeleteCommentColumn(); deleteCommentColumn.setFieldUpdater(new FieldUpdater<AuditLogEntry, SafeHtml>() { public void update(int index, AuditLogEntry row, SafeHtml value) { row.setDeleted(true); dlp.setList(filterDeletedEntries(auditLog)); dlp.refresh(); } }); events.addColumn(deleteCommentColumn); events.setColumnWidth(commentColumn, 35.0, Unit.PCT); events.setColumnWidth(deleteCommentColumn, 5.0, Unit.PCT); } events.setEmptyTableWidget( new Label(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogNoEntries())); events.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE); events.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); events.setPageSize(PAGE_SIZE); // Configure the simple pager. pager.setDisplay(events); pager.setPageSize(PAGE_SIZE); // Add the table to the container. eventsContainer.add(events); }
From source file:org.drools.workbench.screens.guided.scorecard.client.widget.GuidedScoreCardEditor.java
License:Apache License
private Widget addAttributeCellTable(final FlexTable cGrid, final Characteristic characteristic, final boolean enumColumn, final String dataType, final List<String> operators) { String[] enumValues = null;/* www.j a v a 2 s . c o m*/ if (characteristic != null) { //enum values if (enumColumn) { String factName = characteristic.getFact(); String fieldName = characteristic.getField(); enumValues = oracle.getEnumValues(factName, fieldName); } } final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>(); //Operators column final DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators); final Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) { public String getValue(final Attribute object) { return object.getOperator(); } }; operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setOperator(value); attributeCellTable.redraw(); } }); //Value column Column<Attribute, String> valueColumn = null; if (enumValues != null && enumValues.length > 0) { valueColumn = new Column<Attribute, String>(new DynamicSelectionCell(Arrays.asList(enumValues))) { public String getValue(final Attribute object) { return object.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setValue(value); attributeCellTable.redraw(); } }); } if (valueColumn == null) { valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) { public String getValue(final Attribute attribute) { return attribute.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setValue(value); attributeCellTable.redraw(); } }); } //Partial Score column final EditTextCell partialScoreCell = new EditTextCell(); final Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) { public String getValue(final Attribute attribute) { return "" + attribute.getPartialScore(); } }; partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { try { double d = Double.parseDouble(value); object.setPartialScore(d); } catch (Exception e1) { partialScoreCell.clearViewData(object); } attributeCellTable.redraw(); } }); //Reason Code column final Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) { public String getValue(final Attribute attribute) { return attribute.getReasonCode(); } }; reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() { public void update(int index, Attribute object, String value) { object.setReasonCode(value); attributeCellTable.redraw(); } }); final ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() { public void execute(final Attribute attribute) { if (Window.confirm(GuidedScoreCardConstants.INSTANCE.promptDeleteAttribute())) { final List<Attribute> list = characteristicsAttrMap.get(cGrid).getList(); list.remove(attribute); if ("boolean".equalsIgnoreCase(dataType)) { ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2); } attributeCellTable.redraw(); } } }; final Cell<Attribute> actionCell = new ActionCell<Attribute>(GuidedScoreCardConstants.INSTANCE.remove(), delegate); final Column<Attribute, String> actionColumn = new IdentityColumn(actionCell); // Add the columns. attributeCellTable.addColumn(operatorColumn, GuidedScoreCardConstants.INSTANCE.operator()); attributeCellTable.addColumn(valueColumn, GuidedScoreCardConstants.INSTANCE.value()); attributeCellTable.addColumn(partialScoreColumn, GuidedScoreCardConstants.INSTANCE.partialScore()); attributeCellTable.addColumn(reasonCodeColumn, GuidedScoreCardConstants.INSTANCE.reasonCode()); attributeCellTable.addColumn(actionColumn, GuidedScoreCardConstants.INSTANCE.actions()); attributeCellTable.setWidth("100%", true); attributeCellTable.setColumnWidth(operatorColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(valueColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(partialScoreColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(reasonCodeColumn, 20.0, Style.Unit.PCT); attributeCellTable.setColumnWidth(actionColumn, 20.0, Style.Unit.PCT); ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>(); dataProvider.addDataDisplay(attributeCellTable); characteristicsAttrMap.put(cGrid, dataProvider); if ("boolean".equalsIgnoreCase(dataType)) { CustomEditTextCell etc = (CustomEditTextCell) attributeCellTable.getColumn(1).getCell(); etc.setEnabled(false); } return (attributeCellTable); }
From source file:org.eclipse.che.ide.ext.git.client.reset.files.ResetFilesViewImpl.java
License:Open Source License
/** Initialize the columns of the grid. */ private void initColumns() { indexFiles = new CellTable<IndexFile>(); // Create files column: Column<IndexFile, String> filesColumn = new Column<IndexFile, String>(new TextCell()) { @Override//from w w w . ja v a 2 s . co m public String getValue(IndexFile file) { return file.getPath(); } }; // Create column with checkboxes: Column<IndexFile, Boolean> checkColumn = new Column<IndexFile, Boolean>(new CheckboxCell(false, true)) { @Override public Boolean getValue(IndexFile file) { return !file.isIndexed(); } }; // Create bean value updater: FieldUpdater<IndexFile, Boolean> checkFieldUpdater = new FieldUpdater<IndexFile, Boolean>() { @Override public void update(int index, IndexFile file, Boolean value) { file.setIndexed(!value); } }; checkColumn.setFieldUpdater(checkFieldUpdater); filesColumn.setHorizontalAlignment(ALIGN_LEFT); indexFiles.addColumn(checkColumn, new SafeHtml() { @Override public String asString() { return " "; } }); indexFiles.setColumnWidth(checkColumn, 1, Style.Unit.PCT); indexFiles.addColumn(filesColumn, FILES); indexFiles.setColumnWidth(filesColumn, 35, Style.Unit.PCT); indexFiles.addStyleName(resources.gitCSS().cells()); }
From source file:org.javahispano.javaleague.client.application.cars.CarsView.java
License:Apache License
private void initCarGrid() { carGrid = new CellTable<>(); carGrid.setSelectionModel(new NoSelectionModel<CarDto>()); pager = new SimplePager(SimplePager.TextLocation.CENTER); pager.setDisplay(carGrid);//from w w w. ja v a 2 s . c o m pager.setPageSize(PAGE_SIZE); initDataColumns(); initActionColumns(); }
From source file:org.javahispano.javaleague.client.application.manufacturer.ManufacturerView.java
License:Apache License
private void initManufacturerGrid() { manufacturerGrid = new CellTable<>(); manufacturerGrid.setSelectionModel(new NoSelectionModel<ManufacturerDto>()); initDataColumns();//from w w w . j a v a 2 s.c o m initActionColumns(); }
From source file:org.javahispano.javaleague.client.application.rating.RatingView.java
License:Apache License
private void initRatingGrid() { ratingGrid = new CellTable<>(); ratingGrid.setSelectionModel(new NoSelectionModel<RatingDto>()); ratingColumnInitializer.initializeColumns(ratingGrid); initActionColumns();/*from ww w. j a v a2 s . com*/ }
From source file:org.javahispano.javaleague.client.application.report.ReportView.java
License:Apache License
private void initCarGrid() { reportGrid = new CellTable<>(); reportGrid.setSelectionModel(new NoSelectionModel<ManufacturerRatingDto>()); ratingsProvider.addDataDisplay(reportGrid); initDataColumns();//from ww w. j a v a 2s. co m }