Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-03-01 02:42:54 +0000
committerspingel2011-03-01 02:42:54 +0000
commita1bb29fe61cdbc38f1b5d5729176a7e649371d07 (patch)
tree1b0d3b23c01ba1e9bc9fcd5ac02896db0ac16f80 /org.eclipse.mylyn.tasks.ui
parentc7a25dc39530059036063865132ee6a8c2e01625 (diff)
downloadorg.eclipse.mylyn.tasks-a1bb29fe61cdbc38f1b5d5729176a7e649371d07.tar.gz
org.eclipse.mylyn.tasks-a1bb29fe61cdbc38f1b5d5729176a7e649371d07.tar.xz
org.eclipse.mylyn.tasks-a1bb29fe61cdbc38f1b5d5729176a7e649371d07.zip
ASSIGNED - bug 337908: Support custom attribute editor parts
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337908
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java28
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java79
2 files changed, 29 insertions, 78 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java
index 39bfe8260..ed1c66612 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttributePart.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFormUtil;
import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskDiffUtil;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
@@ -314,4 +315,31 @@ public class TaskEditorAttributePart extends AbstractTaskEditorSection {
};
}
+ @Override
+ public boolean setFormInput(Object input) {
+ if (input instanceof String) {
+ String text = (String) input;
+ Map<String, TaskAttribute> attributes = getTaskData().getRoot().getAttributes();
+ for (TaskAttribute attribute : attributes.values()) {
+ if (text.equals(attribute.getId())) {
+ TaskAttributeMetaData properties = attribute.getMetaData();
+ if (TaskAttribute.KIND_DEFAULT.equals(properties.getKind())) {
+ selectReveal(attribute);
+ }
+ }
+ }
+ }
+ return super.setFormInput(input);
+ }
+
+ public void selectReveal(TaskAttribute attribute) {
+ if (attribute == null) {
+ return;
+ }
+ if (!getSection().isExpanded()) {
+ CommonFormUtil.setExpanded(getSection(), true);
+ }
+ EditorUtil.reveal(getTaskEditorPage().getManagedForm().getForm(), attribute.getId());
+ }
+
}
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 d47b735e0..43c4028d9 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
@@ -93,7 +93,6 @@ import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
-import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
@@ -129,7 +128,6 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
@@ -144,7 +142,6 @@ import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.services.IDisposable;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
@@ -1758,81 +1755,7 @@ public abstract class AbstractTaskEditorPage extends TaskFormPage implements ISe
TaskEditorOutlineNode node = (TaskEditorOutlineNode) object;
TaskAttribute attribute = node.getData();
if (attribute != null) {
- if (TaskAttribute.TYPE_COMMENT.equals(attribute.getMetaData().getType())) {
- AbstractTaskEditorPart actionPart = this.getPart(AbstractTaskEditorPage.ID_PART_COMMENTS);
- if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
- CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
- if (actionPart.getControl() instanceof Section) {
- Control client = ((Section) actionPart.getControl()).getClient();
- if (client instanceof Composite) {
- for (Control control : ((Composite) client).getChildren()) {
- // toggle subsections
- if (control instanceof Section) {
- CommonFormUtil.setExpanded((Section) control, true);
- }
- }
- }
- }
- }
- EditorUtil.reveal(this.getManagedForm().getForm(), attribute.getId());
- return true;
- } else if (TaskAttribute.TYPE_ATTACHMENT.equals(attribute.getMetaData().getType())) {
- AbstractTaskEditorPart actionPart = this.getPart(AbstractTaskEditorPage.ID_PART_ATTACHMENTS);
- if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
- CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
- if (actionPart.getControl() instanceof Section) {
- Control client = actionPart.getControl();
- if (client instanceof Composite) {
- for (Control control : ((Composite) client).getChildren()) {
- if (control instanceof Composite) {
- for (Control control1 : ((Composite) control).getChildren()) {
- if (control1 instanceof org.eclipse.swt.widgets.Table) {
- org.eclipse.swt.widgets.Table attachmentTable = ((org.eclipse.swt.widgets.Table) control1);
- TableItem[] attachments = attachmentTable.getItems();
- int index = 0;
- for (TableItem attachment : attachments) {
- Object data = attachment.getData();
- if (data instanceof ITaskAttachment) {
- ITaskAttachment attachmentData = ((ITaskAttachment) data);
- if (attachmentData.getTaskAttribute() == attribute) {
- attachmentTable.deselectAll();
- attachmentTable.select(index);
- IManagedForm mform = actionPart.getManagedForm();
- ScrolledForm form = mform.getForm();
- EditorUtil.focusOn(form, attachmentTable);
- return true;
- }
- }
- index++;
- }
- }
- }
- }
- }
- }
- }
- }
- } else {
- AbstractTaskEditorPart actionPart = this.getPart(AbstractTaskEditorPage.ID_PART_ATTRIBUTES);
- Section section;
- if (actionPart instanceof AbstractTaskEditorSection) {
- section = ((AbstractTaskEditorSection) actionPart).getSection();
- } else {
- section = null;
- }
- if (section != null) {
- boolean expanded = section.isExpanded();
- if (!expanded && actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
- CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
- if (!expanded) {
- CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), false);
- }
- }
- }
-
- EditorUtil.reveal(this.getManagedForm().getForm(), attribute.getId());
- return true;
- }
+ super.selectReveal(attribute.getId());
} else {
TaskRelation taskRelation = node.getTaskRelation();
TaskRepository taskRepository = node.getTaskRepository();

Back to the top