19 package org.symbian.tools.tmw.core.internal.facets; |
19 package org.symbian.tools.tmw.core.internal.facets; |
20 |
20 |
21 import org.eclipse.core.resources.IProject; |
21 import org.eclipse.core.resources.IProject; |
22 import org.eclipse.core.runtime.CoreException; |
22 import org.eclipse.core.runtime.CoreException; |
23 import org.eclipse.core.runtime.IProgressMonitor; |
23 import org.eclipse.core.runtime.IProgressMonitor; |
24 import org.eclipse.core.runtime.Path; |
|
25 import org.eclipse.wst.common.project.facet.core.IDelegate; |
24 import org.eclipse.wst.common.project.facet.core.IDelegate; |
26 import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
25 import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
27 import org.eclipse.wst.jsdt.core.IIncludePathEntry; |
|
28 import org.eclipse.wst.jsdt.core.IJavaScriptProject; |
|
29 import org.eclipse.wst.jsdt.core.JavaScriptCore; |
|
30 |
26 |
31 public class InstallFacetAction implements IDelegate { |
27 public class InstallFacetAction implements IDelegate { |
32 |
28 |
33 public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) |
29 public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) |
34 throws CoreException { |
30 throws CoreException { |
35 final IJavaScriptProject jsProject = JavaScriptCore.create(project); |
31 // Do nothing |
36 final IIncludePathEntry[] rawIncludepath = jsProject.getRawIncludepath(); |
|
37 final Path path = new Path("tmw.coreLibrary"); |
|
38 final int originalEntryCount = rawIncludepath.length; |
|
39 |
|
40 IIncludePathEntry[] newIncludepath = new IIncludePathEntry[originalEntryCount + 1]; |
|
41 System.arraycopy(rawIncludepath, 0, newIncludepath, 0, originalEntryCount); |
|
42 for (IIncludePathEntry entry : rawIncludepath) { |
|
43 if (entry.getPath().equals(path)) { |
|
44 newIncludepath = null; |
|
45 break; |
|
46 } |
|
47 } |
|
48 if (newIncludepath != null) { |
|
49 final IIncludePathEntry newContainerEntry = JavaScriptCore.newContainerEntry(path, false); |
|
50 newIncludepath[originalEntryCount] = newContainerEntry; |
|
51 jsProject.setRawIncludepath(newIncludepath, monitor); |
|
52 } |
|
53 } |
32 } |
54 |
33 |
55 } |
34 } |