1 11 package org.eclipse.pde.internal.ui.wizards.target; 12 13 import java.io.BufferedInputStream ; 14 import java.io.IOException ; 15 import java.net.URL ; 16 17 import org.eclipse.core.resources.IFile; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IConfigurationElement; 20 import org.eclipse.pde.internal.core.PDECore; 21 import org.eclipse.pde.internal.core.TargetDefinitionManager; 22 import org.eclipse.pde.internal.core.itarget.ITargetModel; 23 24 public class TargetDefinitionFromTargetOperation extends 25 BaseTargetDefinitionOperation { 26 27 private String fTargetId; 28 29 public TargetDefinitionFromTargetOperation(IFile file, String id) { 30 super(file); 31 fTargetId = id; 32 } 33 34 protected void initializeTarget(ITargetModel model) { 35 IConfigurationElement elem = PDECore.getDefault().getTargetProfileManager().getTarget(fTargetId); 36 String path = elem.getAttribute("definition"); String symbolicName = elem.getDeclaringExtension().getNamespaceIdentifier(); 38 URL url = TargetDefinitionManager.getResourceURL(symbolicName, path); 39 if (url != null) { 40 try { 41 model.load(new BufferedInputStream (url.openStream()), false); 42 } catch (CoreException e) { 43 } catch (IOException e) { 44 } 45 } 46 } 47 48 } 49 | Popular Tags |