Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2011-01-21 20:45:26 +0000
committerfbecker2011-01-21 20:45:26 +0000
commitaab530b8ef016f32097a61f5886b3dcda7ffce40 (patch)
tree567a2f2e92b687556aff9c10dcdc4a01ded0f701 /org.eclipse.mylyn.bugzilla.ui
parenta75aaee8ab91132643256e3f76a60a3b5343a2bd (diff)
downloadorg.eclipse.mylyn.tasks-aab530b8ef016f32097a61f5886b3dcda7ffce40.tar.gz
org.eclipse.mylyn.tasks-aab530b8ef016f32097a61f5886b3dcda7ffce40.tar.xz
org.eclipse.mylyn.tasks-aab530b8ef016f32097a61f5886b3dcda7ffce40.zip
ASSIGNED - bug 199283: [patch] [api] make attachments actionable from associated comment in task editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=199283
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/Messages.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentHyperlink.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentTableEditorHyperlink.java140
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/messages.properties3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaConnectorUi.java27
5 files changed, 171 insertions, 5 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
index f872cf823..fd0c68360 100644
--- 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
@@ -16,7 +16,9 @@ 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;
+ public static String TaskAttachmentHyperlink_Open_Attachment_X_in_Y;
+
+ public static String TaskAttachmentTableEditorHyperlink_Show_Attachment_X_in_Y;
static {
// initialize resource bundle
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
index c3e9f6651..e36251e7e 100644
--- 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
@@ -43,7 +43,7 @@ public final class TaskAttachmentHyperlink implements IHyperlink {
}
public String getHyperlinkText() {
- return MessageFormat.format(Messages.TaskAttachmentHyperlink_Open_Attachment_X_in_X, attachmentId,
+ return MessageFormat.format(Messages.TaskAttachmentHyperlink_Open_Attachment_X_in_Y, attachmentId,
repository.getRepositoryLabel());
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentTableEditorHyperlink.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentTableEditorHyperlink.java
new file mode 100644
index 000000000..f1cee49d4
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentTableEditorHyperlink.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * @since 3.2
+ */
+public final class TaskAttachmentTableEditorHyperlink implements IHyperlink {
+
+ private final IRegion region;
+
+ private final TaskRepository repository;
+
+ private final String attachmentId;
+
+ public TaskAttachmentTableEditorHyperlink(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.TaskAttachmentTableEditorHyperlink_Show_Attachment_X_in_Y, attachmentId,
+ repository.getRepositoryLabel());
+ }
+
+ public String getTypeLabel() {
+ return null;
+ }
+
+ public void open() {
+ AbstractTaskEditorPage page = getTaskEditorPage();
+ if (page != null) {
+ if (!page.selectReveal(TaskAttribute.PREFIX_ATTACHMENT + attachmentId)) {
+ String url = repository.getUrl() + IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX + attachmentId;
+ TasksUiUtil.openUrl(url);
+ }
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((attachmentId == null) ? 0 : attachmentId.hashCode());
+ result = prime * result + ((region == null) ? 0 : region.hashCode());
+ result = prime * result + ((repository == null) ? 0 : repository.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TaskAttachmentTableEditorHyperlink other = (TaskAttachmentTableEditorHyperlink) obj;
+ if (attachmentId == null) {
+ if (other.attachmentId != null) {
+ return false;
+ }
+ } else if (!attachmentId.equals(other.attachmentId)) {
+ return false;
+ }
+ if (region == null) {
+ if (other.region != null) {
+ return false;
+ }
+ } else if (!region.equals(other.region)) {
+ return false;
+ }
+ if (repository == null) {
+ if (other.repository != null) {
+ return false;
+ }
+ } else if (!repository.equals(other.repository)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "TaskAttachmentHyperlink [attachmentId=" + attachmentId + ", region=" + region + ", repository=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + repository + "]"; //$NON-NLS-1$
+ }
+
+ protected AbstractTaskEditorPage getTaskEditorPage() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (activePage == null) {
+ return null;
+ }
+ IEditorPart editorPart = activePage.getActiveEditor();
+ AbstractTaskEditorPage taskEditorPage = null;
+ if (editorPart instanceof TaskEditor) {
+ TaskEditor taskEditor = (TaskEditor) editorPart;
+ IFormPage formPage = taskEditor.getActivePageInstance();
+ if (formPage instanceof AbstractTaskEditorPage) {
+ taskEditorPage = (AbstractTaskEditorPage) formPage;
+ }
+ }
+ return taskEditorPage;
+ }
+
+}
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
index 7e566285a..982593a44 100644
--- 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
@@ -8,4 +8,5 @@
# Contributors:
# Tasktop Technologies - initial API and implementation
###############################################################################
-TaskAttachmentHyperlink_Open_Attachment_X_in_X=Open Attachment {0} in {1} \ No newline at end of file
+TaskAttachmentHyperlink_Open_Attachment_X_in_Y=Open Attachment {0} in {1}
+TaskAttachmentTableEditorHyperlink_Show_Attachment_X_in_Y=Show Attachment {0} in {1}
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 7f7321257..ad6bbea91 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
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.hyperlink.IHyperlink;
@@ -30,6 +31,7 @@ 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.TaskAttachmentTableEditorHyperlink;
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;
@@ -45,6 +47,8 @@ import org.eclipse.mylyn.tasks.ui.TaskHyperlink;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
/**
* @author Mik Kersten
@@ -65,6 +69,22 @@ public class BugzillaConnectorUi extends AbstractRepositoryConnectorUi {
private static final Pattern PATTERN_ATTACHMENT = Pattern.compile(REGEXP_ATTACHMENT, Pattern.CASE_INSENSITIVE);
+ /*
+ * because of bug# 322293 (NPE when select Hyperlink from MultipleHyperlinkPresenter List)
+ * for MacOS we enable this only if running on Eclipse >= "3.7.0.v201101192000"
+ *
+ */
+ private final boolean doAttachmentTableEditorHyperlink;
+
+ public BugzillaConnectorUi() {
+ super();
+ Bundle bundle = Platform.getBundle("org.eclipse.platform"); //$NON-NLS-1$
+ String versionString = bundle.getHeaders().get("Bundle-Version"); //$NON-NLS-1$
+
+ Version version = new Version(versionString);
+ doAttachmentTableEditorHyperlink = version.compareTo(new Version("3.7.0.v201101192000")) >= 0; //$NON-NLS-1$
+ }
+
@Override
public String getAccountCreationUrl(TaskRepository taskRepository) {
return taskRepository.getRepositoryUrl() + "/createaccount.cgi"; //$NON-NLS-1$
@@ -220,11 +240,14 @@ public class BugzillaConnectorUi extends AbstractRepositoryConnectorUi {
if (index == -1 || (index >= ma.start() && index <= ma.end())) {
// attachment
Region region = new Region(textOffset + ma.start(), ma.end() - ma.start());
- TaskAttachmentHyperlink link = new TaskAttachmentHyperlink(region, repository, ma.group(1));
+ TaskAttachmentHyperlink link0 = new TaskAttachmentHyperlink(region, repository, ma.group(1));
if (hyperlinksFound == null) {
hyperlinksFound = new ArrayList<IHyperlink>();
}
- hyperlinksFound.add(link);
+ hyperlinksFound.add(link0);
+ if (doAttachmentTableEditorHyperlink) {
+ hyperlinksFound.add(new TaskAttachmentTableEditorHyperlink(region, repository, ma.group(1)));
+ }
}
}

Back to the top