List of usage examples for com.google.gwt.user.cellview.client Column setHorizontalAlignment
@Override public void setHorizontalAlignment(HorizontalAlignmentConstant align)
The new horizontal alignment will apply the next time the table is rendered.
From source file:org.kie.dockerui.client.widgets.container.KieContainerDetails.java
License:Apache License
private void configureEnvVarsGrid(final KieContainer container, final org.kie.dockerui.shared.model.KieContainerDetails details, final Settings settings) { // NOTE: If not removing and re-adding columns, grid tow data refresh is not well done. if (envVarsGrid.getColumnCount() > 0) { envVarsGrid.removeColumn(0);//from w ww . j a va2s. c o m envVarsGrid.removeColumn(0); } // Set emtpy message. envVarsGrid.setEmptyTableWidget(new Label(Constants.INSTANCE.noEnvVars())); // Create name column. final com.google.gwt.user.cellview.client.Column<Map.Entry<String, String>, String> nameColumn = new com.google.gwt.user.cellview.client.Column<Map.Entry<String, String>, String>( new EditTextCell()) { @Override public String getValue(Map.Entry<String, String> object) { return object.getKey().toString(); } }; nameColumn.setSortable(false); nameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); envVarsGrid.addColumn(nameColumn, Constants.INSTANCE.name()); envVarsGrid.setColumnWidth(nameColumn, 20, Style.Unit.PCT); // Create value column. final com.google.gwt.user.cellview.client.Column<Map.Entry<String, String>, String> valueColumn = new com.google.gwt.user.cellview.client.Column<Map.Entry<String, String>, String>( new EditTextCell()) { @Override public String getValue(Map.Entry<String, String> object) { return object.getValue().toString(); } }; valueColumn.setSortable(false); valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); envVarsGrid.addColumn(valueColumn, Constants.INSTANCE.value()); envVarsGrid.setColumnWidth(valueColumn, 20, Style.Unit.PCT); final List<Map.Entry<String, String>> list = ClientUtils.toMapEntries(details.getEnvVars(), "="); if (list != null) { envVarsGrid.setRowCount(list.size()); envVarsGrid.setRowData(0, list); } }
From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java
License:Apache License
private void setUpDefaultColumn() { Column<KSessionModel, Boolean> column = new Column<KSessionModel, Boolean>(new CheckboxCell()) { @Override//from ww w . ja v a 2 s .c o m public Boolean getValue(KSessionModel model) { return model.isDefault(); } }; column.setFieldUpdater(new FieldUpdater<KSessionModel, Boolean>() { @Override public void update(int index, KSessionModel model, Boolean value) { model.setDefault(value); presenter.onDefaultChanged(model); } }); column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.Default()); dataGrid.setColumnWidth(column, 80, Style.Unit.PX); }
From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java
License:Apache License
private void setUpOptionsColumn() { final ButtonCell typeImageCell = new ButtonCell(ButtonType.DEFAULT, IconType.EDIT); final Column<KSessionModel, String> column = new Column<KSessionModel, String>(typeImageCell) { @Override//w w w . ja v a 2s .co m public String getValue(KSessionModel model) { return ""; } }; column.setFieldUpdater(new FieldUpdater<KSessionModel, String>() { @Override public void update(int index, KSessionModel model, String value) { presenter.onOptionsSelectedForKSessions(model); } }); column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dataGrid.addColumn(column, CommonConstants.INSTANCE.Edit()); dataGrid.setColumnWidth(column, 60, Style.Unit.PX); }
From source file:org.kie.workbench.common.screens.projecteditor.client.forms.KSessionsPanelViewImpl.java
License:Apache License
private void setUpRemoveColumn() { final ButtonCell typeImageCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH); final Column<KSessionModel, String> column = new Column<KSessionModel, String>(typeImageCell) { @Override//from w w w. j ava2s . c om public String getValue(KSessionModel model) { return ""; } }; column.setFieldUpdater(new FieldUpdater<KSessionModel, String>() { @Override public void update(int index, KSessionModel model, String value) { presenter.onDelete(model); } }); column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dataGrid.addColumn(column, CommonConstants.INSTANCE.Delete()); dataGrid.setColumnWidth(column, 60, Style.Unit.PX); }
From source file:org.kie.workbench.common.screens.projecteditor.client.forms.ListenersPanelViewImpl.java
License:Apache License
private void addDeleteColumn() { final ButtonCell deleteCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH); final Column<ListenerModel, String> column = new Column<ListenerModel, String>(deleteCell) { @Override// ww w . j a v a2 s . c o m public String getValue(ListenerModel object) { return ""; } }; column.setFieldUpdater(new FieldUpdater<ListenerModel, String>() { @Override public void update(int index, ListenerModel model, String value) { presenter.onDelete(model); } }); column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dataGrid.addColumn(column, CommonConstants.INSTANCE.Delete()); dataGrid.setColumnWidth(column, 60, Style.Unit.PX); }
From source file:org.kie.workbench.common.screens.projecteditor.client.forms.WorkItemHandlersPanelViewImpl.java
License:Apache License
private void addDeleteColumn() { final ButtonCell deleteCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH); final Column<WorkItemHandlerModel, String> column = new Column<WorkItemHandlerModel, String>(deleteCell) { @Override//from w w w .j a va 2 s . c om public String getValue(WorkItemHandlerModel object) { return ""; } }; column.setFieldUpdater(new FieldUpdater<WorkItemHandlerModel, String>() { @Override public void update(int index, WorkItemHandlerModel model, String value) { presenter.onDelete(model); } }); column.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); dataGrid.addColumn(column, CommonConstants.INSTANCE.Delete()); dataGrid.setColumnWidth(column, 60, Style.Unit.PX); }
From source file:org.livespark.formmodeler.editor.client.editor.rendering.renderers.selectors.SelectorOptionFormViewImpl.java
License:Apache License
public SelectorOptionFormViewImpl() { initWidget(uiBinder.createAndBindUi(SelectorOptionFormViewImpl.this)); //Init data objects table optionsTable.setEmptyTableWidget(new Label(FieldProperties.INSTANCE.noOptionsDefined())); optionsListDataProvider.addDataDisplay(optionsTable); CheckboxCellImpl defaultValue = new CheckboxCellImpl(false); final Column<SelectorOption, Boolean> defaultValueColumn = new Column<SelectorOption, Boolean>( defaultValue) {//from w ww. ja va2 s . c o m @Override public Boolean getValue(SelectorOption object) { return object.getDefaultValue(); } }; defaultValueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); defaultValueColumn.setFieldUpdater(new FieldUpdater<SelectorOption, Boolean>() { @Override public void update(int index, SelectorOption option, Boolean value) { presenter.setDefaultValue(option); } }); optionsTable.addColumn(defaultValueColumn, FieldProperties.INSTANCE.defaultOption()); optionsTable.setColumnWidth(defaultValueColumn, 30, Style.Unit.PCT); final TextColumn<SelectorOption> valueColumn = new TextColumn<SelectorOption>() { @Override public void render(Cell.Context context, SelectorOption object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final SelectorOption option) { return option.getValue(); } }; optionsTable.addColumn(valueColumn, FieldProperties.INSTANCE.option()); final TextColumn<SelectorOption> textColumn = new TextColumn<SelectorOption>() { @Override public void render(Cell.Context context, SelectorOption object, SafeHtmlBuilder sb) { SafeHtml startDiv = new SafeHtml() { @Override public String asString() { return "<div style=\"cursor: pointer;\">"; } }; SafeHtml endDiv = new SafeHtml() { @Override public String asString() { return "</div>"; } }; sb.append(startDiv); super.render(context, object, sb); sb.append(endDiv); } @Override public String getValue(final SelectorOption option) { return option.getText(); } }; optionsTable.addColumn(textColumn, FieldProperties.INSTANCE.optionText()); final ButtonCell deleteCell = new ButtonCell(ButtonType.DANGER, IconType.TRASH); final Column<SelectorOption, String> deleteOptionColumn = new Column<SelectorOption, String>(deleteCell) { @Override public String getValue(final SelectorOption option) { return Constants.INSTANCE.remove(); } }; deleteOptionColumn.setFieldUpdater(new FieldUpdater<SelectorOption, String>() { public void update(final int index, final SelectorOption option, final String value) { presenter.removeOption(option); } }); deleteOptionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); optionsTable.addColumn(deleteOptionColumn); }
From source file:org.rstudio.studio.client.workbench.views.vcs.ChangelistTable.java
License:Open Source License
private void configureTable() { final Column<StatusAndPath, Boolean> stagedColumn = new Column<StatusAndPath, Boolean>( new TriStateCheckboxCell<StatusAndPath>(selectionModel_)) { @Override//from w ww .java2s . c o m public Boolean getValue(StatusAndPath object) { return "??".equals(object.getStatus()) ? Boolean.FALSE : object.getStatus().charAt(1) == ' ' ? Boolean.TRUE : object.getStatus().charAt(0) == ' ' ? Boolean.FALSE : null; } }; stagedColumn.setHorizontalAlignment(Column.ALIGN_CENTER); stagedColumn.setFieldUpdater(new FieldUpdater<StatusAndPath, Boolean>() { @Override public void update(final int index, final StatusAndPath object, Boolean value) { fireEvent(new StageUnstageEvent(!value, getSelectedItems())); } }); stagedColumn.setSortable(true); sortHandler_.setComparator(stagedColumn, new Comparator<StatusAndPath>() { @Override public int compare(StatusAndPath a, StatusAndPath b) { Boolean a1 = stagedColumn.getValue(a); Boolean b1 = stagedColumn.getValue(b); int a2 = a1 == null ? 0 : a1 ? -1 : 1; int b2 = b1 == null ? 0 : b1 ? -1 : 1; return a2 - b2; } }); table_.addColumn(stagedColumn, "Staged"); table_.setColumnWidth(stagedColumn, "46px"); Column<StatusAndPath, String> statusColumn = new Column<StatusAndPath, String>( new TextCell(new StatusRenderer())) { @Override public String getValue(StatusAndPath object) { return object.getStatus(); } }; statusColumn.setSortable(true); statusColumn.setHorizontalAlignment(Column.ALIGN_CENTER); table_.addColumn(statusColumn, "Status"); table_.setColumnWidth(statusColumn, "56px"); sortHandler_.setComparator(statusColumn, new Comparator<StatusAndPath>() { @Override public int compare(StatusAndPath a, StatusAndPath b) { return a.getStatus().compareTo(b.getStatus()); } }); TextColumn<StatusAndPath> pathColumn = new TextColumn<StatusAndPath>() { @Override public String getValue(StatusAndPath object) { return object.getPath(); } }; pathColumn.setSortable(true); sortHandler_.setComparator(pathColumn, new Comparator<StatusAndPath>() { private String[] splitDirAndName(String path) { int index = path.lastIndexOf("/"); if (index < 0) index = path.lastIndexOf("\\"); if (index < 0) return new String[] { "", path }; else return new String[] { path.substring(0, index), path.substring(index + 1) }; } @Override public int compare(StatusAndPath a, StatusAndPath b) { String[] splitA = splitDirAndName(a.getPath()); String[] splitB = splitDirAndName(b.getPath()); int result = splitA[0].compareTo(splitB[0]); if (result == 0) result = splitA[1].compareTo(splitB[1]); return result; } }); table_.addColumn(pathColumn, "Path"); table_.getColumnSortList().push(pathColumn); }
From source file:org.rstudio.studio.client.workbench.views.vcs.common.ChangelistTable.java
License:Open Source License
protected void configureTable() { Column<StatusAndPath, String> statusColumn = new Column<StatusAndPath, String>( new NotEditingTextCell(getStatusRenderer())) { @Override// w ww . ja va2 s . c om public String getValue(StatusAndPath object) { return object.getStatus(); } }; statusColumn.setSortable(true); statusColumn.setHorizontalAlignment(Column.ALIGN_CENTER); table_.addColumn(statusColumn, "Status"); table_.setColumnWidth(statusColumn, "56px"); sortHandler_.setComparator(statusColumn, new Comparator<StatusAndPath>() { @Override public int compare(StatusAndPath a, StatusAndPath b) { return a.getStatus().compareTo(b.getStatus()); } }); Column<StatusAndPath, String> pathColumn = new Column<StatusAndPath, String>(new NotEditingTextCell()) { @Override public String getValue(StatusAndPath object) { String path = object.getPath(); if (object.isDirectory() && !path.endsWith("/")) path = path + "/"; return path; } }; pathColumn.setSortable(true); sortHandler_.setComparator(pathColumn, new StatusAndPath.PathComparator()); table_.addColumn(pathColumn, "Path"); table_.getColumnSortList().push(pathColumn); }
From source file:org.rstudio.studio.client.workbench.views.vcs.git.GitChangelistTable.java
License:Open Source License
@Override protected void configureTable() { final Column<StatusAndPath, Boolean> stagedColumn = new Column<StatusAndPath, Boolean>( new TriStateCheckboxCell<StatusAndPath>(selectionModel_)) { @Override/* ww w.ja v a2 s. c o m*/ public Boolean getValue(StatusAndPath object) { return "??".equals(object.getStatus()) ? Boolean.FALSE : object.getStatus().charAt(1) == ' ' ? Boolean.TRUE : object.getStatus().charAt(0) == ' ' ? Boolean.FALSE : null; } }; stagedColumn.setHorizontalAlignment(Column.ALIGN_CENTER); stagedColumn.setFieldUpdater(new FieldUpdater<StatusAndPath, Boolean>() { @Override public void update(final int index, final StatusAndPath object, Boolean value) { fireEvent(new StageUnstageEvent(!value, getSelectedItems())); } }); stagedColumn.setSortable(true); sortHandler_.setComparator(stagedColumn, new Comparator<StatusAndPath>() { @Override public int compare(StatusAndPath a, StatusAndPath b) { Boolean a1 = stagedColumn.getValue(a); Boolean b1 = stagedColumn.getValue(b); int a2 = a1 == null ? 0 : a1 ? -1 : 1; int b2 = b1 == null ? 0 : b1 ? -1 : 1; return a2 - b2; } }); table_.addColumn(stagedColumn, "Staged"); table_.setColumnWidth(stagedColumn, "46px"); super.configureTable(); }