From 48f530e5bb819f59ba975d317c5979f4f590cef3 Mon Sep 17 00:00:00 2001 From: relves Date: Thu, 12 Mar 2009 23:02:51 +0000 Subject: NEW - bug 268408: automatically select the last used Product when no selection is present https://bugs.eclipse.org/bugs/show_bug.cgi?id=268408 --- .../mylyn/internal/bugzilla/core/IBugzillaConstants.java | 2 ++ .../internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java | 10 +++++++++- .../internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java | 12 ++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) 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 0544d44cb..3794b4dd5 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 @@ -266,4 +266,6 @@ public interface IBugzillaConstants { public static final String TAG_BUGZILLA_CUSTOM_QUERY = "BugzillaCustomQuery"; //$NON-NLS-1$ public static final String CONTENT_ENCODING_GZIP = "gzip"; //$NON-NLS-1$ + + public static final String LAST_PRODUCT_SELECTION = "last.selection.product"; //$NON-NLS-1$ } 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 c4a888a88..56a855f55 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 @@ -167,7 +167,6 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { @Override public void doSubmit() { - TaskAttribute summaryAttribute = getModel().getTaskData().getRoot().getMappedAttribute(TaskAttribute.SUMMARY); if (summaryAttribute != null && summaryAttribute.getValue().length() == 0) { getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting, @@ -204,6 +203,15 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { return; } + if (getModel().getTaskData().isNew()) { + TaskAttribute productAttribute = getModel().getTaskData().getRoot().getMappedAttribute( + TaskAttribute.PRODUCT); + if (productAttribute != null && productAttribute.getValue().length() > 0) { + getModel().getTaskRepository().setProperty(IBugzillaConstants.LAST_PRODUCT_SELECTION, + productAttribute.getValue()); + } + } + // Force the most recent known good token onto the outgoing task data to ensure submit // bug#263318 TaskAttribute attrToken = getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.TOKEN.getKey()); diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java index 492586434..1b8e28212 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/wizard/NewBugzillaTaskWizard.java @@ -20,6 +20,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; +import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; import org.eclipse.mylyn.tasks.core.IRepositoryQuery; import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.tasks.core.ITaskMapping; @@ -66,8 +67,15 @@ public class NewBugzillaTaskWizard extends NewTaskWizard implements INewWizard { } } } - if (selection == null) { - return null; + if (selection == null || selection.isEmpty()) { + final String lastSelection = getTaskRepository().getProperty(IBugzillaConstants.LAST_PRODUCT_SELECTION); + return new TaskMapping() { + @Override + public String getProduct() { + return lastSelection; + } + }; + } final ArrayList products = new ArrayList(); -- cgit v1.2.3