author | Eugene Ostroukhov <eugeneo@symbian.org> |
Tue, 31 Aug 2010 11:58:53 -0700 | |
changeset 479 | 518afa7c6d2f |
parent 470 | d4809db37847 |
child 480 | b6d992b9b998 |
permissions | -rw-r--r-- |
467
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
/** |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
* All rights reserved. |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
* |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
* Symbian Foundation - initial contribution. |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
* Contributors: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
* Description: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
* Overview: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
* Details: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
* Platforms/Drives/Compatibility: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
* Assumptions/Requirement/Pre-requisites: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
* Failures and causes: |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
*/ |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
package org.symbian.tools.tmw.core.runtimes; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
21 |
import java.io.IOException; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
import java.io.InputStream; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
23 |
import java.util.zip.ZipEntry; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
24 |
import java.util.zip.ZipInputStream; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
25 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
26 |
import org.eclipse.core.resources.IFile; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
import org.eclipse.core.resources.IProject; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
import org.eclipse.core.runtime.CoreException; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
29 |
import org.eclipse.core.runtime.IPath; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
import org.eclipse.core.runtime.IProgressMonitor; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
31 |
import org.eclipse.core.runtime.NullProgressMonitor; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
import org.eclipse.core.runtime.Path; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
import org.eclipse.wst.common.project.facet.core.IDelegate; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
import org.symbian.tools.tmw.core.TMWCore; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
import org.symbian.tools.tmw.core.projects.IProjectSetupConfig; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
public abstract class LibraryInstallDelegate implements IDelegate { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
throws CoreException { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
if (config instanceof IProjectSetupConfig) { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
43 |
final IProjectSetupConfig setupConfig = (IProjectSetupConfig) config; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
44 |
final IPath basePath = getBasePath(project, setupConfig); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
45 |
final InputStream file = openInputStream(); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
46 |
final ZipInputStream stream = new ZipInputStream(file); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
47 |
try { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
48 |
ZipEntry en = stream.getNextEntry(); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
49 |
while (en != null) { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
50 |
if (!en.isDirectory()) { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
51 |
final IPath entry = new Path(en.getName()); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
52 |
final IFile f = setupConfig.addFile(project, basePath.append(entry), stream, |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
53 |
new NullProgressMonitor()); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
54 |
if (isIncludeFile(entry)) { |
479
518afa7c6d2f
Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
55 |
setupConfig.addIncludedJsFile(project, f); |
467
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
56 |
} |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
57 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
58 |
} |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
59 |
en = stream.getNextEntry(); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
60 |
} |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
61 |
} catch (IOException e) { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
62 |
TMWCore.log(null, e); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
63 |
} finally { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
64 |
try { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
65 |
file.close(); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
66 |
} catch (IOException e) { |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
67 |
TMWCore.log(null, e); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
68 |
} |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
69 |
} |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
70 |
} |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
71 |
} |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
72 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
73 |
protected abstract IPath getBasePath(IProject project, IProjectSetupConfig setupConfig); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
74 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
75 |
protected abstract boolean isIncludeFile(IPath entry); |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
76 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
77 |
protected abstract InputStream openInputStream() throws CoreException; |
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
78 |
|
5a2901872fcf
WRTKit facet was introduced
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
79 |
} |