diff options
4 files changed, 18 insertions, 24 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/FileTaskAttachmentSource.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/FileTaskAttachmentSource.java index c14c22467..e5ef39904 100644 --- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/FileTaskAttachmentSource.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/FileTaskAttachmentSource.java @@ -16,9 +16,12 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; +import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Locale; import java.util.Map; +import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -56,10 +59,13 @@ public class FileTaskAttachmentSource extends AbstractTaskAttachmentSource { extensions2Types.put("html", "text/html"); //$NON-NLS-1$ //$NON-NLS-2$ extensions2Types.put("htm", "text/html"); //$NON-NLS-1$ //$NON-NLS-2$ extensions2Types.put("xhtml", "application/xhtml+xml"); //$NON-NLS-1$//$NON-NLS-2$ + extensions2Types.put("jpe", "image/jpeg"); //$NON-NLS-1$ //$NON-NLS-2$ extensions2Types.put("jpg", "image/jpeg"); //$NON-NLS-1$ //$NON-NLS-2$ extensions2Types.put("jpeg", "image/jpeg"); //$NON-NLS-1$ //$NON-NLS-2$ extensions2Types.put("gif", "image/gif"); //$NON-NLS-1$ //$NON-NLS-2$ extensions2Types.put("png", "image/png"); //$NON-NLS-1$ //$NON-NLS-2$ + extensions2Types.put("tif", "image/tiff"); //$NON-NLS-1$ //$NON-NLS-2$ + extensions2Types.put("tiff", "image/tiff"); //$NON-NLS-1$ //$NON-NLS-2$ extensions2Types.put("xml", APPLICATION_XML); //$NON-NLS-1$ extensions2Types.put("zip", APPLICATION_OCTET_STREAM); //$NON-NLS-1$ extensions2Types.put("tar", APPLICATION_OCTET_STREAM); //$NON-NLS-1$ @@ -94,6 +100,13 @@ public class FileTaskAttachmentSource extends AbstractTaskAttachmentSource { return APPLICATION_OCTET_STREAM; } + public static String[] getContentTypes() { + Set<String> types = new HashSet<String>(extensions2Types.values()); + String[] array = types.toArray(new String[0]); + Arrays.sort(array); + return array; + } + private String contentType; private String description; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AttachmentPreviewPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AttachmentPreviewPage.java index a88d0d2ab..b0dd7d582 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AttachmentPreviewPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/AttachmentPreviewPage.java @@ -94,13 +94,13 @@ public class AttachmentPreviewPage extends WizardPage { textTypes = new HashSet<String>(); textTypes.add("text/plain"); //$NON-NLS-1$ textTypes.add("text/html"); //$NON-NLS-1$ - textTypes.add("text/html"); //$NON-NLS-1$ textTypes.add("application/xml"); //$NON-NLS-1$ imageTypes = new HashSet<String>(); imageTypes.add("image/jpeg"); //$NON-NLS-1$ imageTypes.add("image/gif"); //$NON-NLS-1$ imageTypes.add("image/png"); //$NON-NLS-1$ + imageTypes.add("image/tiff"); //$NON-NLS-1$ } private void adjustScrollbars(Rectangle imgSize) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties index b4ff11746..4159d2380 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties @@ -35,7 +35,7 @@ NewWebTaskPage_This_will_open_a_web_browser_that_can_be_used_to_create_a_new_tas NOTE: you may need to log in via the web UI. AttachmentPreviewPage_A_preview_the_type_X_is_currently_not_available=Attaching File {0}\n\ -A preview the type {1} is currently not available +A preview for the type {1} is currently not available AttachmentPreviewPage_Attachment_Preview=Attachment Preview AttachmentPreviewPage_Could_not_create_preview=Could not create preview AttachmentPreviewPage_Preparing_preview=Preparing preview diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/TaskAttachmentPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/TaskAttachmentPage.java index 4253791a7..2b8f6f677 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/TaskAttachmentPage.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/wizards/TaskAttachmentPage.java @@ -12,10 +12,6 @@ package org.eclipse.mylyn.tasks.ui.wizards; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.mylyn.context.core.ContextCore; @@ -58,19 +54,6 @@ import org.eclipse.ui.handlers.IHandlerService; */ public class TaskAttachmentPage extends WizardPage { - private static List<String> contentTypes; - - static { - contentTypes = new LinkedList<String>(); - contentTypes.add("text/plain"); //$NON-NLS-1$ - contentTypes.add("text/html"); //$NON-NLS-1$ - contentTypes.add("application/xml"); //$NON-NLS-1$ - contentTypes.add("image/gif"); //$NON-NLS-1$ - contentTypes.add("image/jpeg"); //$NON-NLS-1$ - contentTypes.add("image/png"); //$NON-NLS-1$ - contentTypes.add(FileTaskAttachmentSource.APPLICATION_OCTET_STREAM); - } - private Button attachContextButton; private RichTextEditor commentEditor; @@ -167,16 +150,14 @@ public class TaskAttachmentPage extends WizardPage { contentTypeList = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); contentTypeList.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1)); - Iterator<String> iter = contentTypes.iterator(); - int i = 0; + String[] contentTypes = FileTaskAttachmentSource.getContentTypes(); int selection = 0; - while (iter.hasNext()) { - String next = iter.next(); + for (int i = 0; i < contentTypes.length; i++) { + String next = contentTypes[i]; contentTypeList.add(next); if (next.equalsIgnoreCase(model.getContentType())) { selection = i; } - i++; } /* Update attachment on select content type */ |