Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2011-06-19 16:13:16 +0000
committerfbecker2011-06-19 16:13:16 +0000
commitcd5ac74522082b60791daf8818e4802888858eaa (patch)
tree96ff45d3159f991fd3cff3f0921c6b2360d394b4 /org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor
parent87164a13614071c3244a2b87ebb124a5ebe6422e (diff)
downloadorg.eclipse.mylyn.tasks-cd5ac74522082b60791daf8818e4802888858eaa.tar.gz
org.eclipse.mylyn.tasks-cd5ac74522082b60791daf8818e4802888858eaa.tar.xz
org.eclipse.mylyn.tasks-cd5ac74522082b60791daf8818e4802888858eaa.zip
ASSIGNED - bug 349620: improve UI for showing private comments
https://bugs.eclipse.org/bugs/show_bug.cgi?id=349620
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorCommentPart.java91
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java16
2 files changed, 106 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorCommentPart.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorCommentPart.java
new file mode 100644
index 000000000..c13ea6f52
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorCommentPart.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Frank Becker and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.ui.editor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylyn.internal.tasks.core.TaskComment;
+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.ui.TasksUiImages;
+
+public class BugzillaTaskEditorCommentPart extends TaskEditorCommentPart {
+ private class LockAction extends Action {
+ private final ITaskComment taskComment;
+
+ public LockAction(ITaskComment taskComment) {
+ this.taskComment = taskComment;
+ updateActionState();
+ }
+
+ private void updateActionState() {
+ if (taskComment.getIsPrivate() != null) {
+ if (taskComment.getIsPrivate()) {
+ this.setImageDescriptor(TasksUiImages.LOCK_CLOSE);
+ this.setToolTipText("private Comment");
+ } else {
+ this.setImageDescriptor(TasksUiImages.LOCK_OPEN);
+ this.setToolTipText("public Comment");
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ if (taskComment.getIsPrivate() != null) {
+ taskComment.setIsPrivate(!taskComment.getIsPrivate());
+ TaskAttribute isprivate = taskComment.getTaskAttribute().getMappedAttribute(
+ TaskAttribute.COMMENT_ISPRIVATE);
+ if (isprivate == null) {
+ isprivate = taskComment.getTaskAttribute().createMappedAttribute(TaskAttribute.COMMENT_ISPRIVATE);
+ }
+ isprivate.setValue(taskComment.getIsPrivate() ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ TaskAttribute commentID = taskComment.getTaskAttribute().getMappedAttribute(TaskAttribute.COMMENT_ID);
+ if (commentID != null) {
+ String value = commentID.getValue();
+ TaskAttribute definedIsPrivate = taskComment.getTaskAttribute().getAttribute(
+ IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE + value);
+ if (definedIsPrivate == null) {
+ definedIsPrivate = taskComment.getTaskAttribute().createAttribute(
+ IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE + value);
+ }
+ TaskAttribute isPrivate = taskComment.getTaskAttribute().getAttribute(
+ IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ if (isPrivate == null) {
+ isPrivate = taskComment.getTaskAttribute().createAttribute(
+ IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ }
+ definedIsPrivate.setValue("1"); //$NON-NLS-1$
+ isPrivate.setValue(taskComment.getIsPrivate() ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ getModel().attributeChanged(taskComment.getTaskAttribute());
+ updateActionState();
+ }
+ }
+ }
+
+ public BugzillaTaskEditorCommentPart() {
+ // ignore
+ }
+
+ @Override
+ protected void addActionsToToolbar(ToolBarManager toolBarManager, TaskComment taskComment,
+ CommentViewer commentViewer) {
+ if (taskComment.getIsPrivate() != null) {
+ LockAction lockAction = new LockAction(taskComment);
+ toolBarManager.add(lockAction);
+ }
+ super.addActionsToToolbar(toolBarManager, taskComment, commentViewer);
+ }
+}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
index 256693d11..77f0f3c51 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
@@ -97,13 +97,18 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
@Override
protected Set<TaskEditorPartDescriptor> createPartDescriptors() {
Set<TaskEditorPartDescriptor> descriptors = super.createPartDescriptors();
-
+ boolean hasPartComments = false;
// remove unnecessary default editor parts
for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
if (taskEditorPartDescriptor.getId().equals(ID_PART_PEOPLE)) {
descriptors.remove(taskEditorPartDescriptor);
break;
}
+ if (taskEditorPartDescriptor.getId().equals(ID_PART_COMMENTS)) {
+ descriptors.remove(taskEditorPartDescriptor);
+ hasPartComments = true;
+ break;
+ }
}
// Add Bugzilla Planning part
@@ -135,6 +140,15 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
}.setPath(ID_PART_ATTRIBUTES + "/" + PATH_PLANNING)); //$NON-NLS-1$
}
}
+ if (hasPartComments) {
+ descriptors.add(new TaskEditorPartDescriptor(ID_PART_COMMENTS) {
+ @Override
+ public AbstractTaskEditorPart createPart() {
+ return new BugzillaTaskEditorCommentPart();
+ }
+ }.setPath(PATH_COMMENTS));
+
+ }
} catch (CoreException e) {
// ignore
}

Back to the top