Skip to content

Commit

Permalink
Port to Mylyn 3.10 version
Browse files Browse the repository at this point in the history
  • Loading branch information
topikachu authored and rombert committed Jan 10, 2014
1 parent 9dfa4aa commit a5f2603
Show file tree
Hide file tree
Showing 15 changed files with 155 additions and 135 deletions.
8 changes: 4 additions & 4 deletions org.review_board.ereviewboard.core/META-INF/MANIFEST.MF
Expand Up @@ -9,10 +9,10 @@ Bundle-Vendor: %Bundle-Vendor
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.mylyn.tasks.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.commons.net;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.commons.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.reviews.core;bundle-version="0.8.0",
org.eclipse.mylyn.tasks.core;bundle-version="[3.10.0,4.0.0)",
org.eclipse.mylyn.commons.net;bundle-version="[3.10.0,4.0.0)",
org.eclipse.mylyn.commons.core;bundle-version="[3.10.0,4.0.0)",
org.eclipse.mylyn.reviews.core;bundle-version="[2.1.0,3.0.0)",
org.json;bundle-version="[1.0.0,2.0.0)",
org.apache.commons.io;bundle-version="1.4.0",
com.google.collect;bundle-version="1.0.0"
Expand Down
Expand Up @@ -57,15 +57,18 @@ public List<IFileItem> createFileItems(String submitter, ReviewboardDiffMapper d
fileItem.setName(fileDiff.getDestinationFile());
fileItem.setId(String.valueOf(fileDiff.getId()));

IFileRevision from = FACTORY.createFileRevision();
IFileVersion from = FACTORY.createFileVersion();
from.setId(String.valueOf(fileDiff.getId()));
from.setPath(fileDiff.getSourceFile());
from.setRevision(fileDiff.getSourceRevision());

from.setDescription((fileDiff.getSourceRevision()));
from.setFile(fileItem);
from.setName(fileItem.getName());
// TODO: should we set and id for 'to' as well? might become problematic to have the same ids
IFileRevision to = FACTORY.createFileRevision();
IFileVersion to = FACTORY.createFileVersion();
to.setPath(fileDiff.getDestinationFile());
to.setRevision(fileDiff.getDestinationDetail());
to.setDescription(fileDiff.getDestinationDetail());
to.setFile(fileItem);
to.setName(fileItem.getName());

fileItem.setBase(from);
fileItem.setTarget(to);
Expand All @@ -81,13 +84,13 @@ public void appendComments(IFileItem fileItem, List<DiffComment> diffComments, D
List<DiffComment> sortedDiffComments = new ArrayList<DiffComment>(diffComments);
Collections.sort(sortedDiffComments, DiffComment.COMPARATOR_ID);

Map<Range, ITopic> rangeToTopics = new HashMap<Range, ITopic>();
Map<Range, IComment> rangeToTopics = new HashMap<Range, IComment>();

for ( DiffComment diffComment : sortedDiffComments ) {

int[] lineMappings = diffCommentLineMapper.getLineMappings(diffComment.getFirstLine());

IFileRevision fileRevision;
IFileVersion fileRevision;
int mappedLine;

// default to base
Expand All @@ -110,36 +113,36 @@ public void appendComments(IFileItem fileItem, List<DiffComment> diffComments, D

ReviewboardCorePlugin.getDefault().trace(TraceLocation.MODEL, "Converted " +
"DiffComment [" + diffComment.getFirstLine()+ ", " + diffComment.getNumLines()+"] " +
"to ILineRange [" + line.getStart()+", " + line.getEnd()+"] on " + fileRevision.getPath() + " ( " + fileRevision.getRevision() + " )");
"to ILineRange [" + line.getStart()+", " + line.getEnd()+"] on " + fileRevision.getPath() + " ( " + fileRevision.getDescription() + " )");

ILineLocation location = FACTORY.createLineLocation();
location.getRanges().add(line);

ITopic topic = rangeToTopics.get(new Range(line));
IComment topic = rangeToTopics.get(new Range(line));

IUser author = createUser(diffComment.getUsername());
if ( topic == null ) {
topic = createTopic(diffComment, fileRevision, location, author);
rangeToTopics.put(new Range(line), topic);
}

IComment topicComment = FACTORY.createComment();
topicComment.setAuthor(author);
topicComment.setCreationDate(diffComment.getTimestamp());
topicComment.setDescription(diffComment.getText());
topicComment.setDraft(Boolean.FALSE.equals(diffComment.getPublic()));

topic.getComments().add(topicComment);
topic.setAuthor(author);
topic.setCreationDate(diffComment.getTimestamp());
topic.setDescription(diffComment.getText());
topic.setDraft(Boolean.FALSE.equals(diffComment.getPublic()));


}
}

private ITopic createTopic(DiffComment diffComment, IFileRevision fileRevision, ILineLocation location, IUser author) {
private IComment createTopic(DiffComment diffComment, IFileVersion fileRevision, ILineLocation location, IUser author) {

ITopic topic = FACTORY.createTopic();
IComment topic = FACTORY.createComment();
topic.setId(String.valueOf(diffComment.getId()));
topic.setAuthor(author);
topic.setCreationDate(diffComment.getTimestamp());
topic.setLocation(location);
topic.getLocations().add(location);
topic.setItem(fileRevision);
topic.setDraft(false);
topic.setDescription(diffComment.getText());
Expand Down
@@ -1,12 +1,12 @@
package org.review_board.ereviewboard.core.model.reviews;

import org.eclipse.mylyn.reviews.core.model.ITopic;
import org.eclipse.mylyn.reviews.core.model.IComment;

/**
* @author Robert Munteanu
*
*/
public interface TopicAddedListener {

void topicAdded(ITopic topic);
void topicAdded(IComment topic);
}
Expand Up @@ -10,7 +10,7 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.team.core,
org.eclipse.mylyn.tasks.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.10.0,4.0.0)",
org.review_board.ereviewboard.core,
org.apache.commons.io;bundle-version="1.4.0",
org.eclipse.team.cvs.core,
Expand Down
4 changes: 2 additions & 2 deletions org.review_board.ereviewboard.cvs.ui/META-INF/MANIFEST.MF
Expand Up @@ -13,8 +13,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.compare,
org.eclipse.team.core,
org.eclipse.mylyn.tasks.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.10.0,4.0.0)",
org.eclipse.mylyn.tasks.ui;bundle-version="[3.10.0,4.0.0)",
org.review_board.ereviewboard.core,
org.review_board.ereviewboard.ui,
org.apache.commons.io;bundle-version="1.4.0",
Expand Down
Expand Up @@ -10,7 +10,7 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.team.core,
org.eclipse.mylyn.tasks.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.10.0,4.0.0)",
org.review_board.ereviewboard.core,
org.apache.commons.io;bundle-version="1.4.0",
org.eclipse.egit.core;bundle-version="1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions org.review_board.ereviewboard.egit.ui/META-INF/MANIFEST.MF
Expand Up @@ -13,8 +13,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.compare,
org.eclipse.team.core,
org.eclipse.mylyn.tasks.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.10.0,4.0.0)",
org.eclipse.mylyn.tasks.ui;bundle-version="[3.10.0,4.0.0)",
org.review_board.ereviewboard.core,
org.review_board.ereviewboard.ui,
org.apache.commons.io;bundle-version="1.4.0",
Expand Down
Expand Up @@ -10,7 +10,7 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.team.core,
org.eclipse.mylyn.tasks.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.10.0,4.0.0)",
org.review_board.ereviewboard.core,
org.review_board.ereviewboard.subclipse.core,
org.apache.commons.io;bundle-version="1.4.0",
Expand Down
Expand Up @@ -13,8 +13,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.compare,
org.eclipse.team.core,
org.eclipse.mylyn.tasks.core;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.mylyn.tasks.core;bundle-version="[3.10.0,4.0.0)",
org.eclipse.mylyn.tasks.ui;bundle-version="[3.10.0,4.0.0)",
org.review_board.ereviewboard.core,
org.review_board.ereviewboard.ui,
org.review_board.ereviewboard.subclipse.core,
Expand Down
Expand Up @@ -42,6 +42,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;


import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -484,7 +486,7 @@ public void readInvalidFormDataException() throws ReviewboardException, IOExcept
try {
reader.ensureSuccess(readJsonTestResource("invalid-form-data.json"));
} catch (ReviewboardException e) {
assertThat(e, is(ReviewboardInvalidFormDataException.class));
assertTrue(e instanceof ReviewboardInvalidFormDataException);

ReviewboardInvalidFormDataException exception = (ReviewboardInvalidFormDataException) e;
assertThat(exception.getMessage(), is("myint : `abc` is not an integer."));
Expand Down
@@ -1,6 +1,6 @@
package org.review_board.ereviewboard.ui.editor;

import org.eclipse.mylyn.reviews.core.model.ITopic;
import org.eclipse.mylyn.reviews.core.model.IComment;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.review_board.ereviewboard.core.model.reviews.TopicAddedListener;
import org.review_board.ereviewboard.ui.util.EditorUtil;
Expand All @@ -18,7 +18,7 @@ public RefreshEditorTopicAddedListener(AbstractTaskEditorPage taskEditorPage) {
_taskEditorPage = taskEditorPage;
}

public void topicAdded(ITopic topic) {
public void topicAdded(IComment topic) {

EditorUtil.refreshEditorPage(_taskEditorPage);
}
Expand Down
Expand Up @@ -47,6 +47,7 @@ class ReviewboardCompareEditorInput extends FileItemCompareEditorInput {
private final TaskData _taskData;
private final SCMFileContentsLocator _locator;
private final int _diffRevisionId;
protected IFileItem _file;

/**
* @param file
Expand All @@ -60,6 +61,11 @@ class ReviewboardCompareEditorInput extends FileItemCompareEditorInput {
_taskData = taskData;
_locator = locator;
this._diffRevisionId = diffRevisionId;
this._file=file;
}

protected IFileItem getFile(){
return this._file;
}

@Override
Expand Down Expand Up @@ -115,7 +121,7 @@ private void appendComments(IProgressMonitor monitor, ReviewboardClient client)
int fileDiffId = Integer.parseInt(getFile().getId());

// do not add comments twice
if ( getFile().getBase().getTopics().isEmpty() && getFile().getTarget().getTopics().isEmpty() ) {
if ( getFile().getBase().getComments().isEmpty() && getFile().getTarget().getComments().isEmpty() ) {
DiffData diffData = client.getDiffData(reviewRequestId, diffId, fileDiffId, monitor);
monitor.worked(1);
new ReviewModelFactory(client).appendComments(getFile(), client.readDiffCommentsForFileDiff(reviewRequestId, diffId, fileDiffId, monitor), new DiffCommentLineMapper(diffData));
Expand Down
Expand Up @@ -35,7 +35,7 @@
import org.eclipse.mylyn.internal.reviews.ui.compare.FileItemCompareEditorInput;
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
import org.eclipse.mylyn.reviews.core.model.IFileItem;
import org.eclipse.mylyn.reviews.core.model.IFileRevision;
import org.eclipse.mylyn.reviews.core.model.IFileVersion;
import org.eclipse.mylyn.reviews.ui.ReviewUi;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
Expand Down Expand Up @@ -123,7 +123,7 @@ public void createControl(Composite parent, FormToolkit toolkit) {
}

private void createSubsection(FormToolkit toolkit, Composite composite, final ReviewboardTaskMapper taskMapper, final ReviewboardDiffMapper diffMapper,
ReviewModelFactory reviewModelFactory, final Integer diffRevision, int style) {
final ReviewModelFactory reviewModelFactory, final Integer diffRevision, int style) {

final Section subSection = toolkit.createSection(composite, style);
GridDataFactory.fillDefaults().grab(true, false).applyTo(subSection);
Expand Down Expand Up @@ -163,15 +163,15 @@ public void open(OpenEvent event) {
return;
}

ReviewUi.setActiveReview(new ReviewboardReviewBehaviour(getTaskEditorPage().getTask(), item, diffRevision, getClient(), listener));
ReviewUi.setActiveReview(new ReviewboardReviewBehaviour(getTaskEditorPage().getTask(), item, diffRevision, getClient(), reviewModelFactory, listener));

SCMFileContentsLocator locator = getSCMFileContentsLocator(taskMapper, item.getBase());
if ( locator == null ) {
MessageDialog.openWarning(null, "Unable to load base file", "Unable to load base file contents since no plug-in was able to handle the repository " + taskMapper.getRepository());
return;
}

ReviewboardReviewBehaviour reviewBehaviour = new ReviewboardReviewBehaviour(getTaskEditorPage().getTask() , item, diffRevision, getClient(), listener);
ReviewboardReviewBehaviour reviewBehaviour = new ReviewboardReviewBehaviour(getTaskEditorPage().getTask() , item, diffRevision, getClient(),reviewModelFactory, listener);

CompareUI.openCompareEditor(new ReviewboardCompareEditorInput(item, reviewBehaviour, getTaskData(), locator, diffRevision));
}
Expand Down Expand Up @@ -260,14 +260,14 @@ private ReviewboardClient getClient() {
return ReviewboardCorePlugin.getDefault().getConnector().getClientManager().getClient(getTaskRepository());
}

private SCMFileContentsLocator getSCMFileContentsLocator(ReviewboardTaskMapper taskMapper, IFileRevision fileRevision) {
private SCMFileContentsLocator getSCMFileContentsLocator(ReviewboardTaskMapper taskMapper, IFileVersion fileRevision) {

IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_POINT_SCM_FILE_CONTENTS_LOCATOR);

for ( IConfigurationElement element : configurationElements ) {
try {
SCMFileContentsLocator locator = (SCMFileContentsLocator) element.createExecutableExtension("class");
locator.init(taskMapper.getRepository(), fileRevision.getPath(), fileRevision.getRevision());
locator.init(taskMapper.getRepository(), fileRevision.getPath(), fileRevision.getDescription());
if ( locator.isEnabled() )
return locator;
} catch (CoreException e) {
Expand Down

0 comments on commit a5f2603

Please sign in to comment.