[GME-commit] GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Asp NameSpecDlg.cpp,1.1,1.2 NameSpecDlg.h,1.1,1.2 NameSpecTbl.cpp,1.3,1.4 NameSpecTbl.h,1.2,1.3

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Thu Apr 7 22:26:27 CDT 2005


Update of /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Asp
In directory escher:/tmp/cvs-serv7689/Asp

Modified Files:
	NameSpecDlg.cpp NameSpecDlg.h NameSpecTbl.cpp NameSpecTbl.h 
Log Message:
Allowing the user to choose a displayed name for equivalent objects also.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: NameSpecDlg.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Asp/NameSpecDlg.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NameSpecDlg.h	30 Jul 2004 00:10:23 -0000	1.1
--- NameSpecDlg.h	7 Apr 2005 21:26:24 -0000	1.2
***************
*** 41,49 ****
  	int	m_lastID;
  	typedef std::map< BON::FCO, std::set< BON::FCO> > LARGE_MAP;
! 	typedef std::map< BON::FCO, std::string> DEFNAMES_MAP;
  
! 	LARGE_MAP m_map;
! 	DEFNAMES_MAP m_dn;
! 	DEFNAMES_MAP m_result;
  
  // Operations
--- 41,49 ----
  	int	m_lastID;
  	typedef std::map< BON::FCO, std::set< BON::FCO> > LARGE_MAP;
! 	typedef std::map< BON::FCO, std::pair<std::string, std::string> > DEFNAMES_MAP;
  
! 	LARGE_MAP m_map;//contains the equivalent fcos (which are non-proxy)
! 	DEFNAMES_MAP m_dn;	// the default values , or initial values shown when the dialog pops up
! 	DEFNAMES_MAP m_result;	// the result
  
  // Operations
***************
*** 60,66 ****
  // Implementation
  public:
! 	void GetEntry(int entryNum, CString& name, CString& kind, const void * &ptr);
  
  	void GetNames(int num, CString& curname, CStringList& names);
  
  	virtual ~NameSpecDlg();
--- 60,67 ----
  // Implementation
  public:
! 	void GetEntry(int entryNum, CString& name, CString& dispname, CString& kind, const void * &ptr);
  
  	void GetNames(int num, CString& curname, CStringList& names);
+ 	void GetDispNames( int num, CString& curdispname, CStringList& dispnames);
  
  	virtual ~NameSpecDlg();

Index: NameSpecDlg.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Asp/NameSpecDlg.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NameSpecDlg.cpp	30 Jul 2004 00:10:23 -0000	1.1
--- NameSpecDlg.cpp	7 Apr 2005 21:26:24 -0000	1.2
***************
*** 4,7 ****
--- 4,8 ----
  #include "stdafx.h"
  #include "NameSpecDlg.h"
+ #include "Any.h"
  
  #ifdef _DEBUG
***************
*** 40,48 ****
  
  
! void NameSpecDlg::GetEntry(int rowID, CString& name, CString& kind, const void * &ptr)
  {
! 	m_nmlist.GetRow(rowID, name, kind);
  }
  
  
  void NameSpecDlg::GetNames( int num, CString& curr, CStringList& names)
--- 41,64 ----
  
  
! void NameSpecDlg::GetEntry(int rowID, CString& name, CString& dispname, CString& kind, const void * &ptr)
  {
! 	m_nmlist.GetRow(rowID, name, dispname, kind);
  }
  
+ void uniqueNames( const CString& to_insert, CStringList& names)
+ {
+ 	bool found = false;
+ 	POSITION pos;
+ 	pos = names.GetHeadPosition();
+ 	while ( pos && !found)
+ 	{
+ 		if( to_insert.Compare(names.GetNext( pos )) == 0)
+ 		{
+ 			found = true;
+ 		}
+ 	}
+ 	if( !found)
+ 		names.InsertAfter( names.GetTailPosition(), to_insert);
+ }
  
  void NameSpecDlg::GetNames( int num, CString& curr, CStringList& names)
