package edit; import caldb.*; import options.UserOptions; /**** * Class Edit is derived from 2.9 of the requirements, which in turn derives * from the commands on the 'Edit' menu. In this abstract model, most of the * generic editing functionality is modeled as operations. * * As with the file methods described in file.File.java, the edit methods take * user workspace inputs and return a workspace if the method changes any * workspace values. */ abstract class Edit { /** * Undo the most recent scheduling operation. Only one level of undo/redo * is specified here. Successive invocations of undo toggle between the * current and previous states of the calendar. Note that the calendar * editing operations support undo by saving a snapshot of the input * calendar in the previous_state component of the workspace.
      pre:
        //
        // The previous saved calendar state is not null.
        //
        (uws.previous_state != null);

      post:
        //
        // The state of the current calendar is the previous state, and vice
        // versa.
        //
        (return.previous_state = uws.calendars[1].items) &&
        (uws.calendars[1].items = uws.previous_state);
     */
    abstract UserWorkSpace undo(UserWorkSpace uws);

    /**
     * Move the currently selected text segment into the clipboard and remove
     * the segment from its context.  Set the workspace selection to empty.
									   
      pre:
        //
        // The selection is not empty.
        //
        uws.selection != null;

      post:
        //
        // The clipboard of the output workspace equals the selection.  The
        // selection context of the output workspace has the selection removed.
        // The selection of the output workspace is null.
        //
        (return.clipboard = uws.context.substring(
            uws.selection.startPosition, uws.selection.endPosition)

             &&

        (return.context.equals(
                uws.context.substring(1,uws.selection.start_position-1) +
                        uws.context.substring(uws.selection.startPosition+1,
                                    uws.context.size())))

             &&

        (return.selection == null);
      */
    abstract UserWorkSpace cut(UserWorkSpace uws);

  
    /**
     * Copy the currently selected text segment into the clipboard.
									   
      pre: 
        //
        // The selection is not empty.
        //
        uws.selection != null;

      post:
        //
        // The clipboard of the output workspace equals the selection.  The
        // context and selection of the output workspace are unchanged.
        //
        (return.context.equals(
                uws.context.substring(1,uws.selection.start_position-1) +
                        uws.context.substring(uws.selection.startPosition+1,
                                    uws.context.size())))

             &&

        (return.context.equals(uws.context))

             &&

        (return.selection.equals(uws.selection));
      */       
    abstract UserWorkSpace copy(UserWorkSpace uws);

    /**
     * Paste the contents of the clipboard into the currently selected start
     * position, replacing any selected text from start to end position.
									   
      pre:
        //
        // The clipboard is not empty.
        //
        uws.clipboard != null;

      post:
        //
        // The context in the output workspace is the string consiting of
        // everything up to the selection, followed by the clipboard, followed
        // by everything after the selection.  The selection of the output
        // workspace is null and the clipboard is unchanged.
        //
        (return.context.equals(
	        uws.context.substring(1,uws.selection.start_position-1) +
                        uws.clipboard +
                        uws.context.substring(uws.selection.start_position+1,
                                    uws.context.size)))

             &&

        (return.selection == null)

             &&

        (return.clipboard.equals(uws.clipboard));
      */
    abstract UserWorkSpace paste(UserWorkSpace uws);

    /**
     * Remove the currently selected text from the context.  Set the workspace
     * selection to empty.
									   
      pre: 
        //
        // The selection is not empty.
        //
        uws.selection != null;

    postcondition:
        //
        // The selection context of the output workspace has the selection
        // removed.  The selection of the output workspace is null.
        //
        (return.context.equals(
	        uws.context.substring(1,uws.selection.start_position-1) +
                        uws.context.substring(uws.selection.start_position+1,
                                    (uws.context.size()))))

             &&

        (return.selection == null);
      */
    abstract UserWorkSpace delete(UserWorkSpace uws);

    UserOptions preferences;
}