01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.target;
11:
12: import java.io.BufferedInputStream;
13: import java.io.IOException;
14: import java.net.URL;
15:
16: import org.eclipse.core.resources.IFile;
17: import org.eclipse.core.runtime.CoreException;
18: import org.eclipse.core.runtime.IConfigurationElement;
19: import org.eclipse.pde.internal.core.PDECore;
20: import org.eclipse.pde.internal.core.TargetDefinitionManager;
21: import org.eclipse.pde.internal.core.itarget.ITargetModel;
22:
23: public class TargetDefinitionFromTargetOperation extends
24: BaseTargetDefinitionOperation {
25:
26: private String fTargetId;
27:
28: public TargetDefinitionFromTargetOperation(IFile file, String id) {
29: super (file);
30: fTargetId = id;
31: }
32:
33: protected void initializeTarget(ITargetModel model) {
34: IConfigurationElement elem = PDECore.getDefault()
35: .getTargetProfileManager().getTarget(fTargetId);
36: String path = elem.getAttribute("definition"); //$NON-NLS-1$
37: String symbolicName = elem.getDeclaringExtension()
38: .getNamespaceIdentifier();
39: URL url = TargetDefinitionManager.getResourceURL(symbolicName,
40: path);
41: if (url != null) {
42: try {
43: model.load(new BufferedInputStream(url.openStream()),
44: false);
45: } catch (CoreException e) {
46: } catch (IOException e) {
47: }
48: }
49: }
50:
51: }
|