Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 113070 Details for
Bug 247745
make CommentGroupStrategy testable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
clipboard.txt (text/plain), 10.45 KB, created by
Steffen Pingel
on 2008-09-20 17:58:30 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2008-09-20 17:58:30 EDT
Size:
10.45 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.sandbox.ui >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorCommentPart.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorCommentPart.java,v >retrieving revision 1.3 >diff -u -r1.3 ExtensibleTaskEditorCommentPart.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorCommentPart.java 20 Sep 2008 06:18:27 -0000 1.3 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorCommentPart.java 20 Sep 2008 21:57:46 -0000 >@@ -20,9 +20,12 @@ > import org.eclipse.jface.layout.GridDataFactory; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; > import org.eclipse.mylyn.internal.sandbox.ui.editors.CommentGroupStrategy.CommentGroup; >+import org.eclipse.mylyn.internal.tasks.core.TaskComment; > import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil; > import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart; >+import org.eclipse.mylyn.tasks.core.ITaskComment; > import org.eclipse.mylyn.tasks.core.data.TaskAttribute; >+import org.eclipse.mylyn.tasks.core.data.TaskDataModel; > import org.eclipse.swt.SWT; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; >@@ -61,9 +64,21 @@ > setPartName("Comments"); > } > >+ private TaskComment convertToTaskComment(TaskDataModel taskDataModel, TaskAttribute commentAttribute) { >+ TaskComment taskComment = new TaskComment(taskDataModel.getTaskRepository(), taskDataModel.getTask(), >+ commentAttribute); >+ taskDataModel.getTaskData().getAttributeMapper().updateTaskComment(taskComment, commentAttribute); >+ return taskComment; >+ } >+ > private void createCommentSubsections(final FormToolkit toolkit, final Composite composite, >- List<TaskAttribute> comments) { >- List<CommentGroup> commentGroups = getCommentGroupStrategy().groupCommentsFromModel(getModel()); >+ List<TaskAttribute> commentAttributes) { >+ List<ITaskComment> comments = new ArrayList<ITaskComment>(); >+ for (TaskAttribute commentAttribute : commentAttributes) { >+ comments.add(convertToTaskComment(getModel(), commentAttribute)); >+ } >+ String currentPersonId = getModel().getTaskRepository().getUserName(); >+ List<CommentGroup> commentGroups = getCommentGroupStrategy().groupComments(comments, currentPersonId); > > // if there is only one subsection, then don't show it > if (commentGroups.size() == 1) { >@@ -217,9 +232,13 @@ > > private CommentGroupStrategy getCommentGroupStrategy() { > if (commentGroupStrategy == null) { >- commentGroupStrategy = new CommentGroupStrategy(); >+ commentGroupStrategy = new CommentGroupStrategy() { >+ @Override >+ protected boolean hasIncomingChanges(ITaskComment taskComment) { >+ return getModel().hasIncomingChanges(taskComment.getTaskAttribute()); >+ } >+ }; > } >- > return commentGroupStrategy; > } > >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/CommentGroupStrategy.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/editors/CommentGroupStrategy.java,v >retrieving revision 1.5 >diff -u -r1.5 CommentGroupStrategy.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/CommentGroupStrategy.java 20 Sep 2008 07:37:13 -0000 1.5 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/editors/CommentGroupStrategy.java 20 Sep 2008 21:57:46 -0000 >@@ -7,48 +7,53 @@ > * > * Contributors: > * Jingwen Ou - initial API and implementation >+ * Tasktop Technologies - improvements > *******************************************************************************/ > > package org.eclipse.mylyn.internal.sandbox.ui.editors; > > import java.util.ArrayList; >+import java.util.Collections; > import java.util.List; > >-import org.eclipse.mylyn.internal.tasks.core.TaskComment; > import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil; > import org.eclipse.mylyn.tasks.core.IRepositoryPerson; >+import org.eclipse.mylyn.tasks.core.ITaskComment; > import org.eclipse.mylyn.tasks.core.data.TaskAttribute; >-import org.eclipse.mylyn.tasks.core.data.TaskDataModel; > > /** > * @author Jingwen Ou >+ * @author Steffen Pingel > */ > public class CommentGroupStrategy { >+ > public class CommentGroup { >- private final List<TaskAttribute> commentAttributes; >+ >+ private final List<ITaskComment> comments; > > private final String groupName; > >- CommentGroup(String groupName, List<TaskAttribute> commentAttributes) { >+ CommentGroup(String groupName, List<ITaskComment> comments) { > this.groupName = groupName; >- this.commentAttributes = commentAttributes; >+ this.comments = comments; > } > > public List<TaskAttribute> getCommentAttributes() { >- return commentAttributes; >+ List<TaskAttribute> commentAttributes = new ArrayList<TaskAttribute>(comments.size()); >+ for (ITaskComment comment : comments) { >+ commentAttributes.add(comment.getTaskAttribute()); >+ } >+ return Collections.unmodifiableList(commentAttributes); >+ } >+ >+ public List<ITaskComment> getComments() { >+ return Collections.unmodifiableList(comments); > } > > public String getGroupName() { > return groupName; > } >- } >- >- private TaskComment convertToTaskComment(TaskDataModel taskDataModel, TaskAttribute commentAttribute) { >- TaskComment taskComment = new TaskComment(taskDataModel.getTaskRepository(), taskDataModel.getTask(), >- commentAttribute); >- taskDataModel.getTaskData().getAttributeMapper().updateTaskComment(taskComment, commentAttribute); > >- return taskComment; > } > > /** >@@ -58,28 +63,21 @@ > * extracts groups of comment for the model > * @return list of comment groups. Groups will be ignored if there are no comments under them. > */ >- public List<CommentGroup> groupCommentsFromModel(TaskDataModel taskDataModel) { >- List<TaskAttribute> taskAttributes = taskDataModel.getTaskData().getAttributeMapper().getAttributesByType( >- taskDataModel.getTaskData(), TaskAttribute.TYPE_COMMENT); >+ public List<CommentGroup> groupComments(List<ITaskComment> comments, String currentPersonId) { > List<CommentGroup> commentGroups = new ArrayList<CommentGroup>(); >- List<TaskAttribute> comments = new ArrayList<TaskAttribute>(); >- >- int currentFromIndex = -1; >- String currentPersonId = taskDataModel.getTaskRepository().getUserName(); > > // current >- List<TaskAttribute> current = new ArrayList<TaskAttribute>(); >+ int currentFromIndex = -1; >+ List<ITaskComment> current = new ArrayList<ITaskComment>(); > > // update task comment and get current group index >- TaskComment latestComment = null; >- for (int i = 0; i < taskAttributes.size(); i++) { >- TaskAttribute commentAttribute = taskAttributes.get(i); >- final TaskComment taskComment = convertToTaskComment(taskDataModel, commentAttribute); >- comments.add(commentAttribute); >+ ITaskComment latestComment = null; >+ for (int i = 0; i < comments.size(); i++) { >+ ITaskComment taskComment = comments.get(i); > > // add all incoming changes >- if (taskDataModel.hasIncomingChanges(taskComment.getTaskAttribute())) { >- current.add(commentAttribute); >+ if (hasIncomingChanges(taskComment)) { >+ current.add(taskComment); > } > > IRepositoryPerson person = taskComment.getAuthor(); >@@ -98,15 +96,14 @@ > // bug 238038 comment #58, if the latest comment is generated automatically, lookback one comment > if (latestComment != null && latestComment.getText().contains(AttachmentUtil.CONTEXT_DESCRIPTION) > && currentFromIndex > 0) { >- TaskComment secondLatestComment = convertToTaskComment(taskDataModel, >- comments.get(currentFromIndex - 1)); >+ ITaskComment secondLatestComment = comments.get(currentFromIndex - 1); > IRepositoryPerson person = secondLatestComment.getAuthor(); > if (person != null && person.getPersonId().equals(currentPersonId)) { > currentFromIndex--; > } > } > >- current.addAll(0, new ArrayList<TaskAttribute>(comments.subList(currentFromIndex, comments.size()))); >+ current.addAll(0, new ArrayList<ITaskComment>(comments.subList(currentFromIndex, comments.size()))); > if (current.size() > 0) { > comments.removeAll(current); > } >@@ -114,7 +111,7 @@ > > // recent > int recentFromIndex = comments.size() - 20 < 0 ? 0 : comments.size() - 20; >- List<TaskAttribute> recent = new ArrayList<TaskAttribute>(comments.subList(recentFromIndex, comments.size())); >+ List<ITaskComment> recent = new ArrayList<ITaskComment>(comments.subList(recentFromIndex, comments.size())); > if (recent.size() > 0) { > comments.removeAll(recent); > } >@@ -136,4 +133,9 @@ > > return commentGroups; > } >+ >+ protected boolean hasIncomingChanges(ITaskComment taskComment) { >+ return false; >+ } >+ > } >Index: .refactorings/2008/9/38/refactorings.history >=================================================================== >RCS file: .refactorings/2008/9/38/refactorings.history >diff -N .refactorings/2008/9/38/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2008/9/38/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<session version="1.0"> >+<refactoring comment="Extract method 'private void hasIncomingChanges(ITaskComment taskComment)' from 'org.eclipse.mylyn.internal.sandbox.ui.editors.CommentGroupStrategy.groupCommentsFromModel()' to 'org.eclipse.mylyn.internal.sandbox.ui.editors.CommentGroupStrategy'
- Original project: 'org.eclipse.mylyn.sandbox.ui'
- Method name: 'hasIncomingChanges'
- Destination type: 'org.eclipse.mylyn.internal.sandbox.ui.editors.CommentGroupStrategy'
- Declared visibility: 'private'" comments="false" description="Extract method 'hasIncomingChanges'" destination="0" exceptions="false" flags="786434" id="org.eclipse.jdt.ui.extract.method" input="/src<org.eclipse.mylyn.internal.sandbox.ui.editors{CommentGroupStrategy.java" name="hasIncomingChanges" replace="false" selection="2421 64" stamp="1221946498104" version="1.0" visibility="2"/> >+</session> >Index: .refactorings/2008/9/38/refactorings.index >=================================================================== >RCS file: .refactorings/2008/9/38/refactorings.index >diff -N .refactorings/2008/9/38/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2008/9/38/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+1221946498104 Extract method 'hasIncomingChanges'
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247745
:
112836
|
112837
| 113070 |
113071