Mercurial > hg > thermostat-tools-eclipse
view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/ProjectUtils.java @ 143:5c3c720c875e
Move duplicate project code into shared class
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Thu, 05 Jun 2014 17:50:39 -0400 |
parents | |
children |
line wrap: on
line source
package com.redhat.thermostat.tools.eclipse.plugin; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Path; public class ProjectUtils { private static IWorkspaceRoot root; static { root = ResourcesPlugin.getWorkspace().getRoot(); } /** Return true if {@code name} corresponds to a valid project */ public static boolean isValid(String name) { if (name.length() == 0) { return false; } IResource container = root.findMember(new Path(name)); if (container == null || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { return false; } if (!container.isAccessible()) { return false; } return true; } }