use of com.google.gwt.view.client.SingleSelectionModel in project che by eclipse.
the class GithubImporterPageViewImpl method createRepositoriesTable.
/**
* Creates table what contains list of available repositories.
*
* @param resources
*/
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() == null ? "" : 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);
}
use of com.google.gwt.view.client.SingleSelectionModel in project che by eclipse.
the class MoveViewImpl method setTreeOfDestinations.
/** {@inheritDoc} */
@Override
public void setTreeOfDestinations(List<JavaProject> projects) {
final SingleSelectionModel<Object> selectionModel = new SingleSelectionModel<>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
Object object = selectionModel.getSelectedObject();
if (object instanceof JavaProject) {
JavaProject project = (JavaProject) object;
delegate.setMoveDestinationPath(project.getPath(), project.getPath());
}
if (object instanceof PackageFragmentRoot) {
PackageFragmentRoot fragmentRoot = (PackageFragmentRoot) object;
delegate.setMoveDestinationPath(fragmentRoot.getPath(), fragmentRoot.getProjectPath());
}
if (object instanceof PackageFragment) {
PackageFragment fragment = (PackageFragment) object;
delegate.setMoveDestinationPath(fragment.getPath(), fragment.getProjectPath());
}
}
});
CellTree tree = new CellTree(new ProjectsAndPackagesModel(projects, selectionModel, resources), null, cellTreeResources);
tree.setAnimationEnabled(true);
treePanel.clear();
treePanel.add(tree);
}
use of com.google.gwt.view.client.SingleSelectionModel in project che by eclipse.
the class PreviewViewImpl method setTreeOfChanges.
/** {@inheritDoc} */
@Override
public void setTreeOfChanges(final RefactoringPreview changes) {
showDiffPanel(false);
final SelectionModel<RefactoringPreview> selectionModel = new SingleSelectionModel<>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
RefactoringPreview selectedNode = (RefactoringPreview) ((SingleSelectionModel) selectionModel).getSelectedObject();
delegate.onSelectionChanged(selectedNode);
}
});
Tree tree = new Tree();
tree.getElement().setId("tree-of-changes");
for (RefactoringPreview parentChange : changes.getChildrens()) {
TreeItem treeItem = new TreeItem();
containerChanges.put(treeItem, parentChange);
createTreeElement(treeItem, parentChange.getText(), parentChange.getChildrens());
tree.addItem(treeItem);
}
tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
if (selectedElement != null) {
selectedElement.getStyle().setProperty("background", "transparent");
}
selectedElement = event.getSelectedItem().getWidget().getElement();
selectedElement.getStyle().setProperty("background", getEditorSelectionColor());
}
});
treePanel.add(tree);
}
use of com.google.gwt.view.client.SingleSelectionModel in project che by eclipse.
the class ResetToCommitViewImpl method createCommitsTable.
/** Creates table what contains list of available commits. */
private void createCommitsTable() {
commits = new CellTable<Revision>(15, tableRes);
Column<Revision, String> dateColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
return DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_MEDIUM).format(new Date((long) revision.getCommitTime()));
}
@Override
public void render(Cell.Context context, Revision revision, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-reset-cellTable-" + context.getIndex() + "\">");
super.render(context, revision, sb);
}
};
Column<Revision, String> commiterColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
if (revision.getCommitter() == null) {
return "";
}
return revision.getCommitter().getName();
}
};
Column<Revision, String> commentColumn = new Column<Revision, String>(new TextCell()) {
@Override
public String getValue(Revision revision) {
return revision.getMessage();
}
};
commits.addColumn(dateColumn, locale.commitGridDate());
commits.setColumnWidth(dateColumn, "20%");
commits.addColumn(commiterColumn, locale.commitGridCommiter());
commits.setColumnWidth(commiterColumn, "20%");
commits.addColumn(commentColumn, locale.commitGridComment());
commits.setColumnWidth(commentColumn, "60%");
final SingleSelectionModel<Revision> selectionModel = new SingleSelectionModel<Revision>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
Revision selectedObject = selectionModel.getSelectedObject();
delegate.onRevisionSelected(selectedObject);
}
});
commits.setSelectionModel(selectionModel);
}
use of com.google.gwt.view.client.SingleSelectionModel in project che by eclipse.
the class RemoteViewImpl method initRepositoriesTable.
/**
* Initialize the columns of the grid.
*
* @param ideResources
*/
private void initRepositoriesTable(org.eclipse.che.ide.Resources ideResources) {
repositories = new CellTable<>(15, ideResources);
Column<Remote, String> nameColumn = new Column<Remote, String>(new TextCell()) {
@Override
public String getValue(Remote remote) {
return remote.getName();
}
@Override
public void render(Cell.Context context, Remote remote, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "git-remotes-remotes-cellTable-" + context.getIndex() + "\">");
super.render(context, remote, sb);
}
};
Column<Remote, String> urlColumn = new Column<Remote, String>(new TextCell()) {
@Override
public String getValue(Remote remote) {
return remote.getUrl();
}
};
repositories.addColumn(nameColumn, locale.remoteGridNameField());
repositories.setColumnWidth(nameColumn, "20%");
repositories.addColumn(urlColumn, locale.remoteGridLocationField());
repositories.setColumnWidth(urlColumn, "80%");
final SingleSelectionModel<Remote> selectionModel = new SingleSelectionModel<Remote>();
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
selectedObject = selectionModel.getSelectedObject();
delegate.onRemoteSelected(selectedObject);
}
});
repositories.setSelectionModel(selectionModel);
}
Aggregations