KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > schema > DevelopmentSchemaDescriptor


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

11 package org.eclipse.pde.internal.core.schema;
12
13 import java.io.File JavaDoc;
14
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.pde.core.plugin.IPluginModelBase;
17 import org.eclipse.pde.internal.core.*;
18
19 /**
20  *
21  */

22 public abstract class DevelopmentSchemaDescriptor extends AbstractSchemaDescriptor {
23 /**
24  * Returns a location of the plug-in given the plug-in ID. The plug-in
25  * can be either workspace or external - this is handled by the
26  * model manager.
27  */

28     public IPath getPluginRelativePath(String JavaDoc pluginId, IPath path) {
29         PluginModelManager manager = PDECore.getDefault().getModelManager();
30         ModelEntry entry = manager.findEntry(pluginId);
31         if (entry==null) return null;
32         IPluginModelBase model = entry.getActiveModel();
33         if (model==null) return null;
34         
35         String JavaDoc location = model.getInstallLocation();
36         IPath schemaPath = new Path(location).append(path);
37         if (schemaPath.toFile().exists())
38             return schemaPath;
39         
40         File JavaDoc sourceFile = getSourceLocationFile(model, path);
41         if (sourceFile != null && sourceFile.exists())
42             return new Path(sourceFile.getAbsolutePath());
43         return null;
44     }
45     
46     private File JavaDoc getSourceLocationFile(IPluginModelBase model, IPath path) {
47         SourceLocationManager sourceManager =
48             PDECore.getDefault().getSourceLocationManager();
49         return sourceManager.findSourceFile(
50             model.getPluginBase(), path);
51     }
52 }
53
Popular Tags