|
1 /** |
|
2 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Symbian Foundation - initial contribution. |
|
11 * Contributors: |
|
12 * Description: |
|
13 * Overview: |
|
14 * Details: |
|
15 * Platforms/Drives/Compatibility: |
|
16 * Assumptions/Requirement/Pre-requisites: |
|
17 * Failures and causes: |
|
18 */ |
|
19 package org.symbian.tools.tmw.core.internal.facets; |
|
20 |
|
21 import org.eclipse.core.resources.IProject; |
|
22 import org.eclipse.core.runtime.CoreException; |
|
23 import org.eclipse.core.runtime.IProgressMonitor; |
|
24 import org.eclipse.core.runtime.Path; |
|
25 import org.eclipse.core.runtime.SubProgressMonitor; |
|
26 import org.eclipse.wst.common.project.facet.core.IDelegate; |
|
27 import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
|
28 import org.eclipse.wst.jsdt.core.IIncludePathEntry; |
|
29 import org.eclipse.wst.jsdt.core.IJavaScriptProject; |
|
30 import org.eclipse.wst.jsdt.core.JavaScriptCore; |
|
31 import org.eclipse.wst.validation.ValidationFramework; |
|
32 import org.symbian.tools.tmw.core.projects.IProjectSetupAction; |
|
33 |
|
34 public class InstallCoreFacetAction implements IDelegate { |
|
35 |
|
36 public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) |
|
37 throws CoreException { |
|
38 monitor.beginTask("Preparing mobile web application project", 300); |
|
39 final IJavaScriptProject jsProject = JavaScriptCore.create(project); |
|
40 final IIncludePathEntry[] rawIncludepath = jsProject.getRawIncludepath(); |
|
41 final Path path = new Path("tmw.coreLibrary"); |
|
42 final int originalEntryCount = rawIncludepath.length; |
|
43 |
|
44 IIncludePathEntry[] newIncludepath = new IIncludePathEntry[originalEntryCount + 1]; |
|
45 System.arraycopy(rawIncludepath, 0, newIncludepath, 0, originalEntryCount); |
|
46 for (IIncludePathEntry entry : rawIncludepath) { |
|
47 if (entry.getPath().equals(path)) { |
|
48 newIncludepath = null; |
|
49 break; |
|
50 } |
|
51 } |
|
52 if (newIncludepath != null) { |
|
53 final IIncludePathEntry newContainerEntry = JavaScriptCore.newContainerEntry(path, false); |
|
54 newIncludepath[originalEntryCount] = newContainerEntry; |
|
55 jsProject.setRawIncludepath(newIncludepath, new SubProgressMonitor(monitor, 30)); |
|
56 } |
|
57 ValidationFramework.getDefault().addValidationBuilder(project); |
|
58 |
|
59 IProjectSetupAction action = (IProjectSetupAction) config; |
|
60 if (action != null) { |
|
61 action.initialize(project, new SubProgressMonitor(monitor, 270)); |
|
62 } |
|
63 monitor.done(); |
|
64 } |
|
65 } |