Bug 193156 - make attachment filename editable
Summary: make attachment filename editable
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: 3.0   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 209610 (view as bug list)
Depends on: 190944
Blocks: 211072
  Show dependency tree
 
Reported: 2007-06-18 13:42 EDT by Felix Berger CLA
Modified: 2008-06-30 15:36 EDT (History)
3 users (show)

See Also:


Attachments
mylyn/context/zip (3.60 KB, application/octet-stream)
2007-11-20 14:19 EST, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Berger CLA 2007-06-18 13:42:15 EDT
Allow the user to enter a filename for a patch that is going to be attached to an issue and provide a more meaningful default.

BUGID.patch

or

BUGID-summary-delimited-by-dashes.patch

seem good.
Comment 1 Steffen Pingel CLA 2007-06-18 15:27:14 EDT
Related: bug 190944 (JIRA ignores description when submitting attachments).
Comment 2 Steffen Pingel CLA 2007-06-18 15:28:15 EDT
This is relevant to all attachments created from the clipboard.
Comment 3 Mik Kersten CLA 2007-06-18 20:06:20 EDT
A meaningful filename could be better, but we would need to work out a suitable default.
* BUGID.patch: what we consider the task ID is usualy an internal ID (Bugzilla is the exception).  In other issue trackers like JIRA, keys such as JDB-123 can change while the internal ID stays the same.
* summary-delimited-by-dashes.patch: summaries can change while the attachment is still valid.
Comment 4 Steffen Pingel CLA 2007-09-11 14:44:16 EDT
Bumping priority since this we now have bug reports with 10+ attachments all named clipboard.txt that were uploaded through Mylyn.
Comment 5 Steffen Pingel CLA 2007-11-13 20:58:25 EST
Copying description from bug 209610:

Current situation:
If you create a patch to the clipboard and add it to the task, the file is added as clipboard.txt. This is confusing to the commiters that review the patch (all have the same name).

Desired situation:
The patch should be names like bugId_Name.txt, f.e. 207432_20071112.txt.
Comment 6 Steffen Pingel CLA 2007-11-13 20:58:38 EST
*** Bug 209610 has been marked as a duplicate of this bug. ***
Comment 7 Felix Berger CLA 2007-11-14 00:01:58 EST
It might also make sense to give the uploading party a choice to name the patch as they would when saving it to the filesystem.

Otherwise picking up version numbers for a series of patches would be nice too. Let's there already exists a patch named:

adds-feature-foo.patch

The following ones coulde have an incremental version number:

adds-feature-foo-2.patch
Comment 8 Eugene Kuleshov CLA 2007-11-14 00:55:52 EST
Out of curiosity, why do you guys need to save patches and actually care about their names? "Apply path" in the task editor does hide all the low level details.
Comment 9 Steffen Pingel CLA 2007-11-14 01:51:53 EST
Eugene, there are more use-cases than applying patches through Mylyn. Even then it is difficult enough to distinguish  different attachments.

Felix, would you be interested in contributing a patch? Most of the relevant code should be in NewAttachmentWizard. 

Another bug related to the attachment wizard is here: bug  209572 .

Comment 10 Felix Berger CLA 2007-11-14 02:30:46 EST
Yeah, I'd be interested in looking into it, if there are no time constraints on it.
Comment 11 Steffen Pingel CLA 2007-11-14 02:43:53 EST
It's only a minor enhancement with a low priority and no fixed milestone. Assigning to you.
Comment 12 Eugene Kuleshov CLA 2007-11-14 11:13:47 EST
(In reply to comment #9)
> Eugene, there are more use-cases than applying patches through Mylyn. Even then
> it is difficult enough to distinguish  different attachments.

Steffen, sorry, but that was question to original reporters, but since you answered, can you please list the use cases you are referring to? I am still curious to hear why it is difficult to distinguish attachments in Mylyn Task Editor, which shows attachment date and it author. Thanks.
Comment 13 Steffen Pingel CLA 2007-11-14 17:30:49 EST
We had issues that had multiple patches addressing several separate concerns in the bug report. Also it is not very convenient to have a meaningless name clipboard.txt suggested as the default when saving the attachment. Moreover the JIRA web ui does not show the date by default. It will only list filenames. Please take a look at this issue for instance that has 13 attachments named clipboard.txt:

https://www.limewire.org/jira/browse/CORE-310
Comment 14 Eugene Kuleshov CLA 2007-11-15 13:59:44 EST
I see. Thanks Steffen.
Comment 15 Felix Berger CLA 2007-11-17 14:52:29 EST
After looking at the code for a bit I have a few questions and a few suggestions for refactoring it:

* Implicit dependencies on NewAttachmentWizard in PreviewAttachmentPage. It casts the wizard to this type in createControl.

I'm in favor making the dependency explicit by passing in the right type of Wizard in the constructor, or better rely on the LocalAttachment as model and get the preview contents from there encapsulating where the content comes from.

* Store the type of attachment in LocalAttachment and try to only pass it around between wizard pages if possible. Also remove the file reading in PreviewAttachmentPage and move it into LocalAttachment as an implementation detail, can also cache the contents there, once read.

* Remove checks where InputAttachmentSourcePage.CLIPBOARD_LABEL is used to find out if an attachment is a clipboard attachment.

* I would only show the "Attachment File Name" field when the attachment comes from the clipboard, otherwise the control would not be visible.

Thanks for your comments,
Felix
Comment 16 Steffen Pingel CLA 2007-11-19 22:42:16 EST
These suggestions sound great. As long as the involved classes are in internal packages we can make these changes. I'll take a more detailed look later today. Could you attach your context?
Comment 17 Eugene Kuleshov CLA 2007-11-20 01:18:09 EST
+1 for using LocalAttachment as a placeholder, but I don't think it is a good idea to put file reading inside that class.

Also before doing these changes it would make sense to finish Willian's patch on bug 195691 which will be conflicting.
Comment 18 Felix Berger CLA 2007-11-20 13:22:09 EST
Can't attach my context, other projects slipped in and Eclipse hangs whenever I try to remove them from the context. I'll file a separate issue for that.
Comment 19 Steffen Pingel CLA 2007-11-20 14:19:25 EST
> Can't attach my context, other projects slipped in and Eclipse hangs whenever I
> try to remove them from the context. I'll file a separate issue for that.

Yes, removing items from the context can cause excessive refresh, please comment on bug 202817 . 

> * Implicit dependencies on NewAttachmentWizard in PreviewAttachmentPage. It
> casts the wizard to this type in createControl.
>
> I'm in favor making the dependency explicit by passing in the right type of
> Wizard in the constructor, or better rely on the LocalAttachment as model and
> get the preview contents from there encapsulating where the content comes from.

That sounds exactly right. Sharing an instance of LocalAttachment between the wizard pages will make this dependency unnecessary.

> * Store the type of attachment in LocalAttachment and try to only pass it around
> between wizard pages if possible. Also remove the file reading in
> PreviewAttachmentPage and move it into LocalAttachment as an implementation
> detail, can also cache the contents there, once read.

That makes sense. Is there a common interface that could be used to abstract access to the data like InputStreams or IStorage?

> * Remove checks where InputAttachmentSourcePage.CLIPBOARD_LABEL is used to find
> out if an attachment is a clipboard attachment.

It would be great if this could abstracted in LocalAttachment.

> * I would only show the "Attachment File Name" field when the attachment comes
> from the clipboard, otherwise the control would not be visible.

I think it would be okay to also show it in the other cases, particularly for JIRA which ignores the description. You can go with the implementation that is easiest and we can iterate on the UI afterwards.  

Felix, don't worry about other contributions conflicting with these changes. I'll take care of the merging if necessary.
Comment 20 Steffen Pingel CLA 2007-11-20 14:19:30 EST
Created attachment 83351 [details]
mylyn/context/zip
Comment 21 Steffen Pingel CLA 2008-05-02 03:30:41 EDT
Implemented as part of bug 222833. All wizard pages now share a common data model and editing of filenames is enabled for JIRA.

For attachments from the clipboard the filename still defaults to clipboard.txt. Have we converged on a better default?
Comment 22 Steffen Pingel CLA 2008-06-30 15:36:31 EDT
Marking this bug as resolved. I have opened bug 239045 for further discussion about to the default filename for attachments created from the clipboard.