当前位置: 首页>>代码示例>>Java>>正文


Java Location类代码示例

本文整理汇总了Java中org.eclipse.osgi.service.datalocation.Location的典型用法代码示例。如果您正苦于以下问题:Java Location类的具体用法?Java Location怎么用?Java Location使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Location类属于org.eclipse.osgi.service.datalocation包,在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populate

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
@Override
public final void populate() throws Exception {
    directory = null;

    final Location location = getLocation();
    if (location != null) {
        final URL url = location.getURL();
        if (url != null) {
            final String locationURLString = location.getURL().toExternalForm();
            if (locationURLString.startsWith("file:/")) //$NON-NLS-1$
            {
                /*
                 * Under windows, the URL string looks like:
                 * file:/C:/home/user/mydir Under linux, it's
                 * file:/home/user/mydir We leave the first forward slash
                 * in, which parses properly as a file under both windows
                 * and linux
                 */
                directory = new File(locationURLString.substring(5));
            }
        }
    }
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:24,代码来源:LocationProvider.java

示例2: getPreviousInstanceLocation

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
private static String getPreviousInstanceLocation(final Location instanceLocation) {
	// CWD is Eclipse infrastructure which stores the location of the
	// current workspace in a (text) file in the configuration area (Toolbox
	// installation directory) in 1.5.3. With version 1.5.4 of the Toolbox, we will
	// use this information below to migrate all workspaces to @user.home/.tlaplus.
	final ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLocation.getDefault());
	final List<String> recentWorkspaces = Arrays.asList(launchData.getRecentWorkspaces());
	if (!recentWorkspaces.isEmpty()) {
		// Get the first non-null workspace. It is the most recently used one.
		for(int i = 0; i < recentWorkspaces.size(); i++) {
			if (recentWorkspaces.get(i) != null) {
				return recentWorkspaces.get(i);
			}
		}
	}
	return null;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:18,代码来源:Application.java

示例3: start

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
@Override
public Object start(final IApplicationContext context) throws Exception {
	Display.setAppName("Gama Platform");
	Display.setAppVersion("1.7.0");
	createProcessor();
	if ( checkWorkspace() == EXIT_OK )
		return EXIT_OK;
	Display display = null;
	try {
		display = Display.getDefault();
		final int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if ( returnCode == PlatformUI.RETURN_RESTART ) { return IApplication.EXIT_RESTART; }
		return IApplication.EXIT_OK;
	} finally {
		if ( display != null )
			display.dispose();
		final Location instanceLoc = Platform.getInstanceLocation();
		if ( instanceLoc != null ) {
			instanceLoc.release();
		}
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:24,代码来源:Application.java

示例4: getHawkServerConfigurationFiles

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
private List<File> getHawkServerConfigurationFiles() {
	try {
		File configurationFolder = null;
		Location configurationLocation = Platform.getConfigurationLocation();
		if(configurationLocation == null) {
			// create a configuration folder
			configurationFolder = new File("configuration");
		} else {
			URL configurationURL = configurationLocation.getURL();
			String path = FileLocator.toFileURL(configurationURL).getPath();
			configurationFolder = new File(path);
		}

		LOGGER.info("Looking for configuration files in {}", configurationFolder.getAbsolutePath());
		FilenameFilter filter = getXmlFilenameFilter();
		if (configurationFolder.exists() && configurationFolder.isDirectory()) {
			return new ArrayList<File>(Arrays.asList(configurationFolder.listFiles(filter)));
		} else {
			configurationFolder.mkdir(); // make directory
		}
	} catch (IOException e) {
		LOGGER.error(e.getMessage(), e);
	}
	return Collections.emptyList();
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:26,代码来源:HawkServerConfigurator.java

示例5: copyToMetadata

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
/**
 * Copy the entries specified from the bundle provided to the metadata area for the bundle provided, and return the URL for the metadata area for this bundle.
 * 
 * @param bundle
 * @param path
 * @param filePattern
 * @param recurse
 * @return URL
 * @throws IOException
 */
public static URL copyToMetadata(Bundle bundle, String path, String filePattern, boolean recurse) throws IOException {
	Location instanceLocation = Platform.getInstanceLocation();
	URL dataArea = getDataArea(instanceLocation, bundle.getSymbolicName());
	Enumeration entries = bundle.findEntries(path, filePattern, recurse);
	while (entries.hasMoreElements()) {
		URL entry = (URL) entries.nextElement();
		String entryPath = entry.getPath();
		try {
			InputStream inputStream = FileLocator.openStream(bundle, new Path(entryPath), false);
			URI dataURI = dataArea.toURI();
			URI fullPath = URI.create(dataURI.toString() + entryPath);
			File file = new File(fullPath);
			if (!file.exists()) {
				file.getParentFile().mkdirs();
				file.createNewFile();
			}
			FileOutputStream outputStream = new FileOutputStream(file);
			IOUtils.copy(inputStream, outputStream);
			outputStream.close();
		} catch (Exception e) {
			// skip this one
		}
	}
	return dataArea;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:36,代码来源:FileUtilities.java

示例6: assignPlatformLocation

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
protected void assignPlatformLocation() {

		Location location = Platform.getInstanceLocation();
		
		if (location.isSet()) {
			return;
		}
		
		try {
			URL platformLocation = initializePlatformLocation("camundaModeler");
			
			// we use toURL here because it properly handles whitespaces
			// (in opposite to toURI())
			location.set(platformLocation, false);
		} catch (IOException e) {
			throw new IllegalStateException("Failed to start Modeler", e);
		}
	}
 
开发者ID:camunda,项目名称:camunda-eclipse-standalone,代码行数:19,代码来源:ModelerApplication.java

示例7: loadConfig

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
public void loadConfig() throws IOException {
	Location location = Platform.getConfigurationLocation();
	if (location != null) {
		URL configURL = location.getURL();
		if (configURL != null && configURL.getProtocol().startsWith("file")) {
			File platformDir = new File(configURL.getFile(), Activator.PLUGIN_ID);
			createDir(platformDir.getAbsolutePath());
			String configFileName = platformDir.getAbsolutePath() + "/" + DEFAULT_CONFIG_FILE_NAME;
			
			commandFile	= new File( platformDir.getAbsolutePath(), "command.txt" );
			serverListFile	= new File( platformDir.getAbsolutePath(), "serverlist.bin" );
			
			loadConfig(configFileName);
		}
	} else {
		loadConfig("_dummy_not_exist_");
	}
}
 
开发者ID:aw20,项目名称:MongoWorkBench,代码行数:19,代码来源:Activator.java

示例8: getInstanceLocation

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
/**
 * @return the instance Location service
 */
public Location getInstanceLocation()
{
	if (locationTracker == null)
	{
		Filter filter = null;
		try
		{
			filter = context.createFilter(Location.INSTANCE_FILTER);
		}
		catch (InvalidSyntaxException e)
		{
			// ignore this. It should never happen as we have tested the
			// above format.
		}
		locationTracker = new ServiceTracker<Location, Location>(context, filter, null);
		locationTracker.open();
	}
	return locationTracker.getService();
}
 
开发者ID:jd-carroll,项目名称:target-baselines,代码行数:23,代码来源:ApiToolsActivator.java

示例9: start

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
public Object start(IApplicationContext context) throws Exception {
	Display display = PlatformUI.createDisplay();
	Shell shell = WorkbenchPlugin.getSplashShell(display);

	if (OSValidator.isWindows() && !PreStartActivity.isDevLaunchMode(context.getArguments())) {
		PreStartActivity activity = new PreStartActivity(shell);
		if (ToolProvider.getSystemJavaCompiler() == null) {
			activity.performPreStartActivity();
		} else {
			activity.updateINIOnJDkUpgrade();
		}
	}
	try {
		Object instanceLocationCheck = checkInstanceLocation(shell, context.getArguments());
		if (instanceLocationCheck != null) {
           	WorkbenchPlugin.unsetSplashShell(display);
               context.applicationRunning();
               return instanceLocationCheck;
           }
		int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		if (display != null) {
			display.dispose();
		}
		Location instanceLoc = Platform.getInstanceLocation();
		if (instanceLoc != null){
			instanceLoc.release();
		}
	}
	
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:36,代码来源:Application.java

示例10: start

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
public Object start(IApplicationContext context) throws Exception {
		Location instanceLocation = Platform.getInstanceLocation();
//		if(instanceLocation.isSet())
//			instanceLocation.release();
//		instanceLocation.set(new URL("file", null, System.getProperty("user.home") + "/scouter-workspace-test"), false);
		
		String workspaceRootName = instanceLocation.getURL().getFile();
		String importWorkingDirName = workspaceRootName + "/import-working";

		try {
			ClientFileUtil.copy(new File(importWorkingDirName + "/" + ClientFileUtil.XLOG_COLUMN_FILE),
					new File(workspaceRootName + "/" + ClientFileUtil.XLOG_COLUMN_FILE));
			ClientFileUtil.copy(new File(importWorkingDirName + "/" + ClientFileUtil.GROUP_FILE),
					new File(workspaceRootName + "/" + ClientFileUtil.GROUP_FILE));
			ClientFileUtil.copy(new File(importWorkingDirName + "/" + ClientFileUtil.WORKSPACE_METADATA_DIR),
					new File(workspaceRootName + "/" + ClientFileUtil.WORKSPACE_METADATA_DIR));
		} catch (IOException e) {
			e.printStackTrace();
		}

		ClientFileUtil.deleteDirectory(new File(importWorkingDirName));

		Display display = PlatformUI.createDisplay();
		Object exitStrategy = IApplication.EXIT_OK;
		try {
			boolean loginSuccessed = loginAutomaticallyWhenAutoLoginEnabled();
			if (loginSuccessed == false) {
				loginSuccessed = openLoginDialog(display);
			}
			if (loginSuccessed) {
				exitStrategy = createAndRunWorkbench(display);
			}
			return exitStrategy;
		} finally {
			display.dispose();
		}
	}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:38,代码来源:Application.java

示例11: computeSdkRegistrantsKeyV2

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
private static String computeSdkRegistrantsKeyV2() {
  StringBuilder key = new StringBuilder(SDK_REGISTRANTS_KEY_PREFIX);
  Location location = Platform.getInstallLocation();
  if (location != null) {
    URL locationUrl = location.getURL();
    if (locationUrl != null) {
      key.append('_').append(locationUrl.toString());
    }
  }

  return key.toString();
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:13,代码来源:GdtPreferences.java

示例12: intializePath

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
/**
 * Get the path and cache it values
 */
private static void intializePath(){
	String path = null;
	Location configArea = Platform.getInstallLocation();
	String product = Platform.getProduct().getName();
	if (configArea != null) {
		if (Util.isMac()) {
			path = configArea.getURL().toExternalForm() + "/" + product + ".app/Contents/MacOS/";
			path = path + product + ".ini";
		}
		else path = configArea.getURL().toExternalForm() + product + ".ini"; //$NON-NLS-1$
	}
	cachedPath = path;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:ConfigurationPathProvider.java

示例13: createFileInWorkingDirectory

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
/**
 * Creates a file in the platform's working directory.
 * 
 * @param relativeFilename
 * @param ins
 * @return boolean
 * @throws IOException
 */
public static boolean createFileInWorkingDirectory(String relativeFilename, InputStream ins) throws IOException {
	Location instanceLocation = Platform.getInstanceLocation();
	if (instanceLocation == null || !instanceLocation.isSet()) {
		Logger logger = Logger.getLogger(FileUtilities.class);
		logger.warn("cannot create file '" + relativeFilename + "' because platform does not have a working directory.");
		return false;
	} else {
		File cacheFile = new File(instanceLocation.getURL().getFile() + File.separator + relativeFilename);
		// if cache file already exists, remove it because we are about to
		// overwrite it
		if (cacheFile.exists()) {
			cacheFile.delete();
		}
		cacheFile.getParentFile().mkdirs();
		cacheFile.createNewFile();
		BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
		FileWriter writer = new FileWriter(cacheFile);
		String line = reader.readLine();
		while (line != null) {
			writer.write(line);
			writer.write("\n");
			line = reader.readLine();
		}
		writer.flush();
		writer.close();
		return true;
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:37,代码来源:FileUtilities.java

示例14: getFileInWorkingDirectory

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
/**
 * @param relativeFilename
 * @return a File corresponding to the working directory + relativeFilename or null if the platform's working directory is not specified
 */
public static File getFileInWorkingDirectory(String relativeFilename) {
	File cacheFile = null;
	Location instanceLocation = Platform.getInstanceLocation();
	if (instanceLocation == null || !instanceLocation.isSet()) {
		Logger logger = Logger.getLogger(FileUtilities.class);
		logger.warn("cannot retrieve file '" + relativeFilename + "' because platform does not have a working directory.");
	} else {
		cacheFile = new File(instanceLocation.getURL().getFile() + File.separator + relativeFilename);
	}
	return cacheFile;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:16,代码来源:FileUtilities.java

示例15: getDataArea

import org.eclipse.osgi.service.datalocation.Location; //导入依赖的package包/类
public static URL getDataArea(Location location, String filename) throws IOException {
	URL base = location.getURL();
	if (base == null)
		throw new IOException("Null location");
	String prefix = base.toExternalForm();
	if (prefix.length() > 0 && prefix.charAt(prefix.length() - 1) != '/')
		prefix += '/';
	prefix = prefix.replace(" ", "%20");
	filename = filename.replace('\\', '/');
	if (filename.length() > 0 && filename.charAt(0) == '/')
		filename.substring(1);
	return new URL(prefix + dataAreaPrefix + filename);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:14,代码来源:FileUtilities.java


注:本文中的org.eclipse.osgi.service.datalocation.Location类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。