Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java29
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStateReader.java9
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java15
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java52
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java40
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java16
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java87
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java57
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java10
9 files changed, 211 insertions, 104 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
index f8cb38b40..a92d0ff63 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
@@ -161,14 +161,17 @@ public class TaskDataManager implements ITaskDataManager {
public void execute(IProgressMonitor monitor) throws CoreException {
final File file = getFile(task, kind);
taskDataStore.putTaskData(ensurePathExists(file), state);
- task.setSynchronizationState(SynchronizationState.OUTGOING);
+ switch (task.getSynchronizationState()) {
+ case SYNCHRONIZED:
+ task.setSynchronizationState(SynchronizationState.OUTGOING);
+ }
taskList.addTask(task);
}
});
taskList.notifyElementChanged(task);
}
- public void putUpdatedTaskData(final ITask itask, final TaskData taskData, boolean user) throws CoreException {
+ public void putUpdatedTaskData(final ITask itask, final TaskData taskData, final boolean user) throws CoreException {
final AbstractTask task = (AbstractTask) itask;
Assert.isNotNull(task);
Assert.isNotNull(taskData);
@@ -183,7 +186,7 @@ public class TaskDataManager implements ITaskDataManager {
if (!taskData.isPartial()) {
File file = getMigratedFile(task, task.getConnectorKind());
newTask = !file.exists();
- taskDataStore.putTaskData(ensurePathExists(file), taskData, task.isMarkReadPending());
+ taskDataStore.putTaskData(ensurePathExists(file), taskData, task.isMarkReadPending(), user);
task.setMarkReadPending(false);
}
@@ -560,11 +563,27 @@ public class TaskDataManager implements ITaskDataManager {
}
}
- void putEdits(ITask task, TaskData editsData) throws CoreException {
+ void putEdits(final ITask itask, final TaskData editsData) throws CoreException {
+ final AbstractTask task = (AbstractTask) itask;
Assert.isNotNull(task);
final String kind = task.getConnectorKind();
Assert.isNotNull(editsData);
- taskDataStore.putEdits(getFile(task, kind), editsData);
+ taskList.run(new ITaskListRunnable() {
+ public void execute(IProgressMonitor monitor) throws CoreException {
+ taskDataStore.putEdits(getFile(task, kind), editsData);
+ switch (task.getSynchronizationState()) {
+ case INCOMING:
+ case INCOMING_NEW:
+ // TODO throw exception instead?
+ task.setSynchronizationState(SynchronizationState.CONFLICT);
+ break;
+ case SYNCHRONIZED:
+ task.setSynchronizationState(SynchronizationState.OUTGOING);
+ break;
+ }
+ }
+ });
+ taskList.notifySynchronizationStateChanged(task);
}
@Deprecated
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStateReader.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStateReader.java
index 55cbd61cd..22e80fd46 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStateReader.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStateReader.java
@@ -42,7 +42,10 @@ public class TaskDataStateReader extends DefaultHandler {
public void start(String uri, String localName, String name, Attributes attributes) throws SAXException {
// create a unique id for each attachment since the actual id is in a child attribute
attribute = createAttribute(parentAttribute, TaskAttribute.PREFIX_ATTACHMENT + ++id);
+ TaskAttributeProperties.defaults().setReadOnly(true).setType(TaskAttribute.TYPE_ATTACHMENT).applyTo(
+ attribute);
attribute.setValue(getValue(attributes, ITaskDataConstants.ATTRIBUTE_ID) + "");
+
TaskAttribute child = createAttribute(attribute, TaskAttribute.ATTACHMENT_AUTHOR);
child.setValue(getValue(attributes, ITaskDataConstants.ATTRIBUTE_CREATOR));
child.putMetaDataValue(TaskAttribute.META_ATTRIBUTE_TYPE, TaskAttribute.TYPE_PERSON);
@@ -149,9 +152,9 @@ public class TaskDataStateReader extends DefaultHandler {
@Override
public void start(String uri, String localName, String name, Attributes attributes) throws SAXException {
attribute = createAttribute(parentAttribute, TaskAttribute.PREFIX_COMMENT + ++id);
- attribute.setValue(getValue(attributes, ITaskDataConstants.ATTRIBUTE_NUMBER));
TaskAttributeProperties.defaults().setReadOnly(true).setType(TaskAttribute.TYPE_COMMENT).applyTo(attribute);
attribute.putMetaDataValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID, TaskAttribute.COMMENT_TEXT);
+ attribute.setValue(getValue(attributes, ITaskDataConstants.ATTRIBUTE_NUMBER));
TaskAttribute child = createAttribute(attribute, TaskAttribute.COMMENT_ATTACHMENT_ID);
child.setValue(getValue(attributes, ITaskDataConstants.ATTRIBUTE_ATTACHMENT_ID));
@@ -236,11 +239,11 @@ public class TaskDataStateReader extends DefaultHandler {
@Override
public void start(String uri, String localName, String name, Attributes attributes) throws SAXException {
attribute = createAttribute(parentAttribute, TaskAttribute.PREFIX_OPERATION + ++id);
- String operationId = getValue(attributes, ITaskDataConstants.ATTRIBUTE_KNOB_NAME);
- attribute.setValue(operationId);
attribute.putMetaDataValue(TaskAttribute.META_ATTRIBUTE_TYPE, TaskAttribute.TYPE_CONTAINER);
attribute.putMetaDataValue(TaskAttribute.META_LABEL, getValue(attributes,
ITaskDataConstants.ATTRIBUTE_OPERATION_NAME));
+ String operationId = getValue(attributes, ITaskDataConstants.ATTRIBUTE_KNOB_NAME);
+ attribute.setValue(operationId);
if (Boolean.parseBoolean(getValue(attributes, ITaskDataConstants.ATTRIBUTE_IS_CHECKED))) {
operationAttribute.setValue(operationId);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
index 82d3634bc..6a00530de 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
@@ -53,7 +53,6 @@ public class TaskDataStore {
public synchronized void putEdits(File file, TaskData data) throws CoreException {
Assert.isNotNull(file);
Assert.isNotNull(data);
-
TaskDataState state = readState(file);
if (state == null) {
state = new TaskDataState(data.getConnectorKind(), data.getRepositoryUrl(), data.getTaskId());
@@ -62,16 +61,22 @@ public class TaskDataStore {
writeState(file, state);
}
- public synchronized void putTaskData(File file, TaskData data, boolean setLastRead) throws CoreException {
+ public synchronized void putTaskData(File file, TaskData data, boolean setLastRead, boolean user)
+ throws CoreException {
Assert.isNotNull(file);
Assert.isNotNull(data);
-
TaskDataState state = null;
try {
state = readState(file);
} catch (CoreException e) {
- // FIME: now what? reading failed: purge user edits or propagate exception?
- e.printStackTrace();
+ if (!user) {
+ throw new CoreException(
+ new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ "Reading of existing task data failed. Forcing synchronization will override outgoing changes.",
+ e));
+ }
}
if (state == null) {
state = new TaskDataState(data.getConnectorKind(), data.getRepositoryUrl(), data.getTaskId());
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java
index 97b4a92c8..961ba9435 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttachmentMapper.java
@@ -28,15 +28,15 @@ public class TaskAttachmentMapper {
private Date creationDate;
- private boolean deprecated;
+ private Boolean deprecated;
private String description;
private String fileName;
- private long length;
+ private Long length;
- private boolean patch;
+ private Boolean patch;
private String url;
@@ -73,7 +73,7 @@ public class TaskAttachmentMapper {
return fileName;
}
- public long getLength() {
+ public Long getLength() {
return length;
}
@@ -81,11 +81,11 @@ public class TaskAttachmentMapper {
return url;
}
- public boolean isDeprecated() {
+ public Boolean isDeprecated() {
return deprecated;
}
- public boolean isPatch() {
+ public Boolean isPatch() {
return patch;
}
@@ -109,7 +109,7 @@ public class TaskAttachmentMapper {
this.creationDate = creationDate;
}
- public void setDeprecated(boolean deprecated) {
+ public void setDeprecated(Boolean deprecated) {
this.deprecated = deprecated;
}
@@ -121,11 +121,11 @@ public class TaskAttachmentMapper {
this.fileName = fileName;
}
- public void setLength(long length) {
+ public void setLength(Long length) {
this.length = length;
}
- public void setPatch(boolean patch) {
+ public void setPatch(Boolean patch) {
this.patch = patch;
}
@@ -213,19 +213,25 @@ public class TaskAttachmentMapper {
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_SHORT_TEXT).applyTo(child);
mapper.setValue(child, getFileName());
}
+ if (isDeprecated() != null) {
+ TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
+ TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
+ mapper.setBooleanValue(child, isDeprecated());
+ }
+ if (isPatch() != null) {
+ TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_PATCH);
+ TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
+ mapper.setBooleanValue(child, isPatch());
+ }
+ if (getLength() != null) {
+ TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_SIZE);
+ mapper.setLongValue(child, getLength());
+ }
if (getUrl() != null) {
TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_URL);
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_URL).applyTo(child);
mapper.setValue(child, getUrl());
}
- TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
- TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
- mapper.setBooleanValue(child, isDeprecated());
- child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_IS_PATCH);
- TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_BOOLEAN).applyTo(child);
- mapper.setBooleanValue(child, isPatch());
- child = taskAttribute.createAttribute(TaskAttribute.ATTACHMENT_SIZE);
- mapper.setLongValue(child, getLength());
}
public void applyTo(ITaskAttachment taskAttachment) {
@@ -245,12 +251,18 @@ public class TaskAttachmentMapper {
if (getFileName() != null) {
taskAttachment.setFileName(getFileName());
}
+ if (isDeprecated() != null) {
+ taskAttachment.setDeprecated(isDeprecated());
+ }
+ if (isPatch() != null) {
+ taskAttachment.setPatch(isPatch());
+ }
+ if (getLength() != null) {
+ taskAttachment.setLength(getLength());
+ }
if (url != null) {
taskAttachment.setUrl(getUrl());
}
- taskAttachment.setDeprecated(isDeprecated());
- taskAttachment.setPatch(isPatch());
- taskAttachment.setLength(getLength());
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
index 3f8815963..91101c731 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
@@ -23,7 +23,6 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
* @author Steffen Pingel
* @since 3.0
*/
-// TODO EDITOR return null if attribute value invalid for primitive types?
public class TaskAttributeMapper {
private final TaskRepository taskRepository;
@@ -47,10 +46,21 @@ public class TaskAttributeMapper {
public TaskAttribute getAssoctiatedAttribute(TaskAttribute taskAttribute) {
String id = taskAttribute.getMetaData(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID);
if (id != null) {
- if (TaskAttribute.TYPE_OPERATION.equals(TaskAttributeProperties.from(taskAttribute).getType())) {
- return taskAttribute.getTaskData().getRoot().getAttribute(id);
+ // look up as nested attribute first
+ TaskAttribute associatedAttribute = taskAttribute.getAttribute(id);
+ if (associatedAttribute != null) {
+ return associatedAttribute;
}
- return taskAttribute.getAttribute(id);
+ // fall back to root
+ return taskAttribute.getTaskData().getRoot().getAttribute(id);
+ }
+ return null;
+ }
+
+ public TaskAttribute getAssoctiatedAttribute(TaskOperation taskOperation) {
+ TaskAttribute taskAttribute = taskOperation.getTaskAttribute();
+ if (taskAttribute != null) {
+ return getAssoctiatedAttribute(taskAttribute);
}
return null;
}
@@ -135,7 +145,21 @@ public class TaskAttributeMapper {
return person;
}
- public TaskOperation getTaskOperation(TaskAttribute taskAttribute) {
+ public TaskOperation[] getTaskOperations(TaskAttribute operationsAttribute) {
+ Assert.isNotNull(operationsAttribute);
+ TaskData taskData = operationsAttribute.getTaskData();
+ List<TaskOperation> result = new ArrayList<TaskOperation>();
+ for (TaskAttribute taskAttribute : taskData.getRoot().getAttributes().values()) {
+ if (TaskAttribute.TYPE_OPERATION.equals(taskAttribute.getProperties().getType())
+ && !taskAttribute.getId().equals(mapToRepositoryKey(taskData.getRoot(), TaskAttribute.OPERATION))) {
+ result.add(TaskOperation.createFrom(taskAttribute));
+ }
+ }
+ return result.toArray(new TaskOperation[0]);
+ }
+
+ public TaskOperation getTaskOperationValue(TaskAttribute taskAttribute) {
+ Assert.isNotNull(taskAttribute);
return TaskOperation.createFrom(taskAttribute);
}
@@ -226,8 +250,10 @@ public class TaskAttributeMapper {
}
}
- public void setTaskOperation(TaskAttribute taskAttribute, TaskOperation taskOperation) {
- taskOperation.applyTo(taskAttribute);
+ public void setTaskOperationValue(TaskAttribute taskAttribute, TaskOperation taskOperation) {
+ Assert.isNotNull(taskAttribute);
+ Assert.isNotNull(taskOperation);
+ TaskOperation.applyTo(taskAttribute, taskOperation.getOperationId(), taskOperation.getLabel());
}
public void setValue(TaskAttribute attribute, String value) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java
index 735a1264c..f60e68187 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskCommentMapper.java
@@ -23,15 +23,13 @@ import org.eclipse.mylyn.tasks.core.ITaskComment;
*/
public class TaskCommentMapper {
- private static final int DEFAULT_NUMBER = -1;
-
private IRepositoryPerson author;
private String commentId;
private Date creationDate;
- private int number;
+ private Integer number;
private String text;
@@ -52,7 +50,7 @@ public class TaskCommentMapper {
return creationDate;
}
- public int getNumber() {
+ public Integer getNumber() {
return number;
}
@@ -76,7 +74,7 @@ public class TaskCommentMapper {
this.creationDate = creationDate;
}
- public void setNumber(int number) {
+ public void setNumber(Integer number) {
this.number = number;
}
@@ -88,6 +86,7 @@ public class TaskCommentMapper {
this.url = url;
}
+ @SuppressWarnings("deprecation")
public static TaskCommentMapper createFrom(TaskAttribute taskAttribute) {
Assert.isNotNull(taskAttribute);
TaskData taskData = taskAttribute.getTaskData();
@@ -111,8 +110,7 @@ public class TaskCommentMapper {
}
child = taskAttribute.getMappedAttribute(TaskAttribute.COMMENT_NUMBER);
if (child != null) {
- Integer value = mapper.getIntegerValue(child);
- comment.setNumber((value != null) ? value : DEFAULT_NUMBER);
+ comment.setNumber(mapper.getIntegerValue(child));
}
child = taskAttribute.getMappedAttribute(TaskAttribute.COMMENT_URL);
if (child != null) {
@@ -143,7 +141,7 @@ public class TaskCommentMapper {
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_DATE).applyTo(child);
mapper.setDateValue(child, getCreationDate());
}
- if (getNumber() != DEFAULT_NUMBER) {
+ if (getNumber() != null) {
TaskAttribute child = taskAttribute.createAttribute(TaskAttribute.COMMENT_NUMBER);
TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_INTEGER).applyTo(child);
mapper.setIntegerValue(child, getNumber());
@@ -169,7 +167,7 @@ public class TaskCommentMapper {
if (getCreationDate() != null) {
taskComment.setCreationDate(getCreationDate());
}
- if (getNumber() != DEFAULT_NUMBER) {
+ if (getNumber() != null) {
taskComment.setNumber(getNumber());
}
if (getUrl() != null) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java
index f16585f0f..45aa6e9bd 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskOperation.java
@@ -17,6 +17,23 @@ import org.eclipse.core.runtime.Assert;
*/
public class TaskOperation {
+ public static void applyTo(TaskAttribute taskAttribute, String operationId, String label) {
+ TaskData taskData = taskAttribute.getTaskData();
+ taskData.getAttributeMapper().setValue(taskAttribute, operationId);
+ TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_OPERATION).setLabel(label).applyTo(taskAttribute);
+ }
+
+ public static TaskOperation createFrom(TaskAttribute taskAttribute) {
+ Assert.isNotNull(taskAttribute);
+ TaskData taskData = taskAttribute.getTaskData();
+ TaskOperation operation = new TaskOperation(taskData.getRepositoryUrl(), taskData.getConnectorKind(),
+ taskData.getTaskId(), taskAttribute.getValue());
+ TaskAttributeProperties properties = TaskAttributeProperties.from(taskAttribute);
+ operation.setLabel(properties.getLabel());
+ operation.setTaskAttribute(taskAttribute);
+ return operation;
+ }
+
private final String connectorKind;
private String label;
@@ -25,15 +42,48 @@ public class TaskOperation {
private final String repositoryUrl;
+ private TaskAttribute taskAttribute;
+
private final String taskId;
public TaskOperation(String connectorKind, String repositoryUrl, String taskId, String operationId) {
+ Assert.isNotNull(connectorKind);
+ Assert.isNotNull(repositoryUrl);
+ Assert.isNotNull(taskId);
+ Assert.isNotNull(operationId);
this.connectorKind = connectorKind;
this.repositoryUrl = repositoryUrl;
this.taskId = taskId;
this.operationId = operationId;
}
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TaskOperation other = (TaskOperation) obj;
+ if (!connectorKind.equals(other.connectorKind)) {
+ return false;
+ }
+ if (!operationId.equals(other.operationId)) {
+ return false;
+ }
+ if (!repositoryUrl.equals(other.repositoryUrl)) {
+ return false;
+ }
+ if (!taskId.equals(other.taskId)) {
+ return false;
+ }
+ return true;
+ }
+
public String getConnectorKind() {
return connectorKind;
}
@@ -50,34 +100,31 @@ public class TaskOperation {
return repositoryUrl;
}
- public String getTaskId() {
- return taskId;
+ public TaskAttribute getTaskAttribute() {
+ return taskAttribute;
}
- public void setLabel(String label) {
- this.label = label;
+ public String getTaskId() {
+ return taskId;
}
- public static TaskOperation createFrom(TaskAttribute taskAttribute, String operationId) {
- Assert.isNotNull(taskAttribute);
- Assert.isNotNull(operationId);
- TaskData taskData = taskAttribute.getTaskData();
- TaskOperation operation = new TaskOperation(taskData.getRepositoryUrl(), taskData.getConnectorKind(),
- taskData.getTaskId(), operationId);
- TaskAttributeProperties properties = TaskAttributeProperties.from(taskAttribute);
- operation.setLabel(properties.getLabel());
- return operation;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + connectorKind.hashCode();
+ result = prime * result + operationId.hashCode();
+ result = prime * result + repositoryUrl.hashCode();
+ result = prime * result + taskId.hashCode();
+ return result;
}
- public static TaskOperation createFrom(TaskAttribute taskAttribute) {
- return createFrom(taskAttribute, taskAttribute.getValue());
+ public void setLabel(String label) {
+ this.label = label;
}
- public void applyTo(TaskAttribute taskAttribute) {
- TaskData taskData = taskAttribute.getTaskData();
- taskData.getAttributeMapper().setValue(taskAttribute, getOperationId());
- TaskAttributeProperties.defaults().setType(TaskAttribute.TYPE_OPERATION).setLabel(getLabel()).applyTo(
- taskAttribute);
+ public void setTaskAttribute(TaskAttribute taskAttribute) {
+ this.taskAttribute = taskAttribute;
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
index 28f20ce35..7ddb309a0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
@@ -22,7 +22,6 @@ import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.ITaskElement;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
-import org.eclipse.mylyn.tasks.core.data.TaskAttributeProperties;
import org.eclipse.mylyn.tasks.core.data.TaskOperation;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
@@ -52,7 +51,7 @@ public class TaskEditorActionPart extends AbstractTaskEditorPart {
public void widgetSelected(SelectionEvent event) {
setSelectedRadionButton((Button) event.widget);
TaskOperation taskOperation = (TaskOperation) event.widget.getData(KEY_OPERATION);
- getTaskData().getAttributeMapper().setTaskOperation(selectedOperationAttribute, taskOperation);
+ getTaskData().getAttributeMapper().setTaskOperationValue(selectedOperationAttribute, taskOperation);
getModel().attributeChanged(selectedOperationAttribute);
}
@@ -211,9 +210,10 @@ public class TaskEditorActionPart extends AbstractTaskEditorPart {
selectedOperationAttribute = getTaskData().getMappedAttribute(TaskAttribute.OPERATION);
if (selectedOperationAttribute != null
- && TaskAttribute.TYPE_OPERATION.equals(TaskAttributeProperties.from(selectedOperationAttribute)
- .getType())) {
- createRadioButtons(buttonComposite, toolkit);
+ && TaskAttribute.TYPE_OPERATION.equals(selectedOperationAttribute.getProperties().getType())) {
+ TaskOperation selectedOperation = getTaskData().getAttributeMapper().getTaskOperationValue(
+ selectedOperationAttribute);
+ createRadioButtons(buttonComposite, toolkit, selectedOperation);
}
createActionButtons(buttonComposite, toolkit);
@@ -242,34 +242,29 @@ public class TaskEditorActionPart extends AbstractTaskEditorPart {
}
}
- private void createRadioButtons(Composite buttonComposite, FormToolkit toolkit) {
- TaskAttribute[] attributes = getTaskData().getAttributeMapper().getAttributesByType(getTaskData(),
- TaskAttribute.TYPE_OPERATION);
- if (attributes.length > 0) {
+ private void createRadioButtons(Composite buttonComposite, FormToolkit toolkit, TaskOperation selectedOperation) {
+ TaskOperation[] operations = getTaskData().getAttributeMapper().getTaskOperations(selectedOperationAttribute);
+ if (operations.length > 0) {
operationButtons = new ArrayList<Button>();
Button selectedButton = null;
- for (TaskAttribute attribute : attributes) {
- TaskOperation operation = getTaskData().getAttributeMapper().getTaskOperation(attribute);
- if (operation != null) {
- Button button = toolkit.createButton(buttonComposite, operation.getLabel(), SWT.RADIO);
- button.setFont(TEXT_FONT);
- button.setData(KEY_OPERATION, operation);
- GridData radioData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- TaskAttribute associatedAttribute = getTaskData().getAttributeMapper().getAssoctiatedAttribute(
- attribute);
- if (associatedAttribute != null) {
- radioData.horizontalSpan = 1;
- addAttribute(buttonComposite, toolkit, associatedAttribute, button);
- } else {
- radioData.horizontalSpan = 4;
- }
- button.setLayoutData(radioData);
- button.addSelectionListener(new RadioButtonListener());
- operationButtons.add(button);
-
- if (getTaskData().getAttributeMapper().equals(attribute, selectedOperationAttribute)) {
- selectedButton = button;
- }
+ for (TaskOperation operation : operations) {
+ Button button = toolkit.createButton(buttonComposite, operation.getLabel(), SWT.RADIO);
+ button.setFont(TEXT_FONT);
+ button.setData(KEY_OPERATION, operation);
+ GridData radioData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ TaskAttribute associatedAttribute = getTaskData().getAttributeMapper().getAssoctiatedAttribute(
+ operation);
+ if (associatedAttribute != null) {
+ radioData.horizontalSpan = 1;
+ addAttribute(buttonComposite, toolkit, associatedAttribute, button);
+ } else {
+ radioData.horizontalSpan = 4;
+ }
+ button.setLayoutData(radioData);
+ button.addSelectionListener(new RadioButtonListener());
+ operationButtons.add(button);
+ if (operation.equals(selectedOperation)) {
+ selectedButton = button;
}
}
// do this last to ensure only a single button is selected
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java
index b4f989560..394a46808 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java
@@ -834,10 +834,12 @@ public abstract class AbstractTaskEditorPage extends FormPage implements ISelect
getManagedForm().addPart(part);
part.initialize(this);
part.createControl(parent, toolkit);
- if (ID_PART_NEW_COMMENT.equals(part.getPartId())) {
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(part.getControl());
- } else {
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(part.getControl());
+ if (part.getControl() != null) {
+ if (ID_PART_NEW_COMMENT.equals(part.getPartId())) {
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(part.getControl());
+ } else {
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(part.getControl());
+ }
}
}

Back to the top