|
Lines 4-11
Link Here
|
| 4 |
import java.util.Set; |
4 |
import java.util.Set; |
| 5 |
|
5 |
|
| 6 |
import org.eclipse.core.resources.IProject; |
6 |
import org.eclipse.core.resources.IProject; |
| 7 |
import org.eclipse.core.runtime.CoreException; |
7 |
import org.eclipse.core.runtime.*; |
| 8 |
import org.eclipse.core.runtime.IProgressMonitor; |
8 |
import org.eclipse.php.internal.core.PHPCorePlugin; |
| 9 |
import org.eclipse.php.internal.core.PHPVersion; |
9 |
import org.eclipse.php.internal.core.PHPVersion; |
| 10 |
import org.eclipse.wst.common.project.facet.core.IFacetedProject; |
10 |
import org.eclipse.wst.common.project.facet.core.IFacetedProject; |
| 11 |
import org.eclipse.wst.common.project.facet.core.IProjectFacet; |
11 |
import org.eclipse.wst.common.project.facet.core.IProjectFacet; |
|
Lines 15-20
Link Here
|
| 15 |
public class PHPFacets { |
15 |
public class PHPFacets { |
| 16 |
|
16 |
|
| 17 |
/** |
17 |
/** |
|
|
18 |
* Synchronizes the php version for facets |
| 19 |
* |
| 20 |
* @param project |
| 21 |
* @return the status of setting the version |
| 22 |
*/ |
| 23 |
public static IStatus setFacetedVersion(IProject project, PHPVersion version) { |
| 24 |
if (isFacetedProject(project)) { |
| 25 |
try { |
| 26 |
final IProjectFacetVersion facetedVersion = convertToFacetVersion(version); |
| 27 |
final IProjectFacet phpFacet = ProjectFacetsManager |
| 28 |
.getProjectFacet(PHPFacetsConstants.PHP_COMPONENT); |
| 29 |
final IFacetedProject faceted = ProjectFacetsManager |
| 30 |
.create(project); |
| 31 |
if (!facetedVersion.equals(faceted |
| 32 |
.getInstalledVersion(phpFacet))) { |
| 33 |
final Set<IFacetedProject.Action> actions = new HashSet<IFacetedProject.Action>(); |
| 34 |
actions.add(new IFacetedProject.Action( |
| 35 |
IFacetedProject.Action.Type.VERSION_CHANGE, |
| 36 |
facetedVersion, null)); |
| 37 |
faceted.modify(actions, new NullProgressMonitor()); |
| 38 |
} |
| 39 |
} catch (CoreException ex) { |
| 40 |
return new Status(IStatus.ERROR, PHPCorePlugin.ID, |
| 41 |
Messages.PHPFacets_SettingVersionFailed, ex); |
| 42 |
} catch (IllegalArgumentException ex) { |
| 43 |
return new Status(IStatus.ERROR, PHPCorePlugin.ID, |
| 44 |
Messages.PHPFacets_SettingVersionFailed, ex); |
| 45 |
} |
| 46 |
} |
| 47 |
return Status.OK_STATUS; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 18 |
* Returns true if the given project is a faceted project and the php core |
51 |
* Returns true if the given project is a faceted project and the php core |
| 19 |
* facet is installed |
52 |
* facet is installed |
| 20 |
* |
53 |
* |