Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 92646 Details for
Bug 222833
[api] refactor LocalAttachment class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
clipboard.txt (text/plain), 47.08 KB, created by
Steffen Pingel
on 2008-03-16 01:41:35 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2008-03-16 01:41:35 EDT
Size:
47.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java,v >retrieving revision 1.8 >diff -u -r1.8 ScreenshotAttachmentPage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java 1 Mar 2008 21:38:51 -0000 1.8 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java 16 Mar 2008 05:39:03 -0000 >@@ -885,6 +885,8 @@ > > private final List<GrabPoint> grabPoints = new ArrayList<GrabPoint>(8); > >+ private boolean dirty; >+ > /** > * Creates the final screenshot > * >@@ -904,12 +906,22 @@ > } > gc.dispose(); > >+ this.dirty = false; >+ > return screenshot; > } > > private void markAttachmentDirty() { >- NewAttachmentWizard wizard = (NewAttachmentWizard) getWizard(); >- ((ImageAttachment) wizard.getAttachment()).markDirty(); >+ // API 3.0 remove >+ if (getWizard() instanceof NewAttachmentWizard) { >+ NewAttachmentWizard wizard = (NewAttachmentWizard) getWizard(); >+ ((ImageAttachment) wizard.getAttachment()).markDirty(); >+ } >+ this.dirty = true; >+ } >+ >+ public boolean isDirty() { >+ return dirty; > } > > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java,v >retrieving revision 1.13 >diff -u -r1.13 InputAttachmentSourcePage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java 1 Mar 2008 21:38:52 -0000 1.13 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java 16 Mar 2008 05:39:03 -0000 >@@ -35,6 +35,8 @@ > import org.eclipse.jface.viewers.TreeViewer; > import org.eclipse.jface.wizard.IWizardPage; > import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.mylyn.internal.tasks.core.AbstractTaskAttachmentSource; >+import org.eclipse.mylyn.internal.tasks.core.TaskAttachment; > import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; > import org.eclipse.swt.SWT; > import org.eclipse.swt.dnd.Clipboard; >@@ -55,7 +57,7 @@ > import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.model.WorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; >-import org.eclipse.ui.views.navigator.ResourceSorter; >+import org.eclipse.ui.views.navigator.ResourceComparator; > > /** > * A wizard to input the source of the attachment. >@@ -67,7 +69,6 @@ > * @author Jeff Pound - modified for attachment input > * @author Chris Aniszczyk <caniszczyk@gmail.com> - bug 209572 > */ >-@SuppressWarnings("deprecation") > public class InputAttachmentSourcePage extends WizardPage { > > // constants >@@ -109,8 +110,6 @@ > > private TreeViewer treeViewer; > >- private final NewAttachmentWizard wizard; >- > private String clipboardContents; > > private boolean initUseClipboard = false; >@@ -119,9 +118,10 @@ > > private final String S_LAST_SELECTION = "lastSelection"; //$NON-NLS-1$ > >+ private TaskAttachment taskAttachment; >+ > public InputAttachmentSourcePage(NewAttachmentWizard wizard) { > super("InputAttachmentPage"); >- this.wizard = wizard; > setTitle("Select attachment source"); > setDescription("Clipboard contents are for text attachments only."); > // setMessage("Please select the source for the attachment"); >@@ -177,11 +177,14 @@ > > @Override > public IWizardPage getNextPage() { >+ if (taskAttachment != null) { >+ taskAttachment.setSource(getSource()); >+ } > if (getInputMethod() == SCREENSHOT) { >- return wizard.getPage("ScreenShotAttachment"); >+ return getWizard().getPage("ScreenShotAttachment"); > } else { > saveDialogSettings(); >- return wizard.getNextPage(this); >+ return getWizard().getNextPage(this); > } > } > >@@ -232,7 +235,9 @@ > gd = new GridData(GridData.FILL_HORIZONTAL); > gd.widthHint = SIZING_TEXT_FIELD_WIDTH; > fileNameField.setLayoutData(gd); >- fileNameField.setText(wizard.getAttachment().getFilePath()); >+ if (getWizard() instanceof NewAttachmentWizard) { >+ fileNameField.setText(((NewAttachmentWizard) getWizard()).getAttachment().getFilePath()); >+ } > > fileBrowseButton = new Button(composite, SWT.PUSH); > fileBrowseButton.setText("Browse..."); >@@ -366,7 +371,7 @@ > treeViewer.expandToLevel(res, 1); > } > } else if (res instanceof IFile) { >- wizard.showPage(getNextPage()); >+ getContainer().showPage(getNextPage()); > } > } > } >@@ -393,7 +398,7 @@ > > treeViewer.setLabelProvider(new WorkbenchLabelProvider()); > treeViewer.setContentProvider(new WorkbenchContentProvider()); >- treeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME)); >+ treeViewer.setComparator(new ResourceComparator(ResourceComparator.NAME)); > treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); > } > >@@ -457,7 +462,10 @@ > } > > setPageComplete(attachmentFound); >- wizard.getAttachment().setFilePath(getAbsoluteAttachmentPath()); >+ if (getWizard() instanceof NewAttachmentWizard) { >+ ((NewAttachmentWizard) getWizard()).getAttachment().setFilePath(getAbsoluteAttachmentPath()); >+ } >+ // API 3.0 set attachment source > > if (showError) { > setErrorMessage(error); >@@ -565,7 +573,10 @@ > if (fileNameField != null) { > return fileNameField.getText(); > } >- return wizard.getAttachment().getFilePath(); >+ if (getWizard() instanceof NewAttachmentWizard) { >+ return ((NewAttachmentWizard) getWizard()).getAttachment().getFilePath(); >+ } >+ return null; > } > > public String getAbsoluteAttachmentPath() { >@@ -676,4 +687,28 @@ > return section; > } > >+ public AbstractTaskAttachmentSource getSource() { >+ switch (getInputMethod()) { >+ case CLIPBOARD: >+ return new TaskAttachmentWizard.ClipboardSource(); >+ case WORKSPACE: >+ IResource[] resources = getResources(treeViewer.getSelection()); >+ if (resources.length > 0) { >+ return new TaskAttachmentWizard.FileSource(resources[0].getLocation().toFile()); >+ } else { >+ return null; >+ } >+ default: // FILE >+ return new TaskAttachmentWizard.FileSource(new File(getAttachmentFilePath())); >+ } >+ } >+ >+ public TaskAttachment getTaskAttachment() { >+ return taskAttachment; >+ } >+ >+ public void setTaskAttachment(TaskAttachment taskAttachment) { >+ this.taskAttachment = taskAttachment; >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/SubmitTaskAttachmentJob.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/SubmitTaskAttachmentJob.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/SubmitTaskAttachmentJob.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/SubmitTaskAttachmentJob.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.mylyn.internal.tasks.core.TaskAttachment; >+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; >+import org.eclipse.mylyn.tasks.core.AbstractTask; >+import org.eclipse.mylyn.tasks.core.TaskRepository; >+ >+/** >+ * @author Steffen Pingel >+ */ >+public class SubmitTaskAttachmentJob extends Job { >+ >+ private static final String LABEL_JOB_SUBMIT = "Submitting to repository"; >+ >+ private final TaskAttachment taskAttachment; >+ >+ private final AbstractRepositoryConnector connector; >+ >+ private final TaskRepository taskRepository; >+ >+ private AbstractTask task; >+ >+ public SubmitTaskAttachmentJob(AbstractRepositoryConnector connector, TaskRepository taskRepository, >+ TaskAttachment taskAttachment) { >+ super(LABEL_JOB_SUBMIT); >+ this.connector = connector; >+ this.taskRepository = taskRepository; >+ this.taskAttachment = taskAttachment; >+ } >+ >+ @Override >+ public IStatus run(IProgressMonitor monitor) { >+ return null; >+// try { >+// if (monitor == null) { >+// monitor = new NullProgressMonitor(); >+// } >+// monitor.beginTask("Attaching file...", 2); >+// task.setSubmitting(true); >+// task.setSynchronizationState(RepositoryTaskSyncState.OUTGOING); >+// >+// if (screenshotMode || InputAttachmentSourcePage.SCREENSHOT_LABEL.equals(path)) { >+// ((ImageAttachment) taskAttachment).ensureImageFileWasCreated(); >+// } else if (InputAttachmentSourcePage.CLIPBOARD_LABEL.equals(path)) { >+// String contents = inputPage.getClipboardContents(); >+// if (contents == null) { >+// throw new InvocationTargetException(new CoreException(new RepositoryStatus(IStatus.ERROR, >+// TasksUiPlugin.ID_PLUGIN, RepositoryStatus.ERROR_INTERNAL, "Clipboard is empty", null))); >+// } >+// taskAttachment.setContent(contents.getBytes()); >+// taskAttachment.setFilename(CLIPBOARD_FILENAME); >+// } else { >+// File file = new File(path); >+// taskAttachment.setFile(file); >+// taskAttachment.setFilename(file.getName()); >+// } >+// >+// attachmentHandler.uploadAttachment(taskRepository, task, taskAttachment, taskAttachment.getComment(), >+// new SubProgressMonitor(monitor, 1)); >+// >+// if (monitor.isCanceled()) { >+// throw new OperationCanceledException(); >+// } >+// >+// if (attachContext && connector.getAttachmentHandler() != null) { >+// connector.getAttachmentHandler().attachContext(taskRepository, task, "", >+// new SubProgressMonitor(monitor, 1)); >+// } >+// } catch (CoreException e) { >+// return e.getStatus(); >+// } finally { >+// task.setSubmitting(false); >+// task.setSynchronizationState(RepositoryTaskSyncState.SYNCHRONIZED); >+// >+// monitor.done(); >+// } >+ } >+ >+// private void synchronizeTask() { >+// TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, false, new JobChangeAdapter() { >+// @Override >+// public void done(final IJobChangeEvent event) { >+// PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { >+// public void run() { >+// if (event.getResult().getException() != null) { >+// >+// MessageDialog.openError(Display.getDefault().getActiveShell(), >+// ITasksUiConstants.TITLE_DIALOG, event.getResult().getMessage()); >+// >+// } >+// forceRefreshInplace(task); >+// } >+// }); >+// } >+// }); >+// } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentPage.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentPage.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,302 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.wizards; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+import java.util.Locale; >+import java.util.Map; >+ >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.mylyn.internal.tasks.core.TaskAttachment; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+ >+/** >+ * A wizard page to enter details of a new attachment. >+ * >+ * @author Jeff Pound >+ * @author Mik Kersten >+ */ >+public class TaskAttachmentPage extends WizardPage { >+ >+ private final TaskAttachment attachment; >+ >+ private Text filePath; >+ >+ private Text attachmentDesc; >+ >+ private Text attachmentComment; >+ >+ private Button isPatchButton; >+ >+ private Button attachContextButton; >+ >+ private Combo contentTypeList; >+ >+ private boolean supportsDescription = true; >+ >+ private static List<String> contentTypes; >+ >+ private static Map<String, String> extensions2Types; >+ >+ static { >+ /* For UI */ >+ contentTypes = new LinkedList<String>(); >+ contentTypes.add("text/plain"); >+ contentTypes.add("text/html"); >+ contentTypes.add("application/xml"); >+ contentTypes.add("image/gif"); >+ contentTypes.add("image/jpeg"); >+ contentTypes.add("image/png"); >+ contentTypes.add("application/octet-stream"); >+ >+ /* For auto-detect */ >+ extensions2Types = new HashMap<String, String>(); >+ extensions2Types.put("txt", "text/plain"); >+ extensions2Types.put("html", "text/html"); >+ extensions2Types.put("htm", "text/html"); >+ extensions2Types.put("jpg", "image/jpeg"); >+ extensions2Types.put("jpeg", "image/jpeg"); >+ extensions2Types.put("gif", "image/gif"); >+ extensions2Types.put("png", "image/png"); >+ extensions2Types.put("xml", "application/xml"); >+ extensions2Types.put("zip", "application/octet-stream"); >+ extensions2Types.put("tar", "application/octet-stream"); >+ extensions2Types.put("gz", "application/octet-stream"); >+ } >+ >+ protected TaskAttachmentPage(TaskAttachment attachment) { >+ super("AttachmentDetails"); >+ setTitle("Attachment Details"); >+ setMessage("Enter a description and verify the content type of the attachment"); >+ this.attachment = attachment; >+ } >+ >+ public void createControl(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NONE); >+ GridLayout gridLayout = new GridLayout(); >+ gridLayout.numColumns = 3; >+ composite.setLayout(gridLayout); >+ setControl(composite); >+ >+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ composite.setLayout(new GridLayout(3, false)); >+ >+ final TaskAttachmentPage thisPage = this; >+ >+ new Label(composite, SWT.NONE).setText("File"); >+ filePath = new Text(composite, SWT.BORDER); >+ filePath.setEditable(false); >+ filePath.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); >+ >+ if (supportsDescription) { >+ new Label(composite, SWT.NONE).setText("Description"); >+ attachmentDesc = new Text(composite, SWT.BORDER); >+ attachmentDesc.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); >+ >+ attachmentDesc.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ if ("".equals(attachmentDesc.getText().trim())) { >+ thisPage.setErrorMessage("Description required"); >+ } else { >+ if (!"".equals(filePath.getText())) { >+ thisPage.setPageComplete(true); >+ thisPage.setErrorMessage(null); >+ } >+ } >+ } >+ >+ }); >+ } >+ >+ Label label = new Label(composite, SWT.NONE); >+ label.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false)); >+ label.setText("Comment"); >+ attachmentComment = new Text(composite, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); >+ attachmentComment.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); >+ >+ new Label(composite, SWT.NONE).setText("Content Type");// .setBackground(parent.getBackground()); >+ >+ contentTypeList = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); >+ contentTypeList.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1)); >+ final HashMap<String, Integer> contentTypeIndices = new HashMap<String, Integer>(); >+ Iterator<String> iter = contentTypes.iterator(); >+ int i = 0; >+ while (iter.hasNext()) { >+ String next = iter.next(); >+ contentTypeList.add(next); >+ contentTypeIndices.put(next, new Integer(i)); >+ i++; >+ } >+ >+ /* Update attachment on select content type */ >+ contentTypeList.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ attachment.setContentType(contentTypeList.getItem(contentTypeList.getSelectionIndex())); >+ } >+ }); >+ contentTypeList.select(0); >+ attachment.setContentType(contentTypeList.getItem(0)); >+ >+ // TODO: is there a better way to pad? >+ new Label(composite, SWT.NONE); >+ >+ isPatchButton = new Button(composite, SWT.CHECK); >+ isPatchButton.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1)); >+ isPatchButton.setText("Patch"); >+ >+ // TODO: is there a better way to pad? >+ new Label(composite, SWT.NONE); >+ >+ attachContextButton = new Button(composite, SWT.CHECK); >+ attachContextButton.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1)); >+ attachContextButton.setText("Attach Context"); >+ attachContextButton.setImage(TasksUiImages.getImage(TasksUiImages.CONTEXT_ATTACH)); >+ attachContextButton.setEnabled((((NewAttachmentWizard) getWizard()).hasContext())); >+ >+ /* >+ * Attachment file name listener, update the local attachment >+ * accordingly >+ */ >+ filePath.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ // Determine type by extension >+ int index = filePath.getText().lastIndexOf("."); >+ if (index > 0 && index < filePath.getText().length()) { >+ String ext = filePath.getText().substring(index + 1); >+ String type = extensions2Types.get(ext.toLowerCase(Locale.ENGLISH)); >+ if (type != null) { >+ contentTypeList.select(contentTypeIndices.get(type)); >+ attachment.setContentType(type); >+ } >+ } >+ >+ // check page completenes >+ if (attachmentDesc != null && "".equals(attachmentDesc.getText())) { >+ thisPage.setErrorMessage("Description required"); >+ } else { >+ if (!"".equals(filePath.getText())) { >+ thisPage.setPageComplete(true); >+ thisPage.setErrorMessage(null); >+ } >+ } >+ } >+ }); >+ >+ filePath.setText(attachment.getName() == null ? "" : attachment.getName()); //$NON-NLS-1$ >+ >+ /* Listener for isPatch */ >+ isPatchButton.addSelectionListener(new SelectionListener() { >+ private int lastSelected; >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ attachment.setPatch(isPatchButton.getSelection()); >+ if (isPatchButton.getSelection()) { >+ lastSelected = contentTypeList.getSelectionIndex(); >+ contentTypeList.select(0); >+ contentTypeList.setEnabled(false); >+ if (attachContextButton.isEnabled()) { >+ attachContextButton.setSelection(true); >+ } >+ } else { >+ contentTypeList.setEnabled(true); >+ contentTypeList.select(lastSelected); >+ } >+ } >+ }); >+ >+ thisPage.setErrorMessage(null); >+ } >+ >+ @Override >+ public boolean isPageComplete() { >+ return !"".equals(filePath.getText().trim()) >+ && (attachmentDesc == null || !"".equals(attachmentDesc.getText().trim())); >+ } >+ >+ public void populateAttachment() { >+ if (attachmentDesc != null) { >+ attachment.setDescription(attachmentDesc.getText()); >+ } >+ attachment.setComment(attachmentComment.getText()); >+ } >+ >+ public TaskAttachment getAttachment() { >+ return attachment; >+ } >+ >+ public void setFilePath(String path) { >+ filePath.setText(path); >+ if (path.endsWith(".patch")) { >+ isPatchButton.setSelection(true); >+ if (attachContextButton.isEnabled()) { >+ attachContextButton.setSelection(true); >+ } >+ } >+ } >+ >+ @Override >+ public IWizardPage getNextPage() { >+ populateAttachment(); >+ // TODO implement preview >+// PreviewAttachmentPage page = new PreviewAttachmentPage(getAttachment()); >+// page.setWizard(getWizard()); >+// return page; >+ return null; >+ } >+ >+ public boolean getAttachContext() { >+ return attachContextButton.getSelection(); >+ } >+ >+ public void setContentType() { >+ String type = attachment.getContentType(); >+ String[] typeList = contentTypeList.getItems(); >+ for (int i = 0; i < typeList.length; i++) { >+ if (typeList[i].equals(type)) { >+ contentTypeList.select(i); >+ contentTypeList.setEnabled(false); >+ isPatchButton.setEnabled(false); >+ return; >+ } >+ } >+ } >+ >+ public boolean supportsDescription() { >+ return supportsDescription; >+ } >+ >+ public void setSupportsDescription(boolean supportsDescription) { >+ this.supportsDescription = supportsDescription; >+ } >+ >+} >Index: .refactorings/2008/3/11/refactorings.history >=================================================================== >RCS file: .refactorings/2008/3/11/refactorings.history >diff -N .refactorings/2008/3/11/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2008/3/11/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<session version="1.0">
<refactoring comment="Copy 1 elements(s) to 'org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizard.java'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Destination element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizard.java'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizard.java'" description="Copy compilation unit" destination="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{NewAttachmentWizard.java" element1="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{NewAttachmentWizard.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205637874637" units="1" version="1.0"/>
<refactoring comment="Inline local variable 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().section' in 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard()'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().section'" description="Inline local variable 'section'" id="org.eclipse.jdt.ui.inline.temp" input="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{TaskAttachmentWizard.java" selection="3849 59" stamp="1205638311233" version="1.0"/>
<refactoring comment="Inline local variable 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().workbenchSettings' in 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard()'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().workbenchSettings'" description="Inline local variable 'workbenchSettings'" id="org.eclipse.jdt.ui.inline.temp" input="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{TaskAttachmentWizard.java" selection="3763 66" stamp="1205638314204" version="1.0"/>
<refactoring comment="Copy 1 elements(s) to 'org.eclipse.mylyn.internal.tasks.ui.wizards.ColorSelectionWindow.java'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Destination element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.ColorSelectionWindow.java'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.InputAttachmentSourcePage.java'" description="Copy compilation unit" destination="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{ColorSelectionWindow.java" element1="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{InputAttachmentSourcePage.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205639811155" units="1" version="1.0"/>
<refactoring comment="Copy 1 elements(s) to 'org.eclipse.mylyn.internal.tasks.ui.wizards.InputAttachmentSourcePage.java'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Destination element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.InputAttachmentSourcePage.java'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentPage.java'" description="Copy compilation unit" destination="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{InputAttachmentSourcePage.java" element1="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{NewAttachmentPage.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205643619044" units="1" version="1.0"/>
<refactoring comment="Copy 1 elements(s) to 'org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskPage.java'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Destination element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskPage.java'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.PreviewAttachmentPage.java'" description="Copy compilation unit" destination="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{NewTaskPage.java" element1="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{PreviewAttachmentPage.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205643880147" units="1" version="1.0"/>
<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylyn.tasks.ui'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.PreviewTaskAttachmentPage.java'" description="Delete element" element1="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{PreviewTaskAttachmentPage.java" elements="1" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1205643958946" subPackages="false" version="1.0"/>
<refactoring comment="Extract method 'private TaskAttachmentPage createEditPage()' from 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.addPages()' to 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Method name: 'createEditPage'
- Destination type: 'org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard'
- Declared visibility: 'private'" comments="false" description="Extract method 'createEditPage'" destination="0" exceptions="false" flags="786434" id="org.eclipse.jdt.ui.extract.method" input="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{TaskAttachmentWizard.java" name="createEditPage" replace="false" selection="7109 38" stamp="1205644094274" version="1.0" visibility="2"/>
<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylyn.tasks.ui'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Original element: 'org.eclipse.mylyn.internal.tasks.ui.wizards.SelectAttachmentSourcePage.java'" description="Delete element" element1="/src<org.eclipse.mylyn.internal.tasks.ui.wizards{SelectAttachmentSourcePage.java" elements="1" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1205645767648" subPackages="false" version="1.0"/> >+</session> >Index: .refactorings/2008/3/11/refactorings.index >=================================================================== >RCS file: .refactorings/2008/3/11/refactorings.index >diff -N .refactorings/2008/3/11/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2008/3/11/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+1205637874637 Copy compilation unit >+1205638311233 Inline local variable 'section' >+1205638314204 Inline local variable 'workbenchSettings' >+1205639811155 Copy compilation unit >+1205643619044 Copy compilation unit >+1205643880147 Copy compilation unit >+1205643958946 Delete element >+1205644094274 Extract method 'createEditPage' >+1205645767648 Delete element >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,310 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.wizards; >+ >+import java.io.ByteArrayInputStream; >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileNotFoundException; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.mylyn.internal.tasks.core.AbstractTaskAttachmentSource; >+import org.eclipse.mylyn.internal.tasks.core.TaskAttachment; >+import org.eclipse.mylyn.internal.tasks.ui.SubmitTaskAttachmentJob; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; >+import org.eclipse.mylyn.monitor.core.StatusHandler; >+import org.eclipse.mylyn.tasks.core.AbstractAttachmentHandler; >+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; >+import org.eclipse.mylyn.tasks.core.RepositoryStatus; >+import org.eclipse.mylyn.tasks.core.TaskRepository; >+import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.tasks.ui.TasksUiUtil; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.dnd.Clipboard; >+import org.eclipse.swt.dnd.TextTransfer; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.ImageLoader; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * A wizard to add a new attachment to a task report. >+ * >+ * @since 3.0 >+ * @author Jeff Pound >+ * @author Steffen Pingel >+ */ >+public class TaskAttachmentWizard extends Wizard { >+ >+ static class ClipboardSource extends AbstractTaskAttachmentSource { >+ >+ @Override >+ public InputStream createInputStream(IProgressMonitor monitor) throws CoreException { >+ String content = getContent(); >+ if (content != null) { >+ return new ByteArrayInputStream(content.getBytes()); >+ } >+ throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Invalid content type.")); >+ } >+ >+ protected String getContent() { >+ Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay()); >+ Object o = clipboard.getContents(TextTransfer.getInstance()); >+ clipboard.dispose(); >+ if (o instanceof String) { >+ return (String) o; >+ } >+ return null; >+ } >+ >+ @Override >+ public String getContentType() { >+ return "text/plain"; >+ } >+ >+ @Override >+ public long getLength() { >+ String content = getContent(); >+ if (content != null) { >+ return content.length(); >+ } >+ return -1; >+ } >+ >+ @Override >+ public String getName() { >+ return "clipboard.txt"; >+ } >+ >+ @Override >+ public boolean isLocal() { >+ return true; >+ } >+ >+ }; >+ >+ static class FileSource extends AbstractTaskAttachmentSource { >+ >+ private final File file; >+ >+ public FileSource(File file) { >+ this.file = file; >+ } >+ >+ @Override >+ public InputStream createInputStream(IProgressMonitor monitor) throws CoreException { >+ try { >+ return new FileInputStream(file); >+ } catch (FileNotFoundException e) { >+ throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, e.getMessage(), e)); >+ } >+ } >+ >+ @Override >+ public String getContentType() { >+ return null; >+ } >+ >+ @Override >+ public long getLength() { >+ return file.length(); >+ } >+ >+ @Override >+ public String getName() { >+ return file.getName(); >+ } >+ >+ @Override >+ public boolean isLocal() { >+ return true; >+ } >+ >+ } >+ >+ static class ImageSource extends AbstractTaskAttachmentSource { >+ >+ private File file; >+ >+ private final IImageCreator imageCreator; >+ >+ public ImageSource(IImageCreator imageCreator) { >+ this.imageCreator = imageCreator; >+ } >+ >+ @Override >+ public InputStream createInputStream(IProgressMonitor monitor) throws CoreException { >+ // TODO check dirty status >+ Image image = imageCreator.createImage(); >+ try { >+ file = File.createTempFile("screenshot", ".jpg"); >+ file.deleteOnExit(); >+ ImageLoader loader = new ImageLoader(); >+ loader.data = new ImageData[] { image.getImageData() }; >+ // create image in memory? >+ loader.save(new FileOutputStream(file), SWT.IMAGE_JPEG); >+ return new FileInputStream(file); >+ } catch (IOException e) { >+ throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, e.getMessage(), e)); >+ } finally { >+ image.dispose(); >+ } >+ } >+ >+ @Override >+ public String getContentType() { >+ return "image/jpeg"; >+ } >+ >+ @Override >+ public long getLength() { >+ return (file != null) ? file.length() : -1; >+ } >+ >+ @Override >+ public String getName() { >+ return "screenshot.jpg"; >+ } >+ >+ @Override >+ public boolean isLocal() { >+ return true; >+ } >+ >+ } >+ >+ public enum Mode { >+ DEFAULT, SCREENSHOT >+ } >+ >+ static class StringSource extends ClipboardSource { >+ >+ private final String content; >+ >+ public StringSource(String content) { >+ this.content = content; >+ } >+ >+ @Override >+ protected String getContent() { >+ return content; >+ } >+ >+ } >+ >+ private static final String DIALOG_SETTINGS_KEY = "AttachmentWizard"; >+ >+ private Mode mode = Mode.DEFAULT; >+ >+ private final TaskAttachment taskAttachment; >+ >+ private final TaskRepository taskRepository; >+ >+ public TaskAttachmentWizard(TaskRepository taskRepository, TaskAttachment taskAttachment) { >+ this.taskRepository = taskRepository; >+ this.taskAttachment = taskAttachment; >+ >+ if (mode == Mode.SCREENSHOT) { >+ setWindowTitle("Attach Screenshot"); >+ setDefaultPageImageDescriptor(TasksUiImages.BANNER_SCREENSHOT); >+ } else { >+ setWindowTitle("Add Attachment"); >+ setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPOSITORY); >+ } >+ >+ setNeedsProgressMonitor(true); >+ setDialogSettings(TasksUiPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY)); >+ } >+ >+ @Override >+ public void addPages() { >+ if (taskAttachment.getSource() == null) { >+ if (mode == Mode.SCREENSHOT) { >+ ScreenshotAttachmentPage shotPage = new ScreenshotAttachmentPage(); >+ taskAttachment.setSource(new ImageSource(shotPage)); >+ addPage(shotPage); >+ } else { >+ InputAttachmentSourcePage inputPage = new InputAttachmentSourcePage(null); >+ inputPage.setTaskAttachment(taskAttachment); >+ addPage(inputPage); >+ } >+ } >+ >+ addPage(createEditPage()); >+ } >+ >+ protected TaskAttachmentPage createEditPage() { >+ return new TaskAttachmentPage(taskAttachment); >+ } >+ >+ public TaskAttachment getAttachment() { >+ return taskAttachment; >+ } >+ >+ private void handleSubmitError(final CoreException exception) { >+ if (exception.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) { >+ if (TasksUiUtil.openEditRepositoryWizard(taskRepository) == Window.OK) { >+ // performFinish(); >+ } >+ } else { >+ StatusHandler.displayStatus("Attachment failed", exception.getStatus()); >+ } >+ } >+ >+ @Override >+ public boolean performFinish() { >+// attachPage.populateAttachment(); >+// final String path = inputPage.getAbsoluteAttachmentPath(); >+ // upload the attachment >+ final AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector( >+ taskRepository.getConnectorKind()); >+ final AbstractAttachmentHandler attachmentHandler = connector.getAttachmentHandler(); >+ if (attachmentHandler == null) { >+ return false; >+ } >+ >+// final boolean attachContext = attachPage.getAttachContext(); >+ >+ final SubmitTaskAttachmentJob job = new SubmitTaskAttachmentJob(connector, taskRepository, taskAttachment); >+ try { >+ getContainer().run(true, true, new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ job.run(monitor); >+ } >+ }); >+ } catch (InvocationTargetException e) { >+ if (e.getCause() instanceof CoreException) { >+ handleSubmitError((CoreException) e.getCause()); >+ } else { >+ StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Attachment failure", e)); >+ } >+ return false; >+ } catch (InterruptedException e) { >+ // cancelled >+ return false; >+ } >+ >+ return true; >+ } >+ >+ public void setMode(Mode mode) { >+ this.mode = mode; >+ } >+ >+} >#P org.eclipse.mylyn.tasks.core >Index: src/org/eclipse/mylyn/tasks/core/RepositoryTaskData.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/RepositoryTaskData.java,v >retrieving revision 1.32 >diff -u -r1.32 RepositoryTaskData.java >--- src/org/eclipse/mylyn/tasks/core/RepositoryTaskData.java 15 Mar 2008 07:28:17 -0000 1.32 >+++ src/org/eclipse/mylyn/tasks/core/RepositoryTaskData.java 16 Mar 2008 05:39:04 -0000 >@@ -269,6 +269,7 @@ > return attachments; > } > >+ // API 3.0 rename to getTaskId() > public String getId() { > return reportID; > } >Index: src/org/eclipse/mylyn/tasks/core/RepositoryTaskAttribute.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/RepositoryTaskAttribute.java,v >retrieving revision 1.39 >diff -u -r1.39 RepositoryTaskAttribute.java >--- src/org/eclipse/mylyn/tasks/core/RepositoryTaskAttribute.java 1 Mar 2008 21:38:35 -0000 1.39 >+++ src/org/eclipse/mylyn/tasks/core/RepositoryTaskAttribute.java 16 Mar 2008 05:39:04 -0000 >@@ -156,6 +156,21 @@ > */ > public static final String TYPE_TASK_DEPENDENCY = "taskDepenedency"; > >+ /** >+ * @since 3.0 >+ */ >+ public static final String TYPE_CONTAINER = "container"; >+ >+ /** >+ * @since 3.0 >+ */ >+ public static final String TYPE_COMMENT = "comment"; >+ >+ /** >+ * @since 3.0 >+ */ >+ public static final String TYPE_ATTACHMENT = "attachment"; >+ > private boolean hidden = false; > > private boolean isReadOnly = false; >Index: src/org/eclipse/mylyn/internal/tasks/core/AbstractAttributeMapper.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractAttributeMapper.java,v >retrieving revision 1.4 >diff -u -r1.4 AbstractAttributeMapper.java >--- src/org/eclipse/mylyn/internal/tasks/core/AbstractAttributeMapper.java 1 Mar 2008 21:38:35 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/tasks/core/AbstractAttributeMapper.java 16 Mar 2008 05:39:04 -0000 >@@ -15,6 +15,7 @@ > > import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory; > import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute; >+import org.eclipse.mylyn.tasks.core.RepositoryTaskData; > > /** > * @author Steffen Pingel >@@ -108,4 +109,18 @@ > > public abstract String getType(RepositoryTaskAttribute taskAttribute); > >+ public AbstractTaskAttachment getTaskAttachment(RepositoryTaskAttribute taskAttribute) { >+ RepositoryTaskData taskData = taskAttribute.getTaskData(); >+ String attachmentId = ""; >+ TaskAttachment attachment = new TaskAttachment(taskData.getRepositoryUrl(), taskData.getRepositoryKind(), >+ taskData.getId(), attachmentId); >+ return attachment; >+ } >+ >+ public AbstractTaskAttachment createTaskAttachment(RepositoryTaskData taskData) { >+ TaskAttachment attachment = new TaskAttachment(taskData.getRepositoryUrl(), taskData.getRepositoryKind(), >+ taskData.getId(), ""); >+ return attachment; >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachment.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachment.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachment.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachment.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,67 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+package org.eclipse.mylyn.internal.tasks.core; >+ >+import java.io.InputStream; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+/** >+ * @author Steffen Pingel >+ */ >+public abstract class AbstractTaskAttachment { >+ >+ private final String attachmentId; >+ >+ private final String connectorKind; >+ >+ private final String repositoryUrl; >+ >+ private final String taskId; >+ >+ public AbstractTaskAttachment(String connectorKind, String repositoryUrl, String taskId, String attachmentId) { >+ this.connectorKind = connectorKind; >+ this.repositoryUrl = repositoryUrl; >+ this.taskId = taskId; >+ this.attachmentId = attachmentId; >+ } >+ >+ public abstract InputStream createInputStream(IProgressMonitor monitor) throws CoreException; >+ >+ public String getAttachmentId() { >+ return attachmentId; >+ } >+ >+ public String getConnectorKind() { >+ return connectorKind; >+ } >+ >+ public abstract String getContentType(); >+ >+ public abstract String getDescription(); >+ >+ public abstract long getLength(); >+ >+ public abstract String getName(); >+ >+ public String getRepositoryUrl() { >+ return repositoryUrl; >+ } >+ >+ public String getTaskId() { >+ return taskId; >+ } >+ >+ public abstract String getUrl(); >+ >+ public abstract boolean isLocal(); >+ >+ public abstract boolean isPatch(); >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/core/TaskAttachment.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/TaskAttachment.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/TaskAttachment.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/TaskAttachment.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.core; >+ >+import java.io.InputStream; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+/** >+ * @since 3.0 >+ * @author Steffen Pingel >+ */ >+public class TaskAttachment extends AbstractTaskAttachment { >+ >+ private String comment; >+ >+ private String contentType; >+ >+ private String description; >+ >+ private boolean patch; >+ >+ private AbstractTaskAttachmentSource source; >+ >+ private String url; >+ >+ public TaskAttachment(String connectorKind, String repositoryUrl, String taskId, String attachmentId) { >+ super(connectorKind, repositoryUrl, taskId, attachmentId); >+ } >+ >+ @Override >+ public InputStream createInputStream(IProgressMonitor monitor) throws CoreException { >+ return source.createInputStream(monitor); >+ } >+ >+ public String getComment() { >+ return comment; >+ } >+ >+ @Override >+ public String getContentType() { >+ return source != null ? source.getContentType() : null; >+ } >+ >+ @Override >+ public String getDescription() { >+ return description; >+ } >+ >+ @Override >+ public long getLength() { >+ return source != null ? source.getLength() : null; >+ } >+ >+ @Override >+ public String getName() { >+ return source != null ? source.getName() : null; >+ } >+ >+ public AbstractTaskAttachmentSource getSource() { >+ return source; >+ } >+ >+ @Override >+ public String getUrl() { >+ return url; >+ } >+ >+ @Override >+ public boolean isLocal() { >+ return source != null && source.isLocal(); >+ } >+ >+ @Override >+ public boolean isPatch() { >+ return patch; >+ } >+ >+ public void setComment(String comment) { >+ this.comment = comment; >+ } >+ >+ public void setContentType(String contentType) { >+ this.contentType = contentType; >+ } >+ >+ public void setDescription(String description) { >+ this.description = description; >+ } >+ >+ public void setPatch(boolean patch) { >+ this.patch = patch; >+ } >+ >+ public void setSource(AbstractTaskAttachmentSource source) { >+ this.source = source; >+ } >+ >+ public void setUrl(String url) { >+ this.url = url; >+ } >+} >Index: src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachmentSource.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachmentSource.java >diff -N src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachmentSource.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachmentSource.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.core; >+ >+import java.io.InputStream; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+public abstract class AbstractTaskAttachmentSource { >+ >+ public abstract InputStream createInputStream(IProgressMonitor monitor) throws CoreException; >+ >+ public abstract boolean isLocal(); >+ >+ public abstract long getLength(); >+ >+ public abstract String getName(); >+ >+ public abstract String getContentType(); >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 222833
: 92646 |
92648
|
92668
|
92669
|
98295