***************
*** 58,66 ****
  		{
  			CString onelem = (*jt)->getName().c_str();
! 			if( onelem != curr) names.AddTail( onelem);
  		}
  	}
  }
  
  
  BOOL NameSpecDlg::OnInitDialog() 
--- 74,106 ----
  		{
  			CString onelem = (*jt)->getName().c_str();
! 			uniqueNames( onelem, names);
! 
  		}
  	}
  }
  
+ void NameSpecDlg::GetDispNames( int num, CString& currdispname, CStringList& dispnames)
+ {
+ 	LARGE_MAP::iterator it = m_map.begin();
+ 	for( int k = 0; k != num && it != m_map.end(); ++it, ++k);
+ 
+ 	dispnames.AddHead( currdispname);
+ 	if( it != m_map.end()) // found
+ 	{
+ 		std::set< BON::FCO>::iterator jt = it->second.begin();
+ 		for( ; jt != it->second.end(); ++jt)
+ 		{
+ 			CString onelem;
+ 			BON::Attribute attr = (*jt)->getAttribute( Any::DisplayedName_str);
+ 			if( attr )
+ 			{
+ 				onelem = attr->getStringValue().c_str();
+ 				uniqueNames( onelem, dispnames);
+ 			}
+ 		}
+ 	}
+ 	uniqueNames( "", dispnames); // thus allowing always the empty disp name possibility
+ }
+ 
  
  BOOL NameSpecDlg::OnInitDialog() 
***************
*** 77,88 ****
  	{
  		BON::FCO ff( it->first);
! 		CString defname = it->second.c_str();
  		CString kind = ff->getObjectMeta().name().c_str();
  
  		//t
  		//kind = CString(ff->getName().c_str()) + ":" + kind;
  		//et
  
! 		m_nmlist.AddRow( m_lastID++, defname, kind);
  	}
  
--- 117,130 ----
  	{
  		BON::FCO ff( it->first);
! 		CString defname     = it->second.first.c_str();
! 		CString defdispname = it->second.second.c_str();
  		CString kind = ff->getObjectMeta().name().c_str();
  
+ 
  		//t
  		//kind = CString(ff->getName().c_str()) + ":" + kind;
  		//et
  
! 		m_nmlist.AddRow( m_lastID++, defname, defdispname, kind);
  	}
  
