OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [RulesList.cpp] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
// RulesView.cpp : implementation file
23
//
24
 
25
#include "stdafx.h"
26
#include "ConfigToolDoc.h"
27
#include "RulesList.h"
28
 
29
#include "RulesView.h"
30
#include "ControlView.h"
31
#include "ConfigItem.h"
32
#include "ConfigTool.h"
33
 
34
#define INCLUDEFILE <string>
35
#include "IncludeSTL.h"
36
 
37
#ifdef _DEBUG
38
#define new DEBUG_NEW
39
#undef THIS_FILE
40
static char THIS_FILE[] = __FILE__;
41
#endif
42
 
43
/////////////////////////////////////////////////////////////////////////////
44
// CRulesList
45
 
46
CRulesList::CRulesList():
47
  m_nLastCol(0x7fffffff),
48
  m_fWidth(0.0)
49
{
50
  m_f[0]=3.0/7.0;
51
  m_f[1]=1.0/7.0;
52
  m_f[2]=3.0/7.0;
53
}
54
 
55
CRulesList::~CRulesList()
56
{
57
}
58
 
59
BEGIN_MESSAGE_MAP(CRulesList, CTTListCtrl)
60
        //{{AFX_MSG_MAP(CRulesList)
61
        ON_WM_CREATE()
62
        ON_WM_SIZE()
63
        ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
64
        ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
65
  ON_NOTIFY(HDN_ENDTRACKW, 0, OnEndTrack)
66
        //}}AFX_MSG_MAP
67
END_MESSAGE_MAP()
68
 
69
/////////////////////////////////////////////////////////////////////////////
70
// CRulesList drawing
71
 
72
/////////////////////////////////////////////////////////////////////////////
73
// CRulesList message handlers
74
 
75
void CRulesList::AddConflict (const CdlConflict &conf)
76
{
77
  // set the item column string
78
  CString strMacroName = (conf)->get_node ()->get_name ().c_str ();
79
  int nIndex = InsertItem (GetItemCount (), strMacroName);
80
  SetItemData (nIndex, (DWORD) (conf));
81
 
82
  // set the conflict column string
83
  if (0 != dynamic_cast<CdlConflict_Unresolved> (conf)) {// a conflict of type 'unresolved'
84
    SetItemText (nIndex, 1, _T("Unresolved"));
85
  } else if (0 != dynamic_cast<CdlConflict_IllegalValue> (conf)) { // a conflict of type 'illegal value'
86
    SetItemText (nIndex, 1, _T("Illegal"));
87
  } else if (0 != dynamic_cast<CdlConflict_EvalException> (conf)) { // a conflict of type 'evaluation exception'
88
    SetItemText (nIndex, 1, _T("Exception"));
89
  } else if (0 != dynamic_cast<CdlConflict_Requires> (conf)) { // a conflict of type 'goal unsatisfied'
90
    SetItemText (nIndex, 1, _T("Unsatisfied"));
91
  } else if (0 != dynamic_cast<CdlConflict_Data> (conf)) { // a conflict of type 'bad data'
92
    SetItemText (nIndex, 1, _T("Bad data"));
93
  } else {
94
    ASSERT (0);
95
  }
96
 
97
        // set the property column string
98
        CString strProperty = conf->get_property ()->get_property_name ().c_str ();
99
        strProperty += _T(" ");
100
        const std::vector<std::string> & argv = conf->get_property ()->get_argv ();
101
        std::vector<std::string>::const_iterator argv_i;
102
  for (argv_i = argv.begin (); argv_i != argv.end (); argv_i++) {// for each property argument...
103
    if (argv_i != argv.begin ())                              // ...except the first
104
    {
105
      strProperty += argv_i->c_str (); // add the argument to the string
106
      strProperty += _T (" "); // separate arguments by a space character
107
    }
108
  }
109
        strProperty.TrimRight (); // remove the trailing space character
110
        SetItemText (nIndex, 2, strProperty);
111
}
112
 
113
int CRulesList::OnCreate(LPCREATESTRUCT lpCreateStruct)
114
{
115
  lpCreateStruct->style|=LVS_REPORT;
116
        if (CTTListCtrl::OnCreate(lpCreateStruct) == -1)
117
                return -1;
118
        SetExtendedStyle(LVS_EX_FULLROWSELECT);
119
 
120
        InsertColumn(0,_T("Item"),        LVCFMT_LEFT,0,0);
121
        InsertColumn(1,_T("Conflict"),LVCFMT_LEFT,0,1);
122
        InsertColumn(2,_T("Property"),LVCFMT_LEFT,0,2);
123
 
124
  return 0;
125
}
126
 
