List of usage examples for com.google.gwt.user.cellview.client CellTable CellTable
public CellTable(int pageSize, ProvidesKey<T> keyProvider)
From source file:org.eclipse.che.ide.ext.git.client.revert.RevertCommitViewImpl.java
License:Open Source License
private void createRevisionsTable(org.eclipse.che.ide.Resources coreRes) { Column<Revision, String> idColumn = new Column<Revision, String>(new TextCell()) { @Override//www .j a v a 2s . co m public String getValue(Revision revision) { return revision.getId().substring(0, 8); } }; Column<Revision, String> dateColumn = new Column<Revision, String>(new TextCell()) { @Override public String getValue(Revision revision) { return dateTimeFormatter.getFormattedDate(revision.getCommitTime()); } }; Column<Revision, String> authorColumn = new Column<Revision, String>(new TextCell()) { @Override public String getValue(Revision revision) { return revision.getCommitter().getName(); } }; Column<Revision, String> commentColumn = new Column<Revision, String>(new TextCell()) { @Override public String getValue(Revision revision) { return revision.getMessage().substring(0, 50); } }; revisions = new CellTable<>(15, coreRes); revisions.setWidth("100%"); revisions.addColumn(idColumn, locale.viewRevertRevisionTableIdTitle()); revisions.setColumnWidth(idColumn, "10%"); revisions.addColumn(dateColumn, locale.viewRevertRevisionTableDateTitle()); revisions.setColumnWidth(dateColumn, "20%"); revisions.addColumn(authorColumn, locale.viewRevertRevisionTableAuthorTitle()); revisions.setColumnWidth(authorColumn, "20%"); revisions.addColumn(commentColumn, locale.viewRevertRevisionTableCommentTitle()); revisions.setColumnWidth(commentColumn, "50%"); this.selectionModel = new SingleSelectionModel<>(); this.selectionModel.addSelectionChangeHandler(event -> { Revision selectedObject = selectionModel.getSelectedObject(); delegate.onRevisionSelected(selectedObject); }); revisions.setSelectionModel(this.selectionModel); this.revisionsPanel.add(revisions); }
From source file:org.eclipse.che.ide.ext.git.ssh.client.manage.SshKeyManagerViewImpl.java
License:Open Source License
/** Creates table what contains list of available ssh keys. */ private void initSshKeyTable(final CellTable.Resources res) { keys = new CellTable<>(15, res); Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) { @Override/* w w w. ja v a 2 s. com*/ public String getValue(SshPairDto object) { return object.getName(); } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-gitSshKeys-cellTable-host-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; hostColumn.setSortable(true); Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "View"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-gitSshKeys-cellTable-key-" + context.getIndex() + "\">"); if (object != null && object.getPublicKey() != null) { super.render(context, object, sb); } } }; // Creates handler on button clicked publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onViewClicked(object); } }); Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "Delete"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-gitSshKeys-cellTable-delete-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; // Creates handler on button clicked deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onDeleteClicked(object); } }); keys.addColumn(hostColumn, "Host"); keys.addColumn(publicKeyColumn, "Public Key"); keys.addColumn(deleteKeyColumn, "Delete"); keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT); keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX); keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX); // don't show loading indicator keys.setLoadingIndicator(null); }
From source file:org.eclipse.che.ide.ext.github.client.importer.page.GithubImporterPageViewImpl.java
License:Open Source License
/** * Creates table what contains list of available repositories. * * @param resources//w w w .j a va 2 s .c om */ private void createRepositoriesTable(final Resources resources, GitHubLocalizationConstant locale) { repositories = new CellTable<>(15, resources); Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>( new ImageResourceCell()) { @Override public ImageResource getValue(ProjectData item) { return null; } }; Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(final ProjectData item) { return SafeHtmlUtils.fromString(item.getName()); } }; Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(final ProjectData item) { return new SafeHtmlBuilder().appendHtmlConstant("<span>").appendEscaped(item.getDescription()) .appendHtmlConstant("</span>").toSafeHtml(); } }; repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX); repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn()); repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn()); // don't show loading indicator repositories.setLoadingIndicator(null); final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { ProjectData selectedObject = selectionModel.getSelectedObject(); delegate.onRepositorySelected(selectedObject); } }); repositories.setSelectionModel(selectionModel); }
From source file:org.eclipse.che.ide.ext.openshift.client.deploy._new.NewApplicationViewImpl.java
License:Open Source License
private CellTable<KeyValue> createCellTable(CellTableResources cellTableResources, final ListDataProvider<KeyValue> dataProvider, final Predicate<String> keyValidator, final Predicate<String> valueValidator) { final CellTable<KeyValue> table = new CellTable<>(50, cellTableResources); table.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); dataProvider.addDataDisplay(table);// w w w . j a va 2 s .co m TextInputCell keyCell = new TextInputCell() { @Override public void onBrowserEvent(Context context, com.google.gwt.dom.client.Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); if (event.getType().equals(BrowserEvents.KEYUP)) { String newValue = getInputElement(parent).getValue(); if (!keyValidator.apply(newValue)) { parent.getParentElement().addClassName(resources.css().deployApplicationTableError()); } else { parent.getParentElement().removeClassName(resources.css().deployApplicationTableError()); } valueUpdater.update(newValue); delegate.updateControls(); } } }; Column<KeyValue, String> nameColumn = new Column<KeyValue, String>(keyCell) { @Override public String getCellStyleNames(Cell.Context context, KeyValue object) { if (!keyValidator.apply(object.getKey())) { return resources.css().deployApplicationTableError(); } return null; } @Override public String getValue(KeyValue object) { return object.getKey(); } }; nameColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue object, String value) { object.setKey(value); } }); TextInputCell valueCell = new TextInputCell() { @Override public void onBrowserEvent(Cell.Context context, com.google.gwt.dom.client.Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); if (event.getType().equals(BrowserEvents.KEYUP)) { String newValue = getInputElement(parent).getValue(); if (!valueValidator.apply(newValue)) { parent.getParentElement().addClassName(resources.css().deployApplicationTableError()); } else { parent.getParentElement().removeClassName(resources.css().deployApplicationTableError()); } valueUpdater.update(newValue); delegate.updateControls(); } } }; Column<KeyValue, String> valueColumn = new Column<KeyValue, String>(valueCell) { @Override public String getCellStyleNames(Cell.Context context, KeyValue object) { if (!valueValidator.apply(object.getValue())) { return resources.css().deployApplicationTableError(); } return null; } @Override public String getValue(KeyValue object) { return object.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue object, String value) { object.setValue(value); } }); Column<KeyValue, String> removeColumn = new Column<KeyValue, String>(new ButtonCell()) { @Override public String getValue(KeyValue object) { return "-"; } @Override public void render(Cell.Context context, KeyValue object, SafeHtmlBuilder sb) { Button removeButton = new Button(); super.render(context, object, sb.appendHtmlConstant(removeButton.getHTML())); } }; removeColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue object, String value) { dataProvider.getList().remove(object); delegate.updateControls(); } }); table.addColumn(nameColumn); table.setColumnWidth(nameColumn, 35, Style.Unit.PCT); table.addColumn(valueColumn); table.setColumnWidth(valueColumn, 55, Style.Unit.PCT); table.addColumn(removeColumn); table.setColumnWidth(removeColumn, 10, Style.Unit.PCT); removeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); return table; }
From source file:org.eclipse.che.ide.ext.openshift.client.service.add.wizard.page.configure.ConfigureServiceViewImpl.java
License:Open Source License
private CellTable<Parameter> createVariablesTable(final CellTableResources tableResources) { envVariablesTable = new CellTable<>(50, tableResources); envVariablesTable.setTableLayoutFixed(true); envVariablesTable.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); envVariablesProvider.addDataDisplay(envVariablesTable); Column<Parameter, String> nameColumn = new Column<Parameter, String>(new TextCell()) { @Override/* w ww . j a v a 2s . c o m*/ public String getValue(Parameter parameter) { return parameter.getName(); } }; TextInputCellWithPlaceHolder variablesCell = new TextInputCellWithPlaceHolder( locale.environmentVarialbesValuePlaceholder()); Column<Parameter, String> valueColumn = new Column<Parameter, String>(variablesCell) { @Override public void onBrowserEvent(Cell.Context context, Element elem, Parameter parameter, NativeEvent event) { super.onBrowserEvent(context, elem, parameter, event); if (event.getType().equals(BrowserEvents.KEYUP)) { TextInputCellWithPlaceHolder cell = (TextInputCellWithPlaceHolder) envVariablesTable .getColumn(context.getColumn()).getCell(); String newValue = cell.getViewData(context.getKey()).getCurrentValue(); if (parameter.getGenerate() == null && Strings.isNullOrEmpty(newValue)) { elem.getParentElement().addClassName(resources.css().applicationTableError()); } else { elem.getParentElement().removeClassName(resources.css().applicationTableError()); } getFieldUpdater().update(context.getIndex(), parameter, newValue); delegate.updateControls(); } } @Override public String getCellStyleNames(Cell.Context context, Parameter parameter) { if (parameter != null && parameter.getGenerate() == null && Strings.isNullOrEmpty(parameter.getValue())) { return resources.css().applicationTableError(); } return null; } @Override public void render(Cell.Context context, Parameter parameter, SafeHtmlBuilder sb) { if (parameter.getGenerate() == null) { String value = parameter.getValue() == null ? "" : parameter.getValue(); sb.append(template.input(value)); } else { super.render(context, parameter, sb); } } @Override public String getValue(Parameter parameter) { return parameter.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<Parameter, String>() { @Override public void update(int index, Parameter parameter, String value) { parameter.setValue(value); delegate.updateControls(); } }); envVariablesTable.addColumn(nameColumn); envVariablesTable.setColumnWidth(nameColumn, 15, Style.Unit.PCT); envVariablesTable.addColumn(valueColumn); envVariablesTable.setColumnWidth(valueColumn, 20, Style.Unit.PCT); return envVariablesTable; }
From source file:org.eclipse.che.ide.ext.openshift.client.service.add.wizard.page.configure.ConfigureServiceViewImpl.java
License:Open Source License
private CellTable<KeyValue> createLabelsTable(CellTableResources tableResources, final Predicate<String> labelValidator) { labelsTable = new CellTable<>(50, tableResources); labelsTable.setTableLayoutFixed(true); labelsTable.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED); labelsProvider.addDataDisplay(labelsTable); final ValidatedInputCell keyTextInputCell = new ValidatedInputCell(labelValidator, locale.labelNamePlaceholder()); final Column<KeyValue, String> keyColumn = new Column<KeyValue, String>(keyTextInputCell) { @Override//from w w w . jav a 2s .co m public String getCellStyleNames(Cell.Context context, KeyValue keyValue) { if (!labelValidator.apply(keyValue.getKey())) { return resources.css().applicationTableError(); } return null; } @Override public String getValue(KeyValue keyValue) { return keyValue.getKey(); } }; keyColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue keyValue, String value) { keyValue.setKey(value); delegate.updateControls(); } }); ValidatedInputCell valueTextInputCell = new ValidatedInputCell(labelValidator, locale.labelValuePlaceholder()); Column<KeyValue, String> valueColumn = new Column<KeyValue, String>(valueTextInputCell) { @Override public String getCellStyleNames(Cell.Context context, KeyValue keyValue) { if (!labelValidator.apply(keyValue.getValue())) { return resources.css().applicationTableError(); } return null; } @Override public String getValue(KeyValue keyValue) { return keyValue.getValue(); } }; valueColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue keyValue, String value) { keyValue.setValue(value); delegate.updateControls(); } }); Column<KeyValue, String> removeColumn = new Column<KeyValue, String>(new ButtonCell()) { @Override public String getValue(KeyValue value) { return "-"; } @Override public void render(Cell.Context context, KeyValue keyValue, SafeHtmlBuilder sb) { Button removeButton = new Button(); super.render(context, keyValue, sb.appendHtmlConstant(removeButton.getHTML())); } }; removeColumn.setFieldUpdater(new FieldUpdater<KeyValue, String>() { @Override public void update(int index, KeyValue keyValue, String value) { labelsProvider.getList().remove(keyValue); labelsProvider.refresh(); delegate.updateControls(); } }); labelsTable.addColumn(keyColumn); labelsTable.setColumnWidth(keyColumn, 20, Style.Unit.PCT); labelsTable.addColumn(valueColumn); labelsTable.setColumnWidth(valueColumn, 20, Style.Unit.PCT); labelsTable.addColumn(removeColumn); labelsTable.setColumnWidth(removeColumn, 1, Style.Unit.PCT); removeColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); return labelsTable; }
From source file:org.eclipse.che.ide.ext.ssh.client.manage.SshKeyManagerViewImpl.java
License:Open Source License
/** Creates table what contains list of available ssh keys. */ private void initSshKeyTable(final CellTable.Resources res) { keys = new CellTable<>(20, res); Column<SshPairDto, String> hostColumn = new Column<SshPairDto, String>(new TextCell()) { @Override/*ww w .j av a 2s . c o m*/ public String getValue(SshPairDto object) { return object.getName(); } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-title-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; hostColumn.setSortable(true); Column<SshPairDto, String> publicKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "View"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-key-" + context.getIndex() + "\">"); if (object != null && object.getPublicKey() != null) { super.render(context, object, sb); } } }; // Creates handler on button clicked publicKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onViewClicked(object); } }); Column<SshPairDto, String> deleteKeyColumn = new Column<SshPairDto, String>(new ButtonCell()) { @Override public String getValue(SshPairDto object) { return "Delete"; } @Override public void render(Context context, SshPairDto object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "-sshKeys-cellTable-delete-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; // Creates handler on button clicked deleteKeyColumn.setFieldUpdater(new FieldUpdater<SshPairDto, String>() { @Override public void update(int index, SshPairDto object, String value) { delegate.onDeleteClicked(object); } }); keys.addColumn(hostColumn, "Title"); keys.addColumn(publicKeyColumn, "Public Key"); keys.addColumn(deleteKeyColumn, "Delete"); keys.setColumnWidth(hostColumn, 50, Style.Unit.PCT); keys.setColumnWidth(publicKeyColumn, 30, Style.Unit.PX); keys.setColumnWidth(deleteKeyColumn, 30, Style.Unit.PX); // don't show loading indicator keys.setLoadingIndicator(null); }
From source file:org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.appliance.processes.ProcessesViewImpl.java
License:Open Source License
private CellTable<MachineProcessDto> createTable(@NotNull TableResources tableResources) { CellTable<MachineProcessDto> table = new CellTable<>(0, tableResources); TextColumn<MachineProcessDto> name = new TextColumn<MachineProcessDto>() { @Override/*from w w w . ja v a2 s . com*/ public String getValue(MachineProcessDto descriptor) { return "Process " + descriptor.getPid(); } }; TextColumn<MachineProcessDto> protocol = new TextColumn<MachineProcessDto>() { @Override public String getValue(MachineProcessDto descriptor) { //TODO it's stub. Need add real value return "tcp"; } }; TextColumn<MachineProcessDto> port = new TextColumn<MachineProcessDto>() { @Override public String getValue(MachineProcessDto descriptor) { //TODO it's stub. Need add real value return "8000"; } }; TextColumn<MachineProcessDto> time = new TextColumn<MachineProcessDto>() { @Override public String getValue(MachineProcessDto descriptor) { //TODO it's stub. Need add real value return "10:12:24"; } }; TextColumn<MachineProcessDto> active = new TextColumn<MachineProcessDto>() { @Override public String getValue(MachineProcessDto descriptor) { boolean isActive = descriptor.isAlive(); //TODO it's stub. Need add real value return isActive ? locale.processActive() : locale.processActive(); } }; table.addColumn(name, locale.processTableName()); table.addColumn(protocol, locale.processTableProtocol()); table.addColumn(port, locale.processTablePort()); table.addColumn(time, locale.processTableTime()); table.addColumn(active, locale.processTableActive()); final SingleSelectionModel<MachineProcessDto> selectionModel = new SingleSelectionModel<>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { delegate.onProcessClicked(selectionModel.getSelectedObject()); } }); table.setSelectionModel(selectionModel); table.setLoadingIndicator(null); return table; }
From source file:org.eclipse.che.ide.extension.machine.client.perspective.widgets.machine.appliance.server.ServerViewImpl.java
License:Open Source License
@NotNull private CellTable<Server> createTable(@NotNull TableResources tableResources) { CellTable<Server> table = new CellTable<>(0, tableResources); table.setLoadingIndicator(null);/*ww w . j a v a2 s . c o m*/ TextColumn<Server> ref = new TextColumn<Server>() { @Override public String getValue(Server server) { return server.getRef(); } }; TextColumn<Server> exposedPort = new TextColumn<Server>() { @Override public String getValue(Server server) { return server.getPort(); } }; TextColumn<Server> address = new TextColumn<Server>() { @Override public String getValue(Server server) { return server.getAddress(); } }; TextColumn<Server> url = new TextColumn<Server>() { @Override public String getValue(Server server) { return server.getUrl(); } }; table.addColumn(ref, locale.infoServerRef()); table.addColumn(exposedPort, locale.infoServerPort()); table.addColumn(address, locale.infoServerAddress()); table.addColumn(url, locale.infoServerUrl()); return table; }
From source file:org.eclipse.che.ide.jseditor.client.preference.keymaps.KeymapsPreferenceViewImpl.java
License:Open Source License
@Inject public KeymapsPreferenceViewImpl(final EditorTypeRegistry editorTypeRegistry, final EditorPreferenceResource resources, final EditorPrefLocalizationConstant constants) { this.keyBindingSelection = new CellTable<EditorType>(5, resources); this.constants = constants; initWidget(UIBINDER.createAndBindUi(this)); this.editorTypeRegistry = editorTypeRegistry; this.cellStyle = resources.cellStyle(); // build keybinding selection table final TextColumn<EditorType> editorColumn = new TextColumn<EditorType>() { @Override/*from w ww . ja v a2s.c o m*/ public String getValue(final EditorType type) { return editorTypeRegistry.getName(type); } @Override public String getCellStyleNames(final Context context, final EditorType object) { return resources.cellStyle().prefCell() + " " + resources.cellStyle().firstColumn(); } }; this.keyBindingSelection.addColumn(editorColumn); // disable row selection this.keyBindingSelection.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); }