My Eclipse plugin needs files imported as link to the current project.
The current approach is to drag and drop the file from explorer and use the following settings:
I want to achieve the same using my SWT window without the user showing the popup seen in the picture above but rather my own SWT window. It is currently checking if the file exists somewhere on the disc and asks if it's the right file and project (IProject
) to copy into (here starts the trouble).
I could copy the file to the current workspace folder as I already have the project name (IProject
) and could get the (changing) workspace folder by code somehow too. But those files wouldn't actually be links.
Are there any ways of doing it inside Eclipse rather than copying files at the OS level and achieving a link somehow?
Read this link. http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/resInt_linked.htm.
Explained clearly on how to create Link files programmatically. If in case I understood your question wrongly, let me know.
Updated based on comments received
Snippet from the Link which explains how Link files shall be created programatically.
IProject project = workspace.getProject("Project");//assume this exists
IFolder link = project.getFolder("Link");
IPath location = new Path("C:\\temp\\folder");
if (workspace.validateLinkLocation(link , location).isOK()) {
try {
link.createLink(location, IResource.NONE, null);
} catch (CoreException e) {
e.printStackTrace();
}
} else {
//invalid location, throw an exception or warn user
}
You now have a linked folder in your workspace called "Link" that is located at "c:\temp\folder".