Search in sources :

Example 11 with Revision

use of org.eclipse.che.api.git.shared.Revision 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 12 with Revision

use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.

the class HistoryPresenterTest method shouldShowCompareWhenOneFileChangedInCurrentRevision.

@Test
public void shouldShowCompareWhenOneFileChangedInCurrentRevision() throws Exception {
    Revision parentRevision = mock(Revision.class);
    Revision selectedRevision = mock(Revision.class);
    when(parentRevision.getId()).thenReturn("commitA");
    when(selectedRevision.getId()).thenReturn("commitB");
    LogResponse logResponse = mock(LogResponse.class);
    List<Revision> revisions = new ArrayList<>();
    revisions.add(selectedRevision);
    revisions.add(parentRevision);
    when(logResponse.getCommits()).thenReturn(revisions);
    presenter.show();
    presenter.onRevisionSelected(selectedRevision);
    verify(logPromise).then(logCaptor.capture());
    logCaptor.getValue().apply(logResponse);
    presenter.onCompareClicked();
    verify(stringPromise).then(stringCaptor.capture());
    stringCaptor.getValue().apply("M file");
    verify(comparePresenter).showCompareBetweenRevisions(eq(Path.valueOf("file")), eq(MODIFIED), eq("commitA"), eq("commitB"));
}
Also used : LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) ArrayList(java.util.ArrayList) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 13 with Revision

use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.

the class HistoryPresenterTest method shouldShowChangedListWhenSeveralFilesChangedInSelectedRevision.

@Test
public void shouldShowChangedListWhenSeveralFilesChangedInSelectedRevision() throws Exception {
    Revision revisionA = mock(Revision.class);
    Revision revisionB = mock(Revision.class);
    when(revisionA.getId()).thenReturn("commitA");
    when(revisionB.getId()).thenReturn("commitB");
    LogResponse logResponse = mock(LogResponse.class);
    List<Revision> revisions = new ArrayList<>();
    revisions.add(revisionA);
    revisions.add(revisionB);
    when(logResponse.getCommits()).thenReturn(revisions);
    presenter.show();
    presenter.onRevisionSelected(revisionA);
    verify(logPromise).then(logCaptor.capture());
    logCaptor.getValue().apply(logResponse);
    presenter.onCompareClicked();
    verify(stringPromise).then(stringCaptor.capture());
    stringCaptor.getValue().apply("M file1\nM file2");
    verify(changedListPresenter).show(anyMap(), eq("commitB"), eq("commitA"), any(Project.class));
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) ArrayList(java.util.ArrayList) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 14 with Revision

use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.

the class HistoryPresenterTest method shouldGetCommitsAndShowDialog.

@Test
public void shouldGetCommitsAndShowDialog() throws Exception {
    LogResponse response = mock(LogResponse.class);
    List<Revision> revisions = singletonList(mock(Revision.class));
    when(response.getCommits()).thenReturn(revisions);
    presenter.show();
    verify(logPromise).then(logCaptor.capture());
    logCaptor.getValue().apply(response);
    verify(view).setRevisions(revisions);
    verify(view).showDialog();
}
Also used : LogResponse(org.eclipse.che.api.git.shared.LogResponse) Revision(org.eclipse.che.api.git.shared.Revision) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 15 with Revision

use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.

the class GitServiceClientImpl method commit.

@Override
public Promise<Revision> commit(DevMachine devMachine, Path project, String message, boolean all, Path[] files, boolean amend) {
    List<String> paths = new ArrayList<>(files.length);
    for (Path file : files) {
        if (!file.isEmpty()) {
            paths.add(file.toString());
        }
    }
    CommitRequest commitRequest = dtoFactory.createDto(CommitRequest.class).withMessage(message).withAmend(amend).withAll(all).withFiles(paths);
    String url = devMachine.getWsAgentBaseUrl() + COMMIT + "?projectPath=" + project;
    return asyncRequestFactory.createPostRequest(url, commitRequest).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(Revision.class));
}
Also used : Path(org.eclipse.che.ide.resource.Path) CommitRequest(org.eclipse.che.api.git.shared.CommitRequest) Revision(org.eclipse.che.api.git.shared.Revision) ArrayList(java.util.ArrayList)

Aggregations

Revision (org.eclipse.che.api.git.shared.Revision)23 GitConnection (org.eclipse.che.api.git.GitConnection)10 Test (org.testng.annotations.Test)9 ArrayList (java.util.ArrayList)6 LogResponse (org.eclipse.che.api.git.shared.LogResponse)5 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)5 Test (org.junit.Test)5 CommitParams (org.eclipse.che.api.git.params.CommitParams)4 TextCell (com.google.gwt.cell.client.TextCell)3 Column (com.google.gwt.user.cellview.client.Column)3 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)3 GitUser (org.eclipse.che.api.git.shared.GitUser)3 DoubleClickEvent (com.google.gwt.event.dom.client.DoubleClickEvent)2 DoubleClickHandler (com.google.gwt.event.dom.client.DoubleClickHandler)2 IOException (java.io.IOException)2 Date (java.util.Date)2 LogPage (org.eclipse.che.api.git.LogPage)2 GitException (org.eclipse.che.api.git.exception.GitException)2 Branch (org.eclipse.che.api.git.shared.Branch)2 CommitRequest (org.eclipse.che.api.git.shared.CommitRequest)2