plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/runtimes/MobileRuntimeLibraryContainer.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 19 Aug 2010 17:48:04 -0700
changeset 470 d4809db37847
parent 468 org.symbian.tools.mtw.core/src/org/symbian/tools/tmw/core/internal/runtimes/MobileRuntimeLibraryContainer.java@a05c6e5cc7d9
child 484 f5df819c1852
permissions -rw-r--r--
Changed repository layout and renamed project files. This revision is untested and may not run.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
461
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/**
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 */
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
package org.symbian.tools.tmw.core.internal.runtimes;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import org.eclipse.core.runtime.CoreException;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
import org.eclipse.core.runtime.IPath;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
import org.eclipse.core.runtime.NullProgressMonitor;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.wst.jsdt.core.IIncludePathEntry;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.wst.jsdt.core.IJavaScriptProject;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.eclipse.wst.jsdt.core.IJsGlobalScopeContainer;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
import org.symbian.tools.tmw.core.TMWCore;
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: 463
diff changeset
    30
import org.symbian.tools.tmw.core.projects.ITMWProject;
461
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
public class MobileRuntimeLibraryContainer implements IJsGlobalScopeContainer {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
    private final IPath containerPath;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
    private final IJavaScriptProject project;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
    public MobileRuntimeLibraryContainer(IJavaScriptProject project, IPath containerPath) {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
        this.project = project;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
        this.containerPath = containerPath;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
    }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
    public IIncludePathEntry[] getIncludepathEntries() {
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: 463
diff changeset
    43
        final ITMWProject proj = TMWCore.create(project.getProject());
461
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
        if (proj != null) {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
            try {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
                IFacetedProject facetedProject = ProjectFacetsManager.create(project.getProject(), false,
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
                        new NullProgressMonitor());
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
                if (facetedProject != null) {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
                    return TMWCore.getDefault().getClasspathManager().getProjectClasspathEntries(facetedProject);
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
                }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    51
            } catch (CoreException e) {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
                TMWCore.log(null, e);
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
            }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
        }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    55
        return new IIncludePathEntry[0];
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    56
    }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    57
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    58
    public String getDescription() {
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: 463
diff changeset
    59
        final ITMWProject proj = TMWCore.create(project.getProject());
461
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    60
        if (proj != null) {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    61
            final IMobileWebRuntime targetRuntime = proj.getTargetRuntime();
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    62
            if (targetRuntime != null) {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
                return String.format("%s API", targetRuntime.getName());
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    64
            }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    65
        }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    66
        return "Mobile Web Runtime Library";
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    67
    }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    68
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    69
    public int getKind() {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    70
        return K_SYSTEM;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
    }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
    public IPath getPath() {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    74
        return containerPath;
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    75
    }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    76
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
    public String[] resolvedLibraryImport(String realImport) {
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    78
        return new String[] { realImport };
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    79
    }
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    80
7a8f9fa8d278 Project model introduction and JSDT classpath support
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    81
}