Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.projectuiapi/1 1.13.22 5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.netbeans.spi.project.ui
Class ProjectOpenedHook

    java.lang.Object
      org.netbeans.spi.project.ui.ProjectOpenedHook

    public abstract class ProjectOpenedHook

extends Object

A hook which can be run when a project is "opened" or "closed" in the GUI.

The meaning of these terms is intentionally left vague, but typically opening a project signals that the user may wish to work with it, so it would be a good idea to make sure caches are up to date, etc. It is perfectly possible to load and use (even run) projects which are not open, so any project type provider using this hook cannot rely on it for basic semantics.

XXX run with mutex read or write held?

`projectOpened()` and `projectClosed()` are always called in pairs, e.g. a project cannot be opened twice in a row without being closed in between. Also a project left open at the end of one VM session will receive `projectClosed()` before shutdown and (if an open project list is persisted) `projectOpened()` sometime during the next startup.

An instance should be placed into a project's lookup to register it. All instances found in the lookup will be notified on project open and close.

See Also:
  `Project.getLookup()`

Constructor Summary
`protected` | `ProjectOpenedHook()` Default constructor for use by subclasses.

Method Summary
`protected abstract void` | `projectClosed()` Called when a project is closed in the GUI.
`protected abstract void` | `projectOpened()` Called when a project is opened in the GUI.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ProjectOpenedHook

    protected ProjectOpenedHook()

  Default constructor for use by subclasses.

Method Detail

### projectOpened

    protected abstract void projectOpened()

  Called when a project is opened in the GUI.

  Typical things to do here:

  - Update build scripts using `GeneratedFilesHelper.refreshBuildScript(...)`.

  - Call `GlobalPathRegistry.register(...)` with source, compile, and boot paths known to the project.

  - Write property `user.properties.file` to `private.properties` with absolute file path of the `build.properties` from the IDE's user directory. This makes it easier for the user to run headless builds in some cases. The IDE's user directory is defined in `netbeans.user` property of IDE's VM.

### projectClosed

    protected abstract void projectClosed()

  Called when a project is closed in the GUI.

  Typical things to do here:

  - Call `ProjectManager.saveProject(org.netbeans.api.project.Project)` as a precaution in case the project was modified in an unusual way (e.g. using `AuxiliaryConfiguration`).

  - Call `GlobalPathRegistry.unregister(...)` with the same paths are were previously registered.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.projectuiapi/1 1.13.22 5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.