當前位置: 首頁>>代碼示例>>Java>>正文


Java FileLocator.getBundleFile方法代碼示例

本文整理匯總了Java中org.eclipse.core.runtime.FileLocator.getBundleFile方法的典型用法代碼示例。如果您正苦於以下問題:Java FileLocator.getBundleFile方法的具體用法?Java FileLocator.getBundleFile怎麽用?Java FileLocator.getBundleFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.runtime.FileLocator的用法示例。


在下文中一共展示了FileLocator.getBundleFile方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBundleLocation

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * @param bundleName
 * @return file this can return null if bundle is not found
 * @throws IOException
 */
public static File getBundleLocation(final String bundleName) throws IOException {
	final Bundle bundle = Platform.getBundle(bundleName);
	if (bundle == null) {
		return null;
	}
	return FileLocator.getBundleFile(bundle);
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:13,代碼來源:BundleUtils.java

示例2: computeActualBaseDir

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private static File computeActualBaseDir(IConfigurationElement ce) throws IOException {
	String bundleId = ce.getNamespaceIdentifier();
	File bundleDir = FileLocator.getBundleFile(Platform.getBundle(bundleId));
	if (!bundleDir.isDirectory()) {
		throw new RuntimeException("Bundle location " + bundleDir
				+ " cannot contribute a TypeScript repository because it is not a directory");
	}

	String baseDir = ce.getAttribute("baseDir");
	File dir = new File(bundleDir, baseDir);
	if (dir.exists()) {
		return dir;
	}

	IPath stateLocationPath = InternalPlatform.getDefault().getStateLocation(Platform.getBundle(bundleId));
	dir = new File(stateLocationPath.toFile(), baseDir);
	if (dir.exists()) {
		return dir;
	}

	File zipFile = new File(bundleDir, baseDir + ZipUtils.ZIP_EXTENSION);
	if (zipFile.exists()) {
		ZipUtils.extractZip(zipFile, dir.getParentFile());
		return dir;
	} else {
		zipFile = new File(bundleDir, baseDir + ZipUtils.TAR_GZ_EXTENSION);
		if (zipFile.exists()) {
			ZipUtils.extractTarGZ(zipFile, dir);
			return dir;
		}
	}
	throw new RuntimeException("Bundle location " + bundleDir
			+ " cannot contribute a TypeScript repository because it is not a directory");
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:35,代碼來源:IDETypeScriptRepositoryManager.java

示例3: resolveClasspathContainer

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) {
	List<IClasspathEntry> cp = new ArrayList<IClasspathEntry>(2);
	for (String id : CP_BUNDLES) {
		Bundle bundle = Platform.getBundle(id);
		try {
			File file = FileLocator.getBundleFile(bundle);
			Path path = new Path(file.getCanonicalPath());
			cp.add(JavaCore.newLibraryEntry(path, null, null));
		}
		catch (IOException e) {
			// ignore
		}
	}
	return cp.toArray(new IClasspathEntry[0]);
}
 
開發者ID:eclipse,項目名稱:cft,代碼行數:16,代碼來源:CloudFoundryRuntimeClasspathProvider.java

示例4: loadSquadTemplates

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private void loadSquadTemplates() {
	
	Bundle templateBundle = Platform.getBundle("us.nineworlds.xstreamer.templates");
	IPath templatePath = new Path("templates/squads/templates.xml");
	
	try {
		File templateFile = FileLocator.getBundleFile(templateBundle);
		File squadTemplatesFile = new File(templateFile, templatePath.toString());
		XmlMapper mapper = new XmlMapper();
		
		Templates templates = mapper.readValue(squadTemplatesFile, Templates.class);
		squadTemplates = templates.getTemplates();
		
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	
	
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:21,代碼來源:Activator.java

示例5: initializeTargetPlatform

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * If necessary, creates and loads a new target platform. Waits until the new platform has been loaded.
 *
 * @throws IOException
 *           if locating bundle file fails
 */
public static void initializeTargetPlatform() throws IOException {
  // The work-around is creating a new target platform adding the parent folders of the bundles
  try {
    final ITargetPlatformService targetPlatformService = TargetPlatformService.getDefault();
    final ITargetHandle workspaceTargetHandle = targetPlatformService.getWorkspaceTargetHandle();
    if (workspaceTargetHandle == null || !TARGET_PLATFORM_NAME.equals(workspaceTargetHandle.getTargetDefinition().getName())) {
      final ITargetDefinition targetDefinition = targetPlatformService.newTarget();
      targetDefinition.setName(TARGET_PLATFORM_NAME);
      final List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
      final Set<String> dirs = new HashSet<String>();
      for (final Bundle bundle : Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles()) { //$NON-NLS-1$
        final File file = FileLocator.getBundleFile(bundle);
        final File folder = file.getParentFile();
        final String path = folder.getAbsolutePath();
        if (dirs.add(path)) {
          ITargetLocation newDirectoryLocation = targetPlatformService.newDirectoryLocation(path);
          bundleContainers.add(newDirectoryLocation);
        }
      }
      targetDefinition.setTargetLocations(bundleContainers.toArray(new ITargetLocation[bundleContainers.size()]));
      targetDefinition.setArch(Platform.getOSArch());
      targetDefinition.setOS(Platform.getOS());
      targetDefinition.setWS(Platform.getWS());
      targetDefinition.setNL(Platform.getNL());
      targetPlatformService.saveTargetDefinition(targetDefinition);

      final CountDownLatch platformLoaded = new CountDownLatch(1);
      LoadTargetDefinitionJob.load(targetDefinition, new JobChangeAdapter() {
        @Override
        public void done(final IJobChangeEvent event) {
          platformLoaded.countDown();
        }
      });

      platformLoaded.await();

    }
  } catch (final CoreException coreException) {
    // Nothing
  } catch (InterruptedException e) {
    // Restore interrupted status
    Thread.currentThread().interrupt();
  }
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:51,代碼來源:TargetDefinitionSetup.java

示例6: createScriptingContainer

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * createScriptingContainer
 * 
 * @param scope
 * @return
 */
private ScriptingContainer createScriptingContainer(LocalContextScope scope)
{
	// ScriptingContainer result = new ScriptingContainer(scope, LocalVariableBehavior.PERSISTENT);
	ScriptingContainer result = new ScriptingContainer(scope, LocalVariableBehavior.TRANSIENT);

	try
	{
		File jrubyHome = null;
		Bundle jruby = Platform.getBundle("org.jruby"); //$NON-NLS-1$
		// try just exploding the jruby lib dir
		URL url = FileLocator.find(jruby, new Path("lib"), null); //$NON-NLS-1$

		if (url != null)
		{
			File lib = ResourceUtil.resourcePathToFile(url);
			// Ok, now use the parent of exploded lib dir as JRuby Home
			jrubyHome = lib.getParentFile();
		}
		else
		{
			// Ok, just assume the plugin is unpacked and pass the root of the plugin as JRuby Home
			jrubyHome = FileLocator.getBundleFile(jruby);
		}

		result.setHomeDirectory(jrubyHome.getAbsolutePath());

		// TODO Generate two containers? A global one for loading bundles, a threadsafe one for executing
		// commands/snippets/etc?
		// Pre-load 'ruble' framework files!
		List<String> loadPaths = result.getLoadPaths();
		loadPaths.addAll(0, getContributedLoadPaths());
		result.setLoadPaths(loadPaths);
	}
	catch (IOException e)
	{
		String message = MessageFormat.format(Messages.ScriptingEngine_Error_Setting_JRuby_Home,
				new Object[] { e.getMessage() });

		IdeLog.logError(ScriptingActivator.getDefault(), message, e);
		ScriptLogger.logError(message);
	}

	return result;
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:51,代碼來源:ScriptingEngine.java


注:本文中的org.eclipse.core.runtime.FileLocator.getBundleFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。