Bug 538713 - When opening a file from filesystem, add it to a dummy project as linked resources
Summary: When opening a file from filesystem, add it to a dummy project as linked reso...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2018-09-06 05:40 EDT by Mickael Istria CLA
Modified: 2018-09-17 01:22 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2018-09-06 05:40:20 EDT
It's frequent that when doing File > Open File... in Eclipse IDE, I'd later would like to reuse those files for other things like showing a local history, diffing with other files and so on. But the vast majority of those powerful actions require file to be visible in the Project Explorer.

When opening a file from filesystem, instead of just showing the editor, it would be convenient to automatically imported as an external resource in the workspace. I imagine we could create a "opened non-project files" or even a "my-sandbox" project and add those external files as children on this project as linked resources.
Comment 1 Lars Vogel CLA 2018-09-06 05:49:57 EDT
+1 I have the same issue for opening files via the command line.

Example:

`eclipse build.gradle` opens the build.gradle in an editor. Now I would love to diff my changes via Eclipse but for this, I need it in the package explorer.

As for the label I think using a name based on the folder name would be another optons.

So if I open build.gradle from the directory "scripts" the label would be "scripts" with build.gradle below it.
Comment 2 Andrey Loskutov CLA 2018-09-06 05:51:45 EDT
Please note, that this will not help with git history context, becuse projects allow only 1:1 mapping to repos.

The idea itself is interesting. We have already 'hidden' projects for search, jdt external folders and something else I can't remember right now. In our product we also create hidden project for some temporary files.

May be this can be generalized?

At lest for the opened external files: should the project disappear on Eclipse restart? Or other way around: how we will do a house keeping there?
Comment 3 Mickael Istria CLA 2018-09-06 05:57:15 EDT
(In reply to Andrey Loskutov from comment #2)
> Please note, that this will not help with git history context, becuse
> projects allow only 1:1 mapping to repos.

Indeed. That could become later an enhancement request for EGit ;)

> The idea itself is interesting. We have already 'hidden' projects for
> search, jdt external folders and something else I can't remember right now.
> In our product we also create hidden project for some temporary files.
> May be this can be generalized?

I don't think this one should be hidden.
And I think we should try to have JDT or other reusing this too. They have their own hidden projects for their reasons which are probably not at all the same as the ones here. There are probably assumptions made on those hidden project that we cannot assume remain true with a "sandbox" project.

> At lest for the opened external files: should the project disappear on
> Eclipse restart? Or other way around: how we will do a house keeping there?

Or another approach: should the IDE do the house keeping automatically or should the user take care of it. The later seems better to me.
Comment 4 Thomas Wolf CLA 2018-09-06 07:44:32 EDT
(In reply to Mickael Istria from comment #3)
> (In reply to Andrey Loskutov from comment #2)
> > Please note, that this will not help with git history context, becuse
> > projects allow only 1:1 mapping to repos.
> 
> Indeed. That could become later an enhancement request for EGit ;)
The restriction that a project must be wholly in one repository (modulo folders in submodules/nested repos) is so deeply ingrained in EGit that I will not change that. I'm not even sure it could be done at all; it would depend on the assumptions Team makes.

The git history of non-workspace files and comparison between versions is available through the git history page.
Comment 5 Nathan Ridge CLA 2018-09-06 17:58:21 EDT
Related suggestions for making Open File friendlier:

  - Give it a friendlier keyboard shortcut than the
    current Alt + F followed by period.

  - Have the dialog start in the workspace directory
    rather than the user's home directory.
Comment 6 Mickael Istria CLA 2018-09-07 01:39:07 EDT
(In reply to Nathan Ridge from comment #5)
> Related suggestions

They're actually not so related. Please.open separate tickets for those.
Comment 7 Greg Amerson CLA 2018-09-07 02:26:08 EDT
I've been using the atom editor recently to fill in a gap that I think Eclipse could fill.  

When I'm roaming around on my filesystem for folders that are coming and going (git branches or ephemeral workspaces) I really want to just "open this folder and see all the files that are under this directory tree in eclipse").  But Eclipse doesn't have a easy way to do this.  Of course I can do this " File > new project > general project > custom location > point to folder > open".  But those steps cause too much friction.

Could we do this?  


$ cd /path/to/some/folder
$ eclipse open .

And eclipse will do the following

1. if folder already have a .project then just open it
2. if no .project, run through 'smart importers' to see if any of them can 'import this type of folder'
3. if no smart importers can do anything, just do the exact same thing as above "create  a .project (basic project) for this folder and open it".

If Eclipse had this workflow, I would avoid using Atom editor and just use eclipse.

No one problem that I'm glossing over is removing the .project or removing the project from eclipse.  I wish Eclipse had a "simple folder/project" concept that didn't require a .project.  But maybe whatever is created by "eclipse open ." could be "uncreated" on workspace/workbench shutdown?? Just thinking out loud.
Comment 8 Greg Amerson CLA 2018-09-07 02:27:38 EDT
Also another problem that I glossed over is the "eclipse open ." getting an "eclipse" executable in your path.  Maybe that is something the OOMPH installers could do?
Comment 9 Mickael Istria CLA 2018-09-07 02:49:44 EDT
(In reply to Greg Amerson from comment #7)
> But Eclipse doesn't have a easy way to do this.  Of course I can
> do this " File > new project > general project > custom location > point to
> folder > open".  But those steps cause too much friction.

File > Open Projects from Filesystem... does that with less friction.

> $ eclipse open .
> And eclipse will do the following
> 1. if folder already have a .project then just open it
> 2. if no .project, run through 'smart importers' to see if any of them can
> 'import this type of folder'
> 3. if no smart importers can do anything, just do the exact same thing as
> above "create  a .project (basic project) for this folder and open it".
> If Eclipse had this workflow, I would avoid using Atom editor and just use
> eclipse.

This seems like proposal in bug 500388
Comment 10 Greg Amerson CLA 2018-09-07 03:16:18 EDT
Thank you for pointing me to that other ticket.  The only thing I don't see there is about the automatically creating the general .project for a folder that has nothing pre-existing or smart-importer doesn't know what to do with it.  I can followup there.
Comment 11 Wim Jongman CLA 2018-09-07 06:40:09 EDT
+1 A great idea. I like it. 

Maybe create a project called "Quick Access" or "Recently Opened" or let the user define a project in the preferences. 

A case can be that I open two files from different locations but with the same name, like pom.xml?
Comment 12 Dani Megert CLA 2018-09-11 10:32:36 EDT
Additional idea: allow to select an existing project.
Comment 13 Mickael Istria CLA 2018-09-11 10:35:03 EDT
(In reply to Dani Megert from comment #12)
> Additional idea: allow to select an existing project.

Do you have a user-story making this useful? The issue with more option is that users tend to dislike the one they never use, so before adding more options, we should have some user-stories supporting them.
Comment 14 Nathan Ridge CLA 2018-09-17 01:22:12 EDT
(In reply to Mickael Istria from comment #6)
> (In reply to Nathan Ridge from comment #5)
> > Related suggestions
> 
> They're actually not so related. Please.open separate tickets for those.

Filed bug 539128 and bug 539129.