diff options
author | Tomasz Zarna | 2014-04-30 07:47:56 +0000 |
---|---|---|
committer | Tomasz Zarna | 2014-05-16 20:08:47 +0000 |
commit | c92c3dc3240e2ae1645e156146695cb6fc4b4df4 (patch) | |
tree | 2cf18359ab3271217240891026cbe43517455ce2 | |
parent | 943ea72b7491b7931677a2906839b6e4f2be8614 (diff) | |
download | org.eclipse.mylyn.reviews-c92c3dc3240e2ae1645e156146695cb6fc4b4df4.tar.gz org.eclipse.mylyn.reviews-c92c3dc3240e2ae1645e156146695cb6fc4b4df4.tar.xz org.eclipse.mylyn.reviews-c92c3dc3240e2ae1645e156146695cb6fc4b4df4.zip |
cleaning up AbstractCommentPart in Mylyn Reviews
Change-Id: Iec211825e6c94fc04078eab98eaae661fb85aae0
Signed-off-by: Tomasz Zarna <tomasz.zarna@tasktop.com>
3 files changed, 14 insertions, 76 deletions
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java index 474c8b4ad..02b53a69e 100644 --- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java +++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java @@ -13,18 +13,16 @@ package org.eclipse.mylyn.internal.reviews.ui.editors.parts; import java.text.DateFormat; -import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.List; +import org.apache.commons.lang.StringUtils; import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.mylyn.internal.reviews.ui.IReviewAction; -import org.eclipse.mylyn.internal.reviews.ui.IReviewActionListener; import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextEditor; import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorExtensions; import org.eclipse.mylyn.reviews.core.model.IComment; @@ -34,6 +32,7 @@ import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.tasks.core.TaskRepository; import org.eclipse.mylyn.tasks.ui.TasksUi; import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; @@ -70,10 +69,10 @@ public abstract class AbstractCommentPart<V extends ExpandablePart<IComment, V>> @Override protected String getSectionHeaderText() { - String headerText = comment.getAuthor().getDisplayName() + " "; //$NON-NLS-1$ - headerText += DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format( - comment.getCreationDate()); - return headerText; + return NLS.bind(Messages.AbstractCommentPart_Section_header, // + comment.getAuthor().getDisplayName(), // + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(comment.getCreationDate()) // + ); } public ReviewBehavior getBehavior() { @@ -129,7 +128,6 @@ public abstract class AbstractCommentPart<V extends ExpandablePart<IComment, V>> update(); return createdControl; - } @Override @@ -168,24 +166,13 @@ public abstract class AbstractCommentPart<V extends ExpandablePart<IComment, V>> GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP).applyTo(avatarLabel); - commentTextComposite = createReadOnlyText(toolkit, twoColumnComposite, getCommentText()); + commentTextComposite = createReadOnlyText(toolkit, twoColumnComposite, comment.getDescription()); GridDataFactory.fillDefaults().grab(true, true).applyTo(commentTextComposite); } - // TODO could be moved to a util method - private String getCommentText() { - String commentText = comment.getDescription(); - - String customFieldsString = ""; //$NON-NLS-1$ - if (customFieldsString.length() > 0) { - commentText += " " + customFieldsString; //$NON-NLS-1$ - } - return commentText; - } - @Override protected String getAnnotationText() { - return comment.isDraft() ? Messages.AbstractCommentPart_Draft : ""; //$NON-NLS-1$ + return comment.isDraft() ? Messages.AbstractCommentPart_Draft : StringUtils.EMPTY; } private Control createReadOnlyText(FormToolkit toolkit, Composite composite, String value) { @@ -199,7 +186,7 @@ public abstract class AbstractCommentPart<V extends ExpandablePart<IComment, V>> AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(repository); - final RichTextEditor editor = new RichTextEditor(repository, style, null, extension); + final RichTextEditor editor = new RichTextEditor(repository, style, null, extension, null); editor.setReadOnly(true); editor.setText(value); editor.createControl(composite, toolkit); @@ -235,53 +222,7 @@ public abstract class AbstractCommentPart<V extends ExpandablePart<IComment, V>> @Override protected List<IReviewAction> getToolbarActions(boolean isExpanded) { - List<IReviewAction> actions = new ArrayList<IReviewAction>(); - if (isExpanded) { - // FIXME -// if (!comment.isReply() && CrucibleUtil.canAddCommentToReview(crucibleReview)) { -// ReplyToCommentAction action = new ReplyToCommentAction(); -// action.selectionChanged(new StructuredSelection(comment)); -// actions.add(action); -// } -// -// if (CrucibleUiUtil.canModifyComment(crucibleReview, comment)) { -// EditCommentAction action = new EditCommentAction(); -// action.selectionChanged(new StructuredSelection(comment)); -// actions.add(action); -// -// if (!comment.isReply() && comment.getReplies().size() > 0) { -// actions.add(new CannotRemoveCommentAction("Remove Comment", CrucibleImages.COMMENT_DELETE)); -// } else { -// RemoveCommentAction action1 = new RemoveCommentAction(); -// action1.selectionChanged(new StructuredSelection(comment)); -// actions.add(action1); -// } -// -// if (CrucibleUtil.canPublishDraft(comment)) { -// PostDraftCommentAction action1 = new PostDraftCommentAction(); -// action1.selectionChanged(new StructuredSelection(comment)); -// actions.add(action1); -// } -// } - } - return actions; - } - - private final class CannotRemoveCommentAction extends Action implements IReviewAction { - public CannotRemoveCommentAction(String text, ImageDescriptor icon) { - super(text); - setImageDescriptor(icon); - } - - public void setActionListener(IReviewActionListener listner) { - } - - @Override - public void run() { - MessageDialog.openInformation(getSection().getShell(), Messages.AbstractCommentPart_Delete, - Messages.AbstractCommentPart_Cannot_delete_comment_with_replies); - } - + return Collections.<IReviewAction> emptyList(); } }
\ No newline at end of file diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/Messages.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/Messages.java index f8ac69b51..e65db5e9e 100644 --- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/Messages.java +++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/Messages.java @@ -16,11 +16,9 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.reviews.ui.editors.parts.messages"; //$NON-NLS-1$ - public static String AbstractCommentPart_Cannot_delete_comment_with_replies; - - public static String AbstractCommentPart_Delete; - public static String AbstractCommentPart_Draft; + + public static String AbstractCommentPart_Section_header; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/messages.properties b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/messages.properties index fa8d39b76..eae3301de 100644 --- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/messages.properties +++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/messages.properties @@ -8,6 +8,5 @@ # Contributors: # Tasktop Technologies - initial API and implementation ############################################################################### -AbstractCommentPart_Cannot_delete_comment_with_replies=Cannot delete comment with replies. You must delete replies first. -AbstractCommentPart_Delete=Delete AbstractCommentPart_Draft=DRAFT +AbstractCommentPart_Section_header={0} {1} |