***************
*** 96,104 ****
  	for( int k = 0; k < m_lastID && it != m_dn.end(); ++k, ++it)
  	{
! 		CString name, kind; void * ptr;
! 		GetEntry( k, name, kind, ptr);
  		BON::FCO fco = it->first;
  		std::string newsel_name = (LPCTSTR) name;
! 		m_result[ fco] = newsel_name;
  
  #ifdef _DEBUG
--- 138,147 ----
  	for( int k = 0; k < m_lastID && it != m_dn.end(); ++k, ++it)
  	{
! 		CString name, dispname, kind; void * ptr;
! 		GetEntry( k, name, dispname, kind, ptr);
  		BON::FCO fco = it->first;
  		std::string newsel_name = (LPCTSTR) name;
! 		std::string newsel_dispname = (LPCTSTR) dispname;
! 		m_result[ fco] = make_pair( newsel_name, newsel_dispname);
  
  #ifdef _DEBUG
***************
*** 107,111 ****
  		for( ; jt != m_map[ fco].end() && (*jt)->getName() != newsel_name; ++jt);
  
! 		if( jt == m_map[ fco].end() && newsel_name != m_dn[ fco])
  			ASSERT(0); // if not found among equivs and is not the default name
  #endif
--- 150,154 ----
  		for( ; jt != m_map[ fco].end() && (*jt)->getName() != newsel_name; ++jt);
  
! 		if( jt == m_map[ fco].end() && newsel_name != m_dn[ fco].first)
  			ASSERT(0); // if not found among equivs and is not the default name
  #endif

Index: NameSpecTbl.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Asp/NameSpecTbl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** NameSpecTbl.cpp	15 Sep 2004 19:48:34 -0000	1.3
--- NameSpecTbl.cpp	7 Apr 2005 21:26:24 -0000	1.4
***************
*** 264,292 ****
  
  
- /*
- void NameSpecTbl::OnLButtonDown(UINT nFlags, CPoint point) 
- {
- 	// TODO: Add your message handler code here and/or call default
- 	
- 	CListCtrl::OnLButtonDown(nFlags, point);
- 
- 	int index;
- 	int colnum;
- 	if( ( index = HitTestEx( point, &colnum )) != -1 )
- 	{
- 		UINT flag = LVIS_FOCUSED;
- 		if( (GetItemState( index, flag ) & flag) == flag && colnum > 0)
- 		{
- 			// Add check for LVS_EDITLABELS
- 			if( GetWindowLong(m_hWnd, GWL_STYLE) & LVS_EDITLABELS )
- 				EditSubLabel( index, colnum );
- 		}
- 		else
- 			SetItemState( index, LVIS_SELECTED | LVIS_FOCUSED ,
- 				    	LVIS_SELECTED | LVIS_FOCUSED); 
- 	}
- 
- }
- */
  void NameSpecTbl::OnLButtonDown(UINT nFlags, CPoint point) 
  {
--- 264,267 ----
***************
*** 314,323 ****
  					CStringList lstItems;
  					int rowID = GetItemData( index);
- 					//dlg->GetAspects(lstItems);
- 					//dlg->GetNames( rowID, lstItems);
  					dlg->GetNames( rowID, CString(item.pszText), lstItems);
  					ShowInPlaceList( index, colnum, lstItems, 0 );
  				}
  			}
  		}
  		else
--- 289,312 ----
  					CStringList lstItems;
  					int rowID = GetItemData( index);
  					dlg->GetNames( rowID, CString(item.pszText), lstItems);
  					ShowInPlaceList( index, colnum, lstItems, 0 );
  				}
  			}
+ 			else if(colnum==1)
+ 			{
+ 				char buff[128];
+ 				LVITEM item;
+ 				item.mask = LVIF_TEXT;
+ 				item.iItem = index;
+ 				item.iSubItem = 1;
+ 				item.pszText = buff;
+ 				item.cchTextMax = 127;
+ 				if (GetItem(&item) && CString(item.pszText) != "N/A") {
+ 					CStringList lstItems;
+ 					int rowID = GetItemData( index);
+ 					dlg->GetDispNames( rowID, CString(item.pszText), lstItems);
+ 					ShowInPlaceList( index, colnum, lstItems, 0 );
+ 				}
+ 			}
  		}
  		else
