Search in sources :

Example 1 with SingleSelectionModel

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);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtmlCell(com.google.gwt.cell.client.SafeHtmlCell) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) ImageResource(com.google.gwt.resources.client.ImageResource) Column(com.google.gwt.user.cellview.client.Column) ImageResourceCell(com.google.gwt.cell.client.ImageResourceCell) ProjectData(org.eclipse.che.plugin.github.ide.load.ProjectData)

Example 2 with SingleSelectionModel

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);
}
Also used : PackageFragment(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragment) JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) PackageFragmentRoot(org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot) SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) CellTree(com.google.gwt.user.cellview.client.CellTree) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 3 with SingleSelectionModel

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);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) TreeItem(com.google.gwt.user.client.ui.TreeItem) Tree(com.google.gwt.user.client.ui.Tree) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent)

Example 4 with SingleSelectionModel

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);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Date(java.util.Date) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Revision(org.eclipse.che.api.git.shared.Revision) Column(com.google.gwt.user.cellview.client.Column)

Example 5 with SingleSelectionModel

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);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) Remote(org.eclipse.che.api.git.shared.Remote) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) TextCell(com.google.gwt.cell.client.TextCell) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Column(com.google.gwt.user.cellview.client.Column)

Aggregations

SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)5 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)5 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 Column (com.google.gwt.user.cellview.client.Column)3 TextCell (com.google.gwt.cell.client.TextCell)2 ImageResourceCell (com.google.gwt.cell.client.ImageResourceCell)1 SafeHtmlCell (com.google.gwt.cell.client.SafeHtmlCell)1 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 CellTree (com.google.gwt.user.cellview.client.CellTree)1 Tree (com.google.gwt.user.client.ui.Tree)1 TreeItem (com.google.gwt.user.client.ui.TreeItem)1 Date (java.util.Date)1 Remote (org.eclipse.che.api.git.shared.Remote)1 Revision (org.eclipse.che.api.git.shared.Revision)1 JavaProject (org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject)1 PackageFragment (org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragment)1 PackageFragmentRoot (org.eclipse.che.ide.ext.java.shared.dto.model.PackageFragmentRoot)1 RefactoringPreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)1 ProjectData (org.eclipse.che.plugin.github.ide.load.ProjectData)1