Example #1
0
  /**
   * Opens a project.
   *
   * @param directory Where the project is stored.
   * @return the BProject that describes the newly opened project or null if it cannot be opened.
   */
  public final BProject openProject(File directory) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    // Yes somebody may just call it with null, for fun..
    if (directory == null) return null;

    Project openProj = Project.openProject(directory.getAbsolutePath(), null);
    if (openProj == null) return null;

    // a hack, since bluej does not handle "opening" of projects correctly.
    // this code should really be into openProject or it should not be possible to open
    // a project is the initial package name is not there.
    Package pkg = openProj.getCachedPackage(openProj.getInitialPackageName());
    if (pkg == null) return null;

    // I make a new identifier out of this
    Identifier aProject = new Identifier(openProj, pkg);

    // This will make the frame if not already there. should not be needed...
    try {
      aProject.getPackageFrame();
    } catch (ExtensionException exc) {
    }

    // Note: the previous Identifier is not used here.
    return openProj.getBProject();
  }