Package bluej.extensions2
Class BProject
- java.lang.Object
-
- bluej.extensions2.BProject
-
public class BProject extends java.lang.Object
A 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 void
close()
Saves any open files, then closes all frames belonging to this project.java.net.URLClassLoader
getClassLoader()
Returns a URLClassLoader that should be used to load project classes.java.io.File
getDir()
Returns the directory in which this project is stored.java.lang.String
getName()
Returns the name of this project.BPackage
getPackage(java.lang.String name)
Gets a package belonging to this project.BPackage[]
getPackages()
Returns all packages belonging to this project.BPackage
newPackage(java.lang.String fullyQualifiedName)
Creates and returns a new package with the given fully qualified name.void
openWebViewTab(java.lang.String url)
Opens a tab editor with a web browser showing the given URL.void
restartVM()
Restarts the VM used to run user code for this project.void
save()
Requests a "save" of all open files in this project.java.lang.String
toString()
Returns a string representation of this package object
-
-
-
Method Detail
-
getName
public java.lang.String getName() throws ProjectNotOpenException
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.
-
getDir
public java.io.File getDir() throws ProjectNotOpenException
Returns the directory in which this project is stored.- Returns:
- A
File
object representing the directory where this project is stored. - Throws:
ProjectNotOpenException
- if the project has been closed by the user.
-
save
public void save() throws ProjectNotOpenException
Requests 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 ProjectNotOpenException
Saves 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 ProjectNotOpenException
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.
-
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
BPackage
object 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
BPackage
object wrapping the requested package,null
if 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
BPackage
objects wrapping this project's packages. - Throws:
ProjectNotOpenException
- if the project has been closed by the user.
-
getClassLoader
public java.net.URLClassLoader getClassLoader() throws ProjectNotOpenException
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.- Returns:
- A
ClassLoader
object 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:
toString
in classjava.lang.Object
-
openWebViewTab
public void openWebViewTab(java.lang.String url) throws ProjectNotOpenException
Opens 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
-
-