indexing
	cluster: "demangler"
	namespace: "candidate"
	description: "Edits a `SYNC_REPORT' objects."
	original_author: "Justin Finnerty"
	original_date: "July 2005"
	current_date: "$Date: 2005/10/31 07:19:34 $"
	current_author: "$Author: finnerty $"
	revision: "$Revision: 2.4 $"	
	-- $Log: report_view.e,v $
	-- Revision 2.4  2005/10/31 07:19:34  finnerty
	-- Added ability to create symlinks between directories as an alternative to merging. The major changes are in DIRDUP_REPORT with others adding/changing features as required.
	--
	-- Revision 2.3  2005/10/30 03:41:51  finnerty
	-- Split REPORT_VIEW into REPORT_CONTROL and REPORT_VIEW. Made changes to other classes as necessary
	--
	-- Revision 2.2  2005/10/28 04:18:47  finnerty
	-- Made `do_report' into an event loop which calls various deferred methods.
	--
	-- Revision 2.1  2005/09/27 06:14:47  finnerty
	-- Updated to use GOBO and work with SE and VE
	--
	-- Revision 2.0  2005/08/26 23:31:39  finnerty
	-- == alpha version ==
	--
	-- Revision 1.2  2005/08/24 12:34:24  finnerty
	-- Inserted feature to allow report objects to display warnings.
	--
	-- Revision 1.1  2005/08/21 11:55:50  finnerty
	-- Alpha 1 version
	--
	--

			-- Notes: [? ?] <=> [user_wants_action user_is_done]
			-- letters (A), (B) etc indicate choices for user. Choices 
			-- with * indicate "automatic" choices.
deferred class REPORT_VIEW
	-- Edits a `SYNC_REPORT' object.
	
feature {ANY}
	-- Event constants for reports
	Action, Done, Edit, Generate, Reset, Undo: INTEGER is unique
	
feature {ANY}
	-- Queries on object
	current_report: SYNC_REPORT
			-- What we are viewing

	has_report: BOOLEAN is
			-- Are we looking at a report?
		do
			Result := current_report /= Void
		end

	unset_report is
			-- Have finished with report
		require
			has_report
		do
			current_report := Void
		ensure
			not has_report
		end

	set_report (a_sync_report: SYNC_REPORT) is
			-- Set new report
		require
			not has_report
		do
			current_report := a_sync_report
		ensure
			current_report = a_sync_report
			has_report
		end
		
feature {ANY}
	-- Procedure on object
	do_report is
			-- Display and perform all actions for this report
		require
			has_report
		do
			view_state := Generate
			from
			until
				view_state = Done
			loop
				inspect
					view_state
				when Action then
					-- Perform the actions of a report
					if 					
						current_report.has_result and then
						current_report.is_actionable
					 then
						current_report.action
						report_action
						-- After doing the `current_report's actions we can:
						-- Undo the actions `Undo';
						-- Regenerate the report `Generate' (for repeating SYNC_REPORT types);
						-- Finish `Done'
					else
						-- Error, can't action an empty report action list so display error message 
						report_invalid_action
						-- From here we can finish `Done' or
						-- we can regenerate the report `Generate'.
					end
					
				when Edit then
					-- Edit the set of actions
					check
						current_report.has_result and then
						current_report.is_actionable
					end
						report_edit
						-- This will lead to: 
						-- Performing the actions `Action';
						-- Redoing the report `Generate';
						-- or ignoring the current actions and ending `Reset';
					
				when Generate then
					-- Generate the report					
					if
						current_report.has_result and then
						current_report.is_actionable
					 then
						current_report.reset
					end
					 -- What if has_result but is_undoable???
					current_report.generate
					if not current_report.has_result then
						report_empty
						-- This will lead to `view_state' = `Done'. We don't
						-- need to go through `Reset' as the
						-- `current_report' is empty. We also can't got to
						-- `Generate' for repeating reports as an repeating
						-- report with no result indicates that report can
						-- do no more.
					else
						report_show
						-- This will lead to: 
						-- Performing the actions `Action'; 
						-- Editing the action list `Edit' (when allowable);
						-- Ignoring the current actions and redoing the report `Generate' (repeating types);
						-- or ignoring the current actions and ending `Reset';
					end					

				when Reset then
					current_report.reset
					view_state := Done

				when Undo then
					if current_report.is_undoable then
						current_report.undo
						current_report.reset
						report_undo
						-- We can:
						-- repeat the report `Generate' or
						-- finish `Done'.
					else
						-- Error, can't undo report
						report_invalid_undo
						-- Couldn't undo the report:
						-- We can only go on `Done'
					end
				else
					-- Why are we here?
				end
			end
		end
		
	report_warning (a_error: STRING) is
			-- Allow `current_report' to display an error message
		deferred
		end
	
feature {REPORT_VIEW}
	-- Implementation features
	view_state: INTEGER
			-- Current state of the event loop in `do_report'
	
	report_action is
			-- Display the results of performing a SYNC_REPORT object's actions. 
			-- The feature must set `view_state` to:
		
			-- `Generate' -> user happy with current report and wants
			-- repeat [Repeating SYNC_REPORT types only]

			-- `Undo' -> user wants undo or undo and regenerate

			-- `Done' -> user happy
		deferred 
		ensure 
			view_state = Done or view_state = Undo or view_state = Generate
		end
	
	report_edit is
			-- Edit the list of actions of a SYNC_REPORT object. 

			-- The feature must set `view_state` to: 

			-- `Action' -> user wants action

			-- `Reset' -> user does not want action

			-- `Generate' -> user wants report regen
		deferred 
		ensure 
			view_state = Action or view_state = Generate or view_state = Reset
		end

	report_empty is
			-- This reports that the `current_report` contained no
			-- results after being generated.

			-- The feature will set the `view_state` to:

			-- `Done' -> Nothing more to do
		deferred 
		ensure 
			view_state = Done
		end
		
	report_invalid_action is
			-- Report that the attempt to perform a report failed. 

			-- The feature must set `view_state' to:

			-- `Generate' -> Regenerate report

			-- `Done' -> Ignore error and quit?
		deferred 
		ensure 
			view_state = Done or view_state = Generate
		end
		
	report_invalid_undo is
			-- Attempt to undo a report failed. 

			-- The feature must set `view_state' to:

			-- `Done' -> Ignore error and quit?
		deferred 
		ensure 
			view_state = Done
		end
		
	report_show is
			-- Display the generated actions of a SYNC_REPORT object. 

			-- The feature must set `view_state` to: 

			-- `Action' -> user wants action

			-- `Reset' -> user does not want action

			-- `Generate' -> user wants report regen
		deferred 
		ensure 
			view_state = Action or view_state = Generate or view_state = Reset
		end

	report_undo is
			-- Have undone a repeating SYNC_REPORT object's actions. 

			-- The feature must set `view_state' to: 

			-- `Generate' -> user wants repeat [Repeating SYNC_REPORT types only]

			-- `Done' -> user happy
		deferred 
		ensure 
			view_state = Done or view_state = Generate
		end
	
end -- class REPORT_VIEW
