blob: c13ea6f527bff62383546df5ebbf56e80e87cdc2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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);
}
}
|