Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2009-08-14 14:04:23 +0000
committerfbecker2009-08-14 14:04:23 +0000
commitb92472547a7356ef8f985331b066c06e23f6767f (patch)
tree56d3156be75cd61f081b304da049c67ad28c719c /org.eclipse.mylyn.bugzilla.ui/src
parentc848224dd470c70e99393db0a1236fdf438d0524 (diff)
downloadorg.eclipse.mylyn.tasks-b92472547a7356ef8f985331b066c06e23f6767f.tar.gz
org.eclipse.mylyn.tasks-b92472547a7356ef8f985331b066c06e23f6767f.tar.xz
org.eclipse.mylyn.tasks-b92472547a7356ef8f985331b066c06e23f6767f.zip
ASSIGNED - bug 279536: [patch] bugzilla hyperlink detector should detect attachment hyperlinks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=279536
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui/src')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/Messages.java28
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentHyperlink.java58
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/messages.properties1
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaConnectorUi.java26
4 files changed, 105 insertions, 8 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/Messages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/Messages.java
new file mode 100644
index 000000000..f872cf823
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/Messages.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.bugzilla.ui.messages"; //$NON-NLS-1$
+
+ public static String TaskAttachmentHyperlink_Open_Attachment_X_in_X;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentHyperlink.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentHyperlink.java
new file mode 100644
index 000000000..e29c57715
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentHyperlink.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+
+/**
+ * @since 3.2
+ */
+public final class TaskAttachmentHyperlink implements IHyperlink {
+
+ private final IRegion region;
+
+ private final TaskRepository repository;
+
+ private final String attachmentId;
+
+ public TaskAttachmentHyperlink(IRegion region, TaskRepository repository, String attachmentId) {
+ Assert.isNotNull(repository);
+ this.region = region;
+ this.repository = repository;
+ this.attachmentId = attachmentId;
+ }
+
+ public IRegion getHyperlinkRegion() {
+ return region;
+ }
+
+ public String getHyperlinkText() {
+ return MessageFormat.format(Messages.TaskAttachmentHyperlink_Open_Attachment_X_in_X, attachmentId,
+ repository.getRepositoryLabel());
+ }
+
+ public String getTypeLabel() {
+ return null;
+ }
+
+ public void open() {
+ String url = repository.getUrl() + IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX + attachmentId;
+ TasksUiUtil.openUrl(url);
+ }
+}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/messages.properties b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/messages.properties
new file mode 100644
index 000000000..29783863a
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/messages.properties
@@ -0,0 +1 @@
+TaskAttachmentHyperlink_Open_Attachment_X_in_X=Open Attachment {0} in {1} \ No newline at end of file
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaConnectorUi.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaConnectorUi.java
index 370d8660a..7ad508c2d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaConnectorUi.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaConnectorUi.java
@@ -29,6 +29,7 @@ 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.internal.bugzilla.ui.BugzillaImages;
+import org.eclipse.mylyn.internal.bugzilla.ui.TaskAttachmentHyperlink;
import org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage;
import org.eclipse.mylyn.internal.bugzilla.ui.wizard.NewBugzillaTaskWizard;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
@@ -49,7 +50,11 @@ import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
*/
public class BugzillaConnectorUi extends AbstractRepositoryConnectorUi {
- private static final String regexp = "(duplicate of|bug|task)( ?#? ?)(\\d+)"; //$NON-NLS-1$
+ private static final int TASK_NUM_GROUP = 3;
+
+ private static final int ATTACHMENT_NUM_GROUP = 4;
+
+ private static final String regexp = "(?:(duplicate of|bug|task)( ?#? ?)(\\d+))|(?:Created an attachment\\s*\\(id=(\\d+)\\))"; //$NON-NLS-1$
private static final Pattern PATTERN = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE);
@@ -80,8 +85,6 @@ public class BugzillaConnectorUi extends AbstractRepositoryConnectorUi {
}
}
- private static final int TASK_NUM_GROUP = 3;
-
@Override
public List<LegendElement> getLegendElements() {
List<LegendElement> legendItems = new ArrayList<LegendElement>();
@@ -202,17 +205,24 @@ public class BugzillaConnectorUi extends AbstractRepositoryConnectorUi {
}
try {
-
- String bugId = m.group(TASK_NUM_GROUP).trim();
start += regionOffset;
end += regionOffset;
-
IRegion sregion = new Region(start, end - start);
- return new TaskHyperlink(sregion, repository, bugId);
+
+ String bugId = m.group(TASK_NUM_GROUP);
+ if (bugId == null) {
+ String attachmentId = m.group(ATTACHMENT_NUM_GROUP);
+ if (attachmentId != null) {
+ return new TaskAttachmentHyperlink(sregion, repository, attachmentId);
+ }
+ } else {
+ bugId.trim();
+ return new TaskHyperlink(sregion, repository, bugId);
+ }
} catch (NumberFormatException e) {
- return null;
}
+ return null;
}
@Override

Back to the top