List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater
public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater)
From source file:stroom.node.client.presenter.NodeMonitoringPresenter.java
License:Apache License
/** * Add the columns to the table.//from w w w . jav a 2 s .c om */ private void initTableColumns() { // Info column. final InfoColumn<NodeInfoResult> infoColumn = new InfoColumn<NodeInfoResult>() { @Override protected void showInfo(final NodeInfoResult row, final int x, final int y) { dispatcher.execute(new ClusterNodeInfoAction(row.getEntity().getId()), new AsyncCallbackAdaptor<ClusterNodeInfo>() { @Override public void onSuccess(final ClusterNodeInfo result) { String html = ""; if (result == null) { if (row != null) { final StringBuilder builder = new StringBuilder(); builder.append("<b>Node Details</b><br/>"); builder.append("Node Name: "); builder.append(row.getEntity().getName()); builder.append("<br/>Cluster URL: "); builder.append(row.getEntity().getClusterURL()); builder.append("<br/>Ping: "); builder.append(row.getPing()); html = builder.toString(); } } else { final StringBuilder builder = new StringBuilder(); builder.append("<b>Node Details</b><br/>"); builder.append("Node Name: "); builder.append(result.getNodeName()); builder.append("<br/>Build Version: "); builder.append(result.getBuildVersion()); builder.append("<br/>Build Date: "); builder.append(result.getBuildDate()); builder.append("<br/>Up Date: "); builder.append(result.getUpDate()); builder.append("<br/>Discover Time: "); builder.append(result.getDiscoverTime()); builder.append("<br/>Cluster URL: "); builder.append(result.getClusterURL()); builder.append("<br/>"); builder.append("<br/><b>Node List</b><br/>"); for (final ClusterNodeInfo.ClusterNodeInfoItem info : result.getItemList()) { builder.append(info.getNode().getName()); if (!info.isActive()) { builder.append(" (Unknown)"); } if (info.isMaster()) { builder.append(" (Master)"); } builder.append("<br/>"); } html = builder.toString(); } tooltipPresenter.setHTML(html); final PopupPosition popupPosition = new PopupPosition(x, y); ShowPopupEvent.fire(NodeMonitoringPresenter.this, tooltipPresenter, PopupType.POPUP, popupPosition, null); } @Override public void onFailure(final Throwable caught) { tooltipPresenter.setHTML(caught.getMessage()); final PopupPosition popupPosition = new PopupPosition(x, y); ShowPopupEvent.fire(NodeMonitoringPresenter.this, tooltipPresenter, PopupType.POPUP, popupPosition, null); } @Override public boolean handlesFailure() { return true; } }); } }; getView().addColumn(infoColumn, "<br/>", 20); // Name. final Column<NodeInfoResult, String> nameColumn = new Column<NodeInfoResult, String>(new TextCell()) { @Override public String getValue(final NodeInfoResult row) { if (row == null) { return null; } return row.getEntity().getName(); } }; getView().addResizableColumn(nameColumn, "Name", 100); // Host Name. final Column<NodeInfoResult, String> hostNameColumn = new Column<NodeInfoResult, String>(new TextCell()) { @Override public String getValue(final NodeInfoResult row) { if (row == null) { return null; } return row.getEntity().getClusterURL(); } }; getView().addResizableColumn(hostNameColumn, "Cluster URL", 400); // Ping. final Column<NodeInfoResult, String> pingColumn = new Column<NodeInfoResult, String>(new TextCell()) { @Override public String getValue(final NodeInfoResult row) { if (row == null) { return null; } return row.getPing(); } }; getView().addResizableColumn(pingColumn, "Ping", 150); // Master. final Column<NodeInfoResult, TickBoxState> masterColumn = new Column<NodeInfoResult, TickBoxState>( new TickBoxCell(new TickBoxCell.NoBorderAppearance(), false, false, false)) { @Override public TickBoxState getValue(final NodeInfoResult row) { if (row == null) { return null; } return TickBoxState.fromBoolean(row.isMaster()); } }; getView().addColumn(masterColumn, "Master", 50); // Priority. final Column<NodeInfoResult, Number> priorityColumn = new Column<NodeInfoResult, Number>( new ValueSpinnerCell(1, 100)) { @Override public Number getValue(final NodeInfoResult row) { if (row == null) { return null; } return new EditableInteger(row.getEntity().getPriority()); } }; priorityColumn.setFieldUpdater(new FieldUpdater<NodeInfoResult, Number>() { @Override public void update(final int index, final NodeInfoResult row, final Number value) { saveQueue.save(new EntitySaveTask<Node>(row) { @Override protected void setValue(final Node entity) { entity.setPriority(value.intValue()); } }); } }); getView().addColumn(priorityColumn, "Priority", 55); // Enabled final Column<NodeInfoResult, TickBoxState> enabledColumn = new Column<NodeInfoResult, TickBoxState>( new TickBoxCell(false, false)) { @Override public TickBoxState getValue(final NodeInfoResult row) { if (row == null) { return null; } return TickBoxState.fromBoolean(row.getEntity().isEnabled()); } }; enabledColumn.setFieldUpdater(new FieldUpdater<NodeInfoResult, TickBoxState>() { @Override public void update(final int index, final NodeInfoResult row, final TickBoxState value) { saveQueue.save(new EntitySaveTask<Node>(row) { @Override protected void setValue(final Node entity) { entity.setEnabled(value.toBoolean()); } }); } }); getView().addColumn(enabledColumn, "Enabled", 60); getView().addEndColumn(new EndColumn<NodeInfoResult>()); }
From source file:stroom.pipeline.processor.client.presenter.ProcessorListPresenter.java
License:Apache License
private void addPriorityColumn() { final boolean updatable = allowUpdate(); final Column<SharedObject, Number> priorityColumn = new Column<SharedObject, Number>( new ValueSpinnerCell(1, 100)) { @Override/*from w w w.j a v a2s. com*/ public Number getValue(final SharedObject row) { Number priority = null; if (row instanceof StreamProcessorFilterRow) { final StreamProcessorFilterRow streamProcessorFilterRow = (StreamProcessorFilterRow) row; if (updatable) { priority = new EditableInteger(streamProcessorFilterRow.getEntity().getPriority()); } else { priority = streamProcessorFilterRow.getEntity().getPriority(); } } return priority; } }; if (updatable) { priorityColumn.setFieldUpdater(new FieldUpdater<SharedObject, Number>() { @Override public void update(final int index, final SharedObject row, final Number value) { if (updatable) { if (row instanceof StreamProcessorFilterRow) { final StreamProcessorFilterRow streamProcessorFilterRow = (StreamProcessorFilterRow) row; final StreamProcessor streamProcessor = streamProcessorFilterRow.getEntity() .getStreamProcessor(); streamProcessorFilterSaveQueue .save(new EntitySaveTask<StreamProcessorFilter>(streamProcessorFilterRow) { @Override protected void setValue(final StreamProcessorFilter entity) { entity.setPriority(value.intValue()); } @Override protected void setEntity(final StreamProcessorFilter entity) { entity.setStreamProcessor(streamProcessor); super.setEntity(entity); } }); } } } }); } getView().addColumn(priorityColumn, "Priority", ColumnSizeConstants.MEDIUM_COL); }
From source file:stroom.pipeline.processor.client.presenter.ProcessorListPresenter.java
License:Apache License
private void addEnabledColumn() { final boolean updatable = allowUpdate(); final Appearance appearance = updatable ? new DefaultAppearance() : new NoBorderAppearance(); // Enabled./*from w ww . j av a2 s . c o m*/ final Column<SharedObject, TickBoxState> enabledColumn = new Column<SharedObject, TickBoxState>( new TickBoxCell(appearance, false, false, updatable)) { @Override public TickBoxState getValue(final SharedObject row) { if (row instanceof StreamProcessorFilterRow) { return TickBoxState.fromBoolean(((StreamProcessorFilterRow) row).getEntity().isEnabled()); } else if (row instanceof StreamProcessorRow) { return TickBoxState.fromBoolean(((StreamProcessorRow) row).getEntity().isEnabled()); } return null; } }; if (updatable) { enabledColumn.setFieldUpdater(new FieldUpdater<SharedObject, TickBoxState>() { @Override public void update(final int index, final SharedObject row, final TickBoxState value) { if (updatable) { if (row instanceof StreamProcessorFilterRow) { final StreamProcessorFilterRow streamProcessorFilterRow = (StreamProcessorFilterRow) row; final StreamProcessor streamProcessor = streamProcessorFilterRow.getEntity() .getStreamProcessor(); streamProcessorFilterSaveQueue .save(new EntitySaveTask<StreamProcessorFilter>(streamProcessorFilterRow) { @Override protected void setValue(final StreamProcessorFilter entity) { entity.setEnabled(value.toBoolean()); } @Override protected void setEntity(final StreamProcessorFilter entity) { entity.setStreamProcessor(streamProcessor); super.setEntity(entity); } }); } else if (row instanceof StreamProcessorRow) { final StreamProcessorRow streamProcessorRow = (StreamProcessorRow) row; final PipelineEntity pipelineEntity = streamProcessorRow.getEntity().getPipeline(); streamProcessorSaveQueue.save(new EntitySaveTask<StreamProcessor>(streamProcessorRow) { @Override protected void setValue(final StreamProcessor entity) { entity.setEnabled(value.toBoolean()); } @Override protected void setEntity(final StreamProcessor entity) { entity.setPipeline(pipelineEntity); super.setEntity(entity); } }); } } } }); } getView().addColumn(enabledColumn, "Enabled", ColumnSizeConstants.MEDIUM_COL); }
From source file:stroom.pool.client.presenter.PoolNodeListPresenter.java
License:Apache License
@Inject public PoolNodeListPresenter(final EventBus eventBus, final ClientDispatchAsync dispatcher, final TooltipPresenter tooltipPresenter) { super(eventBus, new DataGridViewImpl<PoolNodeRow>(false)); this.dispatcher = dispatcher; // Node// w w w .j av a2 s . co m final Column<PoolNodeRow, String> nodeColumn = new Column<PoolNodeRow, String>(new TextCell()) { @Override public String getValue(final PoolNodeRow row) { return row.getNode().getName(); } }; getView().addResizableColumn(nodeColumn, "Node", 200); // Last Access. final Column<PoolNodeRow, String> lastAccessColumn = new Column<PoolNodeRow, String>(new TextCell()) { @Override public String getValue(final PoolNodeRow row) { return ClientDateUtil.createDateTimeString(row.getPoolInfo().getLastAccessTime()); } }; getView().addResizableColumn(lastAccessColumn, "Last Access", 200); // Max Objects Per Key. final Column<PoolNodeRow, String> maxObjectsPerKeyColumn = new Column<PoolNodeRow, String>(new TextCell()) { @Override public String getValue(final PoolNodeRow row) { return row.getPoolInfo().getMaxObjectsPerKey(); } }; getView().addResizableColumn(maxObjectsPerKeyColumn, "Max Objects Per Key", 150); // In Use. final Column<PoolNodeRow, Number> inUseColumn = new Column<PoolNodeRow, Number>(new NumberCell()) { @Override public Number getValue(final PoolNodeRow row) { return row.getPoolInfo().getInUse(); } }; getView().addResizableColumn(inUseColumn, "In Use", 60); // In Pool. final Column<PoolNodeRow, Number> inPoolColumn = new Column<PoolNodeRow, Number>(new NumberCell()) { @Override public Number getValue(final PoolNodeRow row) { return row.getPoolInfo().getInPool(); } }; getView().addResizableColumn(inPoolColumn, "In Pool", 60); // Idle Time. final Column<PoolNodeRow, String> idleTimeColumn = new Column<PoolNodeRow, String>(new TextCell()) { @Override public String getValue(final PoolNodeRow row) { return ModelStringUtil.formatDurationString(row.getPoolInfo().getTimeToIdleMs()); } }; getView().addResizableColumn(idleTimeColumn, "Idle Time", 80); // Live Time. final Column<PoolNodeRow, String> liveTimeColumn = new Column<PoolNodeRow, String>(new TextCell()) { @Override public String getValue(final PoolNodeRow row) { return ModelStringUtil.formatDurationString(row.getPoolInfo().getTimeToLiveMs()); } }; getView().addResizableColumn(liveTimeColumn, "Live Time", 80); // Clear. final Column<PoolNodeRow, String> clearColumn = new Column<PoolNodeRow, String>(new ButtonCell()) { @Override public String getValue(final PoolNodeRow row) { return "Clear"; } }; clearColumn.setFieldUpdater(new FieldUpdater<PoolNodeRow, String>() { @Override public void update(final int index, final PoolNodeRow row, final String value) { dispatcher.execute(new PoolClearAction(row.getPoolInfo().getName(), row.getNode()), null); } }); getView().addColumn(clearColumn, "</br>"); getView().addEndColumn(new EndColumn<PoolNodeRow>()); }
From source file:stroom.security.client.presenter.AppPermissionsPresenter.java
License:Apache License
private void addColumns() { final boolean updateable = isCurrentUserUpdate(); final TickBoxCell.Appearance appearance = updateable ? new TickBoxCell.DefaultAppearance() : new TickBoxCell.NoBorderAppearance(); getView().addColumn(new Column<String, String>(new TextCell()) { @Override// w ww.ja va 2 s.c o m public String getValue(final String row) { return row; } }, "Permission", 200); // Selection. final Column<String, TickBoxState> selectionColumn = new Column<String, TickBoxState>( new TickBoxCell(appearance, true, true, updateable)) { @Override public TickBoxState getValue(final String permission) { final Set<String> permissions = userAppPermissions.getUserPermissons(); if (permissions != null && permissions.contains(permission)) { return TickBoxState.fromBoolean(true); } return TickBoxState.fromBoolean(false); } }; if (updateable) { selectionColumn.setFieldUpdater((index, permission, value) -> { final ChangeUserAction changeUserAction = new ChangeUserAction(); changeUserAction.setUserRef(relatedUser); if (value.toBoolean()) { changeUserAction.getChangedAppPermissions().add(permission); } else { changeUserAction.getChangedAppPermissions().remove(permission); } dispatcher.execute(changeUserAction, new AsyncCallbackAdaptor<VoidResult>() { @Override public void onSuccess(VoidResult result) { refresh(); } }); }); } getView().addColumn(selectionColumn, "<br/>", 50); }
From source file:stroom.security.client.presenter.PermissionsListPresenter.java
License:Apache License
@Inject public PermissionsListPresenter(final EventBus eventBus) { super(eventBus, new CellTableViewImpl<String>(false, (CellTable.Resources) GWT.create(CellTableViewImpl.BasicResources.class))); final boolean updateable = true;//isCurrentUserUpdate(); final TickBoxCell.Appearance appearance = updateable ? new TickBoxCell.DefaultAppearance() : new TickBoxCell.NoBorderAppearance(); getView().addColumn(new Column<String, String>(new TextCell()) { @Override//from www . ja v a 2s. c o m public String getValue(final String row) { return row; } }, 250); // Selection. final Column<String, TickBoxState> selectionColumn = new Column<String, TickBoxState>( new TickBoxCell(appearance, false, false, updateable)) { @Override public TickBoxState getValue(final String permission) { TickBoxState tickBoxState = TickBoxState.UNTICK; if (currentUser != null) { final Set<String> permissions = documentPermissions.getUserPermissions().get(currentUser); if (permissions != null) { if (permissions.contains(permission)) { tickBoxState = TickBoxState.TICK; } else { // If the user has a higher level of permission that is inferred by this level then indicate that with a half tick. String higherPermission = DocumentPermissionNames.getHigherPermission(permission); boolean inferred = false; while (higherPermission != null && !inferred) { inferred = permissions.contains(higherPermission); higherPermission = DocumentPermissionNames.getHigherPermission(higherPermission); } if (inferred) { tickBoxState = TickBoxState.HALF_TICK; } } } } return tickBoxState; } }; if (updateable) { selectionColumn.setFieldUpdater(new FieldUpdater<String, TickBoxState>() { @Override public void update(final int index, final String permission, final TickBoxState value) { if (currentUser != null) { if (value.toBoolean()) { addPermission(currentUser, permission); } else { removePermission(currentUser, permission); } refresh(); } } }); } getView().addColumn(selectionColumn, 50); getView().asWidget().setWidth("auto"); }
From source file:stroom.statistics.client.common.presenter.StatisticsCustomMaskListPresenter.java
License:Apache License
private void addStatFieldColumn(final int fieldPositionNumber, final String fieldname) { // Enabled./*from w ww. j av a2 s. co m*/ final Column<MaskHolder, Boolean> rolledUpColumn = new Column<MaskHolder, Boolean>(new CheckboxCell()) { @Override public Boolean getValue(final MaskHolder row) { return row.getMask().isTagRolledUp(fieldPositionNumber); } }; rolledUpColumn.setFieldUpdater(new FieldUpdater<MaskHolder, Boolean>() { @Override public void update(final int index, final MaskHolder row, final Boolean value) { row.getMask().setRollUpState(fieldPositionNumber, value); DirtyEvent.fire(StatisticsCustomMaskListPresenter.this, true); } }); getView().addResizableColumn(rolledUpColumn, fieldname, 100); columns.add(rolledUpColumn); }
From source file:stroom.stats.client.presenter.StroomStatsStoreCustomMaskListPresenter.java
License:Apache License
private void addStatFieldColumn(final int fieldPositionNumber, final String fieldname) { // Enabled.// www. ja va 2 s . c o m final Column<MaskHolder, Boolean> rolledUpColumn = new Column<MaskHolder, Boolean>(new CheckboxCell()) { @Override public Boolean getValue(final MaskHolder row) { return row.getMask().isTagRolledUp(fieldPositionNumber); } }; rolledUpColumn.setFieldUpdater((index, row, value) -> { row.getMask().setRollUpState(fieldPositionNumber, value); DirtyEvent.fire(StroomStatsStoreCustomMaskListPresenter.this, true); }); getView().addResizableColumn(rolledUpColumn, fieldname, 100); columns.add(rolledUpColumn); }
From source file:stroom.streamstore.client.presenter.AbstractStreamListPresenter.java
License:Apache License
protected void addSelectedColumn(final boolean allowSelectAll) { final TickBoxCell.MarginAppearance tickBoxAppearance = GWT.create(TickBoxCell.MarginAppearance.class); // Select Column final Column<StreamAttributeMap, TickBoxState> column = new Column<StreamAttributeMap, TickBoxState>( new TickBoxCell(tickBoxAppearance, false, false)) { @Override/* w w w .j av a 2 s .c om*/ public TickBoxState getValue(final StreamAttributeMap object) { return TickBoxState.fromBoolean(entityIdSet.isMatch(object.getStream())); } }; if (allowSelectAll) { final Header<TickBoxState> header = new Header<TickBoxState>( new TickBoxCell(tickBoxAppearance, false, false)) { @Override public TickBoxState getValue() { if (Boolean.TRUE.equals(entityIdSet.getMatchAll())) { return TickBoxState.TICK; } if (entityIdSet.getSet().size() > 0) { return TickBoxState.HALF_TICK; } return TickBoxState.UNTICK; } }; getView().addColumn(column, header, 15); header.setUpdater(new ValueUpdater<TickBoxState>() { @Override public void update(final TickBoxState value) { if (value.equals(TickBoxState.UNTICK)) { // masterEntityIdSet.clear(); // masterEntityIdSet.setMatchAll(false); entityIdSet.clear(); entityIdSet.setMatchAll(false); } if (value.equals(TickBoxState.TICK)) { // masterEntityIdSet.clear(); // masterEntityIdSet.setMatchAll(true); entityIdSet.clear(); entityIdSet.setMatchAll(true); } dataProvider.getDataProvider() .updateRowData(dataProvider.getDataProvider().getRanges()[0].getStart(), resultList); DataSelectionEvent.fire(AbstractStreamListPresenter.this, entityIdSet, false); } }); } else { getView().addColumn(column, "", 15); } // Add Handlers column.setFieldUpdater(new FieldUpdater<StreamAttributeMap, TickBoxState>() { @Override public void update(final int index, final StreamAttributeMap row, final TickBoxState value) { if (value.toBoolean()) { // masterEntityIdSet.add(row.getStream()); entityIdSet.add(row.getStream()); } else { // De-selecting one and currently matching all ? if (Boolean.TRUE.equals(entityIdSet.getMatchAll())) { // masterEntityIdSet.setMatchAll(false); entityIdSet.setMatchAll(false); final Set<Long> resultStreamIdSet = getResultStreamIdSet(); // masterEntityIdSet.addAll(resultStreamIdSet); entityIdSet.addAll(resultStreamIdSet); } // masterEntityIdSet.remove(row.getStream()); entityIdSet.remove(row.getStream()); } DataSelectionEvent.fire(AbstractStreamListPresenter.this, entityIdSet, false); } }); }
From source file:stroom.streamstore.client.presenter.MarkerListPresenter.java
License:Apache License
private void addExpanderColumn() { // Expander column. final Column<Marker, Expander> expanderColumn = new Column<Marker, Expander>(new ExpanderCell()) { @Override//from w w w .jav a 2 s. c o m public Expander getValue(final Marker marker) { if (marker instanceof TreeRow) { return ((TreeRow) marker).getExpander(); } return null; } }; expanderColumn.setFieldUpdater(new FieldUpdater<Marker, Expander>() { @Override public void update(final int index, final Marker marker, final Expander value) { final Severity severity = marker.getSeverity(); if (severity != null) { if (expandedSeverities.contains(severity)) { expandedSeverities.remove(severity); } else { expandedSeverities.add(severity); } } dataPresenter.update(true); } }); getView().addColumn(expanderColumn, "<br/>", 16); }