Last active
August 29, 2015 14:00
-
-
Save samueltcsantos/11093131 to your computer and use it in GitHub Desktop.
Listando todos os projetos do workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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