plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/runtimes/RuntimesManagerImpl.java
changeset 479 518afa7c6d2f
parent 470 d4809db37847
child 484 f5df819c1852
equal deleted inserted replaced
478:6c07c755d0c7 479:518afa7c6d2f
    16  * Assumptions/Requirement/Pre-requisites:
    16  * Assumptions/Requirement/Pre-requisites:
    17  * Failures and causes:
    17  * Failures and causes:
    18  */
    18  */
    19 package org.symbian.tools.tmw.core.internal.runtimes;
    19 package org.symbian.tools.tmw.core.internal.runtimes;
    20 
    20 
       
    21 import java.io.InputStream;
    21 import java.util.Collection;
    22 import java.util.Collection;
    22 import java.util.HashMap;
    23 import java.util.HashMap;
    23 import java.util.Map;
    24 import java.util.Map;
    24 import java.util.TreeMap;
    25 import java.util.TreeMap;
    25 
    26 
       
    27 import org.eclipse.core.resources.IFile;
       
    28 import org.eclipse.core.resources.IProject;
       
    29 import org.eclipse.core.runtime.CoreException;
    26 import org.eclipse.core.runtime.IConfigurationElement;
    30 import org.eclipse.core.runtime.IConfigurationElement;
       
    31 import org.eclipse.core.runtime.IPath;
    27 import org.eclipse.core.runtime.Platform;
    32 import org.eclipse.core.runtime.Platform;
    28 import org.symbian.tools.tmw.core.TMWCore;
    33 import org.symbian.tools.tmw.core.TMWCore;
    29 import org.symbian.tools.tmw.core.projects.ITMWProject;
    34 import org.symbian.tools.tmw.core.projects.ITMWProject;
       
    35 import org.symbian.tools.tmw.core.runtimes.IApplicationLayoutProvider;
    30 import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
    36 import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
    31 import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntimeManager;
    37 import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntimeManager;
    32 import org.symbian.tools.tmw.core.runtimes.IPackager;
    38 import org.symbian.tools.tmw.core.runtimes.IPackager;
    33 
    39 
    34 public final class RuntimesManagerImpl implements IMobileWebRuntimeManager {
    40 public final class RuntimesManagerImpl implements IMobileWebRuntimeManager {
   100 
   106 
   101     private String getInternalId(String id, String version) {
   107     private String getInternalId(String id, String version) {
   102         return id + ":" + version;
   108         return id + ":" + version;
   103     }
   109     }
   104 
   110 
       
   111     public static final class LazyProvider implements IApplicationLayoutProvider {
       
   112         private final IConfigurationElement element;
       
   113         private IApplicationLayoutProvider instance;
       
   114 
       
   115         public LazyProvider(IConfigurationElement element) {
       
   116             this.element = element;
       
   117         }
       
   118 
       
   119         public IPath getResourcePath(IFile file) {
       
   120             return getDelegate().getResourcePath(file);
       
   121         }
       
   122 
       
   123         private IApplicationLayoutProvider getDelegate() {
       
   124             if (instance == null) {
       
   125                 try {
       
   126                     instance = (IApplicationLayoutProvider) element.createExecutableExtension("class");
       
   127                 } catch (CoreException e) {
       
   128                     TMWCore.log(null, e);
       
   129                     instance = new IApplicationLayoutProvider() {
       
   130 
       
   131                         public IPath getResourcePath(IFile file) {
       
   132                             return null;
       
   133                         }
       
   134 
       
   135                         public InputStream getResourceFromPath(IProject project, IPath path) {
       
   136                             return null;
       
   137                         }
       
   138 
       
   139                         public IFile getWorkspaceFile(IProject project, IPath applicationPath) {
       
   140                             return null;
       
   141                         }
       
   142 
       
   143                         public IFile getIndexPage(IProject project) {
       
   144                             return null;
       
   145                         }
       
   146                     };
       
   147                 }
       
   148             }
       
   149             return instance;
       
   150         }
       
   151 
       
   152         public InputStream getResourceFromPath(IProject project, IPath path) throws CoreException {
       
   153             return getDelegate().getResourceFromPath(project, path);
       
   154         }
       
   155 
       
   156         public IFile getWorkspaceFile(IProject project, IPath applicationPath) throws CoreException {
       
   157             return getDelegate().getWorkspaceFile(project, applicationPath);
       
   158         }
       
   159 
       
   160         public IFile getIndexPage(IProject project) {
       
   161             return getDelegate().getIndexPage(project);
       
   162         }
       
   163     }
   105 }
   164 }