Пример #1
0
 /** Returns a string representation of this package object */
 public String toString() {
   try {
     Project thisProject = projectId.getBluejProject();
     return "BProject: " + thisProject.getProjectName();
   } catch (ExtensionException exc) {
     return "BProject: INVALID";
   }
 }
Пример #2
0
 /**
  * Get a package belonging to this project.
  *
  * @param name the fully-qualified name of the package
  * @return the requested package, or null if it wasn't found
  * @throws ProjectNotOpenException if the project has been closed by the user.
  */
 public BPackage getPackage(String name) throws ProjectNotOpenException {
   Project bluejProject = projectId.getBluejProject();
   Package pkg = bluejProject.getPackage(name);
   if (pkg == null) {
     return null;
   }
   return pkg.getBPackage();
 }
Пример #3
0
  /**
   * Returns all packages belonging to this project.
   *
   * @return The array of this project's packages, if none exist an empty array is returned.
   * @throws ProjectNotOpenException if the project has been closed by the user.
   */
  public BPackage[] getPackages() throws ProjectNotOpenException {
    Project thisProject = projectId.getBluejProject();

    List<String> names = thisProject.getPackageNames();
    BPackage[] packages = new BPackage[names.size()];
    for (ListIterator<String> li = names.listIterator(); li.hasNext(); ) {
      int i = li.nextIndex();
      String name = li.next();
      packages[i] = getPackage(name);
    }
    return packages;
  }
Пример #4
0
  /**
   * Create and return a new package with the given fully qualified name. The necessary directories
   * and files will be created.
   *
   * @return the requested package, or null if it wasn't found
   * @throws ProjectNotOpenException if the project has been closed by the user.
   * @throws PackageAlreadyExistsException if the named package already exists in the project.
   */
  public BPackage newPackage(String fullyQualifiedName)
      throws ProjectNotOpenException, PackageAlreadyExistsException {
    Project bluejProject = projectId.getBluejProject();

    int result = bluejProject.newPackage(fullyQualifiedName);

    if (result == Project.NEW_PACKAGE_BAD_NAME) {
      throw new IllegalArgumentException(
          "newPackage: Bad package name '" + fullyQualifiedName + "'");
    }

    if (result == Project.NEW_PACKAGE_EXIST) {
      throw new PackageAlreadyExistsException(
          "newPackage: Package '" + fullyQualifiedName + "' already exists");
    }

    if (result == Project.NEW_PACKAGE_NO_PARENT) {
      throw new IllegalStateException(
          "newPackage: Package '" + fullyQualifiedName + "' has no parent package");
    }

    if (result != Project.NEW_PACKAGE_DONE) {
      throw new IllegalStateException("newPackage: Unknown result code=" + result);
    }

    Package pkg = bluejProject.getPackage(fullyQualifiedName);

    if (pkg == null) {
      throw new Error("newPackage: getPackage '" + fullyQualifiedName + "' returned null");
    }

    Package reloadPkg = pkg;
    for (int index = 0; index < 10 && reloadPkg != null; index++) {
      // This is needed since the GUI is not sync with the state
      // It would be better is core BlueJ did fix this..
      reloadPkg.reload();
      reloadPkg = reloadPkg.getParent();
    }

    return pkg.getBPackage();
  }
Пример #5
0
 /**
  * Restarts the VM used to run user code for this project. As a side-effect, removes all objects
  * from the object bench.
  *
  * @throws ProjectNotOpenException if the project has been closed by the user.
  */
 public void restartVM() throws ProjectNotOpenException {
   projectId.getBluejProject().restartVM();
 }
Пример #6
0
  /**
   * Saves any open files, then closes all frames belonging to this project.
   *
   * @throws ProjectNotOpenException if the project has been closed by the user.
   */
  public void close() throws ProjectNotOpenException {
    Project thisProject = projectId.getBluejProject();

    thisProject.saveAll();
    PkgMgrFrame.closeProject(thisProject);
  }
Пример #7
0
  /**
   * Requests a "save" of all open files in this project.
   *
   * @throws ProjectNotOpenException if the project has been closed by the user.
   */
  public void save() throws ProjectNotOpenException {
    Project thisProject = projectId.getBluejProject();

    thisProject.saveAll();
  }
Пример #8
0
  /**
   * Returns the directory in which this project is stored.
   *
   * @throws ProjectNotOpenException if the project has been closed by the user.
   */
  public File getDir() throws ProjectNotOpenException {
    Project thisProject = projectId.getBluejProject();

    return thisProject.getProjectDir();
  }
Пример #9
0
  /**
   * Returns the name of this project. This is what is displayed in the title bar of the frame after
   * 'BlueJ'.
   *
   * @throws ProjectNotOpenException if the project has been closed by the user.
   */
  public String getName() throws ProjectNotOpenException {
    Project thisProject = projectId.getBluejProject();

    return thisProject.getProjectName();
  }
Пример #10
0
 void clearObjectBench() throws ProjectNotOpenException {
   Project thisProject = projectId.getBluejProject();
   thisProject.clearObjectBenches();
 }
Пример #11
0
 void addDebuggerListener(DebuggerListener listener) throws ProjectNotOpenException {
   Project thisProject = projectId.getBluejProject();
   thisProject.getDebugger().addDebuggerListener(listener);
 }
Пример #12
0
  /**
   * Returns a URLClassLoader that should be used to load project classes. Every time a project is
   * compiled, even when the compilation is started from the GUI, a new URLClassLoader is created
   * and if the Extension currently have a copy of the old one it should discard it and use
   * getClassLoader() to acquire the new one.
   *
   * @return A class loader that should be used to load project classes.
   * @throws ProjectNotOpenException if the project has been closed by the user.
   */
  public URLClassLoader getClassLoader() throws ProjectNotOpenException {
    Project thisProject = projectId.getBluejProject();

    return thisProject.getClassLoader();
  }