/*	Author:		Magdin Stoica
	Supervisor: Dr. Ryan Leduc
	
	Project created in conformity with the requirements for the Degree of Master of Engineering in Software Engineering, 
	Computing and Software Department, 
	McMaster University
	2003 - 2007
*/

#pragma once

#include "ui_FlatProjectEditor.h"
#include "ui_HierProjectEditor.h"

#include "BddHiscMain.h"

#include "DesProject.h"
#include <list>


namespace DESpot
{
	//class CtrlStdAlgo;
	class MultiCtrlAlgo;
	class MultiNonBlockingAlgo;
	class ProjIntegrityAlgo;
	class LdInterfaceCheckAlgo;
	class IConsistAlgo;
	class LwNonBlockingAlgo;
	class LwCtrlAlgo;
	class DesHierProject;
	class IConsistAnsAcceptAlgo;
	class LowSubsysIConsistAlgo;
	class HighSubsysNonBlockAlgo;
	class LowSubsysNonBlockAlgo;
	class HighSubsysCtrlAlgo;
	class LowSubsysCtrlAlgo;
	class FlatProjectPropCheck;
	class HierProjectPropCheck;

	class OutputUiPart : QObject
	{
		Q_OBJECT

		public:
			enum LastOutputOption
			{
				eSetLastOutput = 1,
				eAppendLastOutput = 2
			};

			enum OutputSource
			{
				eProjectIntegrityCheck,
				eNonBlockingCheck,
				eControllabilityCheck,
				eInterfConsistCheck,
				eLwNonblockingCheck,
				eLwCtrlCheck,
				eSubsysInterfConsistCheck,
				eLdInterfCheck,
				eSubsysNonblockingCheck,
				eSubsysCtrlCheck,
				eProjectPropCheck
			};


	public:
		typedef std::list<std::wstring> ErrorList;
	    typedef ErrorList::iterator ErrorListIt;

		public:
			OutputUiPart(Ui::FlatProjectEditorUI* pUiContainer, DesProject* pProject);
			OutputUiPart(Ui::HierProjectEditorUI* pUiContainer, DesProject* pProject);
			virtual ~OutputUiPart(void);
			
			void setOwnerTabWidget(QTabWidget* tabWidget);

		public:
			void show(ProjIntegrityAlgo& integAlgo, bool showMsgBox);
			void show(ProjIntegrityAlgo& integAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);

