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


Java FileLocator.resolve方法代碼示例

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


在下文中一共展示了FileLocator.resolve方法的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;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:31,代碼來源:BundleEvaluator.java

示例2: initializeImages

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private static void initializeImages()
{
    
    Bundle bundle = Platform.getBundle("wangkui.statistic.lines");
    
   
    URL baseURL = bundle.getEntry("/");
    try {
        baseURL = FileLocator.resolve(baseURL);
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.out.println("baseURL:"+baseURL);
    createImageDescriptor("elcl16/mode1.gif", baseURL);
    createImageDescriptor("elcl16/mode2.gif", baseURL);
    createImageDescriptor("elcl16/mode3.gif", baseURL);
    createImageDescriptor("elcl16/count.gif", baseURL);
    createImageDescriptor("elcl16/collapseall.gif", baseURL);
    createImageDescriptor("elcl16/refresh.gif", baseURL);
    createImageDescriptor("elcl16/export.gif", baseURL);
    createImageDescriptor("dlcl16/export.gif", baseURL);
    createImageDescriptor("elcl16/clear.gif", baseURL);
    createImageDescriptor("dlcl16/clear.gif", baseURL);
    
    createImageDescriptor("elcl16/help.gif", baseURL);
}
 
開發者ID:qxo,項目名稱:eclipse-code-lines-plugin,代碼行數:27,代碼來源:StatisticImages.java

示例3: DockerConfig

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public DockerConfig() {
    final URL url = Resources.getResource(Constants.PROPERTY_FILE_NAME);
    Properties properties = readPropertyFile(url);
    
    
    version = properties.getProperty(Constants.PROPERTY_DOCKER_API_VERSION);
    uri = properties.getProperty(Constants.PROPERTY_DOCKER_URI);
    username = properties.getProperty(Constants.PROPERTY_USERNAME);
    password = properties.getProperty(Constants.PROPERTY_PASSWORD);
    email = properties.getProperty(Constants.PROPERTY_EMAIL);
    serverAddress = properties
            .getProperty(Constants.PROPERTY_DOCKER_SERVER_ADDRESS);
    dockerCertPath = properties
            .getProperty(Constants.PROPERTY_DOCKER_CERT_PATH);

    URL fullUrl = null;
    try {
        fullUrl = FileLocator.resolve(url);
    } catch (IOException e) {
        e.printStackTrace();
    }
    propertiesFileFullPath = fullUrl == null ? null : fullUrl.getPath();
}
 
開發者ID:domeide,項目名稱:doclipser,代碼行數:24,代碼來源:DockerConfig.java

示例4: getEvoSuiteJar

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * This is tricky because the evosuite jar in the deployed plugin is
 * contained in the plugin jar, but for the client process we need it
 * explicitly on the classpath. Hence, if we see that the evosuite jar is in
 * another jar, we extract it to a temporary location
 * 
 * @return Location of the jar file
 */
public static String getEvoSuiteJar() {
	if (EVOSUITE_CP != null)
		return EVOSUITE_CP;

	Bundle bundle = Platform.getBundle(Activator.EVOSUITE_CORE_BUNDLE);
	URL url = bundle.getEntry(Activator.EVOSUITE_JAR);
			
	try {
		URL evosuiteLib = FileLocator.resolve(url);
		System.out.println("Evosuite JAR is at " + evosuiteLib.getPath());
		if (evosuiteLib.getPath().startsWith("file")) {
			System.out.println("Need to extract jar");
			EVOSUITE_CP = setupJar(evosuiteLib);
		} else {
			System.out.println("Don't need to extract jar");
			EVOSUITE_CP = evosuiteLib.getFile();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

	return EVOSUITE_CP;
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:32,代碼來源:TestGenerationAction.java

示例5: getBundleURL

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * Returns the bundle URL resolved by the {@link FileLocator}.
 * @param bundle the bundle
 * @return the bundle URL
 */
public URL getBundleURL(Bundle bundle) {
	URL bundleURL = null;
	try {
		if (this.isBundleStartingResolvedOrActive(bundle)==true) {
			bundleURL = FileLocator.resolve(bundle.getEntry("/"));
		}
	} catch (IOException ioEx) {
		ioEx.printStackTrace();
	}
	return bundleURL;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:17,代碼來源:BundleEvaluator.java

示例6: launch

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private void launch(IResource file, int line, IType type, String agentArgs, IMethod mainMethod)
		throws CoreException {
	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType confType = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
	ILaunchConfigurationWorkingCopy wc = confType.newInstance(null, file.getName() + " (PandionJ)");
	wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, file.getProject().getName());
	wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
	wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, false);

	//		if(breakPoint != null)
	//			breakPoint.delete();
	//		if(line != -1)
	//			breakPoint = JDIDebugModel.createLineBreakpoint(file, firstType.getFullyQualifiedName(), line, -1, -1, 0, true, null);

	try {	
		Bundle bundle = Platform.getBundle(LaunchCommand.class.getPackage().getName());
		URL find = FileLocator.find(bundle, new Path("lib/agent.jar"), null);
		URL resolve = FileLocator.resolve(find);
		if(!mainMethod.exists()) {
			String path = resolve.getPath();
			if(Platform.getOS().compareTo(Platform.OS_WIN32) == 0)
				path = path.substring(1);

			String args =  "-javaagent:\"" + path + "=" + agentArgs + "\" -Djava.awt.headless=true";
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, args);
		}
	} catch (IOException e1) {
		e1.printStackTrace();
	}
	ILaunchConfiguration config = wc.doSave();
	Activator.launch(config);
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:33,代碼來源:LaunchCommand.java

示例7: getAspectWorkspace

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private static File getAspectWorkspace() {
  try {
    URL url = Platform.getBundle(Activator.PLUGIN_ID).getEntry("resources");
    URL resolved = FileLocator.resolve(url);
    return new File(resolved.getPath());
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
開發者ID:bazelbuild,項目名稱:eclipse,代碼行數:10,代碼來源:BazelAspectLocationImpl.java

示例8: getEmbeddedFileUrl

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public static String getEmbeddedFileUrl(String fileName) throws CoreException {
	Bundle bundle = Platform.getBundle(CoreActivator.PLUGIN_ID);
	IPath hcrPath = new Path("extras").append(fileName);
	URL hcrEmbeddedUrl = FileLocator.find(bundle, hcrPath, null);
	URL hcrUrl;
	try {
		hcrUrl = FileLocator.resolve(hcrEmbeddedUrl);
		URI uri = new URI(hcrUrl.toString().replace(" ", "%20"));
		return Paths.get(uri).toRealPath(LinkOption.NOFOLLOW_LINKS).toString();
	} catch (Exception e) {
		IStatus status = new Status(IStatus.ERROR, CoreActivator.PLUGIN_ID, "Unable to determine local url for "+fileName, e);
		throw new CoreException(status);
	}
}
 
開發者ID:fbricon,項目名稱:wildfly-hive,代碼行數:15,代碼來源:ResourceUtil.java

示例9: findResourceInBundle

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private URI findResourceInBundle(Bundle bundle, URI classpathUri)
        throws MalformedURLException, IOException {
    Path fullPath = new Path(classpathUri.path());
    if (bundle != null) {
        String projectRelativePath = "/" + fullPath;
        URL resourceUrl = bundle.getResource(projectRelativePath);
        if (resourceUrl != null) {
        	URL resolvedUrl = FileLocator.resolve(resourceUrl);
            URI normalizedURI = URI.createURI(
                    resolvedUrl.toString(), true);
            return normalizedURI;
        }
    }
    return classpathUri;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:16,代碼來源:BundleClasspathUriResolver.java

示例10: getFromResourceDirAsUrl

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
@Override
public URL getFromResourceDirAsUrl(final String path)
{
	try {
		return FileLocator.resolve(super.getFromResourceDirAsUrl(path));
	} catch (IOException e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:vogellacompany,項目名稱:languagetool-eclipse-plugin,代碼行數:11,代碼來源:EclipseRessourceDataBroker.java

示例11: registerBundleSdk

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * Attempts to register the SDK from a bundle.
 */
private static void registerBundleSdk(Bundle bundle) throws CoreException {
  try {
    IPath propPath = new Path(SDK_REGISTRANT_PROPERTY_FILE);
    URL propUrl = FileLocator.find(bundle, propPath, (Map<String, String>) null);
    if (propUrl != null) {
      InputStream instream = propUrl.openStream();
      Properties props = new Properties();
      props.load(instream);
      String sdkType = props.getProperty(SDK_BUNDLE_MARKER_PROPERTY);
      String sdkPrefix = props.getProperty(SDK_PATH_PREFIX_PROPERTY);
      if (sdkType != null && sdkPrefix != null) {
        IPath sdkPrefixPath = new Path(sdkPrefix);
        URL sdkPathUrl = FileLocator.find(bundle, sdkPrefixPath, (Map<String, String>) null);
        if (sdkPathUrl == null) {
          // Automatic SDK registration failed. This is expected in dev mode.
          CorePluginLog.logWarning("Failed to register SDK: " + sdkPrefix);
          return;
        }
        // resolve needed to switch from bundleentry to file url
        sdkPathUrl = FileLocator.resolve(sdkPathUrl);
        if (sdkPathUrl != null) {
          if ("file".equals(sdkPathUrl.getProtocol())) {
            GWTSdkRegistrant.registerSdk(sdkPathUrl, sdkType);
          }
        }
      }
    }
  } catch (IOException e) {
    throw new CoreException(new Status(IStatus.WARNING, GdtPlugin.PLUGIN_ID, e.getLocalizedMessage(), e));
  }
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:35,代碼來源:GdtPreferences.java

示例12: getPath

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public IPath getPath() {
	Bundle bundle = Platform.getBundle(Activator.EVOSUITE_CORE_BUNDLE);
	URL url = bundle.getEntry(Activator.EVOSUITE_JAR);
	try {
		URL evosuiteLib = FileLocator.resolve(url);
		System.out.println("Evosuite jar is at " + evosuiteLib.getPath());
		return new Path(evosuiteLib.getPath());
	} catch (Exception e) {
		System.err.println("Error accessing Evosuite jar at " + url);
	}
	System.err.println("Did not find Evosuite jar!");

	return null;
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:15,代碼來源:EvoSuiteClasspathContainerPage.java

示例13: getPath

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
@Override
public IPath getPath() {		
	Bundle bundle = Platform.getBundle(Activator.EVOSUITE_CORE_BUNDLE);
	URL url =  bundle.getEntry(Activator.EVOSUITE_JAR);		
	try {
		URL evosuiteLib = FileLocator.resolve(url);
		System.out.println("Evosuite jar is at " + evosuiteLib.getPath());
		return new Path(evosuiteLib.getPath());
	} catch (Exception e) {
		System.err.println("Error accessing Evosuite jar at " + url);
	}
	System.err.println("Did not find Evosuite jar!");
	return null;
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:15,代碼來源:EvoSuiteClasspathContainer.java

示例14: resolveBundleResourceURL

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
@Override
protected URL resolveBundleResourceURL(URL url) throws IOException {
	return FileLocator.resolve(url);
}
 
開發者ID:eclipse,項目名稱:xtext-extras,代碼行數:5,代碼來源:OnTheFlyJavaCompiler.java

示例15: getSootFilePath

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * Code copied from AJDT implementation http://www.eclipse.org/ajdt
 * org.eclipse.ajdt.internal.core.AspectJRTInitializer
 * @param relativePath 
 */
private static String getSootFilePath(String relativePath) {

	StringBuffer cpath = new StringBuffer();

	// This returns the bundle with the highest version or null if none
	// found
	// - for Eclipse 3.0 compatibility
	Bundle ajdeBundle = Platform
			.getBundle(LIBRARY_PLUGIN_NAME);

	String pluginLoc = null;
	// 3.0 using bundles instead of plugin descriptors
	if (ajdeBundle != null) {
		URL installLoc = ajdeBundle.getEntry("/"); //$NON-NLS-1$
		URL resolved = null;
		try {
			resolved = FileLocator.resolve(installLoc);
			pluginLoc = resolved.toExternalForm();
		} catch (IOException e) {
		}
	}
	if (pluginLoc != null) {
		if (pluginLoc.startsWith("file:")) { //$NON-NLS-1$
			cpath.append(pluginLoc.substring("file:".length())); //$NON-NLS-1$
			cpath.append(relativePath); //$NON-NLS-1$
		}
	}

	String sootJarPath = null;
	
	// Verify that the file actually exists at the plugins location
	// derived above. If not then it might be because we are inside
	// a runtime workbench. Check under the workspace directory.
	if (new File(cpath.toString()).exists()) {
		// File does exist under the plugins directory
		sootJarPath = cpath.toString();
	} else {
		// File does *not* exist under plugins. Try under workspace...
		IPath rootPath = SootPlugin.getWorkspace().getRoot()
				.getLocation();
		IPath installPath = rootPath.removeLastSegments(1);
		cpath = new StringBuffer().append(installPath.toOSString());
		cpath.append(File.separator);
		// TODO: what if the workspace isn't called workspace!!!
		cpath.append("workspace"); //$NON-NLS-1$
		cpath.append(File.separator);
		cpath.append(LIBRARY_PLUGIN_NAME);
		cpath.append(File.separator);
		cpath.append("aspectjrt.jar"); //$NON-NLS-1$

		// Only set the aspectjrtPath if the jar file exists here.
		if (new File(cpath.toString()).exists())
			sootJarPath = cpath.toString();
	}
	
	return sootJarPath;
}
 
開發者ID:flankerhqd,項目名稱:JAADAS,代碼行數:63,代碼來源:SootClasspathVariableInitializer.java


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