本文整理汇总了Java中org.eclipse.core.runtime.FileLocator类的典型用法代码示例。如果您正苦于以下问题:Java FileLocator类的具体用法?Java FileLocator怎么用?Java FileLocator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileLocator类属于org.eclipse.core.runtime包,在下文中一共展示了FileLocator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBundleDirectory
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* Return the bundle directory.
*
* @param bundle the bundle
* @return the bundle directory
*/
public String getBundleDirectory(Bundle bundle) {
if (bundle == null) return null;
// --- Get File URL of bundle ---------------------
URL pluginURL = null;
try {
pluginURL = FileLocator.resolve(bundle.getEntry("/"));
} catch (IOException e) {
throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName());
}
// --- Clean up the directory path ----------------
String pluginInstallDir = pluginURL.getFile().trim();
if (pluginInstallDir.length()==0) {
throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName());
}
// --- Corrections, if we are under windows -------
if (Platform.getOS().compareTo(Platform.OS_WIN32) == 0) {
//pluginInstallDir = pluginInstallDir.substring(1);
}
return pluginInstallDir;
}
示例2: createImageDescriptor
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
public static ImageDescriptor createImageDescriptor(String path, String pluginId) {
if (path == null) {
/* fall back if path null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
if (pluginId == null) {
/* fall back if pluginId null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
Bundle bundle = Platform.getBundle(pluginId);
if (bundle == null) {
/*
* fall back if bundle not available, so avoid NPE in eclipse
* framework
*/
return ImageDescriptor.getMissingImageDescriptor();
}
URL url = FileLocator.find(bundle, new Path(path), null);
ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url);
return imageDesc;
}
示例3: updateClassPath
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
private String [] updateClassPath (ILaunchConfiguration configuration) throws CoreException {
URL resource = this.getClass().getResource(GW4ELaunchConfigurationDelegate.class.getSimpleName() + ".class");
String jarpath = GW4ELaunchConfigurationDelegate.class.getProtectionDomain().getCodeSource().getLocation().getPath ();
try {
resource = FileLocator.toFileURL(resource);
} catch (IOException e) {
ResourceManager.logException(e);
}
String root = resource.toString();
if (root.startsWith("jar:")) {
String vals[] = root.split("/");
for (String val: vals) {
if (val.contains("!")) {
root = val.substring(0, val.length() - 1);
}
}
} else {
int pos = root.indexOf((GW4ELaunchConfigurationDelegate.class.getName() ).replaceAll("\\.", "/"));
root = root.substring(0,pos);
}
String[] defaultCp = getClasspath(configuration);
String[] extendedCp = new String[defaultCp.length+2];
System.arraycopy(defaultCp, 0, extendedCp, 0, defaultCp.length);
extendedCp[extendedCp.length-1] = normalizePath(root);
extendedCp[extendedCp.length-2] = normalizePath(jarpath);
return extendedCp;
}
示例4: computeCamelLanguageServerJarPath
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
private static String computeCamelLanguageServerJarPath() {
String camelLanguageServerJarPath = "";
Bundle bundle = Platform.getBundle(ActivatorCamelLspClient.ID);
URL fileURL = bundle.findEntries("/libs", "camel-lsp-server-*.jar", false).nextElement();
try {
File file = new File(FileLocator.resolve(fileURL).toURI());
if(Platform.OS_WIN32.equals(Platform.getOS())) {
camelLanguageServerJarPath = "\"" + file.getAbsolutePath() + "\"";
} else {
camelLanguageServerJarPath = file.getAbsolutePath();
}
} catch (URISyntaxException | IOException exception) {
ActivatorCamelLspClient.getInstance().getLog().log(new Status(IStatus.ERROR, ActivatorCamelLspClient.ID, "Cannot get the Camel LSP Server jar.", exception)); //$NON-NLS-1$
}
return camelLanguageServerJarPath;
}
示例5: checkMenuNewChildElementTypeIdRefs
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* Check that referenced element type are in the registry
*/
@Test
public void checkMenuNewChildElementTypeIdRefs() {
URI createPlatformPluginURI = URI.createPlatformPluginURI(NEW_CHILD_MENU_PATH, true);
ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
Resource resource = resourceSetImpl.getResource(createPlatformPluginURI, true);
TreeIterator<EObject> allContents = resource.getAllContents();
while (allContents.hasNext()) {
EObject eObject = (EObject) allContents.next();
if (eObject instanceof CreationMenu) {
String iconPath = ((CreationMenu) eObject).getIcon();
if (iconPath != null && !"".equals(iconPath)){
try {
Assert.assertNotNull("The icon "+iconPath+" can't be found", FileLocator.find(new URL(iconPath)));
} catch (MalformedURLException e) {
Assert.fail("The new child menu is refering to a malformed url "+iconPath);
}
}
}
}
}
示例6: DerbyClasspathContainer
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
public DerbyClasspathContainer() {
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
Bundle bundle = Platform.getBundle(CommonNames.CORE_PATH);
Enumeration en = bundle.findEntries("/", "*.jar", true);
String rootPath = null;
try {
rootPath = FileLocator.resolve(FileLocator.find(bundle, new Path("/"), null)).getPath();
} catch(IOException e) {
Logger.log(e.getMessage(), IStatus.ERROR);
}
while(en.hasMoreElements()) {
IClasspathEntry cpe = JavaCore.newLibraryEntry(new Path(rootPath+'/'+((URL)en.nextElement()).getFile()), null, null);
entries.add(cpe);
}
IClasspathEntry[] cpes = new IClasspathEntry[entries.size()];
_entries = (IClasspathEntry[])entries.toArray(cpes);
}
示例7: init
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Creates the sole wizard page contributed by this base implementation; the
* standard Eclipse WizardNewProjectCreationPage.
* </p>
*
* @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
// Set default image for all wizard pages
IPath path = new Path(de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON);
Bundle bundle = de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin.getDefault().getBundle();
URL url = FileLocator.find(bundle, path, null);
ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
setDefaultPageImageDescriptor(descriptor);
wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName);
wizardNewProjectCreationPage.setTitle(pageTitle);
wizardNewProjectCreationPage.setDescription(pageDescription);
wizardNewProjectCreationPage.setInitialProjectName(pageProjectName);
this.addPage(wizardNewProjectCreationPage);
setWindowTitle(de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE);
}
示例8: extractProject
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Unzip the project archive to the specified folder
* </p>
*
* @param projectFolderFile The folder where to unzip the project archive
* @param monitor Monitor to display progress and/or cancel operation
*
* @throws IOException
*
* @throws InterruptedException
*
* @throws FileNotFoundException
*/
private void extractProject(File projectFolderFile, URL url, IProgressMonitor monitor) throws FileNotFoundException, IOException, InterruptedException {
// Get project archive
URL urlZipLocal = FileLocator.toFileURL(url);
// Walk each element and unzip
ZipFile zipFile = new ZipFile(urlZipLocal.getPath());
try {
// Allow for a hundred work units
monitor.beginTask("Extracting Project", zipFile.size());
unzip(zipFile, projectFolderFile, monitor);
} finally {
zipFile.close();
monitor.done();
}
}
示例9: getImageDescriptor
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Returns the image for the given key. Possible keys are:
* </p>
* <p>
* <ul>
* </p>
* <p>
* <li>platform:/plugin/your.plugin/icons/yourIcon.png</li>
* </p>
* <p>
* <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li>
* </p>
* <p>
* </ul>
* </p>
*/
public ImageDescriptor getImageDescriptor(String key) {
IPath path = new Path(key);
de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin plugin = de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin.getDefault();
if (plugin == null) {
return null;
}
ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null));
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
// try loading image from any bundle
try {
URL pluginUrl = new URL(key);
descriptor = ImageDescriptor.createFromURL(pluginUrl);
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
return null;
}
} catch (MalformedURLException mue) {
de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue);
}
}
return descriptor;
}
示例10: init
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Creates the sole wizard page contributed by this base implementation; the
* standard Eclipse WizardNewProjectCreationPage.
* </p>
*
* @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
// Set default image for all wizard pages
IPath path = new Path(eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON);
Bundle bundle = eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin.getDefault().getBundle();
URL url = FileLocator.find(bundle, path, null);
ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
setDefaultPageImageDescriptor(descriptor);
wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName);
wizardNewProjectCreationPage.setTitle(pageTitle);
wizardNewProjectCreationPage.setDescription(pageDescription);
wizardNewProjectCreationPage.setInitialProjectName(pageProjectName);
this.addPage(wizardNewProjectCreationPage);
setWindowTitle(eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE);
}
示例11: getImageDescriptor
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Returns the image for the given key. Possible keys are:
* </p>
* <p>
* <ul>
* </p>
* <p>
* <li>platform:/plugin/your.plugin/icons/yourIcon.png</li>
* </p>
* <p>
* <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li>
* </p>
* <p>
* </ul>
* </p>
*/
public ImageDescriptor getImageDescriptor(String key) {
IPath path = new Path(key);
eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin plugin = eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin.getDefault();
if (plugin == null) {
return null;
}
ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null));
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
// try loading image from any bundle
try {
URL pluginUrl = new URL(key);
descriptor = ImageDescriptor.createFromURL(pluginUrl);
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
return null;
}
} catch (MalformedURLException mue) {
eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue);
}
}
return descriptor;
}
示例12: init
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Creates the sole wizard page contributed by this base implementation; the
* standard Eclipse WizardNewProjectCreationPage.
* </p>
*
* @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
// Set default image for all wizard pages
IPath path = new Path(eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON);
Bundle bundle = eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin.getDefault().getBundle();
URL url = FileLocator.find(bundle, path, null);
ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
setDefaultPageImageDescriptor(descriptor);
wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName);
wizardNewProjectCreationPage.setTitle(pageTitle);
wizardNewProjectCreationPage.setDescription(pageDescription);
wizardNewProjectCreationPage.setInitialProjectName(pageProjectName);
this.addPage(wizardNewProjectCreationPage);
setWindowTitle(eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE);
}
示例13: getImageDescriptor
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Returns the image for the given key. Possible keys are:
* </p>
* <p>
* <ul>
* </p>
* <p>
* <li>platform:/plugin/your.plugin/icons/yourIcon.png</li>
* </p>
* <p>
* <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li>
* </p>
* <p>
* </ul>
* </p>
*/
public ImageDescriptor getImageDescriptor(String key) {
IPath path = new Path(key);
eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin plugin = eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin.getDefault();
if (plugin == null) {
return null;
}
ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null));
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
// try loading image from any bundle
try {
URL pluginUrl = new URL(key);
descriptor = ImageDescriptor.createFromURL(pluginUrl);
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
return null;
}
} catch (MalformedURLException mue) {
eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue);
}
}
return descriptor;
}
示例14: init
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Creates the sole wizard page contributed by this base implementation; the
* standard Eclipse WizardNewProjectCreationPage.
* </p>
*
* @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
// Set default image for all wizard pages
IPath path = new Path(eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIResourceBundle.NEW_PROJECT_WIZARD_PAGE_ICON);
Bundle bundle = eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin.getDefault().getBundle();
URL url = FileLocator.find(bundle, path, null);
ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
setDefaultPageImageDescriptor(descriptor);
wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName);
wizardNewProjectCreationPage.setTitle(pageTitle);
wizardNewProjectCreationPage.setDescription(pageDescription);
wizardNewProjectCreationPage.setInitialProjectName(pageProjectName);
this.addPage(wizardNewProjectCreationPage);
setWindowTitle(eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIResourceBundle.NEW_PROJECT_WIZARD_WINDOW_TITLE);
}
示例15: getImageDescriptor
import org.eclipse.core.runtime.FileLocator; //导入依赖的package包/类
/**
* <p>
* Returns the image for the given key. Possible keys are:
* </p>
* <p>
* <ul>
* </p>
* <p>
* <li>platform:/plugin/your.plugin/icons/yourIcon.png</li>
* </p>
* <p>
* <li>bundleentry://557.fwk3560063/icons/yourIcon.png</li>
* </p>
* <p>
* </ul>
* </p>
*/
public ImageDescriptor getImageDescriptor(String key) {
IPath path = new Path(key);
eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin plugin = eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin.getDefault();
if (plugin == null) {
return null;
}
ImageDescriptor descriptor = ImageDescriptor.createFromURL(FileLocator.find(plugin.getBundle(), path, null));
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
// try loading image from any bundle
try {
URL pluginUrl = new URL(key);
descriptor = ImageDescriptor.createFromURL(pluginUrl);
if (ImageDescriptor.getMissingImageDescriptor().equals(descriptor) || descriptor == null) {
return null;
}
} catch (MalformedURLException mue) {
eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIPlugin.logError("IconProvider can't load image (URL is malformed).", mue);
}
}
return descriptor;
}