org.eclipse.osgi.service.datalocation.Location Java Examples
The following examples show how to use
org.eclipse.osgi.service.datalocation.Location.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Activator.java From orion.server with Eclipse Public License 1.0 | 6 votes |
/** * Returns the root file system location the OSGi instance area. */ public IPath getPlatformLocation() { BundleContext context = Activator.getDefault().getContext(); Collection<ServiceReference<Location>> refs; try { refs = context.getServiceReferences(Location.class, Location.INSTANCE_FILTER); } catch (InvalidSyntaxException e) { // we know the instance location filter syntax is valid throw new RuntimeException(e); } if (refs.isEmpty()) return null; ServiceReference<Location> ref = refs.iterator().next(); Location location = context.getService(ref); try { if (location == null) return null; URL root = location.getURL(); if (root == null) return null; // strip off file: prefix from URL return new Path(root.toExternalForm().substring(5)); } finally { context.ungetService(ref); } }
Example #2
Source File: Application.java From tlaplus with MIT License | 6 votes |
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; }
Example #3
Source File: Activator.java From orion.server with Eclipse Public License 1.0 | 5 votes |
Location getInstanceLocation() { if (instanceLocationTracker == null) { Filter filter; try { filter = bundleContext.createFilter(Location.INSTANCE_FILTER); } catch (InvalidSyntaxException e) { LogHelper.log(e); return null; } instanceLocationTracker = new ServiceTracker<Location, Location>(bundleContext, filter, null); instanceLocationTracker.open(); } return instanceLocationTracker.getService(); }
Example #4
Source File: ResourceUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Directory of the Eclipse platform installation * @return FS path of the eclipse installation or null if it is running without installation * @see {@link Platform#getInstallLocation()} */ public static File getEclipseInstallationDirectory() { Location location = Platform.getInstallLocation(); if (location == null || !location.isSet()){ return null; } try { return new File(location.getURL().toURI()); } catch (URISyntaxException e) { return null; } }
Example #5
Source File: ToolboxIntroPart.java From tlaplus with MIT License | 5 votes |
@Override public void widgetSelected(SelectionEvent se) { final String spec = (String) se.widget.getData(specKey); final String zip = (String) se.widget.getData(zipKey); final URL resource = StandaloneActivator.getDefault().getBundle().getResource(zip); final Location instanceLocation = Platform.getInstanceLocation(); try { // Force-open the getting started guide that new users should read. final Map<String, String> params = new HashMap<>(); params.put("org.lamport.tla.toolbox.doc.contents.param", "/org.lamport.tla.toolbox.doc/html/gettingstarted/gettingstarted.html"); runCommand("org.lamport.tla.toolbox.doc.contents", params); // TODO If the zip is large, this will block the main/UI thread. final File destDir = ZipUtil.unzip(resource.openStream(), new File(instanceLocation.getURL().getFile() + File.separator + spec.replaceFirst(".tla$", "")), true); params.clear(); params.put("toolbox.command.spec.new.param", destDir.getAbsolutePath() + File.separator + spec); runCommand("toolbox.command.spec.new", params); } catch (IOException ex) { StandaloneActivator.getDefault().logError(ex.getMessage(), ex); } }
Example #6
Source File: GdtPreferences.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
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(); }
Example #7
Source File: PlatformUtils.java From olca-app with Mozilla Public License 2.0 | 5 votes |
public static File getInstallRoot() throws Exception { Location installLocation = Platform.getInstallLocation(); if (installLocation == null) return null; log.trace("get install location {}", installLocation.getURL()); File installDir = new File(installLocation.getURL().getFile()); return installDir; }
Example #8
Source File: N4JSApplication.java From n4js with Eclipse Public License 1.0 | 4 votes |
@Override public Object start(final IApplicationContext appContext) throws Exception { final Display display = createDisplay(); try { // look and see if there's a splash shell we can parent off of final Shell shell = WorkbenchPlugin.getSplashShell(display); if (shell != null) { // should should set the icon and message for this shell to be the // same as the chooser dialog - this will be the guy that lives in // the task bar and without these calls you'd have the default icon // with no message. shell.setText(ChooseWorkspaceDialog.getWindowTitle()); shell.setImages(Window.getDefaultImages()); } final Object instanceLocationCheck = checkInstanceLocation(shell, appContext.getArguments()); if (instanceLocationCheck != null) { WorkbenchPlugin.unsetSplashShell(display); appContext.applicationRunning(); return instanceLocationCheck; } // create the workbench with this advisor and run it until it exits // N.B. createWorkbench remembers the advisor, and also registers // the workbench globally so that all UI plug-ins can find it using // PlatformUI.getWorkbench() or AbstractUIPlugin.getWorkbench() final int returnCode = createAndRunWorkbench(display, new N4JSApplicationWorkbenchAdvisor()); // the workbench doesn't support relaunch yet (bug 61809) so // for now restart is used, and exit data properties are checked // here to substitute in the relaunch return code if needed if (returnCode != PlatformUI.RETURN_RESTART) { return EXIT_OK; } // if the exit code property has been set to the relaunch code, then // return that code now, otherwise this is a normal restart return EXIT_RELAUNCH.equals(Integer.getInteger(PROP_EXIT_CODE)) ? EXIT_RELAUNCH : EXIT_RESTART; } finally { if (display != null) { display.dispose(); } final Location instanceLoc = Platform.getInstanceLocation(); if (instanceLoc != null) instanceLoc.release(); } }
Example #9
Source File: Application.java From tlaplus with MIT License | 4 votes |
private static void clearPreviousInstanceLocation(final Location instanceLocation) { final ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLocation.getDefault()); launchData.setRecentWorkspaces(new String[0]); launchData.writePersistedData(); }
Example #10
Source File: Application.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public Object start(final IApplicationContext context) throws Exception { Thread.setDefaultUncaughtExceptionHandler((t, e) -> { if ( e instanceof OutOfMemoryError ) { final boolean close = MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Out of memory", "GAMA is out of memory and will likely crash. Do you want to close now ?"); if ( close ) { this.stop(); } e.printStackTrace(); } }); Display.setAppName("Gama Platform"); Display.setAppVersion("1.8.1"); // DEBUG.OUT(System.getProperties()); createProcessor(); final Object check = checkWorkspace(); if ( EXIT_OK.equals(check) ) { return EXIT_OK; } // if ( check == EXIT_RESTART ) { // ClearWorkspace(true); // No need to restart : the value will be checked later // return EXIT_RESTART; // } Display display = null; try { display = Display.getDefault(); checkWorkbenchXMI(); // final String splash = getProperty("org.eclipse.equinox.launcher.splash.location"); // if ( splash != null ) { // setProperty("org.eclipse.equinox.launcher.splash.location", splash.replace("bmp", "png")); // } 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(); } } }