|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkaapo.Observable
kaapo.projectmanager.ProjectManager
public class ProjectManager
Class that holds reference to the open project. This class is designed to hide the implementation of project and diagrams from GUI and to support undo history. GUI should never directly edit the project, but use appropriate edits and give them to ProjectManager to execute.
All the diagram-editing and state changing goes through ProjectManager. The (G)UI using this class communicates the edits on the project and its diagrams are handled by an UndoableEdit/Edit interface. For every action on the diagram panel either an UndoableEdit or an Edit object is created. This object is then given to executeEdit() for execution and depending on the edit's type also saving for undoing and redoing.
ProjectManager class implements the Observable interface, so that GUI can observe it's state. Currently the selection changes and visible diagram changes launch observers update method.
Observable
,
Observer
Nested Class Summary | |
---|---|
static class |
ProjectManager.ObservableMessage
|
Constructor Summary | |
---|---|
ProjectManager(Project project)
Constructs a new ProjectManager associated with given project. |
Method Summary | |
---|---|
boolean |
canRedo()
Checks if it is possible to redo the latest undo. |
boolean |
canUndo()
Checks if it is possible to undo the latest edit. |
void |
endCompound()
Closes the compound and adds it as a single undoable object to the undomanager |
void |
executeCompoundEdit(AbstractUndoableEdit edit)
Executes the latest UndoableEdit and adds it to compound for the mass-undo or -redo possibly to be done later |
void |
executeEdit(AbstractUndoableEdit edit)
Executes the latest UndoableEdit and saves it for possible undo/redo-action. |
void |
executeEdit(Edit edit)
Executes the latest Edit. |
Project |
getProject()
Returns the associated project |
Selection |
getSelection()
Returns the current selection |
DiagramWrapper |
getVisibleDiagram()
Returns the visible diagram. |
boolean |
isProjectModified()
Returns the true if the project has been modified since last reset. |
void |
notifyObservers()
Notifies observers. |
void |
redo()
Redos the last undone edit. |
void |
resetProjectModified()
Resets the project modified status. |
void |
setSelection(Selection selection)
Updates the selection to the given one. |
void |
setVisibleDiagram(DiagramWrapper diagram)
Sets a new visible diagram. |
void |
undo()
Undos the latest edit. |
Methods inherited from class kaapo.Observable |
---|
addObserver, notifyObservers, removeAllObservers, removeObserver, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProjectManager(Project project)
project
- the project this ProjectManager is associated withMethod Detail |
---|
public void undo() throws CannotRedoException
CannotUndoException
- if cannot undo
CannotRedoException
public void redo() throws CannotRedoException
CannotRedoException
- if cannot redopublic boolean canUndo()
public boolean canRedo()
public void executeEdit(AbstractUndoableEdit edit) throws EditFailedException
edit
- the edit to execute
EditFailedException
- if editing fails for some reasonpublic void executeCompoundEdit(AbstractUndoableEdit edit) throws EditFailedException
edit
- the edit to execute
EditFailedException
- if editing fails for some reasonpublic void executeEdit(Edit edit) throws EditFailedException
edit
- the edit to execute
EditFailedException
- if editing fails for some reasonpublic DiagramWrapper getVisibleDiagram()
public void setVisibleDiagram(DiagramWrapper diagram)
diagram
- the new visible diagrampublic Project getProject()
public Selection getSelection()
public void setSelection(Selection selection)
selection
- the latest selectionpublic boolean isProjectModified()
public void resetProjectModified()
public void notifyObservers()
notifyObservers
in class Observable
Observable.notifyObservers()
public void endCompound()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |