Interface Workspace

  • All Superinterfaces:
    org.openide.util.Lookup.Provider
    All Known Implementing Classes:
    WorkspaceImpl

    public interface Workspace
    extends org.openide.util.Lookup.Provider
    Workspace interface that internally stores, through its Lookup, various information and instances.

    Workpace is a top concept in Gephi because all models that modules possesses are usually divided by workspace, for instance one GraphModel per workspace. Therefore this class has a Lookup mechanism to let modules store their model in the workspace's lookup and query it when needed.

    To know how you can manage loading and saving data in Gephi project files, see WorkspacePersistenceProvider.

    How to associate new data model to the workspace

    In your new module, listen to WorkspaceListener and call add() method when initialize:
    public void initialize(Workspace workspace) {
          workspace.add(new MyDataModel())
     }
     
    When a workspace is selected, retrieve the workspace's data model:
    public void select(Workspace workspace) {
          MyDataModel model = workspace.getLookup().lookup(MyDataModel.class);
     }
     
    Author:
    Mathieu Bastian
    • Method Detail

      • add

        void add​(Object instance)
        Adds an instance to this workspaces lookup.
        Parameters:
        instance - the instance that is to be pushed to the lookup
      • remove

        void remove​(Object instance)
        Removes an instance from this workspaces lookup.
        Parameters:
        instance - the instance that is to be removed from the lookup
      • getLookup

        org.openide.util.Lookup getLookup()
        Get any instance in the current lookup. All important API in Gephi are storing models in this lookup.

        May contains:

        • GraphModel
        • LayoutModel
        • StatisticsModel
        • FiltersModel
        • PreviewModel
        • ...
        Specified by:
        getLookup in interface org.openide.util.Lookup.Provider
        Returns:
        the workspace's lookup
      • getProject

        Project getProject()
        Returns the project this workspace belong to
        Returns:
        the workspace's project
      • getId

        int getId()
        Returns the workspace unique identifier
        Returns:
        the workspace id
      • isOpen

        boolean isOpen()
        Returns true if the workspace is open.
        Returns:
        true if open, false otherwise
      • isClosed

        boolean isClosed()
        Returns true if the workspace is closed.
        Returns:
        true if closed, false otherwise
      • isInvalid

        boolean isInvalid()
        Returns true if the workspace is invalid.
        Returns:
        true if invalid, false otherwise
      • getName

        String getName()
        Returns the name of the workspace.

        The name can't be null and has a default value (e.g. Workspace 1).

        Returns:
        the workspace's name
      • hasSource

        boolean hasSource()
        Returns true if the workspace has a source.
        Returns:
        true if has a source, false otherwise
      • getSource

        String getSource()
        Returns the workspace's source or null if missing.
        Returns:
        workspace's source or null if missing
      • getWorkspaceMetadata

        WorkspaceMetaData getWorkspaceMetadata()
        Returns the workspace's metadata.
        Returns:
        workspace metadata