Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » The tree of workspace
The tree of workspace [message #604839] Mon, 01 March 2010 02:16 Go to next message
Caio Lima is currently offline Caio LimaFriend
Messages: 6
Registered: March 2010
Junior Member
Hi guys... :d

This is my first topic on forum...xP


Well...I want know how can i get workspace tree in my plug-in...

The Resoruce API of PDE have any Class, method or interface to do/aux it??

I write this code to access a source...but i need to access all files, of all open projects

See that =D


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;


public class ShowTesteSource implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
@Override
public void dispose() {
// TODO Auto-generated method stub

}

@Override
public void init(IWorkbenchWindow window) {
this.window = window;

}

@Override
public void run(IAction action) {

IWorkspaceRoot rootW=ResourcesPlugin.getWorkspace().getRoot();

IResource project=rootW.findMember("Java");
IProject java=rootW.getProject("Java");

if(java.exists()){
IFile teste=java.getFile("/src/Teste.java");
IContainer[] files=rootW.findContainersForLocationURI(rootW.getLocationUR I());

if(teste.exists()){
//File testeJava=new File(teste.getLocationURI());
try {
BufferedReader sourceIn=new BufferedReader(new InputStreamReader(teste.getContents()));
String line,source="";
while((line=sourceIn.readLine())!=null){
source+=line+"\n";
}

MessageDialog.openInformation(window.getShell(), "Source", source);
} catch (FileNotFoundException e) {
MessageDialog.openInformation(window.getShell(), "Erro", "Arquivo não enconbtrado");
} catch(IOException iOE){
MessageDialog.openInformation(window.getShell(), "Erro", "Erro ao carregar o código!");
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

}

@Override
public void selectionChanged(IAction action, ISelection selection) {
// TODO Auto-generated method stub

}

}



I thank you now =D

Waiting for help

\o/
Re: The tree of workspace [message #604847 is a reply to message #604839] Tue, 02 March 2010 08:44 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
IWorkspaceRoot interface itself has a method getProjects()

which returns IProject instances....

IProject in tern has members method which returns IResource array... hence forth

You have to do thru the resource api fully...

if you want to handle a java project then jdt api has to be studied...

--
---------------------
Regards,
Vijay


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: The tree of workspace [message #604857 is a reply to message #604839] Tue, 02 March 2010 17:42 Go to previous message
Caio Lima is currently offline Caio LimaFriend
Messages: 6
Registered: March 2010
Junior Member
the vijay...this method that you indicated...what is???


It return a IFile ype or IContainer?



Then...i will study the jdt because i will need to use it x)


But before i will understand the resources API x)



On jdt have any thing to manipule it?


thx for the help x)
Previous Topic:The tree of workspace
Next Topic:Buddy policy doubt
Goto Forum:
  


Current Time: Fri May 10 23:08:50 GMT 2024

Powered by FUDForum. Page generated in 0.03020 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top