org.eclipse.ui.internal.ide.ChooseWorkspaceData Java Examples

The following examples show how to use org.eclipse.ui.internal.ide.ChooseWorkspaceData. 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: StartupHook.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private static void makeCurrentWorkspaceToUsedOnNextLaunch() {
	ChooseWorkspaceData data = new ChooseWorkspaceData(""); //$NON-NLS-1$
	data.readPersistedData();
	
	String[] recentWorkspaces = data.getRecentWorkspaces();
	String workspaceRootPath = ResourceUtils.getWorkspaceRootPath();
	boolean isFound = false;
	for (String workspace : recentWorkspaces) {
		if (workspace == null) continue;
		workspace = (new File(workspace)).getAbsolutePath();
		if (workspace.equals(workspaceRootPath)) {
			isFound = true;
			break;
		}
	}
	if (!isFound) {
		List<String> recentWorkspacesList = new ArrayList<String>(Arrays.asList(recentWorkspaces));
		recentWorkspacesList.add(0, workspaceRootPath);
		data.setRecentWorkspaces(recentWorkspacesList.toArray(new String[0]));
		data.writePersistedData();
	}
}
 
Example #2
Source File: Application.java    From tlaplus with MIT License 6 votes vote down vote up
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: Application.java    From tlaplus with MIT License 4 votes vote down vote up
private static void clearPreviousInstanceLocation(final Location instanceLocation) {
	final ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLocation.getDefault());
	launchData.setRecentWorkspaces(new String[0]);
	launchData.writePersistedData();
}