ides.api.core
Interface Workspace


public interface Workspace

Interface for the main manager (workspace) of DESModels in IDES.

Author:
Lenko Grigorov

Method Summary
 void addModel(DESModel model)
          Adds the given DESModel to the set of models in the workspace.
 void addSubscriber(WorkspaceSubscriber subscriber)
          Attaches the given subscriber to this publisher.
 void fireAboutToRearrangeWorkspace()
          Sends notification to subscribers that the the layout of the workspace is about to change (e.g., a new model is about to become the active model).
 void fireRepaintRequired()
          Sends a notification to subscribers that a repaint is required due to changes to the display options such as Zoom, or toggling show grid, LaTeX rendering, UniformNode size etc.
 DESModel getActiveModel()
          Returns the model currently active in the workspace.
 java.lang.String getActiveModelName()
          Returns the name of the model currently active in the workspace.
 UIDescriptor getActiveUID()
          Returns the UIDescriptor with the UI elements for the currently active model.
 DESModel getModel(java.lang.String name)
          Finds a model open in the workspace by name.
 java.util.Iterator<DESModel> getModels()
          Returns an iterator of all DESModels in this workspace.
<T> java.util.Collection<T>
getModelsOfType(java.lang.Class<T> type)
          Returns all models of the given type opened in the workspace.
 java.lang.String getName()
          Returns the name of the workspace.
 java.util.Collection<Presentation> getPresentations()
          Returns the set of presentations used as the UI for the currently active model.
<T> java.util.Collection<T>
getPresentationsOfType(java.lang.Class<T> type)
          Selects the presentation of the given type from the set of all presentations used as the UI for the currently active model.
 boolean hasModel(java.lang.String name)
          Check if the workspace contains a model with the given name.
 boolean isDirty()
          Returns if the workspace is dirty (it has been changed since the last save).
 boolean isEmpty()
          Check if there are models open in the workspace.
 void removeModel(java.lang.String name)
          Removes a model from the workspace.
 void removeSubscriber(WorkspaceSubscriber subscriber)
          Removes the given subscriber to this publisher.
 void setActiveModel(java.lang.String name)
          Sets the active model to the DESModel with the given name.
 void setActivePresentation(java.lang.String name)
          Makes the specified presentation active in the user interface.
 void setDirty(boolean state)
          Sets the dirty flag of the workspace (i.e., whether it has been changed since the last save).
 int size()
          Get the number of models in the workspace
 

Method Detail

addModel

void addModel(DESModel model)
Adds the given DESModel to the set of models in the workspace.

Parameters:
model - the model to be added

getModel

DESModel getModel(java.lang.String name)
Finds a model open in the workspace by name.

Parameters:
name - the name of the model
Returns:
the model if it is among the models open in the workspace; null otherwise

hasModel

boolean hasModel(java.lang.String name)
Check if the workspace contains a model with the given name.

Parameters:
name - the name of the model
Returns:
true if the workspace contains a model with the given name; false otherwise

removeModel

void removeModel(java.lang.String name)
Removes a model from the workspace. If the workspace does not contain a model with the given name, the method does nothing. If the currently active model is removed, the next model in the workspace becomes active, unless it is the last model in the list in which case the previous model in the workspace becomes active.

Parameters:
name - the name of the model to remove

getActiveModelName

java.lang.String getActiveModelName()
Returns the name of the model currently active in the workspace.

Returns:
the name of the model currently active in the workspace; or an empty string if there is no model in the workspace

getActiveModel

DESModel getActiveModel()
Returns the model currently active in the workspace.

Returns:
the model currently active in the workspace; or null if there is no model in the workspace

getActiveUID

UIDescriptor getActiveUID()
Returns the UIDescriptor with the UI elements for the currently active model.

Returns:
the UIDescriptor with the UI elements for the currently active model; or null if there is no model in the workspace

setActiveModel

void setActiveModel(java.lang.String name)
Sets the active model to the DESModel with the given name. If the workspace does not contain a model with the given name, the method does nothing. If the name is null, no model becomes active.

Parameters:
name - the name of the model to become active; or null if no model should become active

setActivePresentation

void setActivePresentation(java.lang.String name)
Makes the specified presentation active in the user interface. If there is no presentation with the given name, does nothing.

Parameters:
name - the name of the presentation to be made active

getModels

java.util.Iterator<DESModel> getModels()
Returns an iterator of all DESModels in this workspace.

Returns:
an iterator of all DESModels in this workspace

isDirty

boolean isDirty()
Returns if the workspace is dirty (it has been changed since the last save).

Returns:
the dirty flag of the workspace

setDirty

void setDirty(boolean state)
Sets the dirty flag of the workspace (i.e., whether it has been changed since the last save).

Parameters:
state - the new dirty flag of the workspace

getName

java.lang.String getName()
Returns the name of the workspace.

Returns:
the name of the workspace

isEmpty

boolean isEmpty()
Check if there are models open in the workspace.

Returns:
true if there is at least one model in the workspace; false otherwise

size

int size()
Get the number of models in the workspace

Returns:
number of models in the workspace

getModelsOfType

<T> java.util.Collection<T> getModelsOfType(java.lang.Class<T> type)
Returns all models of the given type opened in the workspace.

Type Parameters:
T - the type of model
Parameters:
type - the class type of model
Returns:
all models of the given type opened in the workspace

getPresentations

java.util.Collection<Presentation> getPresentations()
Returns the set of presentations used as the UI for the currently active model.

Returns:
the set of presentations used as the UI for the currently active model

getPresentationsOfType

<T> java.util.Collection<T> getPresentationsOfType(java.lang.Class<T> type)
Selects the presentation of the given type from the set of all presentations used as the UI for the currently active model.

Type Parameters:
T - the type of presentation to be selected
Parameters:
type - the class type of presentation to be selected
Returns:
the subset of presentations of the given type, from all presentations used as the UI for the currently active model

addSubscriber

void addSubscriber(WorkspaceSubscriber subscriber)
Attaches the given subscriber to this publisher. The given subscriber will receive notifications of changes from this publisher.

Parameters:
subscriber - subscriber to be attached

removeSubscriber

void removeSubscriber(WorkspaceSubscriber subscriber)
Removes the given subscriber to this publisher. The given subscriber will no longer receive notifications of changes from this publisher.

Parameters:
subscriber - subscriber to be removed

fireRepaintRequired

void fireRepaintRequired()
Sends a notification to subscribers that a repaint is required due to changes to the display options such as Zoom, or toggling show grid, LaTeX rendering, UniformNode size etc.


fireAboutToRearrangeWorkspace

void fireAboutToRearrangeWorkspace()
Sends notification to subscribers that the the layout of the workspace is about to change (e.g., a new model is about to become the active model).