org.eclipse.core.resourcesの依存関係を追加して以下のようなコードでプロジェクト名一覧が表示される。
package org.okazuki.helloworld.actions; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; 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 ResourceAction implements IWorkbenchWindowActionDelegate { private IWorkbenchWindow window; public void dispose() { } public void init(IWorkbenchWindow window) { this.window = window; } public void run(IAction action) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject[] projects = root.getProjects(); StringBuilder sb = new StringBuilder(); for (IProject project : projects) { sb.append(project.getName()).append("\n"); } MessageDialog.openConfirm(window.getShell(), "Plugins", sb.toString()); } public void selectionChanged(IAction action, ISelection selection) { } }