Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Review editing added
Browse files Browse the repository at this point in the history
  • Loading branch information
fearfall committed Jul 22, 2011
1 parent fc5e028 commit 0ec268f
Show file tree
Hide file tree
Showing 22 changed files with 834 additions and 533 deletions.
5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
</application-components>

<project-components>
<component>
<implementation-class>reviewresult.ReviewManager</implementation-class>
</component>
</project-components>

<actions>
Expand All @@ -24,7 +27,6 @@

<extensions defaultExtensionNs="com.intellij">
<toolWindow id="Code review" secondary="true" anchor="bottom" factoryClass="ui.reviewtoolwindow.CodeReviewToolWindowFactory"/>
<projectService serviceInterface="reviewresult.ReviewManager" serviceImplementation="reviewresult.ReviewManager"/>
<projectService serviceInterface="ui.reviewtoolwindow.ReviewView" serviceImplementation="ui.reviewtoolwindow.ReviewView"/>
</extensions>
</idea-plugin>
110 changes: 40 additions & 70 deletions src/reviewresult/Review.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package reviewresult;

import com.intellij.codeInsight.documentation.DocumentationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.PsiFile;
Expand All @@ -11,6 +15,7 @@
import com.intellij.util.xmlb.annotations.Tag;
import com.intellij.util.xmlb.annotations.Transient;

import java.security.PrivateKey;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -19,93 +24,71 @@
* Date: 7/11/11
* Time: 7:02 PM
*/
@Tag("review")

