Plugins (1067)


Training and Consulting (40)



EPIC Poll

What is your favourite developer portal?

[ Results | Polls ]

Votes: 539
Comments: 0

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
prameela
Post subject: Accessing resources outside your plugin  PostPosted: Jan 08, 2008 - 02:36 AM



Joined: Nov 05, 2007
Posts: 13

Hi,

Has anyone ever tried using some resources outside your plug-in?
The plug-in jar is installed in the ECLIPSE/plugin directory.
If i have another folder within the same directory , what is the best way to get the path to the file(s) stored in that folder.

Any pointers/examples would be of great help,
/Prameela
 
 View user's profile Send private message  
Reply with quote Back to top
bhavya
Post subject: RE: Accessing resources outside your plugin  PostPosted: May 05, 2008 - 06:18 AM



Joined: May 05, 2008
Posts: 2

I had the same issue..
in your Do Finish method add this piece of code


IProjectDescription description = ResourcesPlugin.getWorkspace()
.newProjectDescription(project.getName());
project.create(description, null);

if (project.exists() && !project.isOpen()) {
project.open(null);
}

// Setting Java Nature to the eclipse project
String[] natures = description.getNatureIds();
String[] newNatures = new String[ natures.length + 1 ];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[ natures.length ] = JavaCore.NATURE_ID;
description.setNatureIds(newNatures);
project.setDescription(description, null);

Create Java Project
IJavaProject javaProject = JavaCore.create(project);

if (javaProject.exists() && !javaProject.isOpen()) {
javaProject.open(null);
}
//creating web_struc.xml
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(new Path(containerName));
if (!resource.exists() || !(resource instanceof IContainer)) {
throwCoreException("Container \"" + containerName + "\" does not exist.");
}

IFolder outFolder = project.getFolder(new Path("out"));

if (!outFolder.exists()) {
outFolder.create(false, true, monitor);
}
IFolder outFolder1 = project.getFolder("test");

outFolder1.create(false,true,monitor);

IClasspathEntry[] rawClassPath = javaProject.getRawClasspath();
List classPath = new ArrayList(Arrays.asList(rawClassPath));
classPath.add(JavaRuntime.getDefaultJREContainerEntry());

IClasspathEntry[] paths = (IClasspathEntry[]) classPath.toArray(new IClasspathEntry[ classPath.size() ]);
javaProject.setRawClasspath(paths, null);
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits