Download Implementierung eines Statechart-Editors mit layoutbasierten
Transcript
140
130
120
110
100
clear () ;
180
170
160
150
/**
* Update Undo / Redo Button State and slider dependent on the undo and 190
redo
* stack .
*/
private void u p d a t e H i s t o r y B u t t o n s A n d S l i d e r () {
EditorActions . get ( Act ionEd itUn do . class ) . setEnabled (
! u n d o a b l e E d i t H a p p e n e d C l u s t e r s . isEmpty () ) ;
EditorActions . get ( Act ionEd itRe do . class ) . setEnabled (
! r e d o a b l e E d i t H a p p e n e d C l u s t e r s . isEmpty () ) ;
/**
*
* @return the content of the redo EditStep stack
*/
public EditStep [] g e t A l l R e d o a b l e E d i t S t e p s A s c e n d i n g () {
return ( EditStep []) r e d o a b l e E d i t H a p p e n e d C l u s t e r s . toArray (
new EditStep [0]) ;
}
/**
*
* @return the content of the undo EditStep stack
*/
public EditStep [] g e t A l l U n d o a b l e E d i t S t e p s A s c e n d i n g () {
return ( EditStep []) u n d o a b l e E d i t H a p p e n e d C l u s t e r s . toArray (
new EditStep [0]) ;
}
/**
* @see # slider
* @return .
*/
JSlider getSlider () {
return slider ;
}
/**
* The slider displaying the current relation between undo and redo
steps .
*/
private final JSlider slider = Utils . createJSlider () ;
/**
*
* @return the UndoManager responsible for GraphModel change steps
*/
UndoManager g etUnd oMan ager () {
return undoManager ;
}
}
/**
* Process the whole undo stack .
*
}
}
};
undoManager . setLimit ( Integer . MAX_VALUE ) ;
u p d a t e H i s t o r y B u t t o n s A n d S l i d e r () ;
super . u n d o a b l e E d i t H a p p e n e d ( e ) ;
u p d a t e H i s t o r y B u t t o n s A n d S l i d e r () ; // Update Toolbar
u n d o a b l e E d i t H a p p e n e d C o u n t ++;
public void u n d o a b l e E d i t H a p p e n e d ( final U ndo ab leE di tE v e n t e ) {
if ( i s U n d o M a n a g e r I n P r o g r e s s () ) {
return ;
}
/**
* clears the whole GraphModel undo history by destroying the old
* Gr aphUndoManager . With this also the EditStep undo and redo stacks
have
* to be cleared .
*
*/
void clear () {
r e d o a b l e E d i t H a p p e n e d C l u s t e r s . clear () ;
u n d o a b l e E d i t H a p p e n e d C l u s t e r s . clear () ;
u n d o a b l e E d i t H a p p e n e d C o u n t = 0;
undoManager = new GraphUndoM anager () {
/**
* the undo EditStep stack .
*/
private final Stack u n d o a b l e E d i t H a p p e n e d C l u s t e r s = new Stack () ;
/**
* the count of GraphModel change steps of the current EditStep .
*/
private int u n d o a b l e E d i t H a p p e n e d C o u n t ;
}
if ( listener != null ) {
listener . stackChanged (
u n d o a b l e E d i t H a p p e n e d C l u s t e r s . size () ,
r e d o a b l e E d i t H a p p e n e d C l u s t e r s . size () ) ;
}
updateSlider = false ;
getSlider () . setMinimum (0) ;
getSlider () . setMaximum ( u n d o a b l e E d i t H a p p e n e d C l u s t e r s . size ()
+ r e d o a b l e E d i t H a p p e n e d C l u s t e r s . size () ) ;
getSlider () . setValue ( u n d o a b l e E d i t H a p p e n e d C l u s t e r s . size () ) ;
updateSlider = true ;
A.4. Der Quelltext
195