public class Review {
private List<ReviewItem> reviewItems = new ArrayList<ReviewItem>();
private ReviewBean reviewBean;
private Project project;
@Transient
private RangeMarker rangeMarker;
private String url;
private int start;
private int end;
private String name;
public Review() {
}
//private RangeMarker rangeMarker;
private VirtualFile virtualFile;

public Review(Project project, String reviewName, RangeMarker rangeMarker, VirtualFile virtualFile) {
public Review(ReviewBean reviewBean, Project project) {
this.reviewBean = reviewBean;
this.project = project;
this.rangeMarker = rangeMarker;
this.name = reviewName;
start = rangeMarker.getStartOffset();
end = rangeMarker.getEndOffset();
url = virtualFile.getUrl();
reviewItems = new ArrayList<ReviewItem>();
this.virtualFile = VirtualFileManager.getInstance().findFileByUrl(reviewBean.getUrl());
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if(document == null) return;
//this.rangeMarker = document.createRangeMarker(reviewBean.getStart(), reviewBean.getEnd());
}

@Tag("review_items")
@AbstractCollection(surroundWithTag = false)
public List<ReviewItem> getReviewItems(){
return reviewItems;
}
public Review(Project project, String reviewName, int start, int end,/* RangeMarker rangeMarker,*/ VirtualFile virtualFile) {
this.project = project;
//this.rangeMarker = rangeMarker; rangeMarker.getStartOffset(), rangeMarker.getEndOffset(),
this.virtualFile = virtualFile;

public void setReviewItems(List<ReviewItem> reviewItems) {
this.reviewItems = reviewItems;
this.reviewBean = new ReviewBean(reviewName, start, end, virtualFile.getUrl());
}

public void addReviewItem(ReviewItem reviewItem) {
reviewBean.addReviewItem(reviewItem);
}

reviewItems.add(reviewItem);
public List<ReviewItem> getReviewItems(){
return reviewBean.getReviewItems();
}

@Attribute("name")
public String getName() {
return name;
return reviewBean.getName();
}

public void setName(String name) {
this.name = name;
this.reviewBean.setName(name);
}

@Tag("start")
public int getStart() {
return start;
}

public void setStart(int start) {
this.start = start;
return reviewBean.getStart();
}

@Tag("end")
public int getEnd() {
return end;
public OpenFileDescriptor getElement() {
return new OpenFileDescriptor(project, virtualFile, reviewBean.getStart());
}

public void setEnd(int end) {
this.end = end;
public int getLine() {
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if(document == null) return -1;
return document.getLineNumber(reviewBean.getStart());
}

@Tag("url")
public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
public Project getProject() {
return project;
}

public OpenFileDescriptor getElement() {
VirtualFile virtualFile = VirtualFileManager.getInstance().findFileByUrl(url);
OpenFileDescriptor element = new OpenFileDescriptor(project, virtualFile, start);
return element;
public VirtualFile getVirtualFile() {
return virtualFile;
}

@Transient
public void setProject(Project project) {
this.project = project;
}

public void addReviewItems(List<ReviewItem> reviewItems) {
this.reviewItems.addAll(reviewItems);
public ReviewBean getReviewBean() {
return reviewBean;
}

@Override
Expand All @@ -114,21 +97,8 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;

Review review = (Review) o;
return !(reviewBean != null ? !reviewBean.equals(review.reviewBean) : review.reviewBean != null);

if (end != review.end) return false;
if (start != review.start) return false;
if (name != null ? !name.equals(review.name) : review.name != null) return false;
if (url != null ? !url.equals(review.url) : review.url != null) return false;

return true;
}

@Override
public int hashCode() {
int result = url != null ? url.hashCode() : 0;
result = 31 * result + start;
result = 31 * result + end;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
}
109 changes: 109 additions & 0 deletions src/reviewresult/ReviewBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package reviewresult;

import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;
import org.eclipse.jdt.internal.core.INamingRequestor;

import java.util.ArrayList;
import java.util.List;

/**
* User: Alisa.Afonina
* Date: 7/20/11
* Time: 6:14 PM
*/

@Tag("review")
public class ReviewBean {
private String name;
private int start;
private int end;
private List<ReviewItem> reviewItems = new ArrayList<ReviewItem>();
private String url;

public ReviewBean() {
}

public ReviewBean(String name, int start, int end, String url) {
this.name = name;
this.start = start;
this.end = end;
this.url = url;
}


@Attribute("name")
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Tag("start")
public int getStart() {
return start;
}

public void setStart(int start) {
this.start = start;
}


@Tag("end")
public int getEnd() {
return end;
}

public void setEnd(int end) {
this.end = end;
}


@Tag("review_items")
@AbstractCollection(surroundWithTag = false)
public List<ReviewItem> getReviewItems() {
return reviewItems;
}


public void setReviewItems(List<ReviewItem> reviewItems) {
this.reviewItems = reviewItems;
}

@Tag("url")
public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public void addReviewItem(ReviewItem reviewItem) {
reviewItems.add(reviewItem);
}

public void addReviewItems(List<ReviewItem> reviewItems) {
reviewItems.addAll(reviewItems);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

ReviewBean that = (ReviewBean) o;

if (end != that.end) return false;
if (start != that.start) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (url != null ? !url.equals(that.url) : that.url != null) return false;

return true;
}


}
16 changes: 6 additions & 10 deletions src/reviewresult/ReviewItem.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package reviewresult;


import com.intellij.openapi.project.Project;
import com.intellij.util.xmlb.annotations.Attribute;
import com.intellij.util.xmlb.annotations.Tag;

import java.util.Date;
import java.util.Random;

/**
* User: Alisa.Afonina
Expand All @@ -15,18 +13,17 @@
*/
@Tag("review_item")
public class ReviewItem {
private Date date;
private String author;
private String text;
private Date date = new Date();
private String author;//= System.getProperty("user.name");
private String text;// = "Add comment";
private ReviewStatus status;

public ReviewItem() {
}

public ReviewItem(Project project, String text, ReviewStatus status) {
public ReviewItem(String text, ReviewStatus status) {
this.author = System.getProperty("user.name");
Random random = new Random();
this.text = text;// + " " + String.valueOf(random.nextLong());
this.text = text;
this.date = new Date();
this.status = status;
}
Expand All @@ -46,8 +43,7 @@ public String getText() {
}

public void setText(String text) {
//Random random = new Random();
this.text = text;// + " " + String.valueOf(random.nextLong());
this.text = text;
}

@Attribute("status")
Expand Down
Loading

0 comments on commit 0ec268f

Please sign in to comment.