127
void CRulesList::OnSize(UINT nType, int cx, int cy)
128
{
129
        CTTListCtrl::OnSize(nType, cx, cy);
130
  m_fWidth=cx;
131
  for(int i=0;i<NCOLS;i++){
132
          SetColumnWidth(i,int(cx*m_f[i]));
133
  }
134
}
135
 
136
int CRulesList::CompareFunc(LPARAM lParam1, LPARAM lParam2)
137
{
138
        LV_FINDINFO find1 = { LVFI_PARAM, NULL, lParam1, NULL, NULL };
139
        LV_FINDINFO find2 = { LVFI_PARAM, NULL, lParam2, NULL, NULL };
140
        const int nIndex1 = FindItem (&find1);
141
        const int nIndex2 = FindItem (&find2);
142
        const CString str1 = GetItemText (nIndex1, m_nLastCol & 0x7fffffff);
143
        const CString str2 = GetItemText (nIndex2, m_nLastCol & 0x7fffffff);
144
        return (m_nLastCol & 0x80000000) ^ str1.Compare (str2);
145
}
146
 
147
void CRulesList::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
148
{
149
        NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
150
        LPARAM nCol=pNMListView->iSubItem;
151
        if((nCol&0x7fffffff)==(0x7fffffff&m_nLastCol)){
152
                nCol=m_nLastCol^0x80000000;
153
        }
154
  m_nLastCol=nCol;
155
        SortItems(CompareFunc,(DWORD)this);
156
 
157
        *pResult = 0;
158
}
159
 
160
void CRulesList::OnEndTrack(NMHEADER *pNMHeader, LRESULT*)
161
{
162
  m_f[pNMHeader->iItem]=pNMHeader->pitem->cxy/m_fWidth;
163
}
164
 
165
void CRulesList::AddConflicts (const std::list<CdlConflict>& conflicts)
166
{
167
  for (std::list<CdlConflict>::const_iterator conf_i=conflicts.begin (); conf_i != conflicts.end (); conf_i++) {
168
    AddConflict(*conf_i);
169
  }
170
}
171
 
172
void CRulesList::AddConflicts (const std::vector<CdlConflict>& conflicts)
173
{
174
  for (std::vector<CdlConflict>::const_iterator conf_i=conflicts.begin (); conf_i != conflicts.end (); conf_i++) {
175
    AddConflict(*conf_i);
176
  }
177
}
178
 
179
void CRulesList::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
180
{
181
  if (GetParent ()->IsKindOf (RUNTIME_CLASS (CRulesView))) { // handle double click for conflicts view only
182
    NM_LISTVIEW * pNMListView = (NM_LISTVIEW *) pNMHDR;
183
    int nItem = pNMListView->iItem;
184
    if (-1 != nItem) { // if the double click was on a row of the list
185
      CConfigItem * pItem = AssociatedItem (nItem, pNMListView->iSubItem); // get the referenced item
186
      if (pItem) { // if a referenced item was found
187
        CConfigTool::GetControlView ()->SelectItem (pItem); // select the refreenced item
188
      }
189
    }
190
  }
191
 
192
  *pResult = 0;
193
  UNUSED_ALWAYS(pNMHDR);
194
}
195
 
196
CConfigItem *CRulesList::AssociatedItem(int nRow,int nCol)
197
{
198
  const CdlConflict conflict = (CdlConflict) GetItemData (nRow);
199
  ASSERT (conflict);
200
 
201
  CConfigItem *pItem=NULL;
202
  switch(nCol){
203
    case 2:
204
      {
205
        const CdlGoalExpression goal = dynamic_cast<CdlGoalExpression> (conflict->get_property ());
206
        if (! goal) // if the item is not a goal expression
207
          break; // do nothing
208
        const CdlExpression expression = goal->get_expression ();
209
        if (1 == expression->references.size ()) // if the property contains a single reference
210
                {
211
          // assume that the reference is to another user visible node and try to find it
212
          const CString strName(expression->references [0].get_destination_name ().c_str());
213
          pItem = CConfigTool::GetConfigToolDoc ()->Find(strName);
214
        }
215
      }
216
      break;
217
    case 0:
218
      pItem = CConfigTool::GetConfigToolDoc ()->Find(CString(conflict->get_node ()->get_name ().c_str()));
219
      break;
220
    default:
221
      break;
222
  }
223
  return pItem;
224
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.