diff options
author | Frank Becker | 2012-02-08 19:59:54 +0000 |
---|---|---|
committer | Frank Becker | 2012-02-08 19:59:54 +0000 |
commit | 06b60fa726bcd610fb5d64fce6cfda07130fde32 (patch) | |
tree | a9c4e94dab5e25f6b7b08fb3593ba574d9dc9756 | |
parent | 1ed0499f33860264f9efd2e8e6824b7a28440df0 (diff) | |
download | org.eclipse.mylyn.tasks-06b60fa726bcd610fb5d64fce6cfda07130fde32.tar.gz org.eclipse.mylyn.tasks-06b60fa726bcd610fb5d64fce6cfda07130fde32.tar.xz org.eclipse.mylyn.tasks-06b60fa726bcd610fb5d64fce6cfda07130fde32.zip |
ASSIGNED - bug 168204: [patch] support bugzilla's usermatchmode for
matching names to email addresses
https://bugs.eclipse.org/bugs/show_bug.cgi?id=168204
UI Part
Change-Id: I3ccd86f6a304dcd9be8e2b7b924ae53a3a22f793
10 files changed, 345 insertions, 82 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java index e35eb2dde..0e7a49511 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaUserMatchResponse.java @@ -94,6 +94,7 @@ public class BugzillaUserMatchResponse { && divClass.equals("user_match")) { //$NON-NLS-1$ value = ((HtmlTag) (token.getValue())).getAttribute("value"); //$NON-NLS-1$ name = ((HtmlTag) (token.getValue())).getAttribute("name"); //$NON-NLS-1$ + value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ if (name.equals("newcc")) { //$NON-NLS-1$ newCCProposals.add(value); } else if (name.equals("assigned_to")) { //$NON-NLS-1$ @@ -110,6 +111,7 @@ public class BugzillaUserMatchResponse { && !((HtmlTag) (token.getValue())).isEndTag() && divClass != null && divClass.equals("user_match")) { //$NON-NLS-1$ value = ((HtmlTag) (token.getValue())).getAttribute("value"); //$NON-NLS-1$ + value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ if (name.equals("newcc")) { //$NON-NLS-1$ newCCProposals.add(value); } else if (name.equals("assigned_to")) { //$NON-NLS-1$ @@ -257,6 +259,7 @@ public class BugzillaUserMatchResponse { int endText = divString.indexOf("<", startText + 1); //$NON-NLS-1$ String temp = divString.substring(startText, endText); value = divString.substring(5, start) + temp; + value = value.replace("@", "@"); //$NON-NLS-1$ //$NON-NLS-2$ if (lastDTValue.equals("newcc")) { //$NON-NLS-1$ newCCMsg = value; } else if (lastDTValue.equals("assigned_to")) { //$NON-NLS-1$ 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 3251cda7b..439cb45f6 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 @@ -15,6 +15,7 @@ import java.io.File; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -1192,8 +1193,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { public void testErrorMatchFailedToShort() throws Exception { try { doUserMatch("st", null); + fail("CoreException expected but not found"); } catch (CoreException e) { - assertNotNull(e.getStatus()); assertEquals(BugzillaStatus.ERROR_MATCH_FAILED, e.getStatus().getCode()); BugzillaStatus status = (BugzillaStatus) e.getStatus(); assertNotNull(status); @@ -1220,8 +1221,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { public void testErrorMatchConfirmMatch() throws Exception { try { doUserMatch("est", null); + fail("CoreException expected but not found"); } catch (CoreException e) { - assertNotNull(e.getStatus()); if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_6) < 0) { assertEquals(BugzillaStatus.ERROR_MATCH_FAILED, e.getStatus().getCode()); BugzillaStatus status = (BugzillaStatus) e.getStatus(); @@ -1231,9 +1232,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(0, matchUserResponse.getNewCCProposals().size()); - assertEquals(0, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); assertNull(matchUserResponse.getAssignedToMsg()); assertNull(matchUserResponse.getQaContactMsg()); @@ -1248,8 +1249,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); assertEquals(2, matchUserResponse.getNewCCProposals().size()); - assertEquals(0, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertTrue(matchUserResponse.getNewCCProposals().contains("tests@mylyn.eclipse.org")); assertTrue(matchUserResponse.getNewCCProposals().contains("guest@mylyn.eclipse.org")); assertNull(matchUserResponse.getNewCCMsg()); @@ -1262,8 +1263,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { public void testErrorMatchConfirmMatch2() throws Exception { try { doUserMatch(null, "est"); + fail("CoreException expected but not found"); } catch (CoreException e) { - assertNotNull(e.getStatus()); if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_6) < 0) { assertEquals(BugzillaStatus.ERROR_MATCH_FAILED, e.getStatus().getCode()); BugzillaStatus status = (BugzillaStatus) e.getStatus(); @@ -1273,9 +1274,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(0, matchUserResponse.getNewCCProposals().size()); - assertEquals(0, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNull(matchUserResponse.getNewCCMsg()); assertNotNull(matchUserResponse.getAssignedToMsg()); assertNull(matchUserResponse.getQaContactMsg()); @@ -1289,9 +1290,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(0, matchUserResponse.getNewCCProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); assertEquals(2, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertTrue(matchUserResponse.getAssignedToProposals().contains("tests@mylyn.eclipse.org")); assertTrue(matchUserResponse.getAssignedToProposals().contains("guest@mylyn.eclipse.org")); assertNull(matchUserResponse.getNewCCMsg()); @@ -1304,8 +1305,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { public void testErrorMatchConfirmMatch3() throws Exception { try { doUserMatch("test", "est"); + fail("CoreException expected but not found"); } catch (CoreException e) { - assertNotNull(e.getStatus()); if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_6) < 0) { assertEquals(BugzillaStatus.ERROR_MATCH_FAILED, e.getStatus().getCode()); BugzillaStatus status = (BugzillaStatus) e.getStatus(); @@ -1315,9 +1316,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(0, matchUserResponse.getNewCCProposals().size()); - assertEquals(0, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); assertNotNull(matchUserResponse.getAssignedToMsg()); assertNull(matchUserResponse.getQaContactMsg()); @@ -1334,7 +1335,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getQaContactProposals()); assertEquals(1, matchUserResponse.getNewCCProposals().size()); assertEquals(2, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertTrue(matchUserResponse.getNewCCProposals().contains("tests@mylyn.eclipse.org")); assertTrue(matchUserResponse.getAssignedToProposals().contains("tests@mylyn.eclipse.org")); assertTrue(matchUserResponse.getAssignedToProposals().contains("guest@mylyn.eclipse.org")); @@ -1347,9 +1348,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { public void testErrorMatchFailed() throws Exception { try { - doUserMatch("teste", null); + doUserMatch("tests1@mylyn.eclipse.org", null); + fail("CoreException expected but not found"); } catch (CoreException e) { - assertNotNull(e.getStatus()); assertEquals(BugzillaStatus.ERROR_MATCH_FAILED, e.getStatus().getCode()); BugzillaStatus status = (BugzillaStatus) e.getStatus(); assertNotNull(status); @@ -1358,21 +1359,21 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(0, matchUserResponse.getNewCCProposals().size()); - assertEquals(0, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); assertNull(matchUserResponse.getAssignedToMsg()); assertNull(matchUserResponse.getQaContactMsg()); - assertTrue(matchUserResponse.getNewCCMsg().equals("teste did not match anything ")); + assertTrue(matchUserResponse.getNewCCMsg().equals("tests1@mylyn.eclipse.org did not match anything ")); } } public void testErrorMatchFailed2() throws Exception { try { doUserMatch("est", "test1"); + fail("CoreException expected but not found"); } catch (CoreException e) { - assertNotNull(e.getStatus()); if (BugzillaFixture.current().getBugzillaVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_6) < 0) { assertEquals(BugzillaStatus.ERROR_MATCH_FAILED, e.getStatus().getCode()); BugzillaStatus status = (BugzillaStatus) e.getStatus(); @@ -1382,9 +1383,9 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getNewCCProposals()); assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); - assertEquals(0, matchUserResponse.getNewCCProposals().size()); - assertEquals(0, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getNewCCProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertNotNull(matchUserResponse.getNewCCMsg()); assertNotNull(matchUserResponse.getAssignedToMsg()); assertNull(matchUserResponse.getQaContactMsg()); @@ -1400,8 +1401,8 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest { assertNotNull(matchUserResponse.getAssignedToProposals()); assertNotNull(matchUserResponse.getQaContactProposals()); assertEquals(2, matchUserResponse.getNewCCProposals().size()); - assertEquals(0, matchUserResponse.getAssignedToProposals().size()); - assertEquals(0, matchUserResponse.getQaContactProposals().size()); + assertEquals(Collections.emptyList(), matchUserResponse.getAssignedToProposals()); + assertEquals(Collections.emptyList(), matchUserResponse.getQaContactProposals()); assertTrue(matchUserResponse.getNewCCProposals().contains("tests@mylyn.eclipse.org")); assertTrue(matchUserResponse.getNewCCProposals().contains("guest@mylyn.eclipse.org")); assertNull(matchUserResponse.getNewCCMsg()); diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaPeoplePart.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaPeoplePart.java index d488f5177..7a1cbe0ca 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaPeoplePart.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaPeoplePart.java @@ -68,6 +68,7 @@ public class BugzillaPeoplePart extends AbstractTaskEditorPart { Composite peopleComposite = toolkit.createComposite(section); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 5; + layout.horizontalSpacing = 10; peopleComposite.setLayout(layout); addAttribute(peopleComposite, toolkit, getTaskData().getRoot().getMappedAttribute(TaskAttribute.USER_ASSIGNED)); diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaResponseDetailDialog.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaResponseDetailDialog.java index 1ddeb9cb6..2ba291289 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaResponseDetailDialog.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaResponseDetailDialog.java @@ -11,12 +11,7 @@ package org.eclipse.mylyn.internal.bugzilla.ui.editor; -import java.util.List; -import java.util.Map; - import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryResponse; -import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -27,17 +22,20 @@ import org.eclipse.swt.widgets.Text; public class BugzillaResponseDetailDialog extends Dialog { - private final BugzillaRepositoryResponse response; + private final String titleText; + + private final String messageText; - public BugzillaResponseDetailDialog(Shell parentShell, BugzillaRepositoryResponse response) { + public BugzillaResponseDetailDialog(Shell parentShell, String titleText, String messageText) { super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); - this.response = response; + this.titleText = titleText; + this.messageText = messageText; } @Override protected Control createDialogArea(Composite parent) { - getShell().setText(Messages.BugzillaResponseDetailDialog_Titel); + getShell().setText(titleText); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); @@ -50,24 +48,7 @@ public class BugzillaResponseDetailDialog extends Dialog { gd.widthHint = 300; text.setLayoutData(gd); text.setEditable(false); - - String mes = ""; //$NON-NLS-1$ - for (String iterable_map : response.getResponseData().keySet()) { - if (mes.length() > 0) { - mes += "\n"; //$NON-NLS-1$ - } - mes += NLS.bind(Messages.BugzillaResponseDetailDialog_Bug_Line, iterable_map); - Map<String, List<String>> responseMap = response.getResponseData().get(iterable_map); - for (String iterable_list : responseMap.keySet()) { - mes += NLS.bind(Messages.BugzillaResponseDetailDialog_Action_Line, iterable_list); - List<String> responseList = responseMap.get(iterable_list); - for (String string : responseList) { - mes += NLS.bind(Messages.BugzillaResponseDetailDialog_Email_Line, string); - } - } - - } - text.setText(mes); + text.setText(messageText); parent.pack(); applyDialogFont(composite); return composite; 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 cdfd33f4c..65587f50f 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 @@ -11,6 +11,8 @@ package org.eclipse.mylyn.internal.bugzilla.ui.editor; +import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -21,6 +23,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; import org.eclipse.mylyn.commons.core.StatusHandler; import org.eclipse.mylyn.commons.net.AuthenticationCredentials; import org.eclipse.mylyn.commons.net.AuthenticationType; @@ -31,11 +36,15 @@ import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaOperation; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryResponse; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaStatus; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaUserMatchResponse; import org.eclipse.mylyn.internal.bugzilla.core.BugzillaVersion; import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants; import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration; import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaUiPlugin; +import org.eclipse.mylyn.internal.tasks.ui.PersonProposalProvider; +import org.eclipse.mylyn.internal.tasks.ui.editors.PersonAttributeEditor; import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorActionPart; import org.eclipse.mylyn.tasks.core.RepositoryResponse; import org.eclipse.mylyn.tasks.core.RepositoryStatus; @@ -57,12 +66,20 @@ import org.eclipse.mylyn.tasks.ui.editors.LayoutHint; import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.widgets.Control; 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.keys.IBindingService; /** * @author Rob Elves + * @author Frank Becker * @since 3.0 */ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { @@ -77,6 +94,10 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { private TaskDataModelListener productListener; + private final List<ControlDecoration> errorDecorations = new ArrayList<ControlDecoration>(); + + private final List<PersonAttributeEditor> editorsWithError = new ArrayList<PersonAttributeEditor>(3); + public BugzillaTaskEditorPage(TaskEditor editor) { this(editor, BugzillaCorePlugin.CONNECTOR_KIND); } @@ -328,6 +349,12 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { attrToken.setValue(tokenString); } } + for (ControlDecoration decoration : errorDecorations) { + decoration.hide(); + decoration.dispose(); + } + errorDecorations.clear(); + editorsWithError.clear(); if (!checkCanSubmit(IMessageProvider.ERROR)) { return; } @@ -497,7 +524,15 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { @Override protected void handleTaskSubmitted(SubmitJobEvent event) { - if (event.getJob().getResponse() != null && event.getJob().getResponse() instanceof BugzillaRepositoryResponse) { + if (event.getJob().getStatus() != null) { + switch (event.getJob().getStatus().getCode()) { + case BugzillaStatus.ERROR_CONFIRM_MATCH: + case BugzillaStatus.ERROR_MATCH_FAILED: + showError((BugzillaStatus) event.getJob().getStatus()); + break; + } + } else if (event.getJob().getResponse() != null + && event.getJob().getResponse() instanceof BugzillaRepositoryResponse) { final RepositoryResponse response = event.getJob().getResponse(); if (response instanceof BugzillaRepositoryResponse) { final BugzillaRepositoryResponse bugzillaResponse = (BugzillaRepositoryResponse) response; @@ -506,10 +541,9 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { IMessageProvider.INFORMATION, new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent event) { - BugzillaResponseDetailDialog dialog = new BugzillaResponseDetailDialog( - WorkbenchUtil.getShell(), bugzillaResponse); - dialog.open(); + showSubmitResponse(bugzillaResponse); } + }); } else { getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Changes_Submitted_Message, @@ -567,4 +601,170 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage { } return true; } + + private void showError(BugzillaStatus bugzillaStatus) { + int count = 0; + BugzillaUserMatchResponse response = bugzillaStatus.getUserMatchResponse(); + FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); + FieldDecoration fieldDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); + StringBuilder fields = new StringBuilder(); + StringBuilder detail = new StringBuilder(); + + count += decorateControlsAndUpdateMessages(response.getAssignedToMsg(), response.getAssignedToProposals(), + getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.ASSIGNED_TO.getKey()), fields, + detail, fieldDecoration); + count += decorateControlsAndUpdateMessages(response.getQaContactMsg(), response.getQaContactProposals(), + getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.QA_CONTACT.getKey()), fields, detail, + fieldDecoration); + count += decorateControlsAndUpdateMessages(response.getNewCCMsg(), response.getNewCCProposals(), + getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.NEWCC.getKey()), fields, detail, + fieldDecoration); + updateTaskEditorPageMessageWithError(bugzillaStatus, detail.toString(), count == 1, fields.toString()); + } + + private int decorateControlsAndUpdateMessages(String message, List<String> proposals, TaskAttribute attribute, + StringBuilder fields, StringBuilder detail, FieldDecoration fieldDecoration) { + if (attribute == null || (message == null && proposals.size() == 0)) { + return 0; + } + Map<String, String> newPersonProposalMap = new HashMap<String, String>(); + if (fields.length() > 0) { + fields.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_Error_Label_N, attribute.getMetaData() + .getLabel())); + } else { + fields.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_Error_Label_1, attribute.getMetaData() + .getLabel())); + } + detail.append(attribute.getMetaData().getLabel() + "\n"); //$NON-NLS-1$ + if (message != null && !message.equals("")) { //$NON-NLS-1$ + detail.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_DetailLine, message)); + } else { + for (String proposalValue : proposals) { + detail.append(MessageFormat.format(Messages.BugzillaTaskEditorPage_DetailLine, proposalValue)); + newPersonProposalMap.put(proposalValue, proposalValue); + } + } + AbstractAttributeEditor editor = getEditorForAttribute(attribute); + if (editor != null) { + decorateEditorWithError(fieldDecoration, message, newPersonProposalMap, editor); + } + return 1; + } + + /** + * @param bugzillaStatus + * @param resultDetail + * @param oneError + * @param fieldString + */ + private void updateTaskEditorPageMessageWithError(BugzillaStatus bugzillaStatus, String resultDetail, + boolean oneError, String fieldString) { + String resultString; + final String titleString; + switch (bugzillaStatus.getCode()) { + case BugzillaStatus.ERROR_CONFIRM_MATCH: + if (oneError) { + resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_one, + Messages.BugzillaTaskEditorPage_Confirm, fieldString); + } else { + resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_more, + Messages.BugzillaTaskEditorPage_Confirm, fieldString); + } + titleString = Messages.BugzillaTaskEditorPage_Confirm + Messages.BugzillaTaskEditorPage_match_Detail; + break; + case BugzillaStatus.ERROR_MATCH_FAILED: + if (oneError) { + resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_one, + Messages.BugzillaTaskEditorPage_Error, fieldString); + } else { + resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_more, + Messages.BugzillaTaskEditorPage_Error, fieldString); + } + titleString = Messages.BugzillaTaskEditorPage_Confirm + Messages.BugzillaTaskEditorPage_match_Detail; + break; + default: + resultString = ""; //$NON-NLS-1$ + titleString = ""; //$NON-NLS-1$ + break; + } + + final String resultDetailString = resultDetail; + getTaskEditor().setMessage(resultString, IMessageProvider.ERROR, new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent event) { + BugzillaResponseDetailDialog dialog = new BugzillaResponseDetailDialog(WorkbenchUtil.getShell(), + titleString, resultDetailString); + dialog.open(); + } + }); + } + + /** + * @param fieldDecoration + * @param message + * @param newPersonProposalMap + * @param editor + */ + private void decorateEditorWithError(FieldDecoration fieldDecoration, String message, + Map<String, String> newPersonProposalMap, AbstractAttributeEditor editor) { + final Control control = editor.getControl(); + + final ControlDecoration decoration = new ControlDecoration(control, SWT.LEFT | SWT.DOWN); + decoration.setImage(fieldDecoration.getImage()); + IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class); + if (message != null && !message.equals("")) { //$NON-NLS-1$ + decoration.setDescriptionText(message); + errorDecorations.add(decoration); + } else { + decoration.setDescriptionText(NLS.bind( + Messages.BugzillaTaskEditorPage_Content_Assist_for_Error_Available, + bindingService.getBestActiveBindingFormattedFor(ContentAssistCommandAdapter.CONTENT_PROPOSAL_COMMAND))); + errorDecorations.add(decoration); + + PersonAttributeEditor personEditor = ((PersonAttributeEditor) editor); + final PersonProposalProvider personProposalProvider = (PersonProposalProvider) personEditor.getContentAssistCommandAdapter() + .getContentProposalProvider(); + personProposalProvider.setErrorProposals(newPersonProposalMap); + + editorsWithError.add(personEditor); + if (newPersonProposalMap.size() == 1) { + personEditor.setValue(newPersonProposalMap.keySet().iterator().next()); + + } + personEditor.getText().addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + decoration.hide(); + errorDecorations.remove(decoration); + decoration.dispose(); + personProposalProvider.setErrorProposals(null); + } + }); + } + } + + /** + * @param bugzillaResponse + */ + private void showSubmitResponse(final BugzillaRepositoryResponse bugzillaResponse) { + StringBuilder message = new StringBuilder(); + for (String iterable_map : bugzillaResponse.getResponseData().keySet()) { + if (message.length() > 0) { + message.append("\n"); //$NON-NLS-1$ + } + message.append(NLS.bind(Messages.BugzillaTaskEditorPage_Bug_Line, iterable_map)); + Map<String, List<String>> responseMap = bugzillaResponse.getResponseData().get(iterable_map); + for (String iterable_list : responseMap.keySet()) { + message.append(NLS.bind(Messages.BugzillaTaskEditorPage_Action_Line, iterable_list)); + List<String> responseList = responseMap.get(iterable_list); + for (String string : responseList) { + message.append(NLS.bind(Messages.BugzillaTaskEditorPage_Email_Line, string)); + } + } + } + BugzillaResponseDetailDialog dialog = new BugzillaResponseDetailDialog(WorkbenchUtil.getShell(), + Messages.BugzillaTaskEditorPage_submitted_Changes_Details, message.toString()); + dialog.open(); + } + } diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java index c4264c7f8..d4d047040 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java @@ -51,13 +51,11 @@ public class Messages extends NLS { public static String BugzillaPlanningEditorPart_Team_Planning; - public static String BugzillaResponseDetailDialog_Titel; + public static String BugzillaTaskEditorPage_Bug_Line; - public static String BugzillaResponseDetailDialog_Bug_Line; + public static String BugzillaTaskEditorPage_Action_Line; - public static String BugzillaResponseDetailDialog_Action_Line; - - public static String BugzillaResponseDetailDialog_Email_Line; + public static String BugzillaTaskEditorPage_Email_Line; public static String BugzillaTaskEditorCommentPart_privateComment; @@ -71,6 +69,32 @@ public class Messages extends NLS { public static String BugzillaTaskEditorPage_Changes_Submitted_Message; + public static String BugzillaTaskEditorPage_Confirm; + + public static String BugzillaTaskEditorPage_Content_Assist_for_Error_Available; + + public static String BugzillaTaskEditorPage_DetailLine; + + public static String BugzillaTaskEditorPage_Error; + + public static String BugzillaTaskEditorPage_Error_Label_1; + + public static String BugzillaTaskEditorPage_Error_Label_N; + + public static String BugzillaTaskEditorPage_Legal_Value_1; + + public static String BugzillaTaskEditorPage_Legal_Value_N; + + public static String BugzillaTaskEditorPage_Legal_Values_More; + + public static String BugzillaTaskEditorPage_Legal_Values_One; + + public static String BugzillaTaskEditorPage_match_Detail; + + public static String BugzillaTaskEditorPage_Message_more; + + public static String BugzillaTaskEditorPage_Message_one; + public static String BugzillaTaskEditorPage_Please_enter_a_description_before_submitting; public static String BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting; @@ -81,6 +105,8 @@ public class Messages extends NLS { public static String BugzillaTaskEditorPage_submit_disabled_please_refresh; + public static String BugzillaTaskEditorPage_submitted_Changes_Details; + public static String BugzillaVotesEditor_Show_votes; public static String BugzillaVotesEditor_Vote; diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties index ec01b9b96..2eea51162 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties @@ -23,21 +23,35 @@ BugzillaPeoplePart__Select_to_remove_=(Select to remove) BugzillaPlanningEditorPart_Current_Estimate=Current Estimate: BugzillaPlanningEditorPart_Team_Planning=Team Planning -BugzillaResponseDetailDialog_Titel=submitted Changes Details -BugzillaResponseDetailDialog_Bug_Line={0}\n -BugzillaResponseDetailDialog_Action_Line=\ \ \ \ \ \ \ \ {0}\n -BugzillaResponseDetailDialog_Email_Line=\ \ \ \ \ \ \ \ \ \ \ \ {0}\n +BugzillaTaskEditorPage_Bug_Line={0}\n +BugzillaTaskEditorPage_Action_Line=\ \ \ \ \ \ \ \ {0}\n +BugzillaTaskEditorPage_Email_Line=\ \ \ \ \ \ \ \ \ \ \ \ {0}\n BugzillaTaskEditorCommentPart_privateComment=private Comment BugzillaTaskEditorCommentPart_publicComment=public Comment BugzillaTaskEditorNewCommentPart_privateComment=private Comment BugzillaTaskEditorNewCommentPart_publicComment=public Comment BugzillaTaskEditorPage_Anonymous_can_not_submit_Tasks=Anonymous can not submit Tasks\! BugzillaTaskEditorPage_Changes_Submitted_Message=Changes submitted +BugzillaTaskEditorPage_Confirm=Confirm +BugzillaTaskEditorPage_Content_Assist_for_Error_Available=Content Assist for Error Available ({0}) +BugzillaTaskEditorPage_DetailLine=\t\t{0}\n +BugzillaTaskEditorPage_Error=Error +BugzillaTaskEditorPage_Error_Label_1="{0}" +BugzillaTaskEditorPage_Error_Label_N=, "{0}" +BugzillaTaskEditorPage_Legal_Value_1={0} +BugzillaTaskEditorPage_Legal_Value_N=, \n{0} +BugzillaTaskEditorPage_Legal_Values_More=legal values are:\n{0} +BugzillaTaskEditorPage_Legal_Values_One=legal value is\n{0} +BugzillaTaskEditorPage_match_Detail=\ match Detail +BugzillaTaskEditorPage_Message_more={0} match for fields {1} +BugzillaTaskEditorPage_Message_one={0} match for field {1} + BugzillaTaskEditorPage_Please_enter_a_description_before_submitting=Please enter a description before submitting BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting=Please enter a short summary before submitting BugzillaTaskEditorPage_Please_select_a_component_before_submitting=Please select a component before submitting BugzillaTaskEditorPage_Please_enter_a_bugid_for_duplicate_of_before_submitting=Please enter a bugid for \"duplicate of\" before submitting BugzillaTaskEditorPage_submit_disabled_please_refresh=submit disabled, please check Credentials and refresh +BugzillaTaskEditorPage_submitted_Changes_Details=submitted Changes Details BugzillaVotesEditor_Show_votes=Show votes BugzillaVotesEditor_Vote=Vote diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/PersonProposalProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/PersonProposalProvider.java index 1b6e430d1..ca2dc11fd 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/PersonProposalProvider.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/PersonProposalProvider.java @@ -64,6 +64,8 @@ public class PersonProposalProvider implements IContentProposalProvider { private final Map<String, String> proposals; + private Map<String, String> errorProposals; + public PersonProposalProvider(AbstractTask task, TaskData taskData) { this(task, taskData, new HashMap<String, String>(0)); } @@ -117,19 +119,21 @@ public class PersonProposalProvider implements IContentProposalProvider { // retrieve subset of the tree set using key range SortedSet<String> addressSet = getAddressSet(); - if (!searchText.equals("")) { //$NON-NLS-1$ - // lower bounds - searchText = searchText.toLowerCase(); + if (errorProposals == null || errorProposals.isEmpty()) { + if (!searchText.equals("")) { //$NON-NLS-1$ + // lower bounds + searchText = searchText.toLowerCase(); - // compute the upper bound - char[] nextWord = searchText.toCharArray(); - nextWord[searchText.length() - 1]++; + // compute the upper bound + char[] nextWord = searchText.toCharArray(); + nextWord[searchText.length() - 1]++; - // filter matching keys - addressSet = new TreeSet<String>(addressSet.subSet(searchText, new String(nextWord))); + // filter matching keys + addressSet = new TreeSet<String>(addressSet.subSet(searchText, new String(nextWord))); - // add matching keys based on pretty names - addMatchingProposalsByPrettyName(addressSet, searchText); + // add matching keys based on pretty names + addMatchingProposalsByPrettyName(addressSet, searchText); + } } IContentProposal[] result = new IContentProposal[addressSet.size()]; @@ -207,6 +211,13 @@ public class PersonProposalProvider implements IContentProposalProvider { } }); + if (errorProposals != null && !errorProposals.isEmpty()) { + for (String proposal : errorProposals.keySet()) { + addAddress(addressSet, proposal); + } + return addressSet; + } + if (proposals.size() > 0) { if (repositoryUrl != null && connectorKind != null) { currentUser = getCurrentUser(repositoryUrl, connectorKind); @@ -322,4 +333,16 @@ public class PersonProposalProvider implements IContentProposalProvider { } } + public Map<String, String> getProposals() { + return proposals; + } + + public Map<String, String> getErrorProposals() { + return errorProposals; + } + + public void setErrorProposals(Map<String, String> errorProposals) { + this.errorProposals = errorProposals; + addressSet = null; + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PersonAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PersonAttributeEditor.java index 42fb23043..40ee93f0c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PersonAttributeEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/PersonAttributeEditor.java @@ -26,6 +26,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; +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.FormToolkit; @@ -36,6 +37,8 @@ import org.eclipse.ui.forms.widgets.ImageHyperlink; */ public class PersonAttributeEditor extends TextAttributeEditor { + private ContentAssistCommandAdapter contentAssistCommandAdapter = null; + public PersonAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) { super(manager, taskAttribute); } @@ -65,6 +68,8 @@ public class PersonAttributeEditor extends TextAttributeEditor { final ImageHyperlink selfLink = new ImageHyperlink(composite, SWT.NO_FOCUS); selfLink.setToolTipText(Messages.PersonAttributeEditor_Insert_My_User_Id_Tooltip); + //this is inserted to not get org.eclipse.swt.SWTException: Graphic is disposed on Mac OS Lion + selfLink.setImage(CommonImages.getImage(CommonImages.PERSON_ME_SMALL)); selfLink.setActiveImage(CommonImages.getImage(CommonImages.PERSON_ME_SMALL)); selfLink.setHoverImage(CommonImages.getImage(CommonImages.PERSON_ME_SMALL)); selfLink.addHyperlinkListener(new HyperlinkAdapter() { @@ -85,7 +90,6 @@ public class PersonAttributeEditor extends TextAttributeEditor { public void mouseEnter(MouseEvent e) { ((GridData) selfLink.getLayoutData()).exclude = false; composite.layout(); - selfLink.setImage(CommonImages.getImage(CommonImages.PERSON_ME_SMALL)); selfLink.redraw(); version++; } @@ -98,7 +102,6 @@ public class PersonAttributeEditor extends TextAttributeEditor { if (version != lastVersion || selfLink.isDisposed()) { return; } - selfLink.setImage(null); selfLink.redraw(); ((GridData) selfLink.getLayoutData()).exclude = true; composite.layout(); @@ -140,4 +143,12 @@ public class PersonAttributeEditor extends TextAttributeEditor { getText().setBackground(color); } } + + public ContentAssistCommandAdapter getContentAssistCommandAdapter() { + return contentAssistCommandAdapter; + } + + public void setContentAssistCommandAdapter(ContentAssistCommandAdapter contentAssistCommandAdapter) { + this.contentAssistCommandAdapter = contentAssistCommandAdapter; + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java index 811e48eac..e9c0a44d7 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorToolkit.java @@ -99,6 +99,9 @@ public class AttributeEditorToolkit { ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true); adapter.setLabelProvider(labelPropsalProvider); adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); + if (editor instanceof PersonAttributeEditor) { + ((PersonAttributeEditor) editor).setContentAssistCommandAdapter(adapter); + } } } } else if (editor instanceof RichTextAttributeEditor) { |