***************
*** 329,333 ****
  
  
! void NameSpecTbl::AddRow(int rowID, CString& name, CString& kind)
  {
  	LV_ITEM lvItem;
--- 318,322 ----
  
  
! void NameSpecTbl::AddRow(int rowID, CString& name, CString& disp_name, CString& kind)
  {
  	LV_ITEM lvItem;
***************
*** 338,343 ****
  	int index = InsertItem(&lvItem);
  	
- 
  	lvItem.iSubItem = 1;
  	lvItem.pszText = kind.GetBuffer( kind.GetLength());
  	SetItem(&lvItem);
--- 327,335 ----
  	int index = InsertItem(&lvItem);
  	
  	lvItem.iSubItem = 1;
+ 	lvItem.pszText = disp_name.GetBuffer( disp_name.GetLength());
+ 	SetItem(&lvItem);
+ 
+ 	lvItem.iSubItem = 2;
  	lvItem.pszText = kind.GetBuffer( kind.GetLength());
  	SetItem(&lvItem);
***************
*** 355,364 ****
  
  	InsertColumn(0, _T("Name"), LVCFMT_LEFT,  col1size, -1);
! 	InsertColumn(1, _T("Kind"), LVCFMT_LEFT, col2size, -1);
  
  	return 0;
  }
  
! bool NameSpecTbl::GetRow(int rowID, CString& name, CString& kind)
  {
  	LVFINDINFO lvFind;
--- 347,357 ----
  
  	InsertColumn(0, _T("Name"), LVCFMT_LEFT,  col1size, -1);
! 	InsertColumn(1, _T("Displayed Name"), LVCFMT_LEFT,  col1size, -1);
! 	InsertColumn(2, _T("Kind"), LVCFMT_LEFT, col2size, -1);
  
  	return 0;
  }
  
! bool NameSpecTbl::GetRow(int rowID, CString& name, CString& disp_name, CString& kind)
  {
  	LVFINDINFO lvFind;
***************
*** 380,385 ****
  	
  	
- 
  	lvItem.iSubItem = 1;
  	lvItem.pszText = kind.GetBuffer(255);
  	lvItem.cchTextMax = 254;
--- 373,382 ----
  	
  	
  	lvItem.iSubItem = 1;
+ 	lvItem.pszText = disp_name.GetBuffer(255);
+ 	lvItem.cchTextMax = 254;
+ 	GetItem(&lvItem);
+ 
+ 	lvItem.iSubItem = 2;
  	lvItem.pszText = kind.GetBuffer(255);
  	lvItem.cchTextMax = 254;
***************
*** 469,473 ****
  		int nRetLen = GetItemText(nItem, nColumn,
  						szBuff, sizeof(szBuff));
! 		if (nRetLen == 0)
  			continue;
  
--- 466,470 ----
  		int nRetLen = GetItemText(nItem, nColumn,
  						szBuff, sizeof(szBuff));
! 		if (nColumn != 1 && nRetLen == 0) // in case of the first column we will draw the DFCS_SCROLLDOWN symbol
  			continue;
  
***************
*** 494,502 ****
  		rcLabel = rcItem;
  		rcLabel.left += OFFSET_OTHER;
! 		rcLabel.right -= OFFSET_OTHER;
  
  		pDC->DrawText(pszText, -1, rcLabel,
  			nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
  
  	}
  
--- 491,504 ----
  		rcLabel = rcItem;
  		rcLabel.left += OFFSET_OTHER;
! 		//rcLabel.right -= OFFSET_OTHER;
  
  		pDC->DrawText(pszText, -1, rcLabel,
  			nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
  
+ 		
+ 		CRect r2 = rcLabel;
+ 		r2.left = r2.right - ::GetSystemMetrics(SM_CXHSCROLL);
+ 		if( nColumn == 1 && r2.left > OFFSET_FIRST + 1)
+ 			pDC->DrawFrameControl(r2, DFC_SCROLL, DFCS_SCROLLDOWN);
  	}
  

Index: NameSpecTbl.h
===================================================================
RCS file: /project/gme-repository/GMESRC/Paradigms/MetaGME/MetaInterpreter2004/Asp/NameSpecTbl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** NameSpecTbl.h	9 Aug 2004 16:11:37 -0000	1.2
--- NameSpecTbl.h	7 Apr 2005 21:26:24 -0000	1.3
***************
*** 34,39 ****
  public:
  	CImageList m_checkImages;
! 	bool GetRow( int rowID, CString& name, CString& kind);
! 	void AddRow( int rowID, CString& name, CString& kind);
  
  	virtual ~NameSpecTbl();
--- 34,39 ----
  public:
  	CImageList m_checkImages;
! 	bool GetRow( int rowID, CString& name, CString& disp_name, CString& kind);
! 	void AddRow( int rowID, CString& name, CString& disp_name, CString& kind);
  
  	virtual ~NameSpecTbl();



More information about the GME-commit mailing list