//####COPYRIGHTBEGIN####
|
//####COPYRIGHTBEGIN####
|
//
|
//
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
|
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
|
//
|
//
|
// This program is part of the eCos host tools.
|
// This program is part of the eCos host tools.
|
//
|
//
|
// This program is free software; you can redistribute it and/or modify it
|
// This program is free software; you can redistribute it and/or modify it
|
// under the terms of the GNU General Public License as published by the Free
|
// under the terms of the GNU General Public License as published by the Free
|
// Software Foundation; either version 2 of the License, or (at your option)
|
// Software Foundation; either version 2 of the License, or (at your option)
|
// any later version.
|
// any later version.
|
//
|
//
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
// more details.
|
// more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along with
|
// You should have received a copy of the GNU General Public License along with
|
// this program; if not, write to the Free Software Foundation, Inc.,
|
// this program; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
//
|
//
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
//
|
//
|
//####COPYRIGHTEND####
|
//####COPYRIGHTEND####
|
// FailingRulesDialog.cpp : implementation file
|
// FailingRulesDialog.cpp : implementation file
|
//
|
//
|
|
|
#include "stdafx.h"
|
#include "stdafx.h"
|
#ifndef PLUGIN
|
#ifndef PLUGIN
|
#include "BCMenu.h"
|
#include "BCMenu.h"
|
#endif
|
#endif
|
#include "FailingRulesDialog.h"
|
#include "FailingRulesDialog.h"
|
#include "ConfigItem.h"
|
#include "ConfigItem.h"
|
#include "ConfigTool.h"
|
#include "ConfigTool.h"
|
#include "ConfigToolDoc.h"
|
#include "ConfigToolDoc.h"
|
#include "ControlView.h"
|
#include "ControlView.h"
|
#include "CTUtils.h"
|
#include "CTUtils.h"
|
|
|
#ifdef _DEBUG
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
#undef THIS_FILE
|
#undef THIS_FILE
|
static char THIS_FILE[] = __FILE__;
|
static char THIS_FILE[] = __FILE__;
|
#endif
|
#endif
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
// CFailingRulesDialog dialog
|
// CFailingRulesDialog dialog
|
|
|
|
|
CFailingRulesDialog::CFailingRulesDialog(std::list<CdlConflict> conflicts,CdlTransaction transaction/*=NULL*/,CPtrArray *parConflictsOfInterest/*=NULL*/)
|
CFailingRulesDialog::CFailingRulesDialog(std::list<CdlConflict> conflicts,CdlTransaction transaction/*=NULL*/,CPtrArray *parConflictsOfInterest/*=NULL*/)
|
: CeCosDialog(CFailingRulesDialog::IDD, NULL),
|
: CeCosDialog(CFailingRulesDialog::IDD, NULL),
|
m_conflicts(conflicts),
|
m_conflicts(conflicts),
|
m_Transaction(transaction),
|
m_Transaction(transaction),
|
m_parConflictsOfInterest(parConflictsOfInterest)
|
m_parConflictsOfInterest(parConflictsOfInterest)
|
{
|
{
|
for (std::list<CdlConflict>::const_iterator conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) { // for each conflict
|
for (std::list<CdlConflict>::const_iterator conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) { // for each conflict
|
int nSolutions=(*conf_i)->get_solution().size();
|
int nSolutions=(*conf_i)->get_solution().size();
|
SolutionInfo *pInfo=(SolutionInfo *)malloc(sizeof(SolutionInfo)+(nSolutions-1)*sizeof(int));
|
SolutionInfo *pInfo=(SolutionInfo *)malloc(sizeof(SolutionInfo)+(nSolutions-1)*sizeof(int));
|
pInfo->nCount=nSolutions;
|
pInfo->nCount=nSolutions;
|
for(int i=0;i<nSolutions;i++){
|
for(int i=0;i<nSolutions;i++){
|
pInfo->arItem[i]=SolutionInfo::CHECKED;
|
pInfo->arItem[i]=SolutionInfo::CHECKED;
|
}
|
}
|
m_Map.SetAt(*conf_i,pInfo);
|
m_Map.SetAt(*conf_i,pInfo);
|
}
|
}
|
|
|
//{{AFX_DATA_INIT(CFailingRulesDialog)
|
//{{AFX_DATA_INIT(CFailingRulesDialog)
|
// NOTE: the ClassWizard will add member initialization here
|
// NOTE: the ClassWizard will add member initialization here
|
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
}
|
}
|
|
|
CFailingRulesDialog::~CFailingRulesDialog()
|
CFailingRulesDialog::~CFailingRulesDialog()
|
{
|
{
|
for(POSITION pos = m_Map.GetStartPosition(); pos != NULL; ){
|
for(POSITION pos = m_Map.GetStartPosition(); pos != NULL; ){
|
CdlConflict conflict;
|
CdlConflict conflict;
|
SolutionInfo *pInfo=NULL;
|
SolutionInfo *pInfo=NULL;
|
m_Map.GetNextAssoc(pos, (void *&)conflict, (void *&)pInfo);
|
m_Map.GetNextAssoc(pos, (void *&)conflict, (void *&)pInfo);
|
free(pInfo);
|
free(pInfo);
|
}
|
}
|
}
|
}
|
|
|
void CFailingRulesDialog::DoDataExchange(CDataExchange* pDX)
|
void CFailingRulesDialog::DoDataExchange(CDataExchange* pDX)
|
{
|
{
|
CeCosDialog::DoDataExchange(pDX);
|
CeCosDialog::DoDataExchange(pDX);
|
//{{AFX_DATA_MAP(CFailingRulesDialog)
|
//{{AFX_DATA_MAP(CFailingRulesDialog)
|
DDX_Control(pDX, IDC_LIST2, m_List);
|
DDX_Control(pDX, IDC_LIST2, m_List);
|
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
}
|
}
|
|
|
|
|
BEGIN_MESSAGE_MAP(CFailingRulesDialog, CeCosDialog)
|
BEGIN_MESSAGE_MAP(CFailingRulesDialog, CeCosDialog)
|
//{{AFX_MSG_MAP(CFailingRulesDialog)
|
//{{AFX_MSG_MAP(CFailingRulesDialog)
|
ON_BN_CLICKED(IDC_RESET, OnReset)
|
ON_BN_CLICKED(IDC_RESET, OnReset)
|
ON_BN_CLICKED(IDC_CONFLICTS_NONE, OnConflictsNone)
|
ON_BN_CLICKED(IDC_CONFLICTS_NONE, OnConflictsNone)
|
ON_BN_CLICKED(ID_RESOLVE_CONFLICTS_CONTINUE, OnOK)
|
ON_BN_CLICKED(ID_RESOLVE_CONFLICTS_CONTINUE, OnOK)
|
ON_BN_CLICKED(ID_RESOLVE_CONFLICTS_CANCEL,OnCancel)
|
ON_BN_CLICKED(ID_RESOLVE_CONFLICTS_CANCEL,OnCancel)
|
ON_COMMAND(ID_LOCATE,OnLocate)
|
ON_COMMAND(ID_LOCATE,OnLocate)
|
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
// CFailingRulesDialog message handlers
|
// CFailingRulesDialog message handlers
|
|
|
BOOL CFailingRulesDialog::OnInitDialog()
|
BOOL CFailingRulesDialog::OnInitDialog()
|
{
|
{
|
CeCosDialog::OnInitDialog();
|
CeCosDialog::OnInitDialog();
|
m_List.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
m_List.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
m_List.InsertColumn(0,_T("Item"));
|
m_List.InsertColumn(0,_T("Item"));
|
m_List.InsertColumn(1,_T("Value"));
|
m_List.InsertColumn(1,_T("Value"));
|
|
|
CRect rect;
|
CRect rect;
|
GetDlgItem(IDC_LIST1)->GetWindowRect(rect);
|
GetDlgItem(IDC_LIST1)->GetWindowRect(rect);
|
ScreenToClient(rect);
|
ScreenToClient(rect);
|
|
|
m_RulesList.CreateEx(WS_EX_CLIENTEDGE,WC_LISTVIEW,NULL,WS_VISIBLE|WS_CHILD|LVS_SHOWSELALWAYS,rect,this,IDC_LIST1);
|
m_RulesList.CreateEx(WS_EX_CLIENTEDGE,WC_LISTVIEW,NULL,WS_VISIBLE|WS_CHILD|LVS_SHOWSELALWAYS,rect,this,IDC_LIST1);
|
// Select the first item and fill the solution set
|
// Select the first item and fill the solution set
|
m_RulesList.AddConflicts(m_conflicts);
|
m_RulesList.AddConflicts(m_conflicts);
|
|
|
if(m_parConflictsOfInterest && m_parConflictsOfInterest->GetSize()>0){
|
if(m_parConflictsOfInterest && m_parConflictsOfInterest->GetSize()>0){
|
CPtrArray &arConflictsOfInterest=*m_parConflictsOfInterest;
|
CPtrArray &arConflictsOfInterest=*m_parConflictsOfInterest;
|
for(int i=m_RulesList.GetItemCount()-1;i>=0;--i){
|
for(int i=m_RulesList.GetItemCount()-1;i>=0;--i){
|
for(int j=arConflictsOfInterest.GetSize()-1;j>=0;--j){
|
for(int j=arConflictsOfInterest.GetSize()-1;j>=0;--j){
|
CdlConflict conflict=(CdlConflict)m_RulesList.GetItemData(i);
|
CdlConflict conflict=(CdlConflict)m_RulesList.GetItemData(i);
|
if(arConflictsOfInterest[j]==conflict){
|
if(arConflictsOfInterest[j]==conflict){
|
m_RulesList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
|
m_RulesList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
|
m_RulesList.EnsureVisible(i,false);
|
m_RulesList.EnsureVisible(i,false);
|
arConflictsOfInterest.RemoveAt(j);
|
arConflictsOfInterest.RemoveAt(j);
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
} else {
|
} else {
|
for(int i=m_RulesList.GetItemCount()-1;i>=0;--i){
|
for(int i=m_RulesList.GetItemCount()-1;i>=0;--i){
|
m_RulesList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
|
m_RulesList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
|
}
|
}
|
}
|
}
|
SetButtons();
|
SetButtons();
|
return false; // return TRUE unless you set the focus to a control
|
return false; // return TRUE unless you set the focus to a control
|
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
}
|
}
|
|
|
void CFailingRulesDialog::OnCancel()
|
void CFailingRulesDialog::OnCancel()
|
{
|
{
|
CeCosDialog::OnCancel();
|
CeCosDialog::OnCancel();
|
}
|
}
|
|
|
void CFailingRulesDialog::OnOK()
|
void CFailingRulesDialog::OnOK()
|
{
|
{
|
// Ensure we have the current conflict check array
|
// Ensure we have the current conflict check array
|
for(POSITION pos = m_RulesList.GetFirstSelectedItemPosition();pos;){
|
for(POSITION pos = m_RulesList.GetFirstSelectedItemPosition();pos;){
|
int nItem = m_RulesList.GetNextSelectedItem(pos);
|
int nItem = m_RulesList.GetNextSelectedItem(pos);
|
RemoveConflictSolutions((CdlConflict)m_RulesList.GetItemData(nItem));
|
RemoveConflictSolutions((CdlConflict)m_RulesList.GetItemData(nItem));
|
}
|
}
|
|
|
// Dismiss the window
|
// Dismiss the window
|
CeCosDialog::OnOK();
|
CeCosDialog::OnOK();
|
|
|
for (std::list<CdlConflict>::const_iterator conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) { // for each conflict
|
for (std::list<CdlConflict>::const_iterator conf_i= m_conflicts.begin (); conf_i != m_conflicts.end (); conf_i++) { // for each conflict
|
CdlConflict conflict=*conf_i;
|
CdlConflict conflict=*conf_i;
|
//int nSolutions=conflict->get_solution().size();
|
//int nSolutions=conflict->get_solution().size();
|
SolutionInfo &info=Info(conflict);
|
SolutionInfo &info=Info(conflict);
|
int nIndex=0;
|
int nIndex=0;
|
const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
|
const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
|
for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();soln_i != Solution.end(); soln_i++) {
|
for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();soln_i != Solution.end(); soln_i++) {
|
if(SolutionInfo::CHECKED==info.arItem[nIndex++]){
|
if(SolutionInfo::CHECKED==info.arItem[nIndex++]){
|
CdlValuable valuable = soln_i->first;
|
CdlValuable valuable = soln_i->first;
|
CdlValue value=soln_i->second;
|
CdlValue value=soln_i->second;
|
CdlValueFlavor flavor = valuable->get_flavor();
|
CdlValueFlavor flavor = valuable->get_flavor();
|
const CString strName(valuable->get_name().c_str());
|
const CString strName(valuable->get_name().c_str());
|
const CString strValue(value.get_value().c_str());
|
const CString strValue(value.get_value().c_str());
|
bool rc=true;
|
bool rc=true;
|
CString str;
|
CString str;
|
try {
|
try {
|
switch(flavor) {
|
switch(flavor) {
|
case CdlValueFlavor_None :
|
case CdlValueFlavor_None :
|
str=_T("set CdlValueFlavor_None");
|
str=_T("set CdlValueFlavor_None");
|
rc=false;
|
rc=false;
|
break;
|
break;
|
case CdlValueFlavor_Bool :
|
case CdlValueFlavor_Bool :
|
str.Format(_T("%s %s\n"),value.is_enabled()?_T("disable"):_T("enable"),strName);
|
str.Format(_T("%s %s\n"),value.is_enabled()?_T("disable"):_T("enable"),strName);
|
valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User);
|
valuable->set_enabled (m_Transaction, value.is_enabled(), CdlValueSource_User);
|
break;
|
break;
|
case CdlValueFlavor_BoolData :
|
case CdlValueFlavor_BoolData :
|
{
|
{
|
bool bEnabled=value.is_enabled();
|
bool bEnabled=value.is_enabled();
|
str.Format(_T("%s %s and set value to %s\n"),bEnabled?_T("disable"):_T("enable"),strName,strValue);
|
str.Format(_T("%s %s and set value to %s\n"),bEnabled?_T("disable"):_T("enable"),strName,strValue);
|
// This is wrong: it should set the NEW value. This is the cause of a long-standing bug...
|
// This is wrong: it should set the NEW value. This is the cause of a long-standing bug...
|
// CdlSimpleValue simple_value = valuable->get_simple_value ();
|
// CdlSimpleValue simple_value = valuable->get_simple_value ();
|
//valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User);
|
//valuable->set_enabled_and_value (m_Transaction, bEnabled, simple_value, CdlValueSource_User);
|
valuable->set_enabled_and_value (m_Transaction, bEnabled, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
|
valuable->set_enabled_and_value (m_Transaction, bEnabled, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
|
|
|
}
|
}
|
break;
|
break;
|
case CdlValueFlavor_Data :
|
case CdlValueFlavor_Data :
|
str.Format(_T("set %s to %s\n"),strName,strValue);
|
str.Format(_T("set %s to %s\n"),strName,strValue);
|
valuable->set_value (m_Transaction, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
|
valuable->set_value (m_Transaction, CUtils::UnicodeToStdStr (strValue), CdlValueSource_User);
|
break;
|
break;
|
}
|
}
|
}
|
}
|
catch(...){
|
catch(...){
|
rc=false;
|
rc=false;
|
}
|
}
|
if(rc){
|
if(rc){
|
CConfigTool::GetConfigToolDoc()->SetModifiedFlag();
|
CConfigTool::GetConfigToolDoc()->SetModifiedFlag();
|
} else {
|
} else {
|
CUtils::MessageBoxF(_T("Failed to %s\n"),str);
|
CUtils::MessageBoxF(_T("Failed to %s\n"),str);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
void CFailingRulesDialog::SetAll(bool bOnOff)
|
void CFailingRulesDialog::SetAll(bool bOnOff)
|
{
|
{
|
for(int i=m_List.GetItemCount()-1;i>=0;--i){
|
for(int i=m_List.GetItemCount()-1;i>=0;--i){
|
m_List.SetCheck(i,bOnOff);
|
m_List.SetCheck(i,bOnOff);
|
}
|
}
|
}
|
}
|
|
|
void CFailingRulesDialog::OnReset()
|
void CFailingRulesDialog::OnReset()
|
{
|
{
|
SetAll(true);
|
SetAll(true);
|
}
|
}
|
|
|
void CFailingRulesDialog::OnConflictsNone()
|
void CFailingRulesDialog::OnConflictsNone()
|
{
|
{
|
SetAll(false);
|
SetAll(false);
|
}
|
}
|
|
|
BOOL CFailingRulesDialog::OnItemChanged(UINT, LPNMLISTVIEW pnmv, LRESULT* pResult)
|
BOOL CFailingRulesDialog::OnItemChanged(UINT, LPNMLISTVIEW pnmv, LRESULT* pResult)
|
{
|
{
|
bool bWasSelected=(pnmv->uOldState & LVIS_SELECTED);
|
bool bWasSelected=(pnmv->uOldState & LVIS_SELECTED);
|
bool bIsSelected =(pnmv->uNewState & LVIS_SELECTED);
|
bool bIsSelected =(pnmv->uNewState & LVIS_SELECTED);
|
|
|
if(bWasSelected != bIsSelected) {
|
if(bWasSelected != bIsSelected) {
|
CdlConflict conflict=(CdlConflict) m_RulesList.GetItemData(pnmv->iItem);
|
CdlConflict conflict=(CdlConflict) m_RulesList.GetItemData(pnmv->iItem);
|
if(bIsSelected){
|
if(bIsSelected){
|
if(1==m_List.GetSelectedCount()){
|
if(1==m_List.GetSelectedCount()){
|
GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE);
|
GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE);
|
m_List.ShowWindow(SW_SHOW);
|
m_List.ShowWindow(SW_SHOW);
|
}
|
}
|
AddConflictSolutions(conflict);
|
AddConflictSolutions(conflict);
|
} else {
|
} else {
|
RemoveConflictSolutions(conflict);
|
RemoveConflictSolutions(conflict);
|
}
|
}
|
}
|
}
|
*pResult = 0;
|
*pResult = 0;
|
return false;
|
return false;
|
}
|
}
|
|
|
// We need to use this because the OnItemChanged handler successive receives "not selected" followed by "selected"
|
// We need to use this because the OnItemChanged handler successive receives "not selected" followed by "selected"
|
// notifications. The result is that the "Select one or more conflicts to display available solutions" message
|
// notifications. The result is that the "Select one or more conflicts to display available solutions" message
|
// would be seen briefly when clicking from one selection to another.
|
// would be seen briefly when clicking from one selection to another.
|
BOOL CFailingRulesDialog::OnClick(UINT,LPNMLISTVIEW pnmv, LRESULT* pResult)
|
BOOL CFailingRulesDialog::OnClick(UINT,LPNMLISTVIEW pnmv, LRESULT* pResult)
|
{
|
{
|
if(-1==pnmv->iItem && 0==m_List.GetSelectedCount()){
|
if(-1==pnmv->iItem && 0==m_List.GetSelectedCount()){
|
SetDlgItemText(IDC_STATIC1,_T("Select one or more conflicts to display available solutions"));
|
SetDlgItemText(IDC_STATIC1,_T("Select one or more conflicts to display available solutions"));
|
m_List.ShowWindow(SW_HIDE);
|
m_List.ShowWindow(SW_HIDE);
|
GetDlgItem(IDC_STATIC1)->ShowWindow(SW_SHOW);
|
GetDlgItem(IDC_STATIC1)->ShowWindow(SW_SHOW);
|
GetDlgItem(IDC_RESET)->EnableWindow(false);
|
GetDlgItem(IDC_RESET)->EnableWindow(false);
|
GetDlgItem(IDC_CONFLICTS_NONE)->EnableWindow(false);
|
GetDlgItem(IDC_CONFLICTS_NONE)->EnableWindow(false);
|
}
|
}
|
*pResult = 0;
|
*pResult = 0;
|
return false; // not handled
|
return false; // not handled
|
}
|
}
|
|
|
void CFailingRulesDialog::RemoveConflictSolutions(CdlConflict conflict)
|
void CFailingRulesDialog::RemoveConflictSolutions(CdlConflict conflict)
|
{
|
{
|
SolutionInfo &info=Info(conflict);
|
SolutionInfo &info=Info(conflict);
|
for(int i=0;i<info.nCount;i++){
|
for(int i=0;i<info.nCount;i++){
|
int nItem=info.arItem[i];
|
int nItem=info.arItem[i];
|
ASSERT(nItem>=0);
|
ASSERT(nItem>=0);
|
info.arItem[i]=(1==m_List.GetCheck(nItem)?SolutionInfo::CHECKED:SolutionInfo::UNCHECKED);
|
info.arItem[i]=(1==m_List.GetCheck(nItem)?SolutionInfo::CHECKED:SolutionInfo::UNCHECKED);
|
int nRefs=m_List.GetItemData(nItem);
|
int nRefs=m_List.GetItemData(nItem);
|
if(1==nRefs){
|
if(1==nRefs){
|
m_List.DeleteItem(nItem);
|
m_List.DeleteItem(nItem);
|
for(int i=0;i<m_RulesList.GetItemCount();i++){
|
for(int i=0;i<m_RulesList.GetItemCount();i++){
|
SolutionInfo &info=Info((CdlConflict)m_RulesList.GetItemData(i));
|
SolutionInfo &info=Info((CdlConflict)m_RulesList.GetItemData(i));
|
for(int j=0;j<info.nCount;j++){
|
for(int j=0;j<info.nCount;j++){
|
if(info.arItem[j]>nItem){
|
if(info.arItem[j]>nItem){
|
info.arItem[j]--;
|
info.arItem[j]--;
|
}
|
}
|
}
|
}
|
}
|
}
|
} else {
|
} else {
|
m_List.SetItemData(nItem,nRefs-1);
|
m_List.SetItemData(nItem,nRefs-1);
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
void CFailingRulesDialog::AddConflictSolutions(CdlConflict conflict)
|
void CFailingRulesDialog::AddConflictSolutions(CdlConflict conflict)
|
{
|
{
|
SolutionInfo &info=Info(conflict);
|
SolutionInfo &info=Info(conflict);
|
|
|
const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
|
const std::vector<std::pair<CdlValuable, CdlValue> >&Solution=conflict->get_solution();
|
|
|
int i=0;
|
int i=0;
|
for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();
|
for (std::vector<std::pair<CdlValuable, CdlValue> >::const_iterator soln_i = Solution.begin();
|
soln_i != Solution.end(); soln_i++) {
|
soln_i != Solution.end(); soln_i++) {
|
CdlValuable valuable = soln_i->first;
|
CdlValuable valuable = soln_i->first;
|
CdlValue value=soln_i->second;
|
CdlValue value=soln_i->second;
|
CdlValueFlavor flavor = valuable->get_flavor();
|
CdlValueFlavor flavor = valuable->get_flavor();
|
|
|
CString strValue;
|
CString strValue;
|
switch(flavor) {
|
switch(flavor) {
|
case CdlValueFlavor_None :
|
case CdlValueFlavor_None :
|
break;
|
break;
|
case CdlValueFlavor_Bool :
|
case CdlValueFlavor_Bool :
|
strValue=value.is_enabled() ? _T("Enabled") : _T("Disabled");
|
strValue=value.is_enabled() ? _T("Enabled") : _T("Disabled");
|
break;
|
break;
|
case CdlValueFlavor_BoolData :
|
case CdlValueFlavor_BoolData :
|
strValue.Format(_T("%s, %s"), value.is_enabled() ? _T("Enabled") : _T("Disabled"), CString(value.get_value().c_str()));
|
strValue.Format(_T("%s, %s"), value.is_enabled() ? _T("Enabled") : _T("Disabled"), CString(value.get_value().c_str()));
|
break;
|
break;
|
case CdlValueFlavor_Data :
|
case CdlValueFlavor_Data :
|
strValue=value.get_value().c_str();
|
strValue=value.get_value().c_str();
|
break;
|
break;
|
}
|
}
|
|
|
const CString strName(soln_i->first->get_name().c_str());
|
const CString strName(soln_i->first->get_name().c_str());
|
LVFINDINFO fi;
|
LVFINDINFO fi;
|
fi.flags=LVFI_STRING;
|
fi.flags=LVFI_STRING;
|
fi.psz=strName;
|
fi.psz=strName;
|
int nIndex=m_List.FindItem(&fi);
|
int nIndex=m_List.FindItem(&fi);
|
if(-1==nIndex || strValue!=m_List.GetItemText(nIndex,1)){
|
if(-1==nIndex || strValue!=m_List.GetItemText(nIndex,1)){
|
// We don't have an existing solution that matches this one
|
// We don't have an existing solution that matches this one
|
nIndex=m_List.GetItemCount();
|
nIndex=m_List.GetItemCount();
|
m_List.InsertItem(nIndex,strName);
|
m_List.InsertItem(nIndex,strName);
|
m_List.SetItemData(nIndex,1);
|
m_List.SetItemData(nIndex,1);
|
m_List.SetItemText(nIndex,1,strValue);
|
m_List.SetItemText(nIndex,1,strValue);
|
ASSERT(info.arItem[i]<0);
|
ASSERT(info.arItem[i]<0);
|
m_List.SetCheck(nIndex,SolutionInfo::CHECKED==info.arItem[i]);
|
m_List.SetCheck(nIndex,SolutionInfo::CHECKED==info.arItem[i]);
|
} else {
|
} else {
|
// We do - to avoid duplicates, increment the "ref count"
|
// We do - to avoid duplicates, increment the "ref count"
|
m_List.SetItemData(nIndex,m_List.GetItemData(nIndex)+1);
|
m_List.SetItemData(nIndex,m_List.GetItemData(nIndex)+1);
|
}
|
}
|
info.arItem[i++]=nIndex;
|
info.arItem[i++]=nIndex;
|
}
|
}
|
if(0==i){
|
if(0==i){
|
SetDlgItemText(IDC_STATIC1,_T("No solution is available for this conflict"));
|
SetDlgItemText(IDC_STATIC1,_T("No solution is available for this conflict"));
|
m_List.ShowWindow(SW_HIDE);
|
m_List.ShowWindow(SW_HIDE);
|
} else {
|
} else {
|
SetDlgItemText(IDC_STATIC1,_T("Proposed solution:"));
|
SetDlgItemText(IDC_STATIC1,_T("Proposed solution:"));
|
m_List.ShowWindow(SW_SHOW);
|
m_List.ShowWindow(SW_SHOW);
|
m_List.SetColumnWidth(0,LVSCW_AUTOSIZE);
|
m_List.SetColumnWidth(0,LVSCW_AUTOSIZE);
|
CRect rect;
|
CRect rect;
|
m_List.GetClientRect(rect);
|
m_List.GetClientRect(rect);
|
m_List.SetColumnWidth(1,rect.Width()-m_List.GetColumnWidth(0));
|
m_List.SetColumnWidth(1,rect.Width()-m_List.GetColumnWidth(0));
|
}
|
}
|
}
|
}
|
|
|
BOOL CFailingRulesDialog::OnSolutionItemChanged(UINT,LPNMLISTVIEW, LRESULT*)
|
BOOL CFailingRulesDialog::OnSolutionItemChanged(UINT,LPNMLISTVIEW, LRESULT*)
|
{
|
{
|
SetButtons();
|
SetButtons();
|
return false; // not handled
|
return false; // not handled
|
}
|
}
|
|
|
CFailingRulesDialog::SolutionInfo & CFailingRulesDialog::Info(const CdlConflict conflict)
|
CFailingRulesDialog::SolutionInfo & CFailingRulesDialog::Info(const CdlConflict conflict)
|
{
|
{
|
SolutionInfo *pInfo;
|
SolutionInfo *pInfo;
|
VERIFY(m_Map.Lookup(conflict,(void *&)pInfo));
|
VERIFY(m_Map.Lookup(conflict,(void *&)pInfo));
|
return *pInfo;
|
return *pInfo;
|
}
|
}
|
|
|
BOOL CFailingRulesDialog::OnRClick(UINT, LPNMITEMACTIVATE pnmv, LRESULT* pResult)
|
BOOL CFailingRulesDialog::OnRClick(UINT, LPNMITEMACTIVATE pnmv, LRESULT* pResult)
|
{
|
{
|
DWORD dwPos=GetMessagePos();
|
DWORD dwPos=GetMessagePos();
|
CPoint pt(GET_X_LPARAM(dwPos),GET_Y_LPARAM(dwPos));
|
CPoint pt(GET_X_LPARAM(dwPos),GET_Y_LPARAM(dwPos));
|
m_nContextItem=pnmv->iItem;
|
m_nContextItem=pnmv->iItem;
|
m_nContextRow=pnmv->iSubItem;
|
m_nContextRow=pnmv->iSubItem;
|
if(-1!=m_nContextItem){
|
if(-1!=m_nContextItem){
|
//m_RulesList.SetItemState(m_nContextItem,LVIS_SELECTED,LVIS_SELECTED);
|
//m_RulesList.SetItemState(m_nContextItem,LVIS_SELECTED,LVIS_SELECTED);
|
Menu menu;
|
Menu menu;
|
menu.CreatePopupMenu();
|
menu.CreatePopupMenu();
|
menu.AppendMenu(1==m_RulesList.GetSelectedCount() && m_RulesList.AssociatedItem(m_nContextItem,m_nContextRow)?MF_STRING:(MF_STRING|MF_GRAYED),ID_LOCATE,_T("&Locate"));
|
menu.AppendMenu(1==m_RulesList.GetSelectedCount() && m_RulesList.AssociatedItem(m_nContextItem,m_nContextRow)?MF_STRING:(MF_STRING|MF_GRAYED),ID_LOCATE,_T("&Locate"));
|
#ifndef PLUGIN
|
#ifndef PLUGIN
|
SuppressNextContextMenuMessage();
|
SuppressNextContextMenuMessage();
|
#endif
|
#endif
|
menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, pt.x,pt.y,this);
|
menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, pt.x,pt.y,this);
|
}
|
}
|
|
|
*pResult = 0;
|
*pResult = 0;
|
return TRUE; // handled
|
return TRUE; // handled
|
}
|
}
|
|
|
void CFailingRulesDialog::OnLocate()
|
void CFailingRulesDialog::OnLocate()
|
{
|
{
|
CConfigItem *pItem=m_RulesList.AssociatedItem(m_nContextItem,m_nContextRow);
|
CConfigItem *pItem=m_RulesList.AssociatedItem(m_nContextItem,m_nContextRow);
|
if (pItem) {
|
if (pItem) {
|
CConfigTool::GetControlView()->SelectItem(pItem);
|
CConfigTool::GetControlView()->SelectItem(pItem);
|
}
|
}
|
}
|
}
|
|
|
|
|
void CFailingRulesDialog::SetButtons()
|
void CFailingRulesDialog::SetButtons()
|
{
|
{
|
int nCheckCount=0;
|
int nCheckCount=0;
|
int nItemCount=m_List.GetItemCount();
|
int nItemCount=m_List.GetItemCount();
|
for(int i=nItemCount-1;i>=0;--i){
|
for(int i=nItemCount-1;i>=0;--i){
|
nCheckCount+=m_List.GetCheck(i);
|
nCheckCount+=m_List.GetCheck(i);
|
}
|
}
|
GetDlgItem(IDC_RESET)->EnableWindow(nItemCount>0 && nCheckCount<nItemCount);
|
GetDlgItem(IDC_RESET)->EnableWindow(nItemCount>0 && nCheckCount<nItemCount);
|
GetDlgItem(IDC_CONFLICTS_NONE)->EnableWindow(nItemCount>0 && nCheckCount>0);
|
GetDlgItem(IDC_CONFLICTS_NONE)->EnableWindow(nItemCount>0 && nCheckCount>0);
|
}
|
}
|
|
|
// We have to dispatch our own notify messages because the multiple inheritance of CCSHDialog prevents
|
// We have to dispatch our own notify messages because the multiple inheritance of CCSHDialog prevents
|
// the message map from compiling properly for ON_NOTIFY messages.
|
// the message map from compiling properly for ON_NOTIFY messages.
|
BOOL CFailingRulesDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult )
|
BOOL CFailingRulesDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult )
|
{
|
{
|
LPNMHDR pHdr=(LPNMHDR)lParam;
|
LPNMHDR pHdr=(LPNMHDR)lParam;
|
bool bHandled=false;
|
bool bHandled=false;
|
switch(pHdr->idFrom){
|
switch(pHdr->idFrom){
|
case IDC_LIST1:
|
case IDC_LIST1:
|
switch (pHdr->code) {
|
switch (pHdr->code) {
|
case LVN_ITEMCHANGED:
|
case LVN_ITEMCHANGED:
|
bHandled=OnItemChanged(wParam, (LPNMLISTVIEW)lParam, pResult);
|
bHandled=OnItemChanged(wParam, (LPNMLISTVIEW)lParam, pResult);
|
break;
|
break;
|
case NM_CLICK:
|
case NM_CLICK:
|
bHandled=OnClick(wParam, (LPNMLISTVIEW)lParam, pResult);
|
bHandled=OnClick(wParam, (LPNMLISTVIEW)lParam, pResult);
|
break;
|
break;
|
case NM_RCLICK:
|
case NM_RCLICK:
|
bHandled=OnRClick(wParam, (LPNMITEMACTIVATE)lParam, pResult);
|
bHandled=OnRClick(wParam, (LPNMITEMACTIVATE)lParam, pResult);
|
break;
|
break;
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
break;
|
break;
|
case IDC_LIST2:
|
case IDC_LIST2:
|
switch (pHdr->code) {
|
switch (pHdr->code) {
|
case LVN_ITEMCHANGED:
|
case LVN_ITEMCHANGED:
|
bHandled=OnSolutionItemChanged(wParam,(LPNMLISTVIEW)lParam, pResult);
|
bHandled=OnSolutionItemChanged(wParam,(LPNMLISTVIEW)lParam, pResult);
|
break;
|
break;
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
break;
|
break;
|
}
|
}
|
return bHandled || CeCosDialog::OnNotify(wParam,lParam,pResult);
|
return bHandled || CeCosDialog::OnNotify(wParam,lParam,pResult);
|
}
|
}
|
|
|