Package bluej.extensions2
Class BProject
- java.lang.Object
-
- bluej.extensions2.BProject
-
public class BProject extends java.lang.ObjectA wrapper for a BlueJ project.- Author:
- Clive Mille, Univeristy of Kent at Canterbury, 2002, Damiano Bolla, University of Kent at Canterbury, 2003,2004,2005
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Saves any open files, then closes all frames belonging to this project.java.net.URLClassLoadergetClassLoader()Returns a URLClassLoader that should be used to load project classes.java.io.FilegetDir()Returns the directory in which this project is stored.java.lang.StringgetName()Returns the name of this project.BPackagegetPackage(java.lang.String name)Gets a package belonging to this project.BPackage[]getPackages()Returns all packages belonging to this project.BPackagenewPackage(java.lang.String fullyQualifiedName)Creates and returns a new package with the given fully qualified name.voidopenWebViewTab(java.lang.String url)Opens a tab editor with a web browser showing the given URL.voidrestartVM()Restarts the VM used to run user code for this project.voidsave()Requests a "save" of all open files in this project.java.lang.StringtoString()Returns a string representation of this package object
-
-
-
Method Detail
-
getName
public java.lang.String getName() throws ProjectNotOpenExceptionReturns 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.
-
getDir
public java.io.File getDir() throws ProjectNotOpenExceptionReturns the directory in which this project is stored.- Returns:
- A
Fileobject representing the directory where this project is stored. - Throws:
ProjectNotOpenException- if the project has been closed by the user.
-
save
public void save() throws ProjectNotOpenExceptionRequests a "save" of all open files in this project.- Throws:
ProjectNotOpenException- if the project has been closed by the user.
-
close
public void close() throws ProjectNotOpenExceptionSaves any open files, then closes all frames belonging to this project.- Throws:
ProjectNotOpenException- if the project has been closed by the user.
-
restartVM
public void restartVM() throws ProjectNotOpenExceptionRestarts 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.
-
newPackage
public BPackage newPackage(java.lang.String fullyQualifiedName) throws ProjectNotOpenException, PackageAlreadyExistsException
Creates and returns a new package with the given fully qualified name. The necessary directories and files will be created.- Returns:
- A
BPackageobject wrapping the created package. - Throws:
ProjectNotOpenException- if the project has been closed by the user.PackageAlreadyExistsException- if the named package already exists in the project.
-
getPackage
public BPackage getPackage(java.lang.String name) throws ProjectNotOpenException
Gets a package belonging to this project.- Parameters:
name- the fully-qualified name of the package.- Returns:
- A
BPackageobject wrapping the requested package,nullif it wasn't found. - Throws:
ProjectNotOpenException- if the project has been closed by the user.
-
getPackages
public BPackage[] getPackages() throws ProjectNotOpenException
Returns all packages belonging to this project. If none exist an empty array is returned.- Returns:
- An array of
BPackageobjects wrapping this project's packages. - Throws:
ProjectNotOpenException- if the project has been closed by the user.
-
getClassLoader
public java.net.URLClassLoader getClassLoader() throws ProjectNotOpenExceptionReturns 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.- Returns:
- A
ClassLoaderobject that should be used to load project classes. - Throws:
ProjectNotOpenException- if the project has been closed by the user.
-
toString
public java.lang.String toString()
Returns a string representation of this package object- Overrides:
toStringin classjava.lang.Object
-
openWebViewTab
public void openWebViewTab(java.lang.String url) throws ProjectNotOpenExceptionOpens a tab editor with a web browser showing the given URL. If any open web browser tab is already showing that URL, it is shown and focused instead of opening another browser with the same page.- Parameters:
url- The URL to open in the web browser- Throws:
ProjectNotOpenException- if the project has been closed by the user
-
-