			void show(MultiNonBlockingAlgo& nonBlockAlgo, bool showMsgBox);
			void show(MultiNonBlockingAlgo& nonBlockAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			//void show(CtrlStdAlgo& ctrlAlgo, bool showMsgBox);
			//void show(CtrlStdAlgo& ctrlAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);

			void show(MultiCtrlAlgo& ctrlAlgo, bool showMsgBox);
			void show(MultiCtrlAlgo& ctrlAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			void showMeasurements(const Des* flatSystem);

			void show(LdInterfaceCheckAlgo& ldInterfCheckAlgo, bool showMsgBox);
			void show(LdInterfaceCheckAlgo& ldInterfCheckAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);

			void show(IConsistAnsAcceptAlgo& ansAcceptAlgo, bool showMsgBox);
			void show(IConsistAnsAcceptAlgo& ansAcceptAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			void show(LowSubsysIConsistAlgo& lowSubsysIConsAlgo, bool showMsgBox);
			void show(LowSubsysIConsistAlgo& lowSubsysIConsAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
							 
			void show(IConsistAlgo& iConsAlgo, bool showMsgBox);
			void show(IConsistAlgo& iConsAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			void show(LwNonBlockingAlgo& lwNonBlockAlgo, bool showMsgBox);
			void show(LwNonBlockingAlgo& lwNonBlockAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			void show(LwCtrlAlgo& lwCtrlAlgo, bool showMsgBox);
			void show(LwCtrlAlgo& lwCtrlAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);

			void show(HighSubsysNonBlockAlgo& hSubsysNonBlockAlgo, bool showMsgBox);
			void show(HighSubsysNonBlockAlgo& hSubsysNonBlockAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			void show(LowSubsysNonBlockAlgo& lowSubsysNonBlockAlgo, bool showMsgBox);
			void show(LowSubsysNonBlockAlgo& lowSubsysNonBlockAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			void show(HighSubsysCtrlAlgo& hSubsysCtrlAlgo, bool showMsgBox);
			void show(HighSubsysCtrlAlgo& hSubsysCtrlAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			
			void show(LowSubsysCtrlAlgo& lowSubsysCtrlAlgo, bool showMsgBox);
			void show(LowSubsysCtrlAlgo& lowSubsysCtrlAlgo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);

			void show(FlatProjectPropCheck& projCheckAlgo);
			void show(HierProjectPropCheck& projCheckAlgo);

			void show(OutputSource source, std::wstring heading, std::wstring error, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);

#ifdef __ENABLE_BDD__
			void show(BDDHISC::Hisc_LWNBChkInfo& checkInfo, bool showMsgBox);
			void show(BDDHISC::Hisc_LWNBChkInfo& checkInfo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			void show(BDDHISC::Hisc_SubLWNBChkInfo& checkInfo, bool showMsgBox);
			void show(BDDHISC::Hisc_SubLWNBChkInfo& checkInfo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			void show(BDDHISC::Hisc_LWContChkInfo& checkInfo, bool showMsgBox);
			void show(BDDHISC::Hisc_LWContChkInfo& checkInfo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			void show(BDDHISC::Hisc_SubLWContChkInfo& checkInfo, bool showMsgBox);
			void show(BDDHISC::Hisc_SubLWContChkInfo& checkInfo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			void show(BDDHISC::Hisc_IConsisChkInfo& checkInfo, bool showMsgBox);
			void show(BDDHISC::Hisc_IConsisChkInfo& checkInfo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			void show(BDDHISC::Hisc_SubIConsisChkInfo& checkInfo, bool showMsgBox);
			void show(BDDHISC::Hisc_SubIConsisChkInfo& checkInfo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
			void show(BDDHISC::Hisc_LDIntfChkInfo& checkInfo, bool showMsgBox);
			void show(BDDHISC::Hisc_LDIntfChkInfo& checkInfo, LastOutputOption copyToLastOutput = eSetLastOutput, bool showMsgBox = true);
#endif

			void clearLastOutput();

		protected slots:
			void onShowOutputFor(int sourceIndex);
			void onToggleWrap();

		protected:
			//Initializes the widgets from either the flat project editor or the hierhical project editor
			//Called from the two constructors
			template<class T> 
			void initWidgets(T* pUiContainer);
			void initOutputSelectionWidget();
			void setupConnections();
			void saveOutput();
			void saveLastOutput(LastOutputOption copyToLastOutput);
			DesHierProject* hierProject();
			int getOutputIndexForSource(OutputSource source);
			void showErrors(const DesAlgo::ErrorList& errList);

		protected:
			QComboBox* m_showOutputForWidg;
			
			QToolButton* m_copyBtn;
			QToolButton* m_clearBtn;
			QToolButton* m_wrapBtn;

			OutputWidget* m_outputWidget;

			QTabWidget* m_tabWidget;
			DesProject* m_project;

		protected:
			static const QString cProjIntegOutputTitle;
			static const QString cNonBlockOutputTitle;
			static const QString cCtrlOutputTitle;
			static const QString cMeasureOutputTitle;
			
			static const QString cInterfConsistOutputTitle;
			static const QString cLwNonBlockOutputTitle;
			static const QString cLwCtrlOutputTitle;
			static const QString cSubsysInterfConsistOutputTitle; 
			static const QString cLdInterfCheckTitle;
			static const QString cSubsysNonBlockingOutputTitle; 
			static const QString cSubsysCtrlOutputTitle;

			static const QString cLastOutputTitle;
	};
}
