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.api.project.ui
Class OpenProjects

    java.lang.Object
      org.netbeans.api.project.ui.OpenProjects

    public final class OpenProjects

extends Object

List of projects open in the GUI.

Warning: this API is intended only for a limited set of use cases where obtaining a list of all open projects is really the direct goal. For example, you may wish to display a chooser letting the user select a file from among the top-level source folders of any open project. For many cases, however, this API is not the correct approach, so use it as a last resort. Consider `GlobalPathRegistry`, `ProjectOpenedHook`, and `ProjectSensitiveActions` (or `MainProjectSensitiveActions`) first. Only certain operations should actually be aware of which projects are "open"; by default, all project functionality should be available whether it is open or not.

Field Summary
`static String` | `PROPERTY_OPEN_PROJECTS` Property representing open projects.

Method Summary
`void` | `addPropertyChangeListener(PropertyChangeListener listener)` Adds a listener to changes in the set of open projects.
`void` | `close(Project[] projects)` Closes given projects.
`static OpenProjects` | `getDefault()` Get the default singleton instance of this class.
`Project` | `getMainProject()` Retrieves the current main project set in the IDE.
`Project[]` | `getOpenProjects()` Gets a list of currently open projects.
`void` | `open(Project[] projects, boolean openSubprojects)` Opens given projects.
`void` | `removePropertyChangeListener(PropertyChangeListener listener)` Removes a listener.
`void` | `setMainProject(Project project)` Sets the main project.

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

Field Detail

### PROPERTY_OPEN_PROJECTS

    public static final String PROPERTY_OPEN_PROJECTS

  Property representing open projects.

  See Also:
    `getOpenProjects()`, Constant Field Values

Method Detail

### getDefault

    public static OpenProjects getDefault()

  Get the default singleton instance of this class.

  Returns:
    the default instance

### getOpenProjects

    public Project[] getOpenProjects()

  Gets a list of currently open projects.

  Returns:
    list of projects currently opened in the IDE's GUI; order not specified

### open

    public void open(Project[] projects,
                     boolean openSubprojects)

  Opens given projects. Acquires `ProjectManager.mutex()` in the write mode.

  Parameters:
    `projects` - to be opened. In the case when some of the projects are already opened these projects are not opened again. If the projects contain duplicates, the duplicated projects are opened just once.
    `openSubprojects` - if true also subprojects are opened.
  Since:
    org.netbeans.modules.projectuiapi/0 1.2

    This method is designed for use by logical view's Libraries Node to open one or more of dependent projects. This method can be used also by other project GUI components which need to open certain project(s), eg. code generation wizards.
    The method should not be used for opening newly created project, insted the `WizardDescriptor.InstantiatingIterator.instantiate()` used for creation of new project should return the project directory.
    The method should not be also used to provide a GUI to open subprojects. The `CommonProjectActions.openSubprojectsAction()` should be used instead.

### close

    public void close(Project[] projects)

  Closes given projects. Acquires `ProjectManager.mutex()` in the write mode.

  Parameters:
    `projects` - to be closed. The non opened project contained in the projects array are ignored.
  Since:
    org.netbeans.modules.projectuiapi/0 1.2

### getMainProject

    public Project getMainProject()

  Retrieves the current main project set in the IDE.

  Warning: the set of usecases that require invoking this method is limited. `MainProjectSensitiveActions` should be used in favour of this method if possible. In particular, this method should not be used to let user choose if an action should be run over main or current project.

  Returns:
    the current main project or null if none
  Since:
    1.11

### setMainProject

    public void setMainProject(Project project)
                        throws IllegalArgumentException

  Sets the main project.

  Warning: the set of usecases that require invoking this method is very limited and should be generally avoided if possible. In particular, this method should not be used to set project created by the New Project Wizard as main.

  Parameters:
    `project` - project to set as main project (must be open), or `null` to set no project as main.
  Throws:
    `IllegalArgumentException` - if the project is not opened.
  Since:
    1.11

### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

  Adds a listener to changes in the set of open projects. As this class is a singleton and is not subject to garbage collection, it is recommended to add only weak listeners, or remove regular listeners reliably.

  Parameters:
    `listener` - a listener to add
  See Also:
    `PROPERTY_OPEN_PROJECTS`

### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

  Removes a listener.

  Parameters:
    `listener` - a listener to remove

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.