author | Eugene Ostroukhov <eugeneo@symbian.org> |
Thu, 04 Nov 2010 15:22:02 -0700 | |
changeset 495 | 0008ebdc0ec0 |
parent 484 | f5df819c1852 |
permissions | -rw-r--r-- |
468
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
1 |
/** |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
3 |
* All rights reserved. |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
8 |
* |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
10 |
* Symbian Foundation - initial contribution. |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
11 |
* Contributors: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
12 |
* Description: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
13 |
* Overview: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
14 |
* Details: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
15 |
* Platforms/Drives/Compatibility: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
16 |
* Assumptions/Requirement/Pre-requisites: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
17 |
* Failures and causes: |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
18 |
*/ |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
19 |
package org.symbian.tools.tmw.core.utilities; |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
20 |
|
481
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
21 |
import org.eclipse.core.resources.IProject; |
468
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
22 |
import org.eclipse.core.runtime.Platform; |
481
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
23 |
import org.eclipse.wst.jsdt.core.IJavaScriptProject; |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
24 |
import org.eclipse.wst.jsdt.core.IType; |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
25 |
import org.eclipse.wst.jsdt.core.JavaScriptCore; |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
26 |
import org.eclipse.wst.jsdt.core.JavaScriptModelException; |
468
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
27 |
|
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
28 |
/** |
484
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
29 |
* Utilities used all over the TMW code base. Users can rely on this methods |
468
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
30 |
* even though they are not specific to mobile development. |
484
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
31 |
* |
468
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
32 |
* @author Eugene Ostroukhov (eugeneo@symbian.org) |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
33 |
*/ |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
34 |
public final class CoreUtil { |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
35 |
|
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
36 |
private CoreUtil() { |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
37 |
// Class with only static methods |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
38 |
} |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
39 |
|
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
40 |
public static boolean isMac() { |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
41 |
return "macosx".equals(Platform.getOS()); |
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
42 |
} |
472
bd9f2d7c64a6
Debugger is now Symbian-independant
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
43 |
|
bd9f2d7c64a6
Debugger is now Symbian-independant
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
44 |
public static boolean isLinux() { |
bd9f2d7c64a6
Debugger is now Symbian-independant
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
45 |
return "linux".equals(Platform.getOS()); |
bd9f2d7c64a6
Debugger is now Symbian-independant
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
470
diff
changeset
|
46 |
} |
477
b616697678bf
Providers can now specify fixed facets on per-runtime basis. Those facets will not be shown to users in the project creation wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
472
diff
changeset
|
47 |
|
b616697678bf
Providers can now specify fixed facets on per-runtime basis. Those facets will not be shown to users in the project creation wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
472
diff
changeset
|
48 |
public static String notNull(final String string) { |
484
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
49 |
if (string == null) { |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
50 |
return ""; |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
51 |
} else { |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
52 |
return string.trim(); |
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
53 |
} |
477
b616697678bf
Providers can now specify fixed facets on per-runtime basis. Those facets will not be shown to users in the project creation wizard
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
472
diff
changeset
|
54 |
} |
481
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
55 |
|
484
f5df819c1852
Checkstyle was used to review coding conventions
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
481
diff
changeset
|
56 |
public static boolean hasTypes(IProject p, String... typeNames) throws JavaScriptModelException { |
481
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
57 |
final IJavaScriptProject project = JavaScriptCore.create(p); |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
58 |
if (project != null && project.exists()) { |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
59 |
for (String typeName : typeNames) { |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
60 |
if (!hasType(project, typeName)) { |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
61 |
return false; |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
62 |
} |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
63 |
} |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
64 |
} |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
65 |
return true; |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
66 |
} |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
67 |
|
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
68 |
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=318656 |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
69 |
private static boolean hasType(IJavaScriptProject project, String name) throws JavaScriptModelException { |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
70 |
final IType[] types = project.findTypes(name); |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
71 |
if (types != null) { |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
72 |
for (IType type : types) { |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
73 |
if (type.getJavaScriptProject().equals(project)) { |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
74 |
return true; |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
75 |
} |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
76 |
} |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
77 |
} |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
78 |
return false; |
e908ec135fa1
Application import wizard was refactored into extensible code
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
477
diff
changeset
|
79 |
} |
468
a05c6e5cc7d9
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff
changeset
|
80 |
} |