KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > target > TargetDefinitionFromTargetOperation


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.wizards.target;
12
13 import java.io.BufferedInputStream JavaDoc;
14 import java.io.IOException JavaDoc;
15 import java.net.URL JavaDoc;
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 JavaDoc fTargetId;
28
29     public TargetDefinitionFromTargetOperation(IFile file, String JavaDoc 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 JavaDoc path = elem.getAttribute("definition"); //$NON-NLS-1$
37
String JavaDoc symbolicName = elem.getDeclaringExtension().getNamespaceIdentifier();
38         URL JavaDoc url = TargetDefinitionManager.getResourceURL(symbolicName, path);
39         if (url != null) {
40             try {
41                 model.load(new BufferedInputStream JavaDoc(url.openStream()), false);
42             } catch (CoreException e) {
43             } catch (IOException JavaDoc e) {
44             }
45         }
46     }
47
48 }
49
Popular Tags