(****
 *
 * Module Edit defines the objects and operations related to Edit Processing
 * in the Schedule system.
 *
 *)

module Edit;

from ScheduleDB import ScheduleDB;

  object ToolWorkspace = data:ToolData and undo_data:ToolData and redo_data:ToolData and cut_data:ToolData
    description: (*
              This is a simplified data model for a tool workspace that contains
              the main data on which the tool operates, a copy of the data for undoing.
              and a opy for redoing.  This model supports one-level undo/redo.  For
              multi-level undo, a list of undo data can be used
            *);
  end;
  object ToolData = string
    description: (*
            This object contains the data that is to be copied to keep for later use
            or in the case that it might be moved to another location.  The data is 
            stored as a string so it will not maintain any formatting that was attached
            to the data.
     *);
  end;

  operation EditUndo
    inputs: tw:ToolWorkspace;
    outputs: tw':ToolWorkspace;
    precondition: ;
    postcondition: if tw.undo_data = nil
                   then (tw'.data = tw.data) and (tw'.undo_data = nil) and
                        (tw'.redo_data = nil)
                   else (tw'.data = tw.undo_data) and (tw'.undo_data = nil) and
	                     (tw'.redo_data = tw.data);
    description: (*
         If some tool operation has been performed that sets undo data in the workspace,
         then the effect of undo is to set workspace data to that undo data,
         otherwise undo has no effect.  In either case, the undo data of
         the output workspace is nul, thereby allowing only one level of undo/redo
         If undo data are used, then redo data are set to the original data in the input
         workspace, thereby enabling the redo operation.
    *);
  end EditUndo;

  operation EditRedo
    inputs: tw:ToolWorkspace;
    outputs: tw':ToolWorkspace;
    precondition: ;
    postcondition: if tw.redo_data = nil
                   then (tw'.data = tw.data) and (tw'.redo_data = nil) and
                        (tw'.undo_data = nil)
                   else (tw'.data = tw.redo_data) and (tw'.redo_data = nil) and
	                     (tw'.undo_data = tw.data);
    description: (*
			If this tool operation is preformed then it sets the data to the redo data
         If there was nothing in the redo_data then the operation has no effect on the 
         workspace.
    *);
  end EditRedo;

  operation EditCut
    inputs: tw:ToolWorkspace;
    outputs: tw':ToolWorkspace;
    precondition: ;
    postcondition: (tw'.cut_data = tw.data) and tw'.data = nil;
    description: (*
	               If this tool operation is performed then it sets the cut_data to the data.  It then
						gets ride of the text from the schedule.
    *);
  end EditCut;

  operation EditCopy
    inputs: tw:ToolWorkspace;
    outputs: tw':ToolWorkspace;
    precondition: ;
    postcondition: tw'.cut_data = tw.data and tw'.data = nil;
    description: (*
						If this tool operation is performed then it sets the cut_data to the data.
    *);
  end EditCopy;

  operation EditPaste
    inputs: tw:ToolWorkspace;
    outputs: tw':ToolWorkspace;
    precondition: ;
    postcondition: if (tw.cut_data = nil)
                   then (tw'.data = tw.data)
                   else (tw'.data = tw.cut_data);
    description: (*
						If this tool operation is performed then it sets the data to the cut_data.  If the cut_data was nil
						then the operation will not past anything.
    *);
  end EditPaste;

  operation EditFind
    inputs: ;
    outputs: ;
    precondition: ;
    postcondition: ;
    description: (*
						This operation would find a user, course, or room in the databases.
						********NOT COMPLETED YET
    *);
  end EditFind;

  operation EditSettings
    inputs: ;
    outputs: ;
    precondition: ;
    postcondition: ;
    description: (*
						This would launch the window that allows the user to change the type of user and instructor is.
						********NOT COMPLETED YET
    *);
  end EditSettings;

end Edit;