| Summary: | [Import/Export] Linux export dialog doesn't expand tilde (~) to home directory | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Patrick Dubroy <Patrick_Dubroy> | ||||
| Component: | IDE | Assignee: | Platform UI Triaged <platform-ui-triaged> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P5 | CC: | airvine, b.muskalla, billy.biggs, denis.roy, douglas.pollock, eclipse, fredrik.attebrant, johan.walles, Kevin_McGuire, maxime_daniel | ||||
| Version: | 2.0 | Keywords: | helpwanted | ||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | stalebug | ||||||
| Bug Depends on: | 22643 | ||||||
| Bug Blocks: | 284163 | ||||||
| Attachments: |
|
||||||
|
Description
Patrick Dubroy
build 20011106 DirectoryDialog is supplied by SWT. Moving to SWT for comment. This does not refer to the DirectoryDialog. To clarify, the problem is with the combo labelled "Directory:", not the dialog that appears when you hit the browse button. Typing a directory such as "~/eclipse/dev/eclipse/jre/bin" into the combo, INSTEAD of browsing to the directory, is what causes the problem. Sorry for the confusion. Moving back to UI. This is platform behaviour. If you execute the following code:
import java.io.*;
public class FileTest {
public static void main(String[] args){
try{
File file = new File("~");
file.mkdirs();
File child = new File(file,"bob.txt");
FileOutputStream stream = new FileOutputStream(child);
stream.write('c');
stream.write('d');
stream.write('e');
stream.write('f');
stream.close();
}
catch (IOException exception){
exception.printStackTrace();
};
}
}
you will get a directory called ~ in your eclipse directory with a file called
bob.txt in it. ~ is a command that the shell offers but it is not a reserved
character in Linux - i.e. it is a valid name for a directory.
I concur that this is confusing however but I am not sure what Eclipse should
do about it.
Platform behaviour. Closing. Please re-open. On Unix platforms ~ means "home directory". Why do you think having this behaviour implemented in all shells (or please provide a counter-example) is contradictory to having Eclipse implement it? Johan, We do not have the cycles to look at this problem right now. Since it is obvious that you really care about solving this problem I encourage you to write the code and submit a patch. If you are interested, let me know through the developer's mailing list; and I will help set you up with a self hosting environment. That you don't want to solve this *now* is not a reason for marking this bug as "invalid". If it is not a high priority bug, lower its priority but don't close it!! What mozilla.org does in their bugzilla is that they have a a "helpwanted" status keyword for bugs they don't want to solve themselves. Then they put "nobody@mozilla.org" as responsible for the bugs and leave them in the Bugzilla. You should probably treat this bug the same way. I am not too sure I can find the time to look at this. If I do, I'll be sure to let you know. Please re-open. Your suggestion for a help wanted status is interesting. Let me think about it some more until then I will lower the priority and change the resolution to LATER. No cycles to deal with this feature request now. I realize that "~" is a valid name for a file but as Johan pointed out, every shell in the known universe treats it as a special character, and consequently so do file selection dialogs. Eclipse is *wrong* to ignore this. I believe that this is not a feature request but a bug. I'm not sure that marking it as RESOLVED is the correct thing to do. Reopen for investigation Andrew asked me if I knew of some apps that could be used as a reference, and I found out some interesting things: - the KDE file selection dialog will do something similar to Eclipse -- if you use ~ in the path it treats it as a directory, eg. /home/pdubroy/~/foo - GNOME file selection dialog does The Right Thing (TM) and expands it to your home directory, and does the same for ~someuser. - Netscape replaces ~ with your home directory as soon as you type it. ie., I type ~ and it is immediately expanded to "/home/pdubroy", so typing ~/foo.c will give me what I expect: /home/pdubroy/foo.c. There is no support for ~someuser. - Mozilla is like Netscape in that it supports only plain ~, but it doesn't do the automatic expansion thing. So Andrew: I can't find any small app that does this on its own. Most people use either the Motif, Qt, or GTK file dialogs. You could try looking at these. I don't think it's bad if Eclipse doesn't do the ~user thing, so the easiest thing is probably to just check for "~/" at the beginning, and if it exists, replace it with the contents of $HOME. I intend to add support for ~/ but not ~username. *** Bug 112181 has been marked as a duplicate of this bug. *** I wonder if this enhancement should be an Platform/UI problem or since 3.2, a thing we could get into EFS. I think it's worth to add this to the EFS Local implementation for Linux to get the ~ working for all operations and not only for Import/Export See related bug 169385 There is a similar issue in team stuff. Are we going to resolve ~ into home directory in location fields? (In reply to comment #19) > There is a similar issue in team stuff. Are we going to resolve ~ into home > directory in location fields? as Tod mentioned in Comment #4, its not supported by Java - just the shells. When I do cd ~ and then hit tab, I'm getting many options (I'm on a Mac) Is the ~ char some sort of standard or just a convention followed by the shells? It's not supported by java, however Eclipse could provide such a thing. Personally I can go either way, however since there are user requests for supporting ~ I asked UI for a comment. If UI says we don't want to do this I will follow and users would have to live with it. I think that ~ is just a convention. The reason why I'm picking it up is bug 284163. I would like to either fix it or close it. BTW this bug looks like it WONT be FIXed ;) (In reply to comment #21) > The reason why I'm picking it up is bug 284163. I would like to either fix it > or close it. BTW this bug looks like it WONT be FIXed ;) If most of the other apps support this, then we must also support this. I wouldn't mark this as wont-fix. Its just the priority of this is low compared to the other bugs we have :-) (In reply to comment #22) > If most of the other apps support this, then we must also support this. I > wouldn't mark this as wont-fix. Its just the priority of this is low compared to > the other bugs we have :-) As Denis states in bug 284163, comment 3 GUI apps support this, so we should probably do the same. (In reply to comment #22) > If most of the other apps support this, then we must also support this. I > wouldn't mark this as wont-fix. Its just the priority of this is low compared > to the other bugs we have :-) Which other apps have this so we can compare? I wasn't able to find any with: Label: <field> [Browse] It works if you use the Browse button in eclipse (because it's the native file dialog). Gedit only opens the native file dialog (so we're compatible). Firefox also opens the native dialog for CTRL+O, but if you type any combination with a ~ into the URL field it fails. Gimp doesn't allow ~ in it's preference fields for folders, but picks it up from the native file dialog as well. It's not enough that "some" apps support this. Firefox and Gimp are major apps, and they don't. PW Adding Denis who is interested in this fix and can answer the Paul's question. Created attachment 143140 [details] Screenshot of Gimp preferences (In reply to comment #24) > Firefox also > opens the native dialog for CTRL+O, but if you type any combination with a ~ > into the URL field it fails. Gimp doesn't allow ~ in it's preference fields > for folders, but picks it up from the native file dialog as well. Hmmm, on both Fedora 11 and Kubuntu, I can use the tilde in any File operation in Firefox (CTRL+O, CTRL+S, etc). Even in the preferences, I can use the tilde for file locations. Of course, it doesn't work in the location bar, but I expected that from a URI field. Same with Gimp -- all the file operations, including Preferences > Folders use the native file dialogs, so I can use the tilde. In the case of Preferences, the native dialog is opened by hitting 'other...' from the short drop-down list. Ironically, I used ~/crud/tilde.jpg in the Gimp Save As dialog, and then again in the Firefox Browse for this here file attachment. As I said in the other bug, I use lots of Linux distros, and for me it's easier to use the keyboard and ~ rather than clickety-click my file browser dialogs -- and Eclipse is consistently screwing me up :) (In reply to comment #26) > Created an attachment (id=143140) [details] > Screenshot of Gimp preferences > > (In reply to comment #24) > > Firefox also > > opens the native dialog for CTRL+O, but if you type any combination with a ~ > > into the URL field it fails. Gimp doesn't allow ~ in it's preference fields > > for folders, but picks it up from the native file dialog as well. > > Hmmm, on both Fedora 11 and Kubuntu, I can use the tilde in any File operation > in Firefox (CTRL+O, CTRL+S, etc). Even in the preferences, I can use the tilde > for file locations. Right, ~ works fine in the native dialog (the same as it does in eclipse). I couldn't find anywhere in firefox to enter a file location without using a browser button (which opens the file dialog which does accept ~). > Same with Gimp -- all the file operations, including Preferences > Folders use > the native file dialogs, so I can use the tilde. In the case of Preferences, > the native dialog is opened by hitting 'other...' from the short drop-down > list. Right, my point is the native file dialog in eclipse works the same way. Click browse, and use ~ to your heart's content. > As I said in the other bug, I use lots of Linux distros, I'm still not seeing a free-form text field in the applications mentioned that accepts ~ PW (In reply to comment #27) > > I'm still not seeing a free-form text field in the applications mentioned that > accepts ~ Does that mean the implications for being comparable to the other native apps is that fields with Browse buttons should be read-only (forcing the user through the native file dialog as Gimp and Firefox do)? I'm not in favour of this, just pointing out that's why these other apps work :-) PW (In reply to comment #24) > Which other apps have this so we can compare? I wasn't able to find any with: > Label: <field> [Browse] Sorry, I guess I haven't had enough coffee yet. The above statement is right: all other apps invoke the native dialog immediately, whereas the patch dialogs allow you to type text (which doesn't support the tilde) or Browse, which uses the native dialog. Looks like Eclipse is somewhat inconsistent with other apps with its Label: <field> [Browse] setup, but in the grand scheme of things I think this is a benefit. I'm going to close my bug 284163 as worksforme. (In reply to comment #28) > I'm not in favour of this, just pointing out that's why these other apps work > :-) Agreed. I think it's good to acknowledge that Eclipse is inconsistent with other apps in this respect (hence the reasons users keep trying to use tilde in the wrong field), but IMHO I think the lesser of two evils is leaving the dialog alone, instead of forcing the user to click [Browse]. FWIW, OpenOffice doesn't seem to use the native dialogs, and it supports using the tilde. Found this bug searching for a solution for tilde expansion under Java on Linux. The following code solved my problem:
String directory_name = "~/";
if(directory_name.contains("~")){
directory_name = directory_name.replace("~", System.getProperty("user.home"));
}
File directory = new File(directory_name);
if(directory.exists){
// ...
}
(In reply to comment #32) > if(directory_name.contains("~")){ > directory_name = directory_name.replace("~", > System.getProperty("user.home")); > } Proper ~ expansion should do (at least) two things: 1. Expand "~" to the current user's home directory. Your code does that. 2. Expand "~username" to user username's home directory. Your code doesn't do that. That said, I think typing just "~" is an infinitely more common use case. And supporting just "~" would be a lot better than trying to create directories named "~". I just tried the export dialog btw, which this bug is about (read the description), and: * The browse button now brings up a file dialog that actually does seem to expand "~" properly. * The file dialog also seems to expand "~username" properly. * If I just type "~/monkey.jar" in the text field, Eclipse still tries to create a ~ directory in my workspace. So the dialog works, but the text box is still broken. Same problem also applies to MacOSX (10.6.5). Ran into this on Eclipse 3.6.1. I've hit this (not being able to use ~ or ~user) in import/export dialogs. Also noted that "~" and "~user" is supported natively by MacOSX in Finder and other apps. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. |