### Eclipse Workspace Patch 1.0 #P org.eclipse.mylyn.tasks.ui Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java,v retrieving revision 1.265 diff -u -r1.265 AbstractRepositoryTaskEditor.java --- src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java 27 Jan 2008 04:24:04 -0000 1.265 +++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java 27 Jan 2008 14:26:32 -0000 @@ -145,6 +145,7 @@ import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; @@ -296,6 +297,8 @@ private boolean commentSortIsDown = true; + private boolean commentSortEnable = false; + private Composite addCommentsComposite; /** @@ -2074,7 +2077,7 @@ sortComments(); } }); - sortHyperlink.setEnabled(false); + sortHyperlinkState(false); } if (taskData.getComments().size() > 0) { @@ -2083,11 +2086,11 @@ public void expansionStateChanged(ExpansionEvent e) { if (commentsSection.isExpanded()) { if (supportsCommentSort()) { - sortHyperlink.setEnabled(true); + sortHyperlinkState(true); } } else { if (supportsCommentSort()) { - sortHyperlink.setEnabled(false); + sortHyperlinkState(false); } } } @@ -2117,7 +2120,7 @@ public void run() { revealAllComments(); if (supportsCommentSort()) { - sortHyperlink.setEnabled(true); + sortHyperlinkState(true); } } }); @@ -2299,7 +2302,7 @@ } if (supportsCommentSort()) { if (commentSortIsDown) { - sortHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.SORT_COMMENT_DOWN)); + sortHyperlinkState(commentSortEnable); } else { commentSortIsDown = !commentSortIsDown; sortComments(); @@ -2308,11 +2311,11 @@ if (foundNew) { commentsSection.setExpanded(true); if (supportsCommentSort()) { - sortHyperlink.setEnabled(true); + sortHyperlinkState(true); } } else if (taskData.getComments() == null || taskData.getComments().size() == 0) { if (supportsCommentSort()) { - sortHyperlink.setEnabled(false); + sortHyperlinkState(false); } } else if (editorInput.getTaskData() != null && editorInput.getOldTaskData() != null) { List newTaskComments = editorInput.getTaskData().getComments(); @@ -2320,12 +2323,12 @@ if (newTaskComments == null || oldTaskComments == null) { commentsSection.setExpanded(true); if (supportsCommentSort()) { - sortHyperlink.setEnabled(true); + sortHyperlinkState(true); } } else if (newTaskComments.size() != oldTaskComments.size()) { commentsSection.setExpanded(true); if (supportsCommentSort()) { - sortHyperlink.setEnabled(true); + sortHyperlinkState(true); } } } @@ -2847,13 +2850,13 @@ form.setRedraw(false); refreshEnabled = false; if (supportsCommentSort()) { - sortHyperlink.setEnabled(false); + sortHyperlinkState(false); } if (commentsSection != null && !commentsSection.isExpanded()) { commentsSection.setExpanded(true); if (supportsCommentSort()) { - sortHyperlink.setEnabled(true); + sortHyperlinkState(true); } } for (ExpandableComposite composite : commentComposites) { @@ -2931,6 +2934,28 @@ resetLayout(); } + private void sortHyperlinkState(boolean enabled) { + commentSortEnable = enabled; + + if (sortHyperlink == null) + return; + + sortHyperlink.setEnabled(enabled); + if (enabled) { + if (commentSortIsDown) { + sortHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.SORT_COMMENT_DOWN)); + } else { + sortHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.SORT_COMMENT_UP)); + } + } else { + if (commentSortIsDown) { + sortHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.SORT_COMMENT_DOWN_GRAY)); + } else { + sortHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.SORT_COMMENT_UP_GRAY)); + } + } + } + private void sortComments() { if (addCommentsComposite != null) { Control[] commentControlList = addCommentsComposite.getChildren(); @@ -2938,14 +2963,8 @@ for (int i = 1; i < commentControlListLength; i++) commentControlList[commentControlListLength-i].moveAbove(commentControlList[0]); } - if (sortHyperlink != null) { - if (commentSortIsDown) { - sortHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.SORT_COMMENT_UP)); - } else { - sortHyperlink.setImage(TasksUiImages.getImage(TasksUiImages.SORT_COMMENT_DOWN)); - } - } commentSortIsDown = !commentSortIsDown; + sortHyperlinkState(commentSortEnable); resetLayout(); } Index: src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java,v retrieving revision 1.58 diff -u -r1.58 TasksUiImages.java --- src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java 27 Jan 2008 03:08:26 -0000 1.58 +++ src/org/eclipse/mylyn/internal/tasks/ui/TasksUiImages.java 27 Jan 2008 14:26:30 -0000 @@ -76,6 +76,10 @@ public static final ImageDescriptor SORT_COMMENT_DOWN = create(T_TOOL, "sort-down.gif"); public static final ImageDescriptor SORT_COMMENT_UP = create(T_TOOL, "sort-up.gif"); + + public static final ImageDescriptor SORT_COMMENT_DOWN_GRAY = create(T_TOOL, "sort-down-gray.gif"); + + public static final ImageDescriptor SORT_COMMENT_UP_GRAY = create(T_TOOL, "sort-up-gray.gif"); public static final ImageDescriptor TASKLIST = create("eview16", "task-list.gif");