Java 类org.eclipse.ui.internal.ide.ChooseWorkspaceData 实例源码

项目:tlaplus    文件:Application.java   
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;
}
项目:tlaplus    文件:Application.java   
private static void clearPreviousInstanceLocation(final Location instanceLocation) {
    final ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLocation.getDefault());
    launchData.setRecentWorkspaces(new String[0]);
    launchData.writePersistedData();
}
项目:limpet    文件:Application.java   
/**
 * Open a workspace selection dialog on the argument shell, populating the argument data with the
 * user's selection. Perform first level validation on the selection by comparing the version
 * information. This method does not examine the runtime state (e.g., is the workspace already
 * locked?).
 * 
 * @param shell
 * @param launchData
 * @param force
 *          setting to true makes the dialog open regardless of the showDialog value
 * @return An URL storing the selected workspace or null if the user has canceled the launch
 *         operation.
 */
private URL promptForWorkspace(Shell shell, ChooseWorkspaceData launchData,
    boolean force)
{
  URL url = null;
  do
  {
    // okay to use the shell now - this is the splash shell
    new ChooseWorkspaceDialog(shell, launchData, false, true).prompt(force);
    String instancePath = launchData.getSelection();
    if (instancePath == null)
    {
      return null;
    }

    // the dialog is not forced on the first iteration, but is on every
    // subsequent one -- if there was an error then the user needs to be
    // allowed to fix it
    force = true;

    // 70576: don't accept empty input
    if (instancePath.length() <= 0)
    {
      MessageDialog.openError(shell,
          IDEWorkbenchMessages.IDEApplication_workspaceEmptyTitle,
          IDEWorkbenchMessages.IDEApplication_workspaceEmptyMessage);
      continue;
    }

    // create the workspace if it does not already exist
    File workspace = new File(instancePath);
    if (!workspace.exists())
    {
      workspace.mkdir();
    }

    try
    {
      // Don't use File.toURL() since it adds a leading slash that Platform does not
      // handle properly. See bug 54081 for more details.
      String path =
          workspace.getAbsolutePath().replace(File.separatorChar, '/');
      url = new URL("file", null, path); //$NON-NLS-1$
    }
    catch (MalformedURLException e)
    {
      MessageDialog.openError(shell,
          IDEWorkbenchMessages.IDEApplication_workspaceInvalidTitle,
          IDEWorkbenchMessages.IDEApplication_workspaceInvalidMessage);
      continue;
    }
  }
  while (!checkValidWorkspace(shell, url));

  return url;
}