blob: ffded78d017a124c71c88e02fc19736d2d2958f1 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2006, 2010 Soyatec (http://www.soyatec.com) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Soyatec - initial API and implementation
*******************************************************************************/
package org.eclipse.osbp.vaaclipse.wizards.project;
import java.io.IOException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.osbp.vaaclipse.wizards.ToolsPlugin;
/**
* The Class ResourceLocator.
*/
public class ResourceLocator {
/** The Constant TEMPLATE_FOLDER. */
private static final String TEMPLATE_FOLDER = "templates";
/** The instance. */
private static ResourceLocator instance = new ResourceLocator();
/**
* Instantiates a new resource locator.
*/
private ResourceLocator() {
}
/**
* Gets the single instance of ResourceLocator.
*
* @return single instance of ResourceLocator
*/
public static ResourceLocator getInstance() {
return instance;
}
/**
* Gets the project template files.
*
* @param folder
* the folder
* @return the project template files
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static URL getProjectTemplateFiles(String folder)
throws IOException {
Plugin plugin = getResorucePlugin();
URL installURL = plugin.getBundle().getEntry(
"/" + TEMPLATE_FOLDER + "/" + folder);
// FileLocator.toFileURL(installURL);
URL corePath = FileLocator.resolve(installURL);
return corePath;
}
/**
* Gets the file.
*
* @param relativePath
* the relative path
* @return the file
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static URL getFile(String relativePath) throws IOException {
Plugin plugin = getResorucePlugin();
URL installURL = plugin.getBundle().getEntry(relativePath);
URL corePath = FileLocator.resolve(installURL);
return corePath;
}
/**
* Gets the resoruce plugin.
*
* @return the resoruce plugin
*/
public static Plugin getResorucePlugin() {
return ToolsPlugin.getDefault();
}
}