Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2012-02-18 19:27:17 +0000
committerFrank Becker2012-02-18 19:28:00 +0000
commite87b60aee18c81693c4b05cd784848a08bae2be7 (patch)
tree5dd553c45ae53e9adc305065c690204a017e6a8f
parentd1d4e9582e26e9c5564460124a812c2a9b708af5 (diff)
downloadorg.eclipse.mylyn.tasks-e87b60aee18c81693c4b05cd784848a08bae2be7.tar.gz
org.eclipse.mylyn.tasks-e87b60aee18c81693c4b05cd784848a08bae2be7.tar.xz
org.eclipse.mylyn.tasks-e87b60aee18c81693c4b05cd784848a08bae2be7.zip
ASSIGNED - bug 349620: improve UI for private comments
https://bugs.eclipse.org/bugs/show_bug.cgi?id=349620 Change-Id: I27dddbdee581dd279d6a0c43e932b38f22ff6305
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java22
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java31
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java185
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTestWithGuest.java146
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorDescriptionPart.java75
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java23
7 files changed, 474 insertions, 12 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index ecd1ac001..026168442 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -1551,16 +1551,30 @@ public class BugzillaClient {
String valueID = a.getValue();
TaskAttribute definedIsPrivate = a.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE
+ valueID);
- if (definedIsPrivate != null) {
+ TaskAttribute isPrivate = a.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + valueID);
+ if (definedIsPrivate != null && isPrivate != null) {
fields.put(definedIsPrivate.getId(), new NameValuePair(definedIsPrivate.getId(),
definedIsPrivate.getValue() != null ? definedIsPrivate.getValue() : "")); //$NON-NLS-1$
- }
- TaskAttribute isPrivate = a.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + valueID);
- if (isPrivate != null) {
fields.put(isPrivate.getId(), new NameValuePair(isPrivate.getId(),
isPrivate.getValue() != null ? isPrivate.getValue() : "")); //$NON-NLS-1$
}
+ // Don't post comments ("task.common.comment-")
continue;
+ } else if (id.compareTo(BugzillaAttribute.LONG_DESC.getKey()) == 0) {
+ TaskAttribute idAttribute = a.getAttribute("id"); //$NON-NLS-1$
+ if (idAttribute != null) {
+ String valueID = idAttribute.getValue();
+ TaskAttribute definedIsPrivate = a.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE
+ + valueID);
+ TaskAttribute isPrivate = a.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE
+ + valueID);
+ if (definedIsPrivate != null && isPrivate != null) {
+ fields.put(definedIsPrivate.getId(), new NameValuePair(definedIsPrivate.getId(),
+ definedIsPrivate.getValue() != null ? definedIsPrivate.getValue() : "")); //$NON-NLS-1$
+ fields.put(isPrivate.getId(), new NameValuePair(isPrivate.getId(),
+ isPrivate.getValue() != null ? isPrivate.getValue() : "")); //$NON-NLS-1$
+ }
+ }
} else if (id.startsWith("task.common.")) { //$NON-NLS-1$
// Don't post any remaining non-bugzilla specific attributes
continue;
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java
index 69d3c9db4..9f22dae62 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/IBugzillaConstants.java
@@ -268,6 +268,10 @@ public interface IBugzillaConstants {
public static final String BUGZILLA_INSIDER_GROUP = "bugzilla.insider.group"; //$NON-NLS-1$
+ public static final String BUGZILLA_DESCRIPTION_ID = "id"; //$NON-NLS-1$
+
+ public static final String BUGZILLA_DESCRIPTION_IS_PRIVATE = "isprivate"; //$NON-NLS-1$
+
public static final String BUGZILLA_PREFIX_DEFINED_ISPRIVATE = "defined_isprivate_"; //$NON-NLS-1$
public static final String BUGZILLA_PREFIX_ISPRIVATE = "isprivate_"; //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
index a9b09617d..070d4a299 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java
@@ -624,14 +624,14 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
int longDescsSize = longDescs.size() - 1;
commentNum = 1;
if (longDescsSize == 0) {
- addDescription(longDescs.get(0).commentText);
+ addDescription(longDescs.get(0));
} else if (longDescsSize == 1) {
if (longDescs.get(0).createdTimeStamp.compareTo(longDescs.get(1).createdTimeStamp) <= 0) {
// if created_0 is equal to created_1 we assume that longDescs at index 0 is the description.
- addDescription(longDescs.get(0).commentText);
+ addDescription(longDescs.get(0));
addComment(longDescs.get(1));
} else {
- addDescription(longDescs.get(1).commentText);
+ addDescription(longDescs.get(1));
addComment(longDescs.get(0));
}
} else if (longDescsSize > 1) {
@@ -640,7 +640,7 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
String created_n = longDescs.get(longDescsSize).createdTimeStamp;
if (created_0.compareTo(created_1) <= 0 && created_0.compareTo(created_n) < 0) {
// if created_0 is equal to created_1 we assume that longDescs at index 0 is the description.
- addDescription(longDescs.get(0).commentText);
+ addDescription(longDescs.get(0));
if (created_1.compareTo(created_n) < 0) {
for (int i = 1; i <= longDescsSize; i++) {
@@ -652,7 +652,7 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
}
}
} else {
- addDescription(longDescs.get(longDescsSize).commentText);
+ addDescription(longDescs.get(longDescsSize));
if (created_0.compareTo(created_1) < 0) {
for (int i = 0; i < longDescsSize; i++) {
addComment(longDescs.get(i));
@@ -666,10 +666,23 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
}
}
- private void addDescription(String commentText) {
+ private void addDescription(TaskComment comment) {
TaskAttribute attrDescription = BugzillaTaskDataHandler.createAttribute(repositoryTaskData,
BugzillaAttribute.LONG_DESC);
- attrDescription.setValue(commentText);
+ TaskAttribute idAttribute = attrDescription.createAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_ID);
+ TaskAttribute isprivateAttribute = attrDescription.createAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ attrDescription.setValue(comment.commentText);
+ idAttribute.setValue(Integer.toString(comment.id));
+ if (comment.isPrivate != null) {
+ isprivateAttribute.setValue(comment.isPrivate);
+ }
+ if (!useIsPrivate) {
+ if ("1".equals(comment.isPrivate)) { //$NON-NLS-1$
+ TaskRepository taskRepository = mapper.getTaskRepository();
+ taskRepository.setProperty(IBugzillaConstants.BUGZILLA_INSIDER_GROUP, "true"); //$NON-NLS-1$
+ useIsPrivate = true;
+ }
+ }
}
private void addComment(TaskComment comment) {
@@ -690,8 +703,10 @@ public class SaxMultiBugReportContentHandler extends DefaultHandler {
TaskRepository taskRepository = mapper.getTaskRepository();
taskRepository.setProperty(IBugzillaConstants.BUGZILLA_INSIDER_GROUP, "true"); //$NON-NLS-1$
useIsPrivate = true;
+ taskComment.setIsPrivate("1".equals(comment.isPrivate)); //$NON-NLS-1$
+ } else {
+ taskComment.setIsPrivate(null);
}
- taskComment.setIsPrivate(null);
}
TaskAttribute attrTimestamp = attribute.createAttribute(BugzillaAttribute.BUG_WHEN.getKey());
attrTimestamp.setValue(comment.createdTimeStamp);
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index 439cb45f6..9275482af 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -1479,4 +1479,189 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
response = BugzillaFixture.current().submitTask(taskData, client);
}
+ public void testPrivateDescription() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "TestComponent";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test private comments";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the private comments task";
+ }
+
+ };
+ if (BugzillaFixture.current().equals(BugzillaFixture.BUGS_3_4)) {
+ return;
+ }
+ final TaskData[] taskDataNew = new TaskData[1];
+ // create Task
+ taskDataNew[0] = TasksUiInternal.createTaskData(repository, taskMappingInit, taskMappingSelect, null);
+ ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
+ taskDataNew[0].getRepositoryUrl());
+
+ ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ workingCopy.save(changed, null);
+
+ RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0], client);//connector.getTaskDataHandler().postTaskData(repository, taskDataNew[0], changed,
+ //new NullProgressMonitor());
+ ((AbstractTask) taskNew).setSubmitting(true);
+
+ assertNotNull(response);
+ assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
+ String taskId = response.getTaskId();
+
+ ITask task = generateLocalTaskAndDownload(taskId);
+ assertNotNull(task);
+ TaskDataModel model = createModel(task);
+ TaskData taskData = model.getTaskData();
+ assertNotNull(taskData);
+ TaskAttribute description = taskData.getRoot().getAttribute(BugzillaAttribute.LONG_DESC.getKey());
+ TaskAttribute isPrivateAttribute = description.getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ assertEquals("0", isPrivateAttribute.getValue());
+ TaskAttribute idAttribute = description.getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_ID);
+
+ String value = idAttribute.getValue();
+ TaskAttribute definedIsPrivate = description.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE
+ + value);
+ if (definedIsPrivate == null) {
+ definedIsPrivate = description.createAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE + value);
+ }
+ TaskAttribute isPrivate = description.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ if (isPrivate == null) {
+ isPrivate = description.createAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ }
+ definedIsPrivate.setValue("1"); //$NON-NLS-1$
+ isPrivate.setValue("1"); //$NON-NLS-1$
+
+ model.attributeChanged(description);
+ changed.clear();
+ changed.add(description);
+ workingCopy.save(changed, null);
+ response = BugzillaFixture.current().submitTask(taskData, client);
+
+ task = generateLocalTaskAndDownload(taskId);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ description = taskData.getRoot().getAttribute(BugzillaAttribute.LONG_DESC.getKey());
+ isPrivateAttribute = description.getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ assertEquals("1", isPrivateAttribute.getValue());
+ }
+
+ public void testPrivateComments() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "TestComponent";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test private comments";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the private comments task";
+ }
+
+ };
+ if (BugzillaFixture.current().equals(BugzillaFixture.BUGS_3_4)) {
+ return;
+ }
+
+ final TaskData[] taskDataNew = new TaskData[1];
+ // create Task
+ taskDataNew[0] = TasksUiInternal.createTaskData(repository, taskMappingInit, taskMappingSelect, null);
+ ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
+ taskDataNew[0].getRepositoryUrl());
+
+ ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ workingCopy.save(changed, null);
+
+ RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0], client);//connector.getTaskDataHandler().postTaskData(repository, taskDataNew[0], changed,
+ //new NullProgressMonitor());
+ ((AbstractTask) taskNew).setSubmitting(true);
+
+ assertNotNull(response);
+ assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
+ String taskId = response.getTaskId();
+
+ ITask task = generateLocalTaskAndDownload(taskId);
+ assertNotNull(task);
+ TaskDataModel model = createModel(task);
+ TaskData taskData = model.getTaskData();
+ assertNotNull(taskData);
+
+ TaskAttribute newComment = taskData.getRoot().getAttribute(BugzillaAttribute.NEW_COMMENT.getKey());
+ newComment.setValue("New Comment");
+
+ model.attributeChanged(newComment);
+ changed.clear();
+ changed.add(newComment);
+ workingCopy.save(changed, null);
+ response = BugzillaFixture.current().submitTask(taskData, client);
+
+ task = generateLocalTaskAndDownload(taskId);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ TaskAttribute comment1 = taskData.getRoot().getAttribute("task.common.comment-1");
+ TaskAttribute isPrivateAttribute = comment1.getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ assertEquals("0", isPrivateAttribute.getValue());
+
+ String value = comment1.getValue();
+ TaskAttribute definedIsPrivate = comment1.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE
+ + value);
+ if (definedIsPrivate == null) {
+ definedIsPrivate = comment1.createAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE + value);
+ }
+ TaskAttribute isPrivate = comment1.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ if (isPrivate == null) {
+ isPrivate = comment1.createAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ }
+ definedIsPrivate.setValue("1"); //$NON-NLS-1$
+ isPrivate.setValue("1"); //$NON-NLS-1$
+
+ model.attributeChanged(comment1);
+ changed.clear();
+ changed.add(comment1);
+ workingCopy.save(changed, null);
+ response = BugzillaFixture.current().submitTask(taskData, client);
+
+ task = generateLocalTaskAndDownload(taskId);
+ assertNotNull(task);
+ model = createModel(task);
+ taskData = model.getTaskData();
+ assertNotNull(taskData);
+ comment1 = taskData.getRoot().getAttribute("task.common.comment-1");
+ isPrivateAttribute = comment1.getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ assertEquals("1", isPrivateAttribute.getValue());
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTestWithGuest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTestWithGuest.java
new file mode 100644
index 000000000..4b3c8b7c0
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTestWithGuest.java
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.bugzilla.tests;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.mylyn.bugzilla.tests.support.BugzillaFixture;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
+import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.RepositoryResponse;
+import org.eclipse.mylyn.tasks.core.RepositoryResponse.ResponseKind;
+import org.eclipse.mylyn.tasks.core.TaskMapping;
+import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tests.util.TestFixture;
+import org.eclipse.mylyn.tests.util.TestUtil.PrivilegeLevel;
+
+public class BugzillaRepositoryConnectorTestWithGuest extends AbstractBugzillaTest {
+
+ @Override
+ protected void setUp() throws Exception {
+ TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .setValue(ITasksUiPreferenceConstants.REPOSITORY_SYNCH_SCHEDULE_ENABLED, false);
+ manager = TasksUiPlugin.getRepositoryManager();
+ TestFixture.resetTaskListAndRepositories();
+ this.client = BugzillaFixture.current().client(PrivilegeLevel.GUEST);
+ this.connector = BugzillaFixture.current().connector();
+ this.repository = BugzillaFixture.current().repository();
+ TasksUi.getRepositoryManager().addRepository(repository);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ TestFixture.resetTaskList();
+ manager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath());
+ }
+
+ public void testPrivateDescription() throws Exception {
+ final TaskMapping taskMappingInit = new TaskMapping() {
+
+ @Override
+ public String getProduct() {
+ return "TestProduct";
+ }
+ };
+ final TaskMapping taskMappingSelect = new TaskMapping() {
+ @Override
+ public String getComponent() {
+ return "TestComponent";
+ }
+
+ @Override
+ public String getSummary() {
+ return "test private comments";
+ }
+
+ @Override
+ public String getDescription() {
+ return "The Description of the private comments task";
+ }
+
+ };
+
+ repository.setProperty(IBugzillaConstants.BUGZILLA_INSIDER_GROUP, "true");
+ final TaskData[] taskDataNew = new TaskData[1];
+ // create Task
+ taskDataNew[0] = TasksUiInternal.createTaskData(repository, taskMappingInit, taskMappingSelect, null);
+ ITask taskNew = TasksUiUtil.createOutgoingNewTask(taskDataNew[0].getConnectorKind(),
+ taskDataNew[0].getRepositoryUrl());
+
+ ITaskDataWorkingCopy workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
+ Set<TaskAttribute> changed = new HashSet<TaskAttribute>();
+ workingCopy.save(changed, null);
+
+ RepositoryResponse response = BugzillaFixture.current().submitTask(taskDataNew[0], client);//connector.getTaskDataHandler().postTaskData(repository, taskDataNew[0], changed,
+ //new NullProgressMonitor());
+ ((AbstractTask) taskNew).setSubmitting(true);
+
+ assertNotNull(response);
+ assertEquals(ResponseKind.TASK_CREATED.toString(), response.getReposonseKind().toString());
+ String taskId = response.getTaskId();
+
+ ITask task = generateLocalTaskAndDownload(taskId);
+ assertNotNull(task);
+ TaskDataModel model = createModel(task);
+ TaskData taskData = model.getTaskData();
+ assertNotNull(taskData);
+ TaskAttribute description = taskData.getRoot().getAttribute(BugzillaAttribute.LONG_DESC.getKey());
+ TaskAttribute isPrivateAttribute = description.getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ assertEquals("0", isPrivateAttribute.getValue());
+ TaskAttribute idAttribute = description.getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_ID);
+
+ String value = idAttribute.getValue();
+ TaskAttribute definedIsPrivate = description.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE
+ + value);
+ if (definedIsPrivate == null) {
+ definedIsPrivate = description.createAttribute(IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE + value);
+ }
+ TaskAttribute isPrivate = description.getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ if (isPrivate == null) {
+ isPrivate = description.createAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ }
+ definedIsPrivate.setValue("1"); //$NON-NLS-1$
+ isPrivate.setValue("1"); //$NON-NLS-1$
+
+ model.attributeChanged(description);
+ changed = new HashSet<TaskAttribute>();
+ changed.clear();
+ changed.add(description);
+ workingCopy = TasksUi.getTaskDataManager().createWorkingCopy(taskNew, taskDataNew[0]);
+ workingCopy.save(changed, null);
+ try {
+ BugzillaFixture.current().submitTask(taskData, client);
+
+ } catch (CoreException e) {
+ assertTrue(e.getStatus()
+ .getMessage()
+ .indexOf("Sorry, but you are not allowed to (un)mark comments or attachments as private.") != -1);
+ return;
+ }
+
+ fail("CoreException not found!");
+ }
+
+}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorDescriptionPart.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorDescriptionPart.java
new file mode 100644
index 000000000..36acfd629
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorDescriptionPart.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.ui.editors.TaskEditorDescriptionPart;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.TasksUiImages;
+
+public class BugzillaTaskEditorDescriptionPart extends TaskEditorDescriptionPart {
+ private class LockAction extends Action {
+
+ public LockAction() {
+ super();
+ updateActionState();
+ }
+
+ private void updateActionState() {
+ TaskAttribute isPrivate = getAttribute().getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ if ("1".compareTo(isPrivate.getValue()) == 0) { //$NON-NLS-1$
+ this.setImageDescriptor(TasksUiImages.LOCK_CLOSE);
+ } else {
+ this.setImageDescriptor(TasksUiImages.LOCK_OPEN);
+ }
+ }
+
+ @Override
+ public void run() {
+ TaskAttribute isPrivateAttribute = getAttribute().getAttribute(
+ IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ // isPrivateAttribute can not be null because we only add the Action when the Attribute exists
+ TaskAttribute idAttribute = getAttribute().getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_ID);
+ boolean oldValue = "1".compareTo(isPrivateAttribute.getValue()) == 0; //$NON-NLS-1$
+ isPrivateAttribute.setValue(!oldValue ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ String value = idAttribute.getValue();
+ TaskAttribute definedIsPrivate = getAttribute().getAttribute(
+ IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE + value);
+ if (definedIsPrivate == null) {
+ definedIsPrivate = getAttribute().createAttribute(
+ IBugzillaConstants.BUGZILLA_PREFIX_DEFINED_ISPRIVATE + value);
+ }
+ TaskAttribute isPrivate = getAttribute().getAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ if (isPrivate == null) {
+ isPrivate = getAttribute().createAttribute(IBugzillaConstants.BUGZILLA_PREFIX_ISPRIVATE + value);
+ }
+ definedIsPrivate.setValue("1"); //$NON-NLS-1$
+ isPrivate.setValue(!oldValue ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
+ getModel().attributeChanged(getAttribute());
+ updateActionState();
+ }
+ }
+
+ @Override
+ protected void fillToolBar(ToolBarManager toolBar) {
+ String insidergroup = getModel().getTaskRepository().getProperty(IBugzillaConstants.BUGZILLA_INSIDER_GROUP);
+ TaskAttribute isPrivate = getAttribute().getAttribute(IBugzillaConstants.BUGZILLA_DESCRIPTION_IS_PRIVATE);
+ if (Boolean.parseBoolean(insidergroup) && isPrivate != null) {
+ LockAction lockAction = new LockAction();
+ toolBar.add(lockAction);
+ }
+ super.fillToolBar(toolBar);
+ }
+
+}
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 9385adb09..7bb256f27 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
@@ -75,6 +75,7 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.keys.IBindingService;
/**
@@ -120,6 +121,7 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
Set<TaskEditorPartDescriptor> descriptors = super.createPartDescriptors();
boolean hasPartComments = false;
boolean hasPartNewComment = false;
+ boolean hasPartDescription = false;
// remove unnecessary default editor parts
for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
if (taskEditorPartDescriptor.getId().equals(ID_PART_PEOPLE)) {
@@ -141,6 +143,13 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
break;
}
}
+ for (TaskEditorPartDescriptor taskEditorPartDescriptor : descriptors) {
+ if (taskEditorPartDescriptor.getId().equals(ID_PART_DESCRIPTION)) {
+ descriptors.remove(taskEditorPartDescriptor);
+ hasPartDescription = true;
+ break;
+ }
+ }
// Add Bugzilla Planning part
try {
@@ -171,6 +180,20 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
}.setPath(ID_PART_ATTRIBUTES + "/" + PATH_PLANNING)); //$NON-NLS-1$
}
}
+ if (hasPartDescription) {
+ descriptors.add(new TaskEditorPartDescriptor(ID_PART_DESCRIPTION) {
+ @Override
+ public AbstractTaskEditorPart createPart() {
+ BugzillaTaskEditorDescriptionPart part = new BugzillaTaskEditorDescriptionPart();
+ if (getModel().getTaskData().isNew()) {
+ part.setExpandVertically(true);
+ part.setSectionStyle(ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED);
+ }
+ return part;
+ }
+ }.setPath(PATH_COMMENTS));
+
+ }
if (hasPartComments) {
descriptors.add(new TaskEditorPartDescriptor(ID_PART_COMMENTS) {
@Override

Back to the top