List of usage examples for com.google.gwt.cell.client TextCell TextCell
public TextCell(SafeHtmlRenderer<String> renderer)
From source file:n3phele.client.view.CommandDetailView.java
License:Open Source License
private CompositeCell<FileSpecification> createRepoRefCompositeCell(final boolean isInput) { final RepoIconTextCell repo = new RepoIconTextCell(N3phele.n3pheleResource.repositorySmallIcon(), new TextCell(RepoTextCellRenderer.getInstance())); final TextCell path = new TextCell(FilenamePathRenderer.getInstance()); final ValidInputIndicatorCell valid = new ValidInputIndicatorCell(N3phele.n3pheleResource.inputErrorIcon()); final BrowseActionCell browse = new BrowseActionCell(new Delegate<FileSpecification>() { @Override/*w ww . j av a2 s. com*/ public void execute(final FileSpecification fileSpecification) { final PopupPanel popup = new PopupPanel(true); FileNodeBrowser.BrowserPresenter presenter; FileNodeBrowser view = new FileNodeBrowser(presenter = new FileNodeBrowser.BrowserPresenter() { FileNodeBrowser view; @Override public void setView(FileNodeBrowser view) { this.view = view; } /* (non-Javadoc) * @see n3phele.client.widgets.FileNodeBrowser.BrowserPresenter#select(n3phele.client.model.FileNode) */ @Override public void selectFolder(FileNode value) { if (!value.getMime().equals("application/vnd.com.n3phele.Repository+json")) { String path = value.getPath() == null ? value.getName() + "/" : (value.getPath() + value.getName() + "/"); if (path.startsWith("/")) GWT.log("FileNode " + value + " produces query with leading /"); CommandDetailView.this.presenter.fetchFiles(view, value.getRepository(), path); } else { CommandDetailView.this.presenter.fetchFiles(view, value.getRepository(), null); } } /* (non-Javadoc) * @see n3phele.client.widgets.FileNodeBrowser.BrowserPresenter#select(n3phele.client.model.FileNode) */ @Override public void selectFolder(Repository repo) { if (repo != null) { CommandDetailView.this.presenter.fetchFiles(view, repo.getUri(), null); } else { view.show(new ArrayList<FileNode>(0), new ArrayList<FileNode>(0)); } } /* (non-Javadoc) * @see n3phele.client.widgets.FileNodeBrowser.BrowserPresenter#hide() */ @Override public void hide() { popup.hide(); } /* (non-Javadoc) * @see n3phele.client.widgets.FileNodeBrowser.BrowserPresenter#save(java.lang.String) */ @Override public void save(String repoURI, String filename) { fileSpecification.setFilename(filename); fileSpecification.setRepository(repoURI); if (isInput) inputTable.redraw(); else outputTable.redraw(); updateRunButton(true); CommandDetailView.this.lastRepo = repoURI; CommandDetailView.this.lastPath = getPath(filename); popup.hide(); } /* (non-Javadoc) * @see n3phele.client.widgets.FileNodeBrowser.BrowserPresenter#validate(java.lang.String) */ @Override public boolean validate(String repoURI, String filename) { if (!isInput) { return repoURI == null || (repoURI != null && filename != null && filename.trim().length() != 0); } CommandDetailView.this.presenter.checkExists(view, repoURI, filename); return false; } @Override public void addPlaceholder(FileNode folder) { if (CommandDetailView.this.presenter != null) { CommandDetailView.this.presenter.addPlaceholder(view, folder); } } }, isInput); presenter.setView(view); view.setRepos(CommandDetailView.this.repos, !isInput || fileSpecification.isOptional()); if ((CommandDetailView.this.repos != null && CommandDetailView.this.repos.size() > 0) && (isInput || !isNullOrBlank(fileSpecification.getRepository()))) { if (isNullOrBlank(fileSpecification.getRepository())) { if (CommandDetailView.this.lastRepo != null) { CommandDetailView.this.presenter.fetchFiles(view, CommandDetailView.this.lastRepo, CommandDetailView.this.lastPath); } else { CommandDetailView.this.presenter.fetchFiles(view, CommandDetailView.this.repos.get(0).getUri(), getPath(fileSpecification.getFilename())); } } else { CommandDetailView.this.presenter.fetchFiles(view, fileSpecification.getRepository(), getPath(fileSpecification.getFilename())); } } else { if (CommandDetailView.this.lastRepo != null) { CommandDetailView.this.presenter.fetchFiles(view, CommandDetailView.this.lastRepo, CommandDetailView.this.lastPath); } else { view.show(new ArrayList<FileNode>(0), new ArrayList<FileNode>(0)); } } view.setFilename( isNullOrBlank(fileSpecification.getFilename()) ? getFilename(fileSpecification.getName()) : getFilename(fileSpecification.getFilename()), !isInput && fileSpecification.getName().endsWith(".zip"), !isInput || fileSpecification.isOptional()); popup.add(view); popup.center(); } }, isInput ? "browse repository to select input file" : "browse repository to select output file location and name", isInput ? "select file" : "save as.."); HasCell<FileSpecification, String> repoHasCell = new HasCell<FileSpecification, String>() { @Override public Cell<String> getCell() { return repo; } @Override public FieldUpdater<FileSpecification, String> getFieldUpdater() { return new FieldUpdater<FileSpecification, String>() { @Override public void update(int index, FileSpecification object, String value) { } }; } @Override public String getValue(FileSpecification object) { Repository r = CommandDetailView.this.uriToRepoMap.get(object.getRepository()); if (r != null && r.getName() != null) return r.getName(); else return ""; } }; HasCell<FileSpecification, String> pathHasCell = new HasCell<FileSpecification, String>() { @Override public Cell<String> getCell() { return path; } @Override public FieldUpdater<FileSpecification, String> getFieldUpdater() { return new FieldUpdater<FileSpecification, String>() { @Override public void update(int index, FileSpecification object, String value) { } }; } @Override public String getValue(FileSpecification object) { return object.getFilename(); } }; HasCell<FileSpecification, String> validHasCell = new HasCell<FileSpecification, String>() { @Override public Cell<String> getCell() { return valid; } @Override public FieldUpdater<FileSpecification, String> getFieldUpdater() { return new FieldUpdater<FileSpecification, String>() { @Override public void update(int index, FileSpecification object, String value) { } }; } @Override public String getValue(FileSpecification object) { String text; if (isInput && !object.isOptional()) { text = "Repository name and file required"; } else { text = "Repository name and file required"; } boolean gotRepo = false; boolean gotPath = false; if (object != null) { gotRepo = !isNullOrBlank(object.getRepository()); gotPath = !isNullOrBlank(object.getFilename()); } boolean visible; if (gotRepo || gotPath) { visible = !(gotRepo && gotPath); } else { visible = isInput && !object.isOptional(); } return (visible ? "+" : "-") + text; } }; HasCell<FileSpecification, FileSpecification> browseHasCell = new HasCell<FileSpecification, FileSpecification>() { @Override public Cell<FileSpecification> getCell() { return browse; } @Override public FieldUpdater<FileSpecification, FileSpecification> getFieldUpdater() { return new FieldUpdater<FileSpecification, FileSpecification>() { @Override public void update(int index, FileSpecification object, FileSpecification value) { } }; } @Override public FileSpecification getValue(FileSpecification object) { return object; } }; List<HasCell<FileSpecification, ?>> arg = new ArrayList<HasCell<FileSpecification, ?>>(4); arg.add(validHasCell); arg.add(repoHasCell); arg.add(pathHasCell); arg.add(browseHasCell); return new CompositeCell<FileSpecification>(arg /*, isInput, /*repoRoot, options*/); }
From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.AttributeColumn.java
License:Open Source License
public AttributeColumn(String attributeName) { super(new TextCell(new SafeHtmlRenderer<String>() { @Override//from ww w. j a v a 2 s. c o m public SafeHtml render(String object) { return object == null ? SafeHtmlUtils.EMPTY_SAFE_HTML : SafeHtmlUtils.fromTrustedString(object); } @Override public void render(String object, SafeHtmlBuilder appendable) { appendable.append(SafeHtmlUtils.fromTrustedString(object)); } })); this.attributeName = attributeName; }
From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.LabelValueColumn.java
License:Open Source License
public LabelValueColumn() { super(new TextCell(new SafeHtmlRenderer<String>() { @Override//from w w w . ja v a 2s . co m public SafeHtml render(String object) { return object == null ? SafeHtmlUtils.EMPTY_SAFE_HTML : SafeHtmlUtils.fromTrustedString(object); } @Override public void render(String object, SafeHtmlBuilder appendable) { appendable.append(SafeHtmlUtils.fromTrustedString(object)); } })); }
From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.LocaleTextColumn.java
License:Open Source License
public LocaleTextColumn() { super(new TextCell(new SafeHtmlRenderer<String>() { @Override// w ww .ja va 2 s .c o m public SafeHtml render(String object) { return object == null ? SafeHtmlUtils.EMPTY_SAFE_HTML : SafeHtmlUtils.fromTrustedString(object); } @Override public void render(String object, SafeHtmlBuilder appendable) { appendable.append(SafeHtmlUtils.fromTrustedString(object)); } })); }
From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.ValueColumn.java
License:Open Source License
private static Cell<String> createCell(VariableDto variable) { if (variable.getIsRepeatable()) { return new ClickableTextCell(new ClickableIconRenderer(IconType.LIST)); }/*w w w.ja v a2 s . c o m*/ if ("binary".equalsIgnoreCase(variable.getValueType())) { return new ClickableTextCell(new ClickableIconRenderer(IconType.DOWNLOAD)); } if (variable.getValueType().matches("point|linestring|polygon")) { return new ClickableTextCell(new ClickableIconRenderer(IconType.MAP_MARKER)); } if (VariableDtos.ValueType.TEXT.is(variable.getValueType())) { if (Strings.isNullOrEmpty(variable.getReferencedEntityType())) return new TextCell(new MultilineTextRenderer()); else return new ClickableTextCell(new ClickableIconRenderer(IconType.ELLIPSIS_VERTICAL)); } return new TextCell(); }
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//ww w . j ava 2 s . c om 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); }