Selecting a directory - eclipse-rcp

Is there any way to use the FileDialog to select a directory instead of just a file?
I am aware of this SWT FileDialog: Selecting directories instead of files. But in the latest version of Eclipse (2018-09 4.9) a file selection dialog is used in a place where the DirectoryDialog was usually used (Project Explorer | Import | Existing Maven Project | Browse). I would really like to use this dialog instead of the DirectoryDialog.

Related

Editing workspace source associated with jar file in same workspace

I have a project A in eclipse whose code is compiled into a jar and used by a separate project B.
I have associated the jar to the workspace project A code.
When I run project B I get stack trace on the console which references the jar.
When clicking on the references the correct file opens up from project A but as read only, I want to edit this file and fix my code.
What I end up doing is open the file manually using search typing the name or navigating to it in the package explorer and then edit it.
I mean file is there in the project in my workspace, why is it not editable?
Is there any way around it?
To open a Java file of project A with the Java Editor (editable) instead of with the Java Class Viewer (read-only) when you are in your project B, you have to do the following:
Right-click project B and choose Properties
In Java Build Path, tab Projects click Add...
Select project A and click OK
In Java Build Path, tab Order and Export move project A to the top by selecting project A and clicking UP several times
Click Apply and Close to close properties dialog of project B
I would recommend convert project A to a plug-in project. A plug-in JAR can be used in both, a plain Java and an OSGi application. The code would be more modular and changes in project A would not require a JAR file to be updated in project B.

Eclipse 4.3 SR1: when creating a new item (file, class, etc), it doesn't take into account the current selection

I have recently updated to Eclipse 4.3 (SR1, WTP). And I have an issue: when I want to create something: a file, a class, a dir, etc:
I right click on a dir (or package); e.g. "myDir", or "myPackage"
the wizard appears, but it doesn't propose "myDir" or "myPackage" as parent element. I need to manually specify it
Do you have any idea what may cause this strange behaviour?
For Java Eclipse will only use the folder / package if the folder you right click on in is a source folder (usually the src folder). Source folders are defined in the project preferences in the Java Build Path Source tab.

Import and run applications in Eclipse from folders

I'm trying to open files and run applications from folders that are not in the Package Explorer tab. I'm trying by using the File/Import/General/File System... I then select the folder, but the Finish button is still disabled!?
Is this not the correct way or is there a better way to open projects from other placeses than Package Explorer Tab?
Go to File>import>General - Select Existing project into workspace
Select project folder, uncheck copy project into workspace click finish. Note: Project must be a valid project.
You can only import a folder which contains Eclipse project specific files like .project etc. This way Eclipse knows it is a project.

Import existing src into root directory of Eclipse Project?

I am using Eclipse Indigo. I already have some code that is stored in a repository outside of my workplace directory. The repository contains various projects and so it wouldn't make sense to include it in the workspace. I have created an empty Java ME project and I now want to import various source files and folders by linking them in. I've played around with various settings, but Eclipse insists on creating a top level folder to hold them. To be clear, the hierarchy is:
Java ME Project -> Unwanted Top Level Folder -> Source Files and Folders
Can I make it instead:
Java ME Project -> Source Files and Folders
Update: Thanks Srikanth for the doc link. According to it, the file system should have a "Create selected folders only" option, but it isn't showing in my version (3.7.0.v20110530)
This feature does not seem to be available in Eclipse 3.7. In 3.6 (and maybe lower) it is possible though. While importing the existing src select Create selected folders only radio button.It will import only the wanted folders.

How do I change a Java project's bin folder in Eclipse?

When you have a Java project in Eclipse, how do you change the location where the class files are placed? The bin directory is the default location.
You can change the folder name from bin to something else.
Right click on your project and select Properties.
And then click on Java Build Path.
On the right side you can see the tabs Source, Projects, Libraries,...
Click on Source. Check the Default output folder:. There you can browse and select the different folder you want.
But you cannot change the directory. For example if your project is in D: drive you cannot keep the output folder in C: drive.
Right click on your project and select Properties.
Java Build Path --> select the Source tab
See the below image for more details:
Right-click on our project --> select properties --> select Java Build Path --> select the Source tab. At the bottom of the tab you should see a field named (Default Output Folder:).
I would like to describe an approach below.
First, create a new empty project locally in eclipse work space for storing generated output files say output_bin.
As mentioned in above steps, now from Default Output Folder we need a new Variable to link to our project output folder.
Default Output Folder -> Browse -> Create New Folder...
-> Advance -> check "Link to folder in the file system" ->
Variables -> New.. -> Name = PROJECT_OUT, Location = "CHOOSE_PATH_TO\output_bin\bin\Project1bin" -> Ok
Note: Project1bin is a new directory which stores the bin folder. output_bin is an empty project and you can have multiple bin folder for various projects.
These answers only describe changing for one specific project.
But if you are using a build tool in Eclipse such as Gradle, you are likely to get annoyed by spurious build errors caused by class files being produced under \bin... the best thing is therefore to change the default output folder:
(Eclipse Mars)
Window --> Preferences --> Java --> Build Path --> Output folder name: change from "bin" to "build"
NB be aware, however, that this (currently) only appears to work when you create a new Java project using the Java project wizard. I import Gradle (STS) projects and find that I nevertheless have to change manually from "bin" to "build" for each project.