Skip to content

Instantly share code, notes, and snippets.

@samueltcsantos
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueltcsantos/11093131 to your computer and use it in GitHub Desktop.
Save samueltcsantos/11093131 to your computer and use it in GitHub Desktop.
Listando todos os projetos do workspace
package com.jdt.info.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
/**
* Our sample handler extends AbstractHandler,
* an IHandler base class.
*
* @author xpto Samuel T. C. Santos
*
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class SampleHandler extends AbstractHandler {
/**
* The constructor.
*/
public SampleHandler() {
}
/**
* the command has been executed, so extract extract
* the needed information from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject[] projects = root.getProjects();
for (IProject project : projects){
System.out.println(project.getName());
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment