[GME-commit] GMESRC/Tools/ModelMigrate/FrontEnd AboutDlg.cpp,NONE,1.1
AboutDlg.h,NONE,1.1 AttrGlobalDlg.cpp,NONE,1.1
AttrGlobalDlg.h,NONE,1.1 AttrNameDlg.cpp,NONE,1.1
AttrNameDlg.h,NONE,1.1 AttrTypeChangeDlg.cpp,NONE,1.1
AttrTypeChangeDlg.h,NONE,1.1 CMgaXslt.cpp,NONE,1.1
CMgaXslt.h,NONE,1.1 EnumAttrValueDlg.cpp,NONE,1.1
EnumAttrValueDlg.h,NONE,1.1 Extractor.cpp,NONE,1.1
Extractor.h,NONE,1.1 FileListCtrl.cpp,NONE,1.1
FileListCtrl.h,NONE,1.1 FileTransDlg.cpp,NONE,1.1
FileTransDlg.h,NONE,1.1 FrontEnd.rc,NONE,1.1
FrontEnd.vcproj,NONE,1.1 FrontEnd2.rc,NONE,1.1
FrontEndDlg.cpp,NONE,1.1 FrontEndDlg.h,NONE,1.1 Log.cpp,NONE,1.1
Log.h,NONE,1.1 ModelMigrate.cpp,NONE,1.1 ModelMigrate.h,NONE,1.1
MoveDownElem.cpp,NONE,1.1 MoveDownElem.h,NONE,1.1
MoveUpElem.cpp,NONE,1.1 MoveUpElem.h,NONE,1.1
NewRuleDlg.cpp,NONE,1.1 NewRuleDlg.h,NONE,1.1
OptionsDlg.cpp,NONE,1.1 OptionsDlg.h,NONE,1.1
RemoveDlg.cpp,NONE,1.1 RemoveDlg.h,NONE,1.1
RemoveLocAttrDlg.cpp,NONE,1.1 RemoveLocAttrDlg.h,NONE,1.1Rule.cpp,NON
RuleListCtrl.cpp,NONE,1.1 RuleListCtrl.h,NONE,1.1 Script.cpp,NONE,1.1
Script.h,NONE,1.1 ScriptAbs.cpp,NONE,1.1 ScriptAbs.h,NONE,1.1
ScriptAttrName.cpp,NONE,1.1 ScriptAttrName.h,NONE,1.1
ScriptAttrType.cpp,NONE,1.1 ScriptAttrType.h,NONE,1.1
ScriptCmplx.cpp,NONE,1.1 ScriptCmplx.h,NONE,1.1
ScriptEnumAttrValue.cpp,NONE,1.1 ScriptEnumAttrValue.h,NONE,1.1
ScriptListCtrl.cpp,NONE,1.1 ScriptListCtrl.h,NONE,1.1
ScriptMoveDown.cpp,NONE,1.1 ScriptMoveDown.h,NONE,1.1
ScriptMoveDownEach.cpp,NONE,1.1 ScriptMoveDownEach.h,NONE,1.1
ScriptMoveUp.cpp,NONE,1.1 ScriptMoveUp.h,NONE,1.1 SimpleRepl.cpp,NONE,1.1
SimpleRepl.h,NONE,1.1 Validator.cpp,NONE,1.1 Validator.h,NONE,1.1
resource.h,NONE,1.1 stdafx.cpp,NONE,1.1 stdafx.h,NONE,1.1
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Wed Nov 16 16:01:19 CST 2005
- Previous message: [GME-commit] GMESRC/Tools/ModelMigrate ModelMigrate.sln,NONE,1.1
- Next message: [GME-commit]
GMESRC/Tools/ModelMigrate/FrontEnd/res FrontEnd.ico,NONE,1.1
FrontEnd.manifest,NONE,1.1 FrontEnd.rc2,NONE,1.1
TAttrNameChange.xsl,NONE,1.1 TAttrTypeChange.xsl,NONE,1.1
TAttrTypeCheck2Text.xsl,NONE,1.1 TEnumAttrValueChange.xsl,NONE,1.1
TKindNameChange.xsl,NONE,1.1 TRemoveGlobalAttr.xsl,NONE,1.1
TRemoveKind.xsl,NONE,1.1 TRemoveLocalAttr.xsl,NONE,1.1
header.xsl,NONE,1.1 tail.xsl,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /project/gme-repository/GMESRC/Tools/ModelMigrate/FrontEnd
In directory escher:/tmp/cvs-serv27879/ModelMigrate/FrontEnd
Added Files:
AboutDlg.cpp AboutDlg.h AttrGlobalDlg.cpp AttrGlobalDlg.h
AttrNameDlg.cpp AttrNameDlg.h AttrTypeChangeDlg.cpp
AttrTypeChangeDlg.h CMgaXslt.cpp CMgaXslt.h
EnumAttrValueDlg.cpp EnumAttrValueDlg.h Extractor.cpp
Extractor.h FileListCtrl.cpp FileListCtrl.h FileTransDlg.cpp
FileTransDlg.h FrontEnd.rc FrontEnd.vcproj FrontEnd2.rc
FrontEndDlg.cpp FrontEndDlg.h Log.cpp Log.h ModelMigrate.cpp
ModelMigrate.h MoveDownElem.cpp MoveDownElem.h MoveUpElem.cpp
MoveUpElem.h NewRuleDlg.cpp NewRuleDlg.h OptionsDlg.cpp
OptionsDlg.h RemoveDlg.cpp RemoveDlg.h RemoveLocAttrDlg.cpp
RemoveLocAttrDlg.h Rule.cpp Rule.h RuleEditorDlg.cpp
RuleEditorDlg.h RuleListCtrl.cpp RuleListCtrl.h Script.cpp
Script.h ScriptAbs.cpp ScriptAbs.h ScriptAttrName.cpp
ScriptAttrName.h ScriptAttrType.cpp ScriptAttrType.h
ScriptCmplx.cpp ScriptCmplx.h ScriptEnumAttrValue.cpp
ScriptEnumAttrValue.h ScriptListCtrl.cpp ScriptListCtrl.h
ScriptMoveDown.cpp ScriptMoveDown.h ScriptMoveDownEach.cpp
ScriptMoveDownEach.h ScriptMoveUp.cpp ScriptMoveUp.h
SimpleRepl.cpp SimpleRepl.h Validator.cpp Validator.h
resource.h stdafx.cpp stdafx.h
Log Message:
ModelMigrate tool checked in.
CVS User: Zoltan Molnar, ISIS (zolmol)
--- NEW FILE: Validator.h ---
#pragma once
class Validator
{
public:
Validator(void);
~Validator(void);
static void job( LPCTSTR lpszPathNameIn, LPCTSTR lpszPathNameOut);
};
--- NEW FILE: ScriptListCtrl.h ---
#pragma once
#include <vector>
#include <string>
class FileTransDlg;
// ScriptListCtrl
class ScriptListCtrl : public CListCtrl
{
DECLARE_DYNAMIC(ScriptListCtrl)
public:
ScriptListCtrl();
virtual ~ScriptListCtrl();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
protected:
virtual void PreSubclassWindow();
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
void createPopupMenu( CPoint pnt);
public:
FileTransDlg* m_parent;
void addFile(const CString& file, const CString& path);
int m_rowID;
std::vector< std::string> getSelFiles();
std::vector< std::string> getAllFiles();
void removeSel();
void removeAll();
void mark( std::vector< std::string>& vecs);
void showPopupMenu();
};
--- NEW FILE: ScriptEnumAttrValue.h ---
#pragma once
#include "script.h"
class ScriptEnumAttrValue :
public Script
{
public:
ScriptEnumAttrValue(void);
~ScriptEnumAttrValue(void);
virtual CString instantiat2( const std::vector< std::string >& pars, std::ostream& pstream);
};
--- NEW FILE: FileTransDlg.cpp ---
// FileTransDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CMgaXslt.h"
#include "ModelMigrate.h"
#include "FileTransDlg.h"
#include "RuleEditorDlg.h"
#include "Validator.h"
#include "OptionsDlg.h"
#include "AboutDlg.h"
#include <afxwin.h>
#include ".\filetransdlg.h"
#define DEF_APPEND_STR "_out"
#define DEF_OUTPUTDIR_STR ""
/*static*/ CString FileTransDlg::m_strSection = "Options";
/*static*/ CString FileTransDlg::m_strDirStringItem = "DefaultDir";
/*static*/ CString FileTransDlg::m_strScrStringItem = "DefaultScr";
/*static*/ CString FileTransDlg::m_strAppendStringItem = "AppendedString";
/*static*/ CString FileTransDlg::m_strAppendStr = DEF_APPEND_STR;
/*static*/ CString FileTransDlg::m_strOutputDirStringItem = "OutputDir";
/*static*/ CString FileTransDlg::m_strOutputDirStr = DEF_OUTPUTDIR_STR;
// FileTransDlg dialog
IMPLEMENT_DYNAMIC(FileTransDlg, CDialog)
FileTransDlg::FileTransDlg(CWnd* pParent /*=NULL*/)
: CDialog(FileTransDlg::IDD, pParent)
, m_cx( 0)
, m_cy( 0)
, m_dlgRuleEditor( 0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
FileTransDlg::~FileTransDlg()
{
closeDlgRuleEditor(IDCANCEL);
m_dlgRuleEditor = 0;
}
void FileTransDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LISTFILES, m_lstFiles);
DDX_Control(pDX, IDC_EDIT4, m_log);
DDX_Control(pDX, IDC_LISTSCRIPT, m_lstScript);
}
BEGIN_MESSAGE_MAP(FileTransDlg, CDialog)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_SIZING()
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedRuleEditor)
ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton5)
ON_BN_CLICKED(IDC_BUTTON6, OnBnClickedButton6)
ON_BN_CLICKED(IDC_BUTTONCLEAR, OnBnClickedButtonclear)
ON_BN_CLICKED(IDC_BUTTON8, OnBnClickedButton8)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_NOTIFY(LVN_KEYDOWN, IDC_LISTSCRIPT, OnLvnKeydownListscript)
ON_NOTIFY(LVN_KEYDOWN, IDC_LISTFILES, OnLvnKeydownListfiles)
END_MESSAGE_MAP()
// FileTransDlg message handlers
BOOL FileTransDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//HACCEL hA = LoadAccelerators( 0, "IDR_MAINACCELERATOR");
///BOOL res = TranslateAccelerator( GetSafeHwnd(), hA, 0);
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_lstFiles.m_parent = this;
m_lstScript.m_parent = this;
CWinApp* pApp = AfxGetApp();
CString strV1, strV2, strV3, strV4 ;
loadMyOptions( strV1, strV2, strV3, strV4);
loadDir( strV1);
CString conn( strV2);
if( !strV2.IsEmpty())
{
int pos = conn.ReverseFind('\\');
if( pos != -1)
m_lstScript.addFile( conn.Right( conn.GetLength() - pos - 1), conn);
else
m_lstScript.addFile( conn, conn);
}
FileTransDlg::m_strAppendStr = strV3.IsEmpty()? DEF_APPEND_STR:strV3;
FileTransDlg::m_strOutputDirStr = strV4;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
int FileTransDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rect;
GetWindowRect( &rect);
m_cy = rect.bottom;
m_cx = rect.right;
return 0;
}
void FileTransDlg::OnSizing(UINT fwSide, LPRECT pRect)
{
const int desiredX = 300, desiredY = 300;
if( pRect->bottom - pRect->top > desiredY
&& pRect->right - pRect->left > desiredX)
CDialog::OnSizing(fwSide, pRect);
else
{
if( pRect->bottom - pRect->top < desiredY) pRect->bottom = pRect->top + desiredY;
if( pRect->right - pRect->left < desiredX) pRect->right = pRect->left + desiredX;
}
}
void FileTransDlg::OnSize(UINT nType, int cx, int cy)
{
if( cx < 150) cx = 150; // these are not preventing the user to make the window to small
if( cy < 150) cy = 150; // just prevent the controls to be shuffled when cx,cy are very close to 0
CDialog::OnSize(nType, cx, cy);
if( nType == SIZE_MINIMIZED) return;
m_cx = cx;
m_cy = cy;
CRect rect, r1, r2;
int sy = 0;
if( cx && cy && m_lstFiles.GetSafeHwnd() && m_log.GetSafeHwnd()) // if minimized cx == cy == 0
{
m_lstFiles.GetWindowRect( &r1); ScreenToClient( &r1);
m_log.GetWindowRect( &r2); ScreenToClient( &r2);
rect = r1;
sy = (cy - r1.top)*3/5;
rect.bottom = rect.top + sy;
rect.right = cx - rect.left; // maintain margin
m_lstFiles.SetWindowPos( 0, 0, 0, rect.Width(), rect.Height(), SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW);
rect.top = rect.bottom + r2.top - r1.bottom;
rect.bottom = cy - 13;
rect.right = cx - rect.left; // maintain margin
m_log.SetWindowPos( 0, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER|SWP_SHOWWINDOW);
}
}
void FileTransDlg::OnBnClickedRuleEditor()
{
ruleEditor();
}
void FileTransDlg::OnBnClickedButton2()
{
selDir();
}
void FileTransDlg::OnBnClickedButton6()
{
selFile();
}
void FileTransDlg::OnBnClickedButton3()
{
CFileDialog dlg( TRUE, "xsl", 0, 0,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
m_lstScript.addFile( dlg.GetFileName(), dlg.GetPathName());
}
}
void FileTransDlg::OnBnClickedButton4()
{
processAll();
}
void FileTransDlg::OnBnClickedButton8()
{
processSel();
}
void FileTransDlg::OnBnClickedButton5()
{
options();
}
void FileTransDlg::options()
{
OptionsDlg dlg;
// load the current values from registry
loadMyOptions( dlg.m_dir, dlg.m_scr, dlg.m_append, dlg.m_outputDir);
if( dlg.m_append.IsEmpty()) dlg.m_append = FileTransDlg::m_strAppendStr;
if( dlg.DoModal() == IDOK)
{
// store the freshly modified options in static members
FileTransDlg::m_strAppendStr = dlg.m_append;
FileTransDlg::m_strOutputDirStr = dlg.m_outputDir;
// save into registry
saveMyOptions( dlg.m_dir, dlg.m_scr, dlg.m_append, dlg.m_outputDir);
}
}
void FileTransDlg::ruleEditor()
{
// stored by a member variable
if( !m_dlgRuleEditor)
{
m_dlgRuleEditor = new RuleEditorDlg();
}
if( m_dlgRuleEditor->m_closed)
{
m_dlgRuleEditor->Create( RuleEditorDlg::IDD, this);
m_dlgRuleEditor->ShowWindow( SW_SHOWNORMAL);
}
m_dlgRuleEditor->SetActiveWindow();
}
void FileTransDlg::validatorGen()
{
CFileDialog dlg( TRUE, 0, 0, 0,
"Paradigms (*.xmp)|*.xmp|Parsed Paradigms (*.parsed)|*.parsed|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
CString fn = dlg.GetPathName();
int pos = fn.Find( '.');
CString defname = fn.Left( pos) + "_validator.xsl";
CFileDialog sdlg( FALSE, ".xsl", defname, OFN_OVERWRITEPROMPT,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( sdlg.DoModal() == IDOK)
{
Validator::job( dlg.GetPathName(), sdlg.GetPathName());
}
}
}
void FileTransDlg::selFile()
{
CFileDialog dlg( TRUE, "xme", 0, OFN_ALLOWMULTISELECT|OFN_EXPLORER,
"XME Files (*.xme;*.xml)|*.xme; *.xml|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
//m_lstFiles.addFile( dlg.GetFileName(), dlg.GetPathName());
POSITION pos = dlg.GetStartPosition();
while( pos)
{
CString path = dlg.GetNextPathName( pos);
CFileFind ff;
if(ff.FindFile(path))
{
ff.FindNextFile();
m_lstFiles.addFile( ff.GetFileName(), path);
}
}
}
}
void FileTransDlg::selDir()
{
CString d = FileTransDlg::getDirectory();
if( !d.IsEmpty())
loadDir( d);
}
void FileTransDlg::loadDir( CString pDir)
{
CFileFind finder;
BOOL bWorking = finder.FindFile( pDir + "\\*.xme");
while (bWorking)
{
bWorking = finder.FindNextFile();
m_lstFiles.addFile( finder.GetFileName(), finder.GetFilePath());
}
}
void FileTransDlg::process( const std::vector< std::string>& pToRun)
{
std::vector< std::string> scripts = m_lstScript.getAllFiles();
if( scripts.size() == 0 || scripts[0].empty()) { appendLn( "Invalid or no entries in script list!"); return; }
bool multi = scripts.size() > 1;
CString xsltScript, f_In, f_Out, f_OrigOut;
appendLn( "Processing started on " + CTime::GetCurrentTime().Format("%b %d, %H:%M:%S"));
std::vector<std::string> ok;
std::vector<std::string> fail;
for( unsigned int i = 0; i < pToRun.size(); ++i)
{
CString err;
f_Out = f_In = pToRun[i].c_str();
// transform a 'file.xme' to 'file_out.xme' in single case
// to 'file_out01.xme' multiple case
int dpos = f_Out.ReverseFind('.');
if( dpos == -1) f_Out += FileTransDlg::m_strAppendStr;
else f_Out.Insert( dpos, FileTransDlg::m_strAppendStr + (multi?"01":""));
// change the output directory if specified
if( directoryExists( FileTransDlg::m_strOutputDirStr)) // status fetched succesfully
{
dpos = f_Out.ReverseFind('\\');
if( dpos == -1) // not found '\\'
{
f_Out.Insert( 0, '\\');
f_Out.Insert( 0, FileTransDlg::m_strOutputDirStr);
}
else
{
f_Out = FileTransDlg::m_strOutputDirStr + '\\' + f_Out.Right( f_Out.GetLength() - dpos - 1);
}
}
xsltScript = scripts[0].c_str();
// do the 1st step separately
apply( xsltScript, f_In, f_Out, err);
// analyze error
if( !err.IsEmpty())
{
fail.push_back( pToRun[i]);
appendLn( f_In + (multi?" step 1 in":"") + " transformation failed: " + err);
}
else
{
ok.push_back( (LPCTSTR) f_Out);
appendLn( f_In + (multi?" step 1 in":"") + " transformation OK.");
}
if( multi)
{
bool any_error = false;
dpos = f_Out.ReverseFind('.');
if( dpos != -1 && dpos >= 2) f_OrigOut = f_Out.Left( dpos-2); // "01" was already there
else f_OrigOut = f_Out;
// do the remaining steps
for( unsigned int j = 1; err.IsEmpty() && j < scripts.size(); ++j)
{
err.Empty();
CString j_str;
if( j+1 != scripts.size()) // the intermediate files look like: a_out01.xme
j_str.Format( "%.2d", j+1);
f_In = f_Out;
f_Out = f_OrigOut + j_str + ".xme";
xsltScript = scripts[j].c_str();
// invoke step i
apply( xsltScript, f_In, f_Out, err);
j_str.Format( "%d", j+1);
if( !err.IsEmpty())
{
fail.push_back( pToRun[i]); // the original file is marked
any_error = true;
appendLn( f_In + " step " + j_str + " in" + " transformation failed: " + err);
}
else
{
ok.push_back( (LPCTSTR) f_Out);
appendLn( f_In + " step " + j_str + " in" + " transformation OK.");
}
}
appendLn( CString( pToRun[i].c_str()) + " succesfully transformed to " + f_Out);
appendLn( "");
}
}
// mark the failed file list with 'failed'
m_lstFiles.mark( fail);
appendLn( CString( '=', 80));
for( unsigned int i = 0; i < ok.size(); ++i)
{
if( i == 0) appendLn( "Successful cases:");
appendLn( ok[i].c_str());
}
appendLn( CString( '-', 160));
for( unsigned int i = 0; i < fail.size(); ++i)
{
if( i == 0) appendLn( "Failed cases:");
appendLn( fail[i].c_str());
}
}
void FileTransDlg::processSel()
{
process( m_lstFiles.getSelFiles());
}
void FileTransDlg::processAll()
{
process( m_lstFiles.getAllFiles());
}
void FileTransDlg::selScript()
{
CFileDialog dlg( TRUE, "xsl", 0, OFN_ALLOWMULTISELECT|OFN_EXPLORER,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
//m_lstScript.addFile( dlg.GetFileName(), dlg.GetPathName());
POSITION pos = dlg.GetStartPosition();
while( pos)
{
CString path = dlg.GetNextPathName( pos);
CFileFind ff;
if(ff.FindFile(path))
{
ff.FindNextFile();
m_lstScript.addFile( ff.GetFileName(), path);
}
}
}
}
void FileTransDlg::selScriptDir()
{
CString d = FileTransDlg::getDirectory( "Load .xsl and .xslt files from directory");
if( !d.IsEmpty())
loadScriptDir( d);
}
void FileTransDlg::loadScriptDir( CString pDir)
{
CFileFind finder;
BOOL bWorking = finder.FindFile( pDir + "\\*.xsl");
while (bWorking)
{
bWorking = finder.FindNextFile();
m_lstScript.addFile( finder.GetFileName(), finder.GetFilePath());
}
bWorking = finder.FindFile( pDir + "\\*.xslt");
while (bWorking)
{
bWorking = finder.FindNextFile();
m_lstScript.addFile( finder.GetFileName(), finder.GetFilePath());
}
}
void FileTransDlg::apply( CString pScrF, CString pInF, CString pOutF, CString& f4)
{
CXslt::doNativeXslt( pScrF, pInF, pOutF, f4);
}
void FileTransDlg::loadMyOptions( CString& pStrVal1, CString& pStrVal2, CString& pStrVal3, CString& pStrVal4)
{
CWinApp* pApp = AfxGetApp();
pStrVal1 = pApp->GetProfileString( m_strSection, m_strDirStringItem);
pStrVal2 = pApp->GetProfileString( m_strSection, m_strScrStringItem);
pStrVal3 = pApp->GetProfileString( m_strSection, m_strAppendStringItem);
pStrVal4 = pApp->GetProfileString( m_strSection, m_strOutputDirStringItem);
}
void FileTransDlg::saveMyOptions( const CString& pStrVal1, const CString& pStrVal2, const CString& pStrVal3, const CString& pStrVal4)
{
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString( m_strSection, m_strDirStringItem, pStrVal1);
pApp->WriteProfileString( m_strSection, m_strScrStringItem, pStrVal2);
pApp->WriteProfileString( m_strSection, m_strAppendStringItem, pStrVal3);
pApp->WriteProfileString( m_strSection, m_strOutputDirStringItem, pStrVal4);
}
CString FileTransDlg::getDirectory( const CString& text)
{
BROWSEINFO bi;
TCHAR szDir[MAX_PATH];
CString Dir = "";
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
OleInitialize(NULL);
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
ZeroMemory(&bi,sizeof(bi));
bi.hwndOwner = NULL;
bi.pszDisplayName = 0;
bi.lpszTitle = text;
bi.pidlRoot = 0;
bi.ulFlags = BIF_BROWSEINCLUDEFILES | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_EDITBOX | BIF_VALIDATE ;
bi.lpfn = NULL;
//Displays a dialog box that enables the user to select a shell folder
pidl = SHBrowseForFolder(&bi) ;
if (pidl)
{
// Converts an item identifier list to a file system path
if (!SHGetPathFromIDList(pidl,szDir))
{
pMalloc->Free(pidl) ;
pMalloc->Release() ;
}
pMalloc->Free(pidl);
pMalloc->Release();
}
else
{ // Selected 'Not to save'
return "";
}
Dir = szDir;
//Dir += "\\";
}
// end of getting directory info
return Dir;
}
void FileTransDlg::closeDlgRuleEditor( int nRes)
{
if( m_dlgRuleEditor)
{
if( m_dlgRuleEditor->GetSafeHwnd())
{
m_dlgRuleEditor->EndDialog( nRes);
m_dlgRuleEditor->DestroyWindow();
}
delete m_dlgRuleEditor;
m_dlgRuleEditor = 0;
}
}
void FileTransDlg::OnOK()
{
//IDOK is used for other purposes
//closeDlgRuleEditor( IDOK);
}
void FileTransDlg::OnCancel()
{
if( AfxMessageBox( "Do you really want to exit?", MB_YESNOCANCEL) == IDYES)
{
closeDlgRuleEditor( IDCANCEL);
EndDialog( IDCANCEL);
DestroyWindow();
}
}
void FileTransDlg::appendLn( CString t)
{
appendLog( t);
appendLog( "\r\n");
}
void FileTransDlg::appendLog( CString t)
{
CString old;
m_log.GetWindowText( old);
old.Append( t);
m_log.SetWindowText( old);
m_log.LineScroll( m_log.GetLineCount());
}
void FileTransDlg::clearLog()
{
m_log.SetWindowText("");
}
bool FileTransDlg::directoryExists( const CString& dir)
{
bool res = false;
CFileStatus stat;
if( !dir.IsEmpty() // not-empty string
&& CFile::GetStatus( dir, stat)) // status fetched succesfully
{
if( (stat.m_attribute & CFile::directory) == CFile::directory // it is a directory
&& (stat.m_attribute & CFile::readOnly) == 0) // not read only
{
res = true;
}
}
return res;
}
void FileTransDlg::OnBnClickedButtonclear()
{
clearLog();
}
void FileTransDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
AboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void FileTransDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
BOOL FileTransDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch( wParam) {
case IDOK: onReturn(); break;
case ID_SCRIPTS_ADD: selScript(); break;
case ID_SCRIPTS_ADDDIRECTORY: selScriptDir(); break;
case ID_SCRIPTS_REMOVEALL: m_lstScript.removeAll(); break;
case ID_SCRIPTS_REMOVESELECTED: m_lstScript.removeSel(); break;
case ID_FILES_ADDFILE: selFile(); break;
case ID_FILES_ADDDIRECTORY: selDir(); break;
case ID_FILES_REMOVEALL: m_lstFiles.removeAll(); break;
case ID_FILES_REMOVESELECTED: m_lstFiles.removeSel(); break;
case ID_RULES_EDITRULES: ruleEditor(); break;
case ID_RULES_VALIDATE: validatorGen(); break;
case ID_PROCESSING_PROCESSALL: processAll(); break;
case ID_PROCESSING_PROCESSSELECTED: processSel(); break;
case ID_MISC_OPTIONS: options(); break;
case ID_MISC_CLEARLOG: clearLog(); break;
};
return CDialog::OnCommand(wParam, lParam);
}
void FileTransDlg::onReturn()
{
CWnd* child = this->GetFocus();
if( !child) return;
if( child == GetDlgItem(IDC_LISTSCRIPT))
{ ; } // do nothing
else if( child == GetDlgItem(IDC_LISTFILES))
processSel();
}
void FileTransDlg::OnLvnKeydownListscript(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
NMLVKEYDOWN &s = *pLVKeyDow;
bool cntrl = GetKeyState( VK_CONTROL) < 0;
bool shft = GetKeyState( VK_SHIFT) < 0;
bool alt = GetKeyState( VK_MENU) < 0; // alt key
if( s.wVKey == VK_APPS) m_lstScript.showPopupMenu();
if( s.wVKey == VK_F3 || s.wVKey == VK_INSERT && !cntrl) // F3, INS - Add Script
SendMessage( WM_COMMAND, ID_SCRIPTS_ADD, 0);
if( s.wVKey == VK_F4 && !alt || s.wVKey == VK_INSERT && cntrl) // F4, CTRL INS - Add Script Dir (but not ALT+F4)
SendMessage( WM_COMMAND, ID_SCRIPTS_ADDDIRECTORY, 0);
if( s.wVKey == VK_DELETE && !cntrl)
SendMessage( WM_COMMAND, ID_SCRIPTS_REMOVESELECTED, 0); // DEL - Remove Sel
if( s.wVKey == VK_DELETE && cntrl)
SendMessage( WM_COMMAND, ID_SCRIPTS_REMOVEALL, 0); // CTRL DEL - Remove All
if(( s.wVKey == IDOK || s.wVKey == VK_RETURN || s.wVKey == VK_F5) && !cntrl) // F5 - Run Sel
SendMessage( WM_COMMAND, ID_PROCESSING_PROCESSSELECTED, 0);
if(( s.wVKey == IDOK || s.wVKey == VK_RETURN || s.wVKey == VK_F5) && cntrl) // CTRL F5 - Run All
SendMessage( WM_COMMAND, ID_PROCESSING_PROCESSALL, 0);
*pResult = 0;
}
void FileTransDlg::OnLvnKeydownListfiles(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
NMLVKEYDOWN &s = *pLVKeyDow;
bool cntrl = GetKeyState( VK_CONTROL) < 0;
bool shft = GetKeyState( VK_SHIFT) < 0;
if( s.wVKey == VK_APPS) m_lstFiles.showPopupMenu();
if( s.wVKey == VK_F6 || s.wVKey == VK_INSERT && !cntrl) // F6, INS - Add File
SendMessage( WM_COMMAND, ID_FILES_ADDFILE, 0);
if( s.wVKey == VK_F7 || s.wVKey == VK_INSERT && cntrl) // F7, CTRL INS - Add Dir
SendMessage( WM_COMMAND, ID_FILES_ADDDIRECTORY, 0);
if( s.wVKey == VK_DELETE && !cntrl) // DEL - Remove Sel
SendMessage( WM_COMMAND, ID_FILES_REMOVESELECTED, 0);
if( s.wVKey == VK_DELETE && cntrl) // CTRL DEL - Remove All
SendMessage( WM_COMMAND, ID_FILES_REMOVEALL, 0);
if(( s.wVKey == IDOK || s.wVKey == VK_RETURN || s.wVKey == VK_F5) && !cntrl) // F5 - Run Sel
SendMessage( WM_COMMAND, ID_PROCESSING_PROCESSSELECTED, 0);
if(( s.wVKey == IDOK || s.wVKey == VK_RETURN || s.wVKey == VK_F5) && cntrl) // CTRL F5 - Run All
SendMessage( WM_COMMAND, ID_PROCESSING_PROCESSALL, 0);
*pResult = 0;
}
--- NEW FILE: EnumAttrValueDlg.cpp ---
// EnumAttrValueDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "EnumAttrValueDlg.h"
#include ".\enumattrvaluedlg.h"
#include "AttrGlobalDlg.h"
// EnumAttrValueDlg dialog
IMPLEMENT_DYNAMIC(EnumAttrValueDlg, CDialog)
EnumAttrValueDlg::EnumAttrValueDlg(CWnd* pParent /*=NULL*/)
: CDialog(EnumAttrValueDlg::IDD, pParent)
, m_enumAttr(_T(""))
, m_newEnumV(_T(""))
, m_global(_T("1"))
, m_owner(_T(""))
{
}
EnumAttrValueDlg::~EnumAttrValueDlg()
{
}
void EnumAttrValueDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_enumAttr);
DDX_Text(pDX, IDC_EDIT2, m_oldEnumV);
DDX_Text(pDX, IDC_EDIT3, m_newEnumV);
}
BEGIN_MESSAGE_MAP(EnumAttrValueDlg, CDialog)
ON_BN_CLICKED(IDGLOBAL, OnBnClickedGlobal)
END_MESSAGE_MAP()
// EnumAttrValueDlg message handlers
const CString& EnumAttrValueDlg::getPar1() const
{
return m_enumAttr;
}
const CString& EnumAttrValueDlg::getPar2() const
{
return m_oldEnumV;
}
const CString& EnumAttrValueDlg::getPar3() const
{
return m_newEnumV;
}
const CString& EnumAttrValueDlg::getPar4() const
{
return m_global;
}
const CString& EnumAttrValueDlg::getPar5() const
{
return m_owner;
}
void EnumAttrValueDlg::init( const CString& par1, const CString& par2, const CString& par3, const CString& par4, const CString& par5)
{
m_enumAttr = par1;
m_oldEnumV = par2;
m_newEnumV = par3;
m_global = par4;
m_owner = par5;
}
void EnumAttrValueDlg::OnBnClickedGlobal()
{
AttrGlobalDlg dlg( m_global, m_owner);
if( dlg.DoModal() == IDOK)
{
m_global = dlg.getGlobal();
m_owner = dlg.getOwner();
}
}
--- NEW FILE: CMgaXslt.cpp ---
#include "stdafx.h"
#include "CMgaXslt.h"
#define DISPATCH_XSLT 0
#if(DISPATCH_XSLT)
// it seems Mga.MgaXSLT is not really Dispatch compatible yet
#else
// in this case we use MIDL produced h file from an idl file which includes only the gme idls
#include "..\IDLComp\GMEIDLs_h.h"
#endif
void CXslt::doNativeXslt( LPCTSTR pScrF, LPCTSTR pInF, LPCTSTR pOutF, CString& resError)
{
// native vtable based
CComPtr<IMgaXslt> xslt;
HRESULT hr = xslt.CoCreateInstance(L"Mga.MgaXslt");
ASSERT( xslt != NULL );
if( FAILED( hr) || xslt == NULL) { resError = "COM Error at CreateInstance!"; return; }
CComBSTR x_scr( pScrF);
CComBSTR f_iin( pInF);
CComBSTR f_out( pOutF);
CComBSTR error;
try
{
hr = xslt->ApplyXslt( x_scr, f_iin, f_out, &error);
if( FAILED( hr)) throw hr;
} catch( HRESULT&)
{
if( error && error.Length() > 0)
resError = COLE2T( error);
else
resError = "COM Error!";
}
}
void CXslt::doDispatchXslt( LPCTSTR pScrF, LPCTSTR pInF, LPCTSTR pOutF, CString& resError)
{
// dispatch based, if it worked
CComPtr<IUnknown> unknwn;
HRESULT hr;
hr = unknwn.CoCreateInstance( L"Mga.MgaXslt");
if( FAILED( hr)) { resError = "COM Error at CreateInstance!"; return; }
CComPtr<IDispatch> disp;
hr = unknwn.QueryInterface( &disp);
if( FAILED( hr)) { resError = "COM Error at QueryInterface!"; return; }
CMgaXsltDriver xslt( disp);
CComBSTR error;
try
{
hr = xslt.ApplyXslt( pScrF, pInF, pOutF, &error);
if( FAILED( hr)) throw hr;
} catch( HRESULT&)
{
if( error && error.Length() > 0)
resError = COLE2T( error);
else // error is empty
resError = "COM Error";
}
}
--- NEW FILE: FrontEndDlg.h ---
// FrontEndDlg.h : header file
//
#pragma once
#include "afxcmn.h"
#include "RuleListCtrl.h"
#include "afxwin.h"
// CFrontEndDlg dialog
class CFrontEndDlg : public CDialog
{
// Construction
public:
CFrontEndDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_FRONTEND_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
virtual void OnCancel();
// Implementation
protected:
void closeDlg( int pResult = 0);
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg void OnLbnDblclkList2();
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedButton2();
DECLARE_MESSAGE_MAP()
public:
RuleListCtrl m_list;
CListBox m_choice;
};
--- NEW FILE: AttrTypeChangeDlg.h ---
#pragma once
#include "afxwin.h"
// AttrTypeChangeDlg dialog
class AttrTypeChangeDlg : public CDialog
{
DECLARE_DYNAMIC(AttrTypeChangeDlg)
public:
AttrTypeChangeDlg(CWnd* pParent = NULL); // standard constructor
virtual ~AttrTypeChangeDlg();
// Dialog Data
enum { IDD = IDD_DLG_PROPATTRTYPECHANGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
protected:
CString m_attrName;
BOOL m_bTerm;
CString m_global;
CString m_owner;
protected:
static void genSeparateScript( CString pAttrName, CString pFileName, bool pGlobal, CString pOwner);
public:
void init( const CString& par1, const CString& par2, const CString& par3, const CString& par4);
const CString& getPar1() const;
CString getPar2() const;
const CString& getPar3() const;
const CString& getPar4() const;
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedGlobal();
};
--- NEW FILE: OptionsDlg.h ---
#pragma once
// OptionsDlg dialog
class OptionsDlg : public CDialog
{
DECLARE_DYNAMIC(OptionsDlg)
public:
OptionsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~OptionsDlg();
// Dialog Data
enum { IDD = IDD_DLG_OPTIONS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
DECLARE_MESSAGE_MAP()
public:
CString m_dir;
CString m_scr;
CString m_append;
CString m_outputDir;
afx_msg void OnBnClickedButton1();
afx_msg void OnBnClickedButton6();
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedButton7();
};
--- NEW FILE: ModelMigrate.h ---
// ModelMigrate.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
// CModelMigrateApp:
// See ModelMigrate.cpp for the implementation of this class
//
class CModelMigrateApp : public CWinApp
{
public:
CModelMigrateApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CModelMigrateApp theApp;
--- NEW FILE: Validator.cpp ---
#include "StdAfx.h"
#include ".\validator.h"
#include "Extractor.h"
#include "ScriptAbs.h"
#include "ScriptCmplx.h"
Validator::Validator(void)
{
}
Validator::~Validator(void)
{
}
void Validator::job( LPCTSTR lpszPathNameIn, LPCTSTR lpszPathNameOut)
{
Extractor extr;
std::string fName( lpszPathNameIn);
size_t dpos = fName.rfind('.');
if( dpos != std::string::npos && fName.substr( dpos).compare( ".parsed") == 0) // '.' found, and ends with '.parsed'
extr.doPlainLoad( fName);
else
extr.doJob( fName);
ScriptAbs* scr = new ScriptCmplx();
scr->gen( extr.getKinds(), extr.getAttrs(), lpszPathNameOut);
delete scr;
}
--- NEW FILE: CMgaXslt.h ---
class CXslt
{
public:
static void doNativeXslt( LPCTSTR stylesheet, LPCTSTR infile, LPCTSTR outfile, CString& error);
static void doDispatchXslt( LPCTSTR stylesheet, LPCTSTR infile, LPCTSTR outfile, CString& error);
};
// CMgaXsltDriver wrapper class
class CMgaXsltDriver : public COleDispatchDriver
{
public:
CMgaXsltDriver(){} // Calls COleDispatchDriver default constructor
CMgaXsltDriver(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
CMgaXsltDriver(const CMgaXsltDriver& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}
// Attributes
public:
// Operations
public:
// IMgaXslt methods
public:
STDMETHOD(ApplyXslt)(LPCTSTR stylesheet, LPCTSTR infile, LPCTSTR outfile, BSTR * error)
{
HRESULT result;
static BYTE parms[] = VTS_BSTR VTS_BSTR VTS_BSTR VTS_PBSTR ;
InvokeHelper(0x60020000, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms, stylesheet, infile, outfile, error);
return result;
}
// IMgaXslt properties
public:
};
--- NEW FILE: stdafx.h ---
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxdhtml.h>
--- NEW FILE: stdafx.cpp ---
// stdafx.cpp : source file that includes just the standard includes
// FrontEnd.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
--- NEW FILE: OptionsDlg.cpp ---
// OptionsDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "OptionsDlg.h"
#include ".\optionsdlg.h"
#include "FileTransDlg.h"
// OptionsDlg dialog
IMPLEMENT_DYNAMIC(OptionsDlg, CDialog)
OptionsDlg::OptionsDlg(CWnd* pParent /*=NULL*/)
: CDialog(OptionsDlg::IDD, pParent)
, m_dir(_T(""))
, m_scr(_T(""))
, m_append(_T(""))
{
}
OptionsDlg::~OptionsDlg()
{
}
void OptionsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_dir);
DDX_Text(pDX, IDC_EDIT2, m_scr);
DDX_Text(pDX, IDC_EDIT5, m_append);
DDX_Text(pDX, IDC_EDIT6, m_outputDir);
}
BEGIN_MESSAGE_MAP(OptionsDlg, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON6, OnBnClickedButton6)
ON_BN_CLICKED(IDC_BUTTON7, OnBnClickedButton7)
END_MESSAGE_MAP()
// OptionsDlg message handlers
void OptionsDlg::OnBnClickedButton1()
{
UpdateData( TRUE);
CString dir = FileTransDlg::getDirectory("Load .xme files on startup from this directory");
if( !dir.IsEmpty())
{
m_dir = dir;
}
UpdateData( FALSE);
}
void OptionsDlg::OnBnClickedButton6()
{
UpdateData( TRUE);
CFileDialog dlg( TRUE, "xsl", 0, 0,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
m_scr = dlg.GetPathName();
}
UpdateData( FALSE);
}
BOOL OptionsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void OptionsDlg::OnBnClickedButton7()
{
UpdateData( TRUE);
CString dir = FileTransDlg::getDirectory("Please specify a target directory for artifact .xme files");
if( !dir.IsEmpty())
{
m_outputDir = dir;
}
UpdateData( FALSE);
}
void OptionsDlg::OnOK()
{
UpdateData( TRUE);
if( m_outputDir.Right(1) == '\\')
m_outputDir.Truncate( m_outputDir.GetLength() - 1);// delete trailing '\\'
UpdateData( FALSE);
if( m_outputDir.IsEmpty() && m_append.IsEmpty())
{
AfxMessageBox( "The scripts must save output to a destination file different from the source file.\nEither select a target directory or specify a string which will be appended to destination filenames!");
}
else if( !m_outputDir.IsEmpty() && !FileTransDlg::directoryExists( m_outputDir))
{
AfxMessageBox( "Invalid target directory specified!");
}
else
{
CDialog::OnOK();
}
}
--- NEW FILE: FileTransDlg.h ---
#pragma once
#include "afxcmn.h"
#include "FileListCtrl.h"
#include "ScriptListCtrl.h"
#include "RuleEditorDlg.h"
#include "Log.h"
#include "afxwin.h"
// FileTransDlg dialog
class FileTransDlg : public CDialog
{
DECLARE_DYNAMIC(FileTransDlg)
public:
FileTransDlg(CWnd* pParent = NULL); // standard constructor
virtual ~FileTransDlg();
// Dialog Data
enum { IDD = IDD_DLG_FILETRANS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
public:
FileListCtrl m_lstFiles;
ScriptListCtrl m_lstScript;
Log m_log;//CEdit m_log;
HICON m_hIcon;
virtual BOOL OnInitDialog();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
afx_msg void OnBnClickedRuleEditor();
afx_msg void OnBnClickedButton2();
afx_msg void OnBnClickedButton3();
afx_msg void OnBnClickedButton4();
afx_msg void OnBnClickedButton5();
afx_msg void OnBnClickedButton6();
afx_msg void OnBnClickedButton8();
afx_msg void OnBnClickedButtonclear();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg void OnLvnKeydownListscript(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLvnKeydownListfiles(NMHDR *pNMHDR, LRESULT *pResult);
protected:
int m_cx;
int m_cy;
RuleEditorDlg * m_dlgRuleEditor;
void closeDlgRuleEditor( int nRes);
void loadDir( CString pDir);
void loadScriptDir( CString pDir);
void loadMyOptions( CString& pStrVal1, CString& pStrVal2, CString& pStrVal3, CString& pStrVal4);
void saveMyOptions( const CString& pStrVal1, const CString& pStrVal2, const CString& pStrVal3, const CString& pStrVal4);
void process( const std::vector< std::string>& pToRun);
void apply( CString f1, CString f2, CString f3, CString& f4);
void appendLog( CString t);
void appendLn( CString t);
void clearLog();
void onReturn();
public:
void selFile();
void selDir();
void processSel();
void processAll();
// misc
void ruleEditor();
void validatorGen();
void options();
// script related methods
void selScript();
void selScriptDir();
protected: // static strings
static CString m_strSection;
static CString m_strDirStringItem;
static CString m_strScrStringItem;
static CString m_strAppendStringItem;
static CString m_strAppendStr;
static CString m_strOutputDirStringItem;
static CString m_strOutputDirStr;
public: // public static methods
static CString getDirectory( const CString& text = "Load .xme files from directory");
static bool directoryExists( const CString& dir);
};
--- NEW FILE: Extractor.h ---
#pragma once
#include <string>
#include <vector>
#include <map>
class Extractor
{
public:
typedef std::vector<std::string> NAMES;
typedef std::map< std::string, std::string> ATTRS;
public:
Extractor(void);
~Extractor(void);
public:
void doJob( std::string& pFName);
void doPlainLoad( std::string& pFName);
const NAMES& getKinds();
const ATTRS& getAttrs();
protected:
void init();
NAMES m_names;
ATTRS m_attrs;
public:
static std::string get( const std::string& attr, const std::string& buff);
static NAMES tokenize( const std::string& pList);
};
--- NEW FILE: RemoveLocAttrDlg.h ---
#pragma once
#include "afxwin.h"
// RemoveLocalAttrDlg dialog
class RemoveLocalAttrDlg : public CDialog
{
DECLARE_DYNAMIC(RemoveLocalAttrDlg)
public:
RemoveLocalAttrDlg(CWnd* pParent = NULL); // standard constructor
virtual ~RemoveLocalAttrDlg();
// Dialog Data
enum { IDD = IDD_DLG_PROPREMOVELOCALATTR };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
void init( const CString& par1, const CString& par2);
const CString& getPar1() const;
const CString& getPar2() const;
protected:
CString m_attr;
CString m_owner;
};
--- NEW FILE: AttrTypeChangeDlg.cpp ---
// AttrTypeChangeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "AttrTypeChangeDlg.h"
#include ".\attrtypechangedlg.h"
#include "AttrGlobalDlg.h"
#include "Script.h"
#include <fstream>
// AttrTypeChangeDlg dialog
IMPLEMENT_DYNAMIC(AttrTypeChangeDlg, CDialog)
AttrTypeChangeDlg::AttrTypeChangeDlg(CWnd* pParent /*=NULL*/)
: CDialog(AttrTypeChangeDlg::IDD, pParent)
, m_attrName(_T(""))
, m_bTerm(FALSE)
, m_global(_T("1"))
, m_owner(_T(""))
{
}
AttrTypeChangeDlg::~AttrTypeChangeDlg()
{
}
void AttrTypeChangeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_attrName);
DDX_Check(pDX, IDC_CHECK1, m_bTerm);
}
BEGIN_MESSAGE_MAP(AttrTypeChangeDlg, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
ON_BN_CLICKED(IDGLOBAL, OnBnClickedGlobal)
END_MESSAGE_MAP()
void AttrTypeChangeDlg::init( const CString& par1, const CString& par2, const CString& par3, const CString& par4)
{
m_attrName = par1;
m_bTerm = par2 == "1";
m_global = par3;
m_owner = par4;
}
const CString& AttrTypeChangeDlg::getPar1() const
{
return m_attrName;
}
CString AttrTypeChangeDlg::getPar2() const
{
return m_bTerm?"1":"0";
}
const CString& AttrTypeChangeDlg::getPar3() const
{
return m_global;
}
const CString& AttrTypeChangeDlg::getPar4() const
{
return m_owner;
}
// AttrTypeChangeDlg message handlers
void AttrTypeChangeDlg::OnBnClickedButton1()
{
UpdateData( TRUE);
if( m_attrName.IsEmpty())
{
AfxMessageBox( "No Attribute Kind specified!");
return;
}
CFileDialog dlg( FALSE, ".xsl", m_attrName + "2IntCheck", OFN_OVERWRITEPROMPT,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
genSeparateScript( m_attrName, dlg.GetPathName(), m_global == "1", m_owner);
}
UpdateData( FALSE);
}
void AttrTypeChangeDlg::genSeparateScript( CString pAttrName, CString pOutputFileName, bool pGlobal, CString pOwner)
{
CString contents = Script::getXSLFromResource( "TAttrTypeCheck2Text.xsl").c_str();
contents.Replace( "##|par1|##", pAttrName);
// whether global or local attribute
if( pGlobal)
contents.Replace( "##|OPTIONALLOCALCONDITION|##", "");
else
{
if( pOwner == "") AfxMessageBox( "No owner specified for local attribute!");
CString toIns = " and ../@kind='" + pOwner + "'";
contents.Replace( "##|OPTIONALLOCALCONDITION|##", toIns);
}
std::fstream f;
f.open( (LPCTSTR) pOutputFileName, std::ios_base::out|std::ios_base::binary); // write out as is (not to mess with additional CR-s)
ASSERT( f.is_open());
if( !f.is_open())
{
AfxMessageBox( "Could not create target file!");
return;
}
if( !contents.IsEmpty())
{
f.write( (LPCTSTR) contents, (std::streamsize) contents.GetLength());
}
f.close();
AfxMessageBox( pOutputFileName + " saved. You can apply anytime this script to an xme file to check whether its '" + pAttrName + "' values are convertible to numbers.");
}
void AttrTypeChangeDlg::OnBnClickedGlobal()
{
AttrGlobalDlg dlg( m_global, m_owner);
if( dlg.DoModal() == IDOK)
{
m_global = dlg.getGlobal();
m_owner = dlg.getOwner();
}
}
--- NEW FILE: RemoveLocAttrDlg.cpp ---
// SimpleRepl.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "RemoveLocAttrDlg.h"
// RemoveLocalAttrDlg dialog
IMPLEMENT_DYNAMIC(RemoveLocalAttrDlg, CDialog)
RemoveLocalAttrDlg::RemoveLocalAttrDlg(CWnd* pParent /*=NULL*/)
: CDialog(RemoveLocalAttrDlg::IDD, pParent)
, m_attr(_T(""))
, m_owner(_T(""))
{
}
RemoveLocalAttrDlg::~RemoveLocalAttrDlg()
{
}
void RemoveLocalAttrDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_attr);
DDX_Text(pDX, IDC_EDIT2, m_owner);
}
BEGIN_MESSAGE_MAP(RemoveLocalAttrDlg, CDialog)
END_MESSAGE_MAP()
// RemoveLocalAttrDlg message handlers
const CString& RemoveLocalAttrDlg::getPar1() const
{
return m_attr;
}
const CString& RemoveLocalAttrDlg::getPar2() const
{
return m_owner;
}
void RemoveLocalAttrDlg::init( const CString& par1, const CString& par2)
{
m_attr = par1;
m_owner = par2;
}
--- NEW FILE: ScriptMoveUp.cpp ---
#include "StdAfx.h"
#include ".\ScriptMoveUp.h"
//<!-- =============================================================================== -->
//<!-- Kind movement in a hierarchy -->
//<!-- This template rule will unwrap a kind from enclosing containers -->
//<!-- =============================================================================== -->
//
//<!-- movement -->
//<xsl:template match="*[@kind='##|par3|##']">
//
// <xsl:copy>
// <xsl:apply-templates select="@*"/>
// <xsl:apply-templates/>
// </xsl:copy>
//
// <!-- any kind of ##|par3|##/##|par2|##/##|par1|## becomes a sybling of ##|par3|## -->
// <xsl:copy-of select="*[./@kind='##|par2|##']/*[./@kind='##|par1|##']">
// </xsl:copy-of>
//</xsl:template>
//
//<!-- ignoring it in the old place -->
//<xsl:template match="*[./@kind='##|par1|##' and ../@kind='##|par2|##' and ../../@kind='##|par3|##']">
// <xsl:comment> Item moved from here: <xsl:value-of select="@id"/></xsl:comment>
//</xsl:template>
const char * strGeneralHeaderUp = "\
<!-- =============================================================================== -->\r\n\
<!-- Kind movement up in a hierarchy -->\r\n\
<!-- This template rule will unwrap a kind from enclosing containers -->\r\n\
<!-- =============================================================================== -->\r\n\
\r\n\r\n";
// <!-- movement -->
const char * strMovementHead1 = "\
<!-- movement -->\r\n\
<xsl:template match=\"*[@kind='"; // ##|par3|## will be inserted here
const char * strMovementHead3 = "\
']\">\r\n";
const char * strMovementBody1 = "\
\r\n\
\t<xsl:copy>\r\n\
\t<xsl:apply-templates select=\"@*\"/>\r\n\
\t<xsl:apply-templates/>\r\n\
\t</xsl:copy>\r\n\
\r\n";
const char * strMovementBodyComment1 = "\
\t<!-- each "; // sequence like: ##|par3|##/##|par2|##/##|par1|##
const char * strMovementBodyComment3 = "\
becomes a sybling of "; // element : ##|par3|##
const char * strMovementBodyComment5 = "-->\r\n";
const char * strMovementBody2 = "\
\t<xsl:copy-of select=\"";
// sequence like: *[./@kind='##|par2|##']/*[./@kind='##|par1|##']
const char * strMovementBody4 = "\"/>\r\n\
\r\n";
const char * strMovementTail = "</xsl:template>\r\n\r\n";
// <!-- ignoring -->
const char * strDisregardBegin1 = "<!-- ignoring "; // elem: ##|par1|##
const char * strDisregardBegin3 = " in the old place -->\r\n\
<xsl:template match=\"*["; // ./@kind='##|par1|##' and ../@kind='##|par2|##' and ../../@kind='##|par3|##'
const char * strDisregardEnd = "]\">\r\n\
\t<xsl:comment> Item moved from here: <xsl:value-of select=\"@id\"/></xsl:comment>\r\n\
</xsl:template>\r\n\
\r\n";
ScriptMoveUp::ScriptMoveUp(void)
{
}
ScriptMoveUp::~ScriptMoveUp(void)
{
}
CString ScriptMoveUp::instantiat2( const std::vector< std::string >& pars, std::ostream& pstream)
{
// pars contains the hierarchy that will be eliminated
// pars.back() contains the element that will survive (moved up)
ASSERT( pars.size() >= 2);
std::string elemContn = pars.front();
std::string elemMoved = pars.back();
std::string seqA; // ##|par3|##/##|par2|##/##|par1|##
std::string seqB; // *[./@kind='##|par2|##']/*[./@kind='##|par1|##']
std::string seqC; // ./@kind='##|par1|##' and ../@kind='##|par2|##' and ../../@kind='##|par3|##']">
std::string path_pref = "./";
for( unsigned int i = 0; i < pars.size(); ++i)
{
if( !seqA.empty()) seqA += '/';
if( !seqB.empty()) seqB += '/';
if( !seqC.empty()) seqC += " and ";
seqA += pars[i];
if( i != 0) // for seqB the first element is skipped
{
seqB += "*[./@kind='";
seqB += pars[i];
seqB += "']";
}
seqC += path_pref;
seqC += "@kind='";
seqC += pars[ pars.size() - i - 1];
seqC += "'";
if( i == 0) path_pref = "../";
else path_pref += "../";
}
pstream << strGeneralHeaderUp;
pstream << strMovementHead1;
pstream << elemContn;
pstream << strMovementHead3;
pstream << strMovementBody1;
pstream << strMovementBodyComment1;
pstream << seqA;
pstream << strMovementBodyComment3;
pstream << elemContn;
pstream << strMovementBodyComment5;
pstream << strMovementBody2;
pstream << seqB;
pstream << strMovementBody4;
pstream << strMovementTail;
pstream << strDisregardBegin1;
pstream << elemMoved;
pstream << strDisregardBegin3;
pstream << seqC;
pstream << strDisregardEnd;
return "";
}
--- NEW FILE: FileListCtrl.h ---
#pragma once
#include <vector>
#include <string>
class FileTransDlg;
// FileListCtrl
class FileListCtrl : public CListCtrl
{
DECLARE_DYNAMIC(FileListCtrl)
public:
FileListCtrl();
virtual ~FileListCtrl();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDropFiles(HDROP hDropInfo);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
protected:
virtual void PreSubclassWindow();
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
void createPopupMenu( CPoint pnt);
public:
FileTransDlg* m_parent;
void addFile(const CString& file, const CString& path);
int m_rowID;
std::vector< std::string> getSelFiles();
std::vector< std::string> getAllFiles();
void removeSel();
void removeAll();
void mark( std::vector< std::string>& vecs);
void showPopupMenu();
};
--- NEW FILE: RemoveDlg.h ---
#pragma once
#include "afxwin.h"
// RemoveDlg dialog
class RemoveDlg : public CDialog
{
DECLARE_DYNAMIC(RemoveDlg)
public:
RemoveDlg( bool changeTitle, CWnd* pParent = NULL); // standard constructor
virtual ~RemoveDlg();
// Dialog Data
enum { IDD = IDD_DLG_PROPREMOVEELEM };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
void init( const CString& par1);
const CString& getPar1() const;
protected:
CString m_name;
public:
virtual BOOL OnInitDialog(); // will set just the title of the window
protected:
CString m_title; // stores the title of the window
};
--- NEW FILE: FrontEnd.rc ---
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#include ""res\\FrontEnd.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\FrontEnd.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "About ModelMigrate"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "ModelMigrate Version 1.3",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) ISIS, Vanderbilt University 2005",
IDC_STATIC,40,25,178,8
DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP
LTEXT "Author: Zoltan Molnar, Vanderbilt University",
IDC_STATIC,40,40,178,8
END
IDD_DLG_PROPNAMECHANGE DIALOGEX 0, 0, 186, 87
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Replace"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,13,54,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "New:",IDC_STATIC,15,42,18,8
LTEXT "Old:",IDC_STATIC,16,10,14,8
END
IDD_DLG_ADDRULE DIALOGEX 0, 0, 186, 95
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "New Rule"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LISTBOX IDC_LIST1,7,7,114,81,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
END
IDD_DLG_PROPENATTRCHANGE DIALOGEX 0, 0, 303, 122
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Enum Attribute Value Change"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,21,27,90,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,21,65,90,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT3,128,65,90,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,246,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,246,24,50,14
PUSHBUTTON "Global/Local",IDGLOBAL,246,41,50,14
LTEXT "Enum Attribute Name",IDC_STATIC,21,15,81,8
LTEXT "Old Enumeration Value",IDC_STATIC,21,52,81,8
LTEXT "New Enumeration Value",IDC_STATIC,128,52,81,8
LTEXT "Note: Only the values need to be transformed. The labels displayed are handled automatically by GME.",
IDC_STATIC,20,86,197,20
END
IDD_DLG_PROPATTRCHANGE DIALOGEX 0, 0, 186, 86
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Attribute Name Change"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,13,54,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
PUSHBUTTON "Global/Local",IDGLOBAL,129,42,50,14
LTEXT "New:",IDC_STATIC,15,42,18,8
LTEXT "Old:",IDC_STATIC,16,10,14,8
END
IDD_DLG_FILETRANS DIALOGEX 0, 0, 494, 345
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP |
WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "ModelMigrate"
MENU IDR_MENU1
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_LISTSCRIPT,"SysListView32",LVS_REPORT |
LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP,7,7,480,63,WS_EX_ACCEPTFILES
PUSHBUTTON "&Add File",IDC_BUTTON6,7,71,50,14
PUSHBUTTON "A&dd Dir",IDC_BUTTON2,62,71,50,14
PUSHBUTTON "&Process Selected",IDC_BUTTON8,120,71,64,14
PUSHBUTTON "P&rocess All",IDC_BUTTON4,190,71,50,14
PUSHBUTTON "&Edit Rules",IDC_BUTTON1,381,71,50,14
PUSHBUTTON "&Clear Log",IDC_BUTTONCLEAR,437,71,50,14
CONTROL "",IDC_LISTFILES,"SysListView32",LVS_REPORT |
LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP,7,87,480,137,WS_EX_ACCEPTFILES
EDITTEXT IDC_EDIT4,7,228,480,110,ES_MULTILINE | ES_AUTOHSCROLL |
ES_READONLY | WS_VSCROLL | WS_HSCROLL
END
IDD_DLG_OPTIONS DIALOGEX 0, 0, 308, 149
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Options"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,17,21,192,15,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTON1,213,21,22,14
EDITTEXT IDC_EDIT2,17,53,192,15,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTON6,213,53,22,14
EDITTEXT IDC_EDIT5,17,84,192,15,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT6,17,115,192,15,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTON7,213,115,22,14
DEFPUSHBUTTON "OK",IDOK,251,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,251,24,50,14
LTEXT "Initial directory to load:",IDC_STATIC,20,10,126,8
LTEXT "Default script to apply:",IDC_STATIC,20,41,81,8
LTEXT "Appended string to filenames:",IDC_STATIC,20,73,128,8
LTEXT "Target directory (if empty then same directory as input)",
IDC_STATIC,20,104,185,8
END
IDD_DLG_RULEEDITOR DIALOGEX 600, 100, 350, 206
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION |
WS_SYSMENU | WS_THICKFRAME
CAPTION "Rule Editor"
MENU IDR_MENU2
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Add &Rule...",IDADDRULE,7,7,46,14
PUSHBUTTON "Generate &All",IDGENERATE,62,7,47,14
PUSHBUTTON "Generate S&elected",IDGENERATESEL,117,7,68,14
PUSHBUTTON "&Load",IDLOAD,258,7,38,14
PUSHBUTTON "&Save",IDSAVE,300,7,43,14
CONTROL "",IDC_RULELIST,"SysListView32",LVS_REPORT |
LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP,7,24,336,175
END
IDD_DLG_PROPMOVEUP DIALOGEX 0, 0, 228, 223
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Move Element Up In Hierarchy"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_TREE1,"SysTreeView32",TVS_HASBUTTONS |
TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS |
TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,7,26,155,155
PUSHBUTTON "OK",IDOK,171,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,171,24,50,14
PUSHBUTTON "Insert Child",IDC_BUTTON_INSERTNODE,171,48,50,14
PUSHBUTTON "Delete Child",IDC_BUTTON_DELETENODE,171,71,50,14
LTEXT "Please construct the hierarchy of elements to be matched. The lowest child will be moved up:",
IDC_STATIC,7,7,155,19
LTEXT "When the transformer meets such a construct it will move the lowest child up (its syblings remain there), so that it becomes a sybling of the highest element in this hierarchy.",
IDC_STATIC,7,187,214,27
END
IDD_DLG_PROPMOVEDOWN DIALOGEX 0, 0, 237, 220
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Move Down Element in Hierarchy"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDITKIND,7,20,162,12,ES_AUTOHSCROLL
EDITTEXT IDC_EDITPARENT,7,47,162,12,ES_AUTOHSCROLL
CONTROL "",IDC_TREETWO,"SysTreeView32",TVS_HASBUTTONS |
TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS |
TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,7,76,162,118
DEFPUSHBUTTON "OK",IDOK,180,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,180,24,50,14
PUSHBUTTON "Insert Child",IDC_BUTTON_INSERTNODE,180,50,50,14
PUSHBUTTON "Delete Child",IDC_BUTTON_DELETENODE,180,73,50,14
LTEXT "Element to be moved down:",IDC_STATIC,9,10,143,10
LTEXT "Wrap into:",IDC_STATIC,9,65,143,10
LTEXT "When specifying the wrapper elements, please indicate Models by appending a ':M' to the label.",
IDC_STATIC,7,195,167,18
LTEXT "Parent:",IDC_STATIC,9,36,143,10
END
IDD_DLG_PROPATTRTYPECHANGE DIALOGEX 0, 0, 299, 170
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Conversion Test of Attribute Values (string to number)"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,7,17,211,14,ES_AUTOHSCROLL
CONTROL "Terminate on conversion failure?",IDC_CHECK1,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,75,213,10
PUSHBUTTON "Generate Separate Script",IDC_BUTTON1,7,117,215,14
DEFPUSHBUTTON "OK",IDOK,242,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,242,24,50,14
PUSHBUTTON "Global/Local",IDGLOBAL,242,42,50,14
LTEXT "Attribute kind to be checked for conversion to number:",
IDC_STATIC,7,7,211,10
LTEXT "Note: Values are not really converted, just checked. This script is only checking if the conversion will succeed when GME will parse the file. If it doesn't, then a comment is introduced ('CONVERROR') into the target file.",
IDC_STATIC,7,36,211,35
LTEXT "Note: if unchecked please check manually the target file for 'CONVERROR's since the transformer will not show any error.",
IDC_STATIC,7,87,215,24
LTEXT "Note: By generating a separate script you can execute this stand-alone script and get as output a formatted text file containing the error occurences, if any.",
IDC_STATIC,7,135,214,29
END
IDD_DLG_PROPATTRGLOBALLOCAL DIALOGEX 0, 0, 237, 46
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Global or Local Attribute?"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,180,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,180,24,50,14
CONTROL "Global",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON |
WS_GROUP | WS_TABSTOP,13,11,35,10
CONTROL "Local",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,13,24,32,
10
EDITTEXT IDC_EDIT3,65,21,96,13,ES_AUTOHSCROLL
LTEXT "Owned by:",IDC_STATIC,66,11,36,8
END
IDD_DLG_PROPREMOVEELEM DIALOGEX 0, 0, 186, 46
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Remove Kind"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "Name:",-1,16,10,80,8
END
IDD_DLG_PROPREMOVELOCALATTR DIALOGEX 0, 0, 186, 87
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Remove Local Attribute"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,13,54,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "Owned by:",IDC_STATIC,15,42,36,8
LTEXT "Attribute:",IDC_STATIC,16,10,32,8
END
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,1
PRODUCTVERSION 1,3,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "ISIS, Vanderbilt University, 2005"
VALUE "FileDescription", "Model Migrate executable, for generating and applying XSLT scripts"
VALUE "FileVersion", "1.3.0.1"
VALUE "InternalName", "FrontEnd.exe"
VALUE "LegalCopyright", "ISIS, Vanderbilt University, 2005"
VALUE "OriginalFilename", "FrontEnd.exe"
VALUE "ProductName", "ModelMigrate"
VALUE "ProductVersion", "1.3.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 228
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_DLG_PROPNAMECHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 80
END
IDD_DLG_ADDRULE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
IDD_DLG_PROPENATTRCHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 296
TOPMARGIN, 7
BOTTOMMARGIN, 115
END
IDD_DLG_PROPATTRCHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 79
END
IDD_DLG_FILETRANS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 487
TOPMARGIN, 7
BOTTOMMARGIN, 338
END
IDD_DLG_OPTIONS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 301
TOPMARGIN, 7
BOTTOMMARGIN, 142
END
IDD_DLG_RULEEDITOR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 343
TOPMARGIN, 7
BOTTOMMARGIN, 199
END
IDD_DLG_PROPMOVEUP, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 221
TOPMARGIN, 7
BOTTOMMARGIN, 216
END
IDD_DLG_PROPMOVEDOWN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 230
TOPMARGIN, 7
BOTTOMMARGIN, 213
END
IDD_DLG_PROPATTRTYPECHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 292
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
IDD_DLG_PROPATTRGLOBALLOCAL, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 230
TOPMARGIN, 7
BOTTOMMARGIN, 39
END
IDD_DLG_PROPREMOVEELEM, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 39
END
IDD_DLG_PROPREMOVELOCALATTR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 80
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// XSL
//
Header.xsl XSL "res\\header.xsl"
Tail.xsl XSL "res\\tail.xsl"
TKindNameChange.xsl XSL "res\\TKindNameChange.xsl"
TAttrNameChange.xsl XSL "res\\TAttrNameChange.xsl"
TEnumAttrValueChange.xsl XSL "res\\TEnumAttrValueChange.xsl"
TAttrTypeChange.xsl XSL "res\\TAttrTypeChange.xsl"
TAttrTypeCheck2Text.xsl XSL "res\\TAttrTypeCheck2Text.xsl"
TRemoveGlobalAttr.xsl XSL "res\\TRemoveGlobalAttr.xsl"
TRemoveLocalAttr.xsl XSL "res\\TRemoveLocalAttr.xsl"
TRemoveKind.xsl XSL "res\\TRemoveKind.xsl"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MENU1 MENU
BEGIN
POPUP "Scripts"
BEGIN
MENUITEM "Add Script\tF3", ID_SCRIPTS_ADD
MENUITEM "Add Directory\tF4", ID_SCRIPTS_ADDDIRECTORY
MENUITEM "Remove All", ID_SCRIPTS_REMOVEALL
MENUITEM "Remove Selected", ID_SCRIPTS_REMOVESELECTED
END
POPUP "Files"
BEGIN
MENUITEM "Add File\tF6", ID_FILES_ADDFILE
MENUITEM "Add Directory\tF7", ID_FILES_ADDDIRECTORY
MENUITEM "Remove All", ID_FILES_REMOVEALL
MENUITEM "Remove Selected", ID_FILES_REMOVESELECTED
END
POPUP "Rules"
BEGIN
MENUITEM "Edit Rules", ID_RULES_EDITRULES
MENUITEM "Generate Validator Script", ID_RULES_VALIDATE
END
POPUP "Processing"
BEGIN
MENUITEM "Process All\t^F5", ID_PROCESSING_PROCESSALL
MENUITEM "Process Selected\tF5", ID_PROCESSING_PROCESSSELECTED
END
POPUP "Misc"
BEGIN
MENUITEM "Options", ID_MISC_OPTIONS
MENUITEM "Clear Log", ID_MISC_CLEARLOG
END
END
IDR_MENU2 MENU
BEGIN
POPUP "File"
BEGIN
MENUITEM "New", ID_MYFILENEW
MENUITEM "Load", ID_MYFILELOAD
MENUITEM "Save", ID_MYFILESAVE
END
POPUP "Rule"
BEGIN
MENUITEM "Add", ID_RULE_ADD
MENUITEM "Clone", ID_RULE_CLONE
MENUITEM SEPARATOR
MENUITEM "Delete Selected", ID_RULE_DELETESELECTED
MENUITEM "Delete All", ID_RULE_DELETEALL
MENUITEM SEPARATOR
MENUITEM "Move Up", ID_RULE_MOVEUP
MENUITEM "Move Down", ID_RULE_MOVEDOWN
END
POPUP "Script"
BEGIN
MENUITEM "Generate All", ID_SCRIPT_GENERATEALL
MENUITEM "Generate Selected", ID_SCRIPT_GENERATESELECTED
END
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_ABOUTBOX "&About ModelMigrate..."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#include "res\FrontEnd.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
--- NEW FILE: NewRuleDlg.h ---
#pragma once
#include "afxwin.h"
// NewRuleDlg dialog
class NewRuleDlg : public CDialog
{
DECLARE_DYNAMIC(NewRuleDlg)
public:
NewRuleDlg(CWnd* pParent = NULL); // standard constructor
virtual ~NewRuleDlg();
// Dialog Data
enum { IDD = IDD_DLG_ADDRULE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CListBox m_rules;
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedOk();
public:
int m_choice;
CString m_choiceStr;
afx_msg void OnLbnDblclkList1();
};
--- NEW FILE: ScriptMoveDownEach.cpp ---
#include "StdAfx.h"
#include ".\ScriptMoveDown.h"
//<xsl:template match="*[@kind='##|par1|##']">
//
// <!-- each ##|par1|## kind is put into a ##|par3|##/##|par2|## -->
//
// <##|typ1|## kind="##|par1|##">
// <name>New##|par1|##</name>
// <##|typ2|## kind="##|par2|##" role="##|par2|##">
// <name>New##|par2|##</name>
//
// <xsl:element name="{name()}"> <!-- element name is not hardcoded -->
//
// <xsl:for-each select="@*">
// <xsl:copy/> <!-- other attributes are just copied-->
// </xsl:for-each>
//
// <xsl:apply-templates/>
//
// </xsl:element>
// </##|typ2|##>
// </##|typ1|##>
//
//</xsl:template>
const char * strGeneralHeaderDown = "\
<!-- =============================================================================== -->\r\n\
<!-- Kind movement down in a hierarchy -->\r\n\
<!-- This template rule will wrap certain kinds into containers -->\r\n\
<!-- =============================================================================== -->\r\n\
\r\n\r\n";
const char * strTemplateHeadBegin = "<xsl:template match=\"*[@kind='";
const char * strTemplateHeadEnd = "']\">\r\n";
const char * strTemplateTail = "</xsl:template>\r\n";
//<!-- each ##|par1|## kind is put into a ##|par3|##/##|par2|## -->
const char * strComment2Begin = "\r\n<!-- each ";
const char * strComment2Mid = " kind is put into a ";
const char * strComment2End = " -->\r\n";
// <##|typ|## kind="##|par|##">
// <name>New##|par|##</name>
const char * strSkeletonOpen = "\
\t<##|typ|## kind=\"##|par|##\">\r\n\
\t\t<name>New##|par|##</name>\
\r\n";
const char * strInternals = "\
\t\t<xsl:copy>\r\n\
\t\t<xsl:apply-templates select=\"@*\"/>\r\n\
\t\t<xsl:apply-templates/>\r\n\
\t\t</xsl:copy>\r\n";
const char * strSkeletonClose = "\
\t</##|typ|##>\r\n";
ScriptMoveDown::ScriptMoveDown(void)
{
}
ScriptMoveDown::~ScriptMoveDown(void)
{
}
CString ScriptMoveDown::instantiat2( const std::vector< std::string >& pars, std::ostream& pstream)
{
// pars[1..len] contains the hierarchy that will be created
// pars.front() contains the element that will be wrapped (moved down)
ASSERT( pars.size() >= 2);
if( pars.size() < 2) return "";
std::string sequence;
std::string skeleton_head, skeleton_tail;
for( unsigned int i = 1; i < pars.size(); ++i)
{
if( sequence.length() != 0)
{
sequence += '/';
}
CString pi = pars[i].c_str();
CString type = "folder";
CString kind = pi;
if( pi.Right(2) == ":M")
{
type = "model";
kind = pi.Left( pi.GetLength() - 2);
} else if( pi.Right(2) == ":F")
{
kind = pi.Left( pi.GetLength() - 2);
}
sequence += kind;
CString open_tags( strSkeletonOpen);
CString clos_tags( strSkeletonClose);
open_tags.Replace( "##|typ|##", type);
open_tags.Replace( "##|par|##", kind);
clos_tags.Replace( "##|typ|##", type);
skeleton_head += open_tags;
skeleton_tail = (LPCTSTR) clos_tags + skeleton_tail;
}
pstream << strGeneralHeaderDown;
pstream << strComment2Begin;
pstream << pars[0]; // the node (element) moved
pstream << strComment2Mid;
pstream << sequence; // the wrapper structure
pstream << strComment2End;
pstream << strTemplateHeadBegin;
pstream << pars[0]; // the node (element) moved
pstream << strTemplateHeadEnd;
pstream << skeleton_head;
pstream << strInternals;
pstream << skeleton_tail;
pstream << strTemplateTail;
return "";
}
--- NEW FILE: RuleEditorDlg.cpp ---
// RuleEditorDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "RuleEditorDlg.h"
#include ".\ruleeditordlg.h"
// RuleEditorDlg dialog
IMPLEMENT_DYNAMIC(RuleEditorDlg, CDialog)
RuleEditorDlg::RuleEditorDlg(CWnd* pParent /*=NULL*/)
: CDialog(RuleEditorDlg::IDD, pParent)
, m_closed( true)
{
}
RuleEditorDlg::~RuleEditorDlg()
{
}
void RuleEditorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RULELIST, m_ruleList);
}
BEGIN_MESSAGE_MAP(RuleEditorDlg, CDialog)
ON_BN_CLICKED(IDGENERATE, OnBnClickedGenerate)
ON_BN_CLICKED(IDGENERATESEL, OnBnClickedGeneratesel)
ON_BN_CLICKED(IDADDRULE, OnBnClickedAddrule)
ON_BN_CLICKED(IDSAVE, OnBnClickedSave)
ON_BN_CLICKED(IDLOAD, OnBnClickedLoad)
ON_WM_SIZE()
ON_WM_KEYDOWN()
ON_NOTIFY(LVN_KEYDOWN, IDC_RULELIST, OnLvnKeydownRulelist)
END_MESSAGE_MAP()
// RuleEditorDlg message handlers
void RuleEditorDlg::OnBnClickedGenerate()
{
m_ruleList.genAll();
}
void RuleEditorDlg::OnBnClickedGeneratesel()
{
m_ruleList.genSelected();
}
void RuleEditorDlg::closeDlg( int pResult)
{
EndDialog( pResult);
DestroyWindow();
m_closed = true;
}
void RuleEditorDlg::OnOK()
{
//int resp = AfxMessageBox( "Save changes?", MB_YESNOCANCEL);
//if( resp == IDYES)
//{
// OnBnClickedSave();
// closeDlg( IDOK);
//}
//else if( resp == IDNO)
//{
// closeDlg( IDOK);
//}
}
void RuleEditorDlg::OnCancel()
{
if( AfxMessageBox( "Close dialog and discard changes?", MB_YESNOCANCEL) == IDYES)
closeDlg( IDCANCEL);
}
void RuleEditorDlg::OnBnClickedAddrule()
{
m_ruleList.add();
}
BOOL RuleEditorDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_closed = false;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void RuleEditorDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if( cx < 200) cx = 200; // to prevent mixing/shuffling controls because of the very
if( cy < 150) cy = 150; // small values (the box resizing is not prevented by these)
if( m_ruleList.GetSafeHwnd())
{
CRect rect;
m_ruleList.GetWindowRect( &rect);
ScreenToClient( &rect);
rect.bottom = cy - rect.left;
rect.right = cx - rect.left; // maintain margin
m_ruleList.SetWindowPos( 0, 0, 0, rect.Width(), rect.Height(), SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW);
}
}
void RuleEditorDlg::OnBnClickedSave()
{
m_ruleList.fileSave();
}
void RuleEditorDlg::OnBnClickedLoad()
{
m_ruleList.fileLoad();
}
void RuleEditorDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();
}
void RuleEditorDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
void RuleEditorDlg::OnLvnKeydownRulelist(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVKEYDOWN pLVKeyDow = reinterpret_cast<LPNMLVKEYDOWN>(pNMHDR);
NMLVKEYDOWN &s = *pLVKeyDow;
bool cntrl = GetKeyState( VK_CONTROL) < 0;
bool shft = GetKeyState( VK_SHIFT) < 0;
bool alt = GetKeyState( VK_MENU) < 0; // ALT
// VK_ENTER -> is handled in OnCommand with when IDOK comes in
if( s.wVKey == VK_APPS) m_ruleList.showPopupMenu();
if( s.wVKey == VK_F3) // F3, Load
SendMessage( WM_COMMAND, ID_MYFILELOAD, 0);
if( s.wVKey == VK_F2) // F2, Save
SendMessage( WM_COMMAND, ID_MYFILESAVE, 0);
if( s.wVKey == VK_UP && alt)
SendMessage( WM_COMMAND, ID_RULE_MOVEUP, 0); // MoveUp
if( s.wVKey == VK_DOWN && alt)
SendMessage( WM_COMMAND, ID_RULE_MOVEDOWN, 0);// MoveDown
if( s.wVKey == VK_INSERT && !cntrl) // Add Rule
SendMessage( WM_COMMAND, ID_RULE_ADD, 0);
if( s.wVKey == VK_INSERT && cntrl) // Clone Rule
SendMessage( WM_COMMAND, ID_RULE_CLONE, 0);
if( s.wVKey == VK_DELETE && !cntrl) // Del Sel
SendMessage( WM_COMMAND, ID_RULE_DELETESELECTED, 0);
if( s.wVKey == VK_DELETE && cntrl) // Del All
SendMessage( WM_COMMAND, ID_RULE_DELETEALL, 0);
*pResult = 0;
}
BOOL RuleEditorDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch( wParam)
{
case IDOK: onReturn(); break;
case ID_MYFILENEW: onFileNew();break;
case ID_MYFILELOAD: onFileLoad();break;
case ID_MYFILESAVE: onFileSave();break;
case ID_RULE_ADD: m_ruleList.onAdd();;break;
case ID_RULE_CLONE: m_ruleList.onClone();break;
case ID_RULE_DELETESELECTED: m_ruleList.onDeleSel();break;
case ID_RULE_DELETEALL: m_ruleList.onDeleAll();break;
case ID_RULE_MOVEUP: m_ruleList.onMoveUp();break;
case ID_RULE_MOVEDOWN: m_ruleList.onMoveDown();break;
case ID_SCRIPT_GENERATEALL: m_ruleList.onGenAll();break;
case ID_SCRIPT_GENERATESELECTED: m_ruleList.onGenSel();break;
default: return CDialog::OnCommand(wParam, lParam);
};
return CDialog::OnCommand(wParam, lParam);
}
void RuleEditorDlg::onReturn()
{
CWnd* child = this->GetFocus();
if( !child) return;
if( child == GetDlgItem(IDC_RULELIST))
{
m_ruleList.onEdit();
}
}
void RuleEditorDlg::onFileNew()
{
bool empty = m_ruleList.erasable();
if( !empty)
empty = IDOK == AfxMessageBox("Create new file?");
if( empty)
m_ruleList.fileNew();
}
void RuleEditorDlg::onFileLoad()
{
m_ruleList.fileLoad();
}
void RuleEditorDlg::onFileSave()
{
m_ruleList.fileSave();
}
--- NEW FILE: ScriptEnumAttrValue.cpp ---
#include "StdAfx.h"
#include ".\ScriptEnumAttrValue.h"
ScriptEnumAttrValue::ScriptEnumAttrValue(void)
{
}
ScriptEnumAttrValue::~ScriptEnumAttrValue(void)
{
}
CString ScriptEnumAttrValue::instantiat2( const std::vector< std::string >& pars, std::ostream& pstream)
{
CString res = Script::instantiat2( pars, pstream);
if( pars.size() >= 5 && pars[3] != "1") // not a global attribute
{
if( pars[4] == "") { AfxMessageBox( "No owner specified for local attribute!"); return ""; }
CString toIns = CString( " and ../@kind='") + pars[4].c_str() + "'";
res.Replace( "##|OPTIONALLOCALCONDITION|##", toIns);
}
else
res.Replace( "##|OPTIONALLOCALCONDITION|##", "");
return res;
}
--- NEW FILE: ModelMigrate.cpp ---
// ModelMigrate.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "FileTransDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#define _WIN32_DCOM // for COInitializeEx
// CModelMigrateApp
BEGIN_MESSAGE_MAP(CModelMigrateApp, CWinApp)
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
// CModelMigrateApp construction
CModelMigrateApp::CModelMigrateApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CModelMigrateApp object
CModelMigrateApp theApp;
// CModelMigrateApp initialization
BOOL CModelMigrateApp::InitInstance()
{
// InitCommonControls() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
InitCommonControls();
CWinApp::InitInstance();
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("ISIS-ModelMigrate"));
// init COM
HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
ASSERT( SUCCEEDED( hr));
FileTransDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// uninit COM
CoUninitialize();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
--- NEW FILE: ScriptAttrName.cpp ---
#include "StdAfx.h"
#include ".\scriptattrname.h"
ScriptAttrName::ScriptAttrName(void)
{
}
ScriptAttrName::~ScriptAttrName(void)
{
}
CString ScriptAttrName::instantiat2( const std::vector< std::string >& pars, std::ostream& pstream)
{
CString res = Script::instantiat2( pars, pstream);
if( pars.size() >= 4 && pars[2] != "1") // not a global attribute
{
if( pars[3] == "") { AfxMessageBox( "No owner specified for local attribute!"); return ""; }
CString toIns = CString( " and ../@kind='") + pars[3].c_str() + "'";
res.Replace( "##|OPTIONALLOCALCONDITION|##", toIns);
}
else
res.Replace( "##|OPTIONALLOCALCONDITION|##", "");
return res;
}
--- NEW FILE: AttrGlobalDlg.h ---
#pragma once
// AttrGlobalDlg dialog
class AttrGlobalDlg : public CDialog
{
DECLARE_DYNAMIC(AttrGlobalDlg)
public:
AttrGlobalDlg( const CString& pGlobal, const CString& pOwner, CWnd* pParent = NULL); // standard constructor
virtual ~AttrGlobalDlg();
// Dialog Data
enum { IDD = IDD_DLG_PROPATTRGLOBALLOCAL };
CString getGlobal() const;
const CString& getOwner() const;
protected:
int m_iGlobalLocal;
CString m_ownerKind;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
DECLARE_MESSAGE_MAP()
afx_msg void OnBnClickedRadio1();
afx_msg void OnBnClickedRadio2();
virtual BOOL OnInitDialog();
};
--- NEW FILE: FileListCtrl.cpp ---
// FileListCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "FileListCtrl.h"
#include ".\filelistctrl.h"
#include "FileTransDlg.h"
#include <algorithm>
#define ADD_FILE_CMD 2101
#define ADD_DIR_CMD 2102
#define REMOVE_SEL_CMD 2103
#define REMOVE_ALL_CMD 2104
#define PROCESS_SEL_CMD 2105
#define PROCESS_ALL_CMD 2106
// FileListCtrl
IMPLEMENT_DYNAMIC(FileListCtrl, CListCtrl)
FileListCtrl::FileListCtrl()
: m_rowID(0)
{
}
FileListCtrl::~FileListCtrl()
{
}
BEGIN_MESSAGE_MAP(FileListCtrl, CListCtrl)
ON_WM_CREATE()
ON_WM_DROPFILES()
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()
// FileListCtrl message handlers
int FileListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
BOOL FileListCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= WS_CHILD|WS_VISIBLE|WS_BORDER|WS_TABSTOP|LVS_REPORT;//|LVS_SINGLESEL;
return CListCtrl::PreCreateWindow(cs);
}
void FileListCtrl::addFile(const CString& file, const CString& path)
{
CString knd = file, ttt = path;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = GetItemCount();
lvItem.iSubItem = 0;
lvItem.pszText = knd.GetBuffer(knd.GetLength());
int index = InsertItem(&lvItem);
lvItem.iSubItem = 1;
lvItem.pszText = ttt.GetBuffer(ttt.GetLength());
SetItem(&lvItem);
lvItem.iSubItem = 2;
lvItem.pszText = _T("");
SetItem(&lvItem);
//lvItem.iSubItem = 3;
//lvItem.pszText = _T("");
//SetItem(&lvItem);
SetItemData(index, ++m_rowID);
}
void FileListCtrl::PreSubclassWindow()
{
int col0size = 2*GetStringWidth("FileName.xme");
int col1size = 2*GetStringWidth("Full Path To File Is Very Long");
int col2size = 2*GetStringWidth("Status");
//int col3size = 2*GetStringWidth("MessageWillBeVeryLong");
InsertColumn(0, _T("File"), LVCFMT_LEFT, col0size, -1);
InsertColumn(1, _T("Full Path"), LVCFMT_LEFT, col1size, -1);
InsertColumn(2, _T("Status"), LVCFMT_LEFT, col2size, -1);
//InsertColumn(3, _T(" "), LVCFMT_LEFT, col3size, -1);
SetExtendedStyle( LVS_EX_FULLROWSELECT );
CListCtrl::PreSubclassWindow();
}
void FileListCtrl::OnDropFiles(HDROP hDropInfo)
{
UINT nFiles = DragQueryFile( hDropInfo, 0xFFFFFFFF, NULL, 0);
if( nFiles < 1)
AfxMessageBox( "No file dropped!");
for( UINT iF = 0; iF < nFiles; ++iF)
{
TCHAR szFileName[_MAX_PATH];
UINT res = DragQueryFile( hDropInfo, iF, szFileName, _MAX_PATH);
if (res > 0)
{
CString conn( szFileName);
int pos = conn.ReverseFind('\\');
if( pos != -1)
addFile( conn.Right( conn.GetLength() - pos - 1), szFileName);
else
addFile( szFileName, "");
}
else
AfxMessageBox( "File name error!");
}
CListCtrl::OnDropFiles(hDropInfo);
}
std::vector<std::string> FileListCtrl::getSelFiles()
{
std::vector< std::string> res;
for( int i = 0; i < GetItemCount(); ++i)
{
CString knd;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT | LVIF_STATE;
lvItem.iItem = i;
lvItem.iSubItem = 1;
lvItem.pszText = knd.GetBuffer( 1024);
lvItem.cchTextMax = 1024;
lvItem.stateMask = LVIS_SELECTED;
GetItem( &lvItem);
// reset 'status'
lvItem.iSubItem = 2;
lvItem.pszText = "";
SetItem( &lvItem);
if( (lvItem.state & LVIS_SELECTED) == LVIS_SELECTED)
res.push_back( (LPCTSTR) knd );
}
return res;
}
std::vector<std::string> FileListCtrl::getAllFiles()
{
CString ress = "";
std::vector< std::string> res;
for( int i = 0; i < GetItemCount(); ++i)
{
CString knd;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = i;
lvItem.iSubItem = 1;
lvItem.pszText = knd.GetBuffer( 1024);
lvItem.cchTextMax = 1024;
GetItem( &lvItem);
lvItem.iSubItem = 2;
lvItem.pszText = "";
SetItem( &lvItem);
res.push_back( (LPCTSTR) knd );
}
return res;
}
void FileListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
bool sent = false;
CListCtrl::OnLButtonDblClk(nFlags, point);
for( int i = 0; !sent && i < GetItemCount(); ++i)
{
UINT flag = LVIS_FOCUSED | LVIS_SELECTED;
if( (GetItemState( i, flag ) & flag) == flag )
{
this->PostMessage( WM_COMMAND, PROCESS_SEL_CMD);
sent = true;
}
}
}
void FileListCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
CListCtrl::OnRButtonDown(nFlags, point);
ClientToScreen( &point);
createPopupMenu( point);
}
void FileListCtrl::showPopupMenu()
{
// find the focused item to determine the position of the popup menu
int idx = -1;
for( int i = 0; idx == -1 && i < GetItemCount(); ++i)
{
UINT flag = LVIS_FOCUSED;// | LVIS_SELECTED;
if( (GetItemState( i, flag ) & flag) == flag )
{
idx = i;
}
}
CPoint point;
if( idx != -1)
GetItemPosition( idx, &point);
else
{
// no item found, use the top-left corner of the empty listcontrol
CRect rect;
GetClientRect(rect);
point = CPoint( rect.left, rect.top);
}
point.Offset( 10, 10);
ClientToScreen( &point);
createPopupMenu( point);
}
void FileListCtrl::createPopupMenu( CPoint pnt)
{
CMenu m;
m.CreatePopupMenu();
m.AppendMenu( MF_ENABLED|MF_STRING, ADD_FILE_CMD, "Add File...");
m.AppendMenu( MF_ENABLED|MF_STRING, ADD_DIR_CMD, "Add Directory...");
m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
m.AppendMenu( MF_ENABLED|MF_STRING, REMOVE_ALL_CMD, "Remove All");
m.AppendMenu( MF_ENABLED|MF_STRING, REMOVE_SEL_CMD, "Remove Selected");
m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
m.AppendMenu( MF_ENABLED|MF_STRING, PROCESS_ALL_CMD, "Process All");
m.AppendMenu( MF_ENABLED|MF_STRING, PROCESS_SEL_CMD, "Process Selected");
m.TrackPopupMenu( TPM_LEFTALIGN |TPM_RIGHTBUTTON, pnt.x, pnt.y, this);
}
BOOL FileListCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch( wParam)
{
case ADD_FILE_CMD: m_parent->selFile();break;
case ADD_DIR_CMD: m_parent->selDir();break;
case REMOVE_ALL_CMD: removeAll();break;
case REMOVE_SEL_CMD: removeSel();break;
case PROCESS_SEL_CMD: m_parent->processSel();break;
case PROCESS_ALL_CMD: m_parent->processAll();break;
};
return CListCtrl::OnCommand(wParam, lParam);
}
void FileListCtrl::mark( std::vector< std::string>& vecs)
{
for( int i = 0; i < GetItemCount(); ++i)
{
CString knd;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT | LVIF_STATE;
lvItem.iItem = i;
lvItem.iSubItem = 1;
lvItem.pszText = knd.GetBuffer( 1024);
lvItem.cchTextMax = 1024;
lvItem.stateMask = LVIS_SELECTED;
GetItem( &lvItem);
std::string to_find = (LPCTSTR) knd;
if( std::find( vecs.begin(), vecs.end(), to_find) != vecs.end()) // found
{
lvItem.iSubItem = 2;
lvItem.pszText = _T("failed");
SetItem(&lvItem);
}
}
}
void FileListCtrl::removeAll()
{
DeleteAllItems();
}
void FileListCtrl::removeSel()
{
for( int i = GetItemCount(); i > 0 ; --i)
{
UINT sel = GetItemState( i-1, LVIS_SELECTED);
if( sel & LVIS_SELECTED)
{
DeleteItem( i-1);
}
}
}
--- NEW FILE: Rule.h ---
#pragma once
#include <vector>
#include <string>
#include <ostream>
class Rule //: public CObject
{
public: // typedefs
typedef enum // keep in sync with rule_templates
{
KindNameChange,
AttrNameChange,
AttrTypeChange,
EnumAttrValueChange,
MoveUpElem,
MoveDownElem,
RemoveKind,
RemoveGlobalAttr,
RemoveLocalAttr
} rule_type;
static const int rule_nmb = 9;
static const char * rule_templates[ rule_nmb];// keep in sync
//{ "TKindNameChange.xsl"
//, "TAttrNameChange.xsl"
//, "TAttrTypeChange.xsl"
//, "TEnumAttrValueChange.xsl"
//, "TMoveUpElem.xsl"
//, "TMoveDownElem.xsl"
//, "TRemoveKind.xsl"
//, "TRemoveGlobalAttr.xsl"
//, "TRemoveLocalAttr.xsl"
//};
static CString ruleTypeStr( int i);
static CString ruleSummary( const Rule& pRule);
static CString ruleSummary( Rule::rule_type pTyp, const std::vector<std::string>& pParams);
public:
//DECLARE_SERIAL( Rule)
void Serialize( CArchive& ar);
Rule(void); // needed for SERIAL
Rule( rule_type rt, std::vector<std::string>& vec);
~Rule(void);
void gen( std::ostream& pFstream);
//std::string getSummary();
rule_type m_type;
std::vector< std::string> m_params;
std::string m_name;
//protected:
Rule( const Rule&);
const Rule& operator=( const Rule&);
};
--- NEW FILE: MoveDownElem.cpp ---
// MoveDownElem.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "MoveDownElem.h"
#include ".\movedownelem.h"
// MoveDownElem dialog
IMPLEMENT_DYNAMIC(MoveDownElem, CDialog)
MoveDownElem::MoveDownElem(CWnd* pParent /*=NULL*/)
: CDialog(MoveDownElem::IDD, pParent)
{
}
MoveDownElem::~MoveDownElem()
{
}
void MoveDownElem::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TREETWO, m_tree);
DDX_Control(pDX, IDC_EDITKIND, m_editKind);
DDX_Control(pDX, IDC_EDITPARENT, m_parentKind);
}
BEGIN_MESSAGE_MAP(MoveDownElem, CDialog)
ON_BN_CLICKED(IDC_BUTTON_INSERTNODE, OnBnClickedButtonInsertnode)
ON_NOTIFY(TVN_ENDLABELEDIT, IDC_TREETWO, OnTvnEndlabeleditTree1)
ON_NOTIFY(NM_RETURN, IDC_TREETWO, OnNMReturnTree1)
ON_BN_CLICKED(IDC_BUTTON_DELETENODE, OnBnClickedButtonDeletenode)
END_MESSAGE_MAP()
// MoveDownElem message handlers
void MoveDownElem::addChild( const char * pLabel)
{
HTREEITEM hLastGoodItem = lastChild();
HTREEITEM hNewItem = m_tree.InsertItem( _T(pLabel), hLastGoodItem);
m_tree.Expand( hLastGoodItem, TVE_EXPAND);
m_tree.EnsureVisible( hNewItem);
}
void MoveDownElem::OnBnClickedButtonInsertnode()
{
addChild( "Node");
HTREEITEM lc = lastChild();
if( lc) m_tree.EditLabel( lc);
}
void MoveDownElem::OnBnClickedButtonDeletenode()
{
remChild();
}
HTREEITEM MoveDownElem::lastChild()
{
HTREEITEM hLastGoodItem = TVI_ROOT;
HTREEITEM h = m_tree.GetRootItem();
while ( h != NULL)
{
m_tree.Expand( h, TVE_EXPAND);
hLastGoodItem = h;
h = m_tree.GetChildItem( h);
}
return hLastGoodItem;
}
void MoveDownElem::remChild()
{
HTREEITEM hLastGoodItem = lastChild();
if( hLastGoodItem && hLastGoodItem != TVI_ROOT) m_tree.DeleteItem( hLastGoodItem);
else
AfxMessageBox( "No more elements to delete!");
}
void MoveDownElem::closeDlg( int pResult)
{
EndDialog( pResult);
DestroyWindow();
}
void MoveDownElem::OnOK()
{
if( AfxMessageBox( "Close dialog and save changes?", MB_YESNOCANCEL) == IDYES)
{
m_storage = getValues();
closeDlg( IDOK);
}
}
void MoveDownElem::OnCancel()
{
if( AfxMessageBox( "Close dialog and discard changes?", MB_YESNOCANCEL) == IDYES)
closeDlg( IDCANCEL);
}
void MoveDownElem::OnTvnEndlabeleditTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTVDISPINFO pTVDispInfo = reinterpret_cast<LPNMTVDISPINFO>(pNMHDR);
if( !pTVDispInfo->item.pszText) return; // if 0 means edit cancelled
m_tree.SetItem( &pTVDispInfo->item);
*pResult = 0;
}
void MoveDownElem::OnNMReturnTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
*pResult = 0;
}
std::string MoveDownElem::getKindField()
{
CString txt;
m_editKind.GetWindowText( txt);
return (LPCTSTR) txt;
}
std::string MoveDownElem::getParentField()
{
CString txt;
m_parentKind.GetWindowText( txt);
return (LPCTSTR) txt;
}
std::vector< std::string> MoveDownElem::getValues()
{
std::vector< std::string> res;
// #0 is the element to move
res.push_back( getKindField());
// #1 is the parent of this
res.push_back( getParentField());
// now the wrappers
HTREEITEM h = m_tree.GetRootItem();
while ( h != NULL)
{
res.push_back( (LPCTSTR) m_tree.GetItemText( h));
h = m_tree.GetChildItem( h);
}
return res;
}
std::vector< std::string> MoveDownElem::getSequence()
{
return m_storage;
}
void MoveDownElem::init( const std::vector< std::string>& pars)
{
m_storage = pars;
}
BOOL MoveDownElem::OnInitDialog()
{
CDialog::OnInitDialog();
if( !m_storage.empty())
m_editKind.SetWindowText( m_storage[0].c_str());
else
m_editKind.SetWindowText( "<Specify here the kind that will be wrapped>");
if( m_storage.size() >= 2)
m_parentKind.SetWindowText( m_storage[1].c_str());
else
m_parentKind.SetWindowText("<Its parent must be specified here>");
// m_storage[0] is the to-be-moved kind
// m_storage[1] is the parent of the to-be-moved kind
for( unsigned int i = 2; i < m_storage.size(); ++i)
{
addChild( m_storage[i].c_str());
}
m_storage.clear();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
--- NEW FILE: RuleListCtrl.h ---
#pragma once
#include "Rule.h"
// RuleListCtrl
class RuleListCtrl : public CListCtrl
{
DECLARE_DYNAMIC(RuleListCtrl)
public: // typedefs
typedef std::vector<Rule> RULE_VEC;
typedef std::vector<Rule>::iterator RULE_VEC_ITERATOR;
public:
RuleListCtrl();
virtual ~RuleListCtrl();
protected:
DECLARE_MESSAGE_MAP()
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual void PreSubclassWindow();
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
public:
CString genAll();
CString genSelected();
void add();
void fileNew();
void fileSave();
void fileLoad();
void showPopupMenu();
bool erasable();
void onAdd();
void onEdit();
void onDeleSel();
void onDeleAll();
void onClone();
void onGenAll();
void onGenSel();
void onMoveUp();
void onMoveDown();
protected: // impl
void addNewItem( int pChoice);
int gen( const std::string& pOutputFileName, const std::vector<int>& pSelectVec);
int rowID;
int HitTestEx(CPoint &point, int *col) const;
RULE_VEC m_rules;
int getFirstFocSel();
void setFocSel( int index);
int addRule( int chc, std::vector<std::string>& vec);
void showPropertyPage( int idx);
void getItem( CString& pStr, int idx, int subIdx = 0);
void setItem( CString pStr, int idx, int subIdx = 0);
int insertItem( const Rule& pRule);
void createPopupMenu( CPoint point);
};
--- NEW FILE: Rule.cpp ---
#include "StdAfx.h"
#include ".\rule.h"
#include "Script.h"
#include "ScriptMoveUp.h"
#include "ScriptMoveDown.h"
#include "ScriptAttrName.h"
#include "ScriptAttrType.h"
#include "ScriptEnumAttrValue.h"
//IMPLEMENT_SERIAL(Rule, CObject, 1)
Rule::Rule(void) // needed for the SERIAL
{
}
Rule::Rule( rule_type rt, std::vector<std::string>& vec)
: m_type( rt)
, m_params( vec)
, m_name( "")
{
}
Rule::~Rule(void)
{
}
Rule::Rule( const Rule& pRule)
: m_type( pRule.m_type)
, m_params( pRule.m_params)
, m_name( pRule.m_name)
{
}
const Rule& Rule::operator=( const Rule& pRule)
{
if( this == &pRule)
return *this;
m_type = pRule.m_type;
m_params = pRule.m_params;
m_name = pRule.m_name;
return *this;
}
void Rule::Serialize( CArchive& ar)
{
// base is called
//CObject::Serialize( ar);
if( ar.IsStoring())
{
int type = m_type;
unsigned int size = (unsigned int) m_params.size();
ar << type;
ar << CString( m_name.c_str());
ar << size;
for( unsigned int i = 0; i < m_params.size(); ++i)
{
ar << CString(m_params[i].c_str());
}
}
else
{
ASSERT( ar.IsLoading());
int type;
CString name;
unsigned int size;
ar >> type;
m_type = (Rule::rule_type) type;
ar >> name;
m_name = (LPCTSTR) name;
ar >> size;
m_params.resize( size);
for( unsigned int i = 0; i < size; ++i)
{
CString el;
ar >> el;
m_params[i] = (LPCTSTR) el;
}
}
}
/*static*/ const char * Rule::rule_templates[] =
{ "TKindNameChange.xsl"
, "TAttrNameChange.xsl"
, "TAttrTypeChange.xsl"
, "TEnumAttrValueChange.xsl"
, "TMoveUpElem.xsl"
, "TMoveDownElem.xsl"
, "TRemoveKind.xsl"
, "TRemoveGlobalAttr.xsl"
, "TRemoveLocalAttr.xsl"
};
/*static*/ CString Rule::ruleTypeStr( int i)
{
CString fN( Rule::rule_templates[i]);
fN.Replace( ".xsl", "");
return fN.Right( fN.GetLength() - 1);
}
void Rule::gen( std::ostream& pFstream)
{
Script * scr = 0;
if( m_type == Rule::MoveDownElem)
scr = new ScriptMoveDown();
else if( m_type == Rule::MoveUpElem)
scr = new ScriptMoveUp();
else if( m_type == Rule::AttrNameChange)
scr = new ScriptAttrName();
else if( m_type == Rule::AttrTypeChange)
scr = new ScriptAttrType();
else if( m_type == Rule::EnumAttrValueChange)
scr = new ScriptEnumAttrValue();
else
scr = new Script();
scr->init( rule_templates[ (int) m_type]);
CString txt = scr->instantiat2( this->m_params, pFstream);
pFstream << txt;
delete scr;
}
/*static*/ CString Rule::ruleSummary( Rule::rule_type pTyp, const std::vector<std::string>& pParams)
{
std::string sum;
if( pTyp == Rule::KindNameChange)
{
sum = pParams[0] + " -> " + pParams[1];
}
else if( pTyp == Rule::AttrNameChange)
{
sum = pParams[0] + " -> " + pParams[1];
}
else if( pTyp == Rule::AttrTypeChange)
{
sum = pParams[0] + ": typecheck";
}
else if( pTyp == Rule::EnumAttrValueChange)
{
sum = pParams[0] + ":" + pParams[1] + " -> " + pParams[2];
}
else if( pTyp == Rule::MoveUpElem)
{
if( pParams.empty())
sum = "(empty)";
else
sum = pParams.back() + " move up";
}
else if( pTyp == Rule::MoveDownElem)
{
if( pParams.empty())
sum = "(empty)";
else
sum = pParams.front() + " move down";
}
else if( pTyp == Rule::RemoveKind
|| pTyp == Rule::RemoveGlobalAttr)
{
sum = pParams[0] + " remove";
}
else if( pTyp == Rule::RemoveLocalAttr)
{
sum = pParams[0] + " (in " + pParams[1] + ") remove";
}
return CString( sum.c_str());
}
/*static*/ CString Rule::ruleSummary( const Rule& pRule)
{
return ruleSummary( pRule.m_type, pRule.m_params);
}
--- NEW FILE: Extractor.cpp ---
#include "StdAfx.h"
#include ".\extractor.h"
#include <fstream>
#include <algorithm>
Extractor::Extractor(void)
{
}
Extractor::~Extractor(void)
{
}
void Extractor::init()
{
m_names.clear();
m_attrs.clear();
}
void Extractor::doJob( std::string& pName)
{
init();
std::ofstream ofile( ( pName + ".parsed").c_str(), std::ios_base::out);
std::ifstream file( pName.c_str());
if( !file) return;
char buff[1024];
bool global_attr = true;
std::string last_kind = "";
while( file)
{
//
file.getline( buff, 1024);
std::string bf( buff);
for( unsigned int i = 0; i < bf.length() && (bf[i] == ' ' || bf[i] == 9); ++i);
const int kindsNo = 6;
std::string kinds[ kindsNo ] =
{ "<atom name"
, "<set name"
, "<reference name"
, "<connection name"
, "<model name"
, "<folder name"
};
bool found = false;
unsigned int j = 0;
for( ; !found && j < kindsNo; ++j)
{
found = 0 == kinds[j].compare( bf.substr( i, kinds[j].length()));
}
if( found)
{
--j;
std::string one_name = get( " name", bf.substr(i)); // whitespaces stripped off
last_kind = one_name;
if( std::find( m_names.begin(), m_names.end(), one_name) != m_names.end()) // already there
ASSERT(0); // how come?
else
m_names.push_back( one_name);
// my attributes are inserted there
std::string myattrs = get( " attributes", bf.substr(i));
if( !myattrs.empty())
m_attrs[ one_name ] = myattrs;
}
}
for( NAMES::iterator it = m_names.begin(); it != m_names.end(); ++it)
{
ofile << "k" << ' ' << *it << ' ' << std::endl;
if( m_attrs.find( *it) != m_attrs.end()) // found, key/value really exists
ofile << "a" << ' ' << *it << ' ' << m_attrs[ *it ] << std::endl; // the attributes of *it
}
file.close();
ofile.close();
}
void Extractor::doPlainLoad( std::string& pName)
{
init();
std::basic_ifstream<char> f( pName.c_str());
while( f)
{
std::string type;
std::string one_name;
f >> type >> one_name;
if( type == "k")
{
if( std::find( m_names.begin(), m_names.end(), one_name) != m_names.end()) // already there
ASSERT(0); // how come?
else
m_names.push_back( one_name);
}
else if( type == "a")
{
char buffer[5024];
f.getline( buffer, 5024);
m_attrs[ one_name ] = buffer; // one_name in this case is the owner of the attributes
}
}
f.close();
}
const Extractor::NAMES& Extractor::getKinds()
{
return m_names;
}
const Extractor::ATTRS& Extractor::getAttrs()
{
return m_attrs;
}
/*static*/ std::string Extractor::get( const std::string& attr, const std::string& buff)
{
std::string res;
size_t attr_start = buff.find( attr);
if( attr_start == std::string::npos) return "";
size_t quot_begin = buff.find( '"', attr_start + attr.length());
size_t quot_end = buff.find( '"', quot_begin + 1);
if( quot_begin == std::string::npos || quot_end == std::string::npos) return "";
return buff.substr( quot_begin + 1, quot_end - quot_begin - 1);
}
/*static*/ Extractor::NAMES Extractor::tokenize( const std::string& source)
{
NAMES result;
if( source.empty()) return result;
const std::string whsp = " "; // whitespaces to ignore
unsigned int last = 0;
do
{
unsigned int curr_token_start = source.find_first_not_of( whsp, last);
unsigned int curr_token_end = source.find( whsp, curr_token_start);
if( curr_token_end > curr_token_start)
result.push_back( source.substr( curr_token_start, curr_token_end - curr_token_start));
last = curr_token_end;
}
while( last != std::string::npos );
return result;
}
--- NEW FILE: ScriptAttrType.cpp ---
#include "StdAfx.h"
#include ".\ScriptAttrType.h"
ScriptAttrType::ScriptAttrType(void)
{
}
ScriptAttrType::~ScriptAttrType(void)
{
}
CString ScriptAttrType::instantiat2( const std::vector< std::string >& pars, std::ostream& pstream)
{
CString res = Script::instantiat2( pars, pstream);
if( pars.size() >= 4 && pars[2] != "1") // is not a global attribute
{
if( pars[3] == "") { AfxMessageBox( "No owner specified for local attribute!"); return ""; }
CString toIns = CString( " and ../@kind='") + pars[3].c_str() + "'";
res.Replace( "##|OPTIONALLOCALCONDITION|##", toIns);
}
else
res.Replace( "##|OPTIONALLOCALCONDITION|##", "");
return res;
}
--- NEW FILE: ScriptCmplx.cpp ---
#include "StdAfx.h"
#include ".\scriptcmplx.h"
#include <fstream>
#include <strstream>
/*static*/ const char * ScriptCmplx::output_log_file = "ValidatorLog.txt";
// this uses XSLT version 1.1
/*static*/ const char * ScriptCmplx::header = "\
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.1\">\n\
\n\
<xsl:output method=\"xml\" omit-xml-declaration=\"no\" doctype-system=\"mga.dtd\" indent=\"yes\"/>\n\
\n\
<xsl:template match=\"/\">\n\
\t<xsl:apply-templates/>\n\
</xsl:template>\n\
\n\
\n";
/*static*/ const char * ScriptCmplx::kind_removed_log_cmd = "KINDREMOVAL: <xsl:value-of select = \"@kind\"/> [<xsl:value-of select = \"./name\"/>] in <xsl:value-of select=\"../@kind\"/> [<xsl:value-of select = \"../name\"/>]";
/*static*/ const char * ScriptCmplx::attr_removed_log_cmd = "ATTRREMOVAL: <xsl:value-of select = \"@kind\"/> attribute in <xsl:value-of select=\"../@kind\"/> [<xsl:value-of select = \"../name\"/>]";
// ---------------------------------------------------------
// body
// ---------------------------------------------------------
//<xsl:template match="project">
// <xsl:variable name="kinds_to_remove" select="//*[name() != 'attribute' and
//@kind != 'M1' and
//@kind != 'M2' and
//@kind != 'RootFolder'
//]"/>
//
// <!-- separate variable for each attribute owner kind -- >
// <xsl:variable name="attrs_to_remove1" select="//attribute[
//../@kind = 'M1' and
//@kind != 'L1' and
//@kind != 'L2' and
//@kind != 'G1' and
//@kind != 'G2'
//]"/>
//
//
// <!-- separate variable for each attribute owner kind -- >
// <xsl:variable name="attrs_to_remove2" select="//attribute[
//../@kind = 'M2' and
//@kind != 'L5' and
//@kind != 'L6' and
//@kind != 'G7' and
//@kind != 'G8'
//]"/>
//
// <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
// <!-- producing the summary text file -->
// <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
// <xsl:document href="removals.txt" method="text">Summary of kind and attribute removals
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//<xsl:for-each select="$kinds_to_remove">KINDREMOVAL: <xsl:value-of select = "@kind"/> [<xsl:value-of select = "./name"/>] in <xsl:value-of select="../@kind"/> [<xsl:value-of select = "../name"/>]
//</xsl:for-each>
//
//<xsl:for-each select="$attrs_to_remove">ATTRREMOVAL: <xsl:value-of select = "@kind"/> attribute in <xsl:value-of select="../@kind"/> [<xsl:value-of select = "../name"/>]
//</xsl:for-each>
//
// </xsl:document>
//
//
// <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
// <!-- producing the summary at the beginning of the project -->
// <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
//<xsl:comment>
//
//Summary of kind and attribute removals
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <xsl:for-each select="$kinds_to_remove">
//KINDREMOVAL: <xsl:value-of select = "@kind"/> [<xsl:value-of select = "./name"/>] in <xsl:value-of select="../@kind"/> [<xsl:value-of select = "../name"/>]</xsl:for-each>
//
// <xsl:for-each select="$attrs_to_remove">
//ATTRREMOVAL: <xsl:value-of select = "@kind"/> attribute in <xsl:value-of select="../@kind"/> [<xsl:value-of select = "../name"/>]</xsl:for-each>
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//End of Summary
//</xsl:comment>
//
// <xsl:copy>
// <xsl:apply-templates select="@*"/>
// <xsl:apply-templates/>
// </xsl:copy>
//</xsl:template>
//
//<xsl:template match="*[
//name() != 'attribute' and
//@kind != 'M1' and
//@kind != 'M2' and
//@kind != 'RootFolder'
//]">
//<xsl:comment>KINDREMOVAL: <xsl:value-of select = "@kind"/> [<xsl:value-of select = "./name"/>] in <xsl:value-of select="../@kind"/> [<xsl:value-of select = "../name"/>]</xsl:comment>
//</xsl:template>
//
//<!-- M1 has L1, L2 (local) and G1, G2 global attributes, but they aren't distinguished -->
//<xsl:template match="attribute[
//../@kind = 'M1' and
//@kind != 'L1' and
//@kind != 'L2' and
//@kind != 'G1' and
//@kind != 'G2'
//]">
//<xsl:comment>ATTRREMOVAL: <xsl:value-of select = "@kind"/> attribute in <xsl:value-of select="../@kind"/> [<xsl:value-of select = "../name"/>]</xsl:comment>
//</xsl:template>
// ---------------------------------------------------------
// end
// ---------------------------------------------------------
/*static*/ const char * ScriptCmplx::tail = "\
<xsl:template match=\"*|@*\">\n\
\t<xsl:copy>\n\
\t<xsl:apply-templates select=\"@*\"/>\n\
\t<xsl:apply-templates/>\n\
\t</xsl:copy>\n\
</xsl:template>\n\
\n\
</xsl:stylesheet>";
ScriptCmplx::ScriptCmplx(void)
: ScriptAbs()
{
}
ScriptCmplx::~ScriptCmplx(void)
{
}
void ScriptCmplx::gen( const Extractor::NAMES& pNames, const Extractor::ATTRS& pAttrs, const char *pfName)
{
std::ofstream f( pfName, std::ios_base::out);
std::ostrstream pred_for_kinds;
//[ name() != 'attribute'
// and @kind != 'M1'
// and @kind != 'M2'
// and @kind != 'A1'
// and @kind != 'RootFolder'
//]
// let's produce the predicate above (for kinds):
genPredKinds( pred_for_kinds, pNames);
f << header;
// ################################################
// bulding an xsl:template for project manipulation
// ################################################
// the 'project' matching rule will output the summary
f << "<xsl:template match=\"project\">" << std::endl;
// one variable for storing the kinds that are removed
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<!-- one variable storing each unknown element node -->" << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<xsl:variable name=\"kinds_to_remove\" select=\"//*";
f << pred_for_kinds.str();
f << "\"/>" << std::endl << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<!-- separate variables for each attribute owner kind -->" << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
unsigned int i = 0;
for( Extractor::ATTRS::const_iterator it = pAttrs.begin(); it != pAttrs.end(); ++it, ++i)
{
std::ostrstream predi;
genPredAttrs( predi, it);
f << "\t<xsl:variable name=\"attrs_to_remove" << i << "\" select=\"//attribute";
f << predi.str() << "\"/>" << std::endl << std::endl;
}
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<!-- producing the summary at the beginning of the project -->" << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "<xsl:comment>" << std::endl;
f << std::endl;
f << "Summary of kind and attribute removals" << std::endl;
f << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <xsl:for-each select=\"$kinds_to_remove\">" << std::endl;
f << kind_removed_log_cmd << "</xsl:for-each>" << std::endl;
f << std::endl;
if( !pAttrs.empty())
{
f << "<xsl:for-each select=\"";
unsigned int i = 0;
for( Extractor::ATTRS::const_iterator it = pAttrs.begin(); it != pAttrs.end(); ++it, ++i)
{
if( i != 0) f << "|";
f << "$attrs_to_remove" << i;
}
f << "\">" << std::endl; // end the for-each opening tag
f << attr_removed_log_cmd << "</xsl:for-each>" << std::endl;
}
f << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
f << "End of Summary" << std::endl;
f << "</xsl:comment>" << std::endl;
f << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<!-- producing the summary text file -->" << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<xsl:document href=\"" << output_log_file << "\" method=\"text\">Summary of kind and attribute removals" << std::endl;
f << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
f << "<xsl:for-each select=\"$kinds_to_remove\">" << kind_removed_log_cmd << std::endl;
f << "</xsl:for-each>" << std::endl;
f << std::endl;
if( !pAttrs.empty())
{
f << "<xsl:for-each select=\"";
unsigned int i = 0;
for( Extractor::ATTRS::const_iterator it = pAttrs.begin(); it != pAttrs.end(); ++it, ++i)
{
if( i != 0) f << "|";
f << "$attrs_to_remove" << i;
}
f << "\">"; // end the for-each opening tag
f << attr_removed_log_cmd << std::endl;
f << "</xsl:for-each>";
}
f << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
f << "End of Summary" << std::endl;
f << "\t</xsl:document>" << std::endl;
f << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<!-- launch inner processing of the project -->" << std::endl;
f << "\t<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->" << std::endl;
f << "\t<xsl:copy>" << std::endl;
f << "\t<xsl:apply-templates select=\"@*\"/>" << std::endl;
f << "\t<xsl:apply-templates/>" << std::endl;
f << "\t</xsl:copy>" << std::endl;
f << "</xsl:template>" << std::endl;
f << std::endl;
// ################################################
// end of bulding project manipulation template
// ################################################
// ################################################
// bulding an xsl:template to ignore unknown kinds
// ################################################
f << "<xsl:template match=\"*" << pred_for_kinds.str() << "\">" << std::endl;
f << "<xsl:comment>" << kind_removed_log_cmd << "</xsl:comment>" << std::endl;
f << "</xsl:template>" << std::endl;
f << std::endl;
// ################################################
// bulding several xsl:templates to ignore unknown attributes
// ################################################
for( Extractor::ATTRS::const_iterator it = pAttrs.begin(); it != pAttrs.end(); ++it)
{
std::ostrstream predi;
genPredAttrs( predi, it);
f << "<xsl:template match=\"attribute" << predi.str() << "\">" << std::endl;
f << "<xsl:comment>" << attr_removed_log_cmd << "</xsl:comment>" << std::endl;
f << "</xsl:template>" << std::endl;
f << std::endl;
}
f << tail;
f.close();
}
void ScriptCmplx::genPredAttrs( std::ostream& ostr, const Extractor::ATTRS::const_iterator& iter)
{
Extractor::NAMES res = Extractor::tokenize( iter->second);
if( !res.empty())
{
ostr << "[ ../@kind = '" << iter->first << "'" << std::endl;
for( Extractor::NAMES::iterator jt = res.begin(); jt != res.end(); ++jt)
ostr << " and @kind != '" << *jt << "'" << std::endl;
ostr << "]";
}
ostr << std::ends;
}
void ScriptCmplx::genPredKinds( std::ostream& ostr, const Extractor::NAMES& pNames)
{
ostr << "[ name() != 'attribute'" << std::endl;
for( Extractor::NAMES::const_iterator it = pNames.begin(); it != pNames.end(); ++it)
{
ostr << " and @kind != '" << *it << "'" << std::endl;
}
ostr << "]";
ostr << std::ends;
}
--- NEW FILE: AttrGlobalDlg.cpp ---
// AttrGlobalDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "AttrGlobalDlg.h"
// AttrGlobalDlg dialog
IMPLEMENT_DYNAMIC(AttrGlobalDlg, CDialog)
AttrGlobalDlg::AttrGlobalDlg( const CString& pGlobal, const CString& pOwner, CWnd* pParent /*=NULL*/)
: CDialog(AttrGlobalDlg::IDD, pParent)
, m_iGlobalLocal( pGlobal=="1"?0:1)
, m_ownerKind( pOwner)
{
}
AttrGlobalDlg::~AttrGlobalDlg()
{
}
void AttrGlobalDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Radio(pDX, IDC_RADIO1, m_iGlobalLocal);
DDX_Text(pDX, IDC_EDIT3, m_ownerKind);
}
BEGIN_MESSAGE_MAP(AttrGlobalDlg, CDialog)
ON_BN_CLICKED(IDC_RADIO1, OnBnClickedRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnBnClickedRadio2)
END_MESSAGE_MAP()
// AttrGlobalDlg message handlers
void AttrGlobalDlg::OnBnClickedRadio1()
{
if( GetDlgItem( IDC_EDIT3)) GetDlgItem( IDC_EDIT3)->EnableWindow( FALSE);
}
void AttrGlobalDlg::OnBnClickedRadio2()
{
if( GetDlgItem( IDC_EDIT3)) GetDlgItem( IDC_EDIT3)->EnableWindow( TRUE);
}
BOOL AttrGlobalDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if( m_iGlobalLocal == 0 && GetDlgItem( IDC_EDIT3)) GetDlgItem( IDC_EDIT3)->EnableWindow( FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AttrGlobalDlg::OnOK()
{
UpdateData( TRUE);
if( m_iGlobalLocal == 1 && m_ownerKind == "")
{
AfxMessageBox( "No owner specified for local attribute!", MB_ICONSTOP);
}
else
{
EndDialog( IDOK);
DestroyWindow();
}
}
CString AttrGlobalDlg::getGlobal() const
{
return (m_iGlobalLocal == 0)?"1":"0";
}
const CString& AttrGlobalDlg::getOwner() const
{
return m_ownerKind;
}
--- NEW FILE: FrontEnd2.rc ---
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#include ""res\\FrontEnd.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON "res\\FrontEnd.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "About ModelMigrate"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,21,20
LTEXT "ModelMigrate Version 1.0",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) ISIS, Vanderbilt University 2005",
IDC_STATIC,40,25,178,8
DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP
LTEXT "Author: Zoltan Molnar, Vanderbilt University",
IDC_STATIC,40,40,178,8
END
IDD_DLG_PROPNAMECHANGE DIALOGEX 0, 0, 186, 87
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Replace"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,13,54,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "New:",IDC_STATIC,15,42,18,8
LTEXT "Old:",IDC_STATIC,16,10,14,8
END
IDD_DLG_ADDRULE DIALOGEX 0, 0, 186, 95
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "New Rule"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LISTBOX IDC_LIST1,7,7,114,81,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
END
IDD_DLG_PROPENATTRCHANGE DIALOGEX 0, 0, 303, 122
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Enum Attribute Value Change"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,21,27,90,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,21,65,90,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT3,128,65,90,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,246,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,246,24,50,14
PUSHBUTTON "Global/Local",IDGLOBAL,246,41,50,14
LTEXT "Enum Attribute Name",IDC_STATIC,21,15,81,8
LTEXT "Old Enumeration Value",IDC_STATIC,21,52,81,8
LTEXT "New Enumeration Value",IDC_STATIC,128,52,81,8
LTEXT "Note: Only the values need to be transformed. The labels displayed are handled automatically by GME.",
IDC_STATIC,20,86,197,20
END
IDD_DLG_PROPATTRCHANGE DIALOGEX 0, 0, 186, 86
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Attribute Name Change"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,13,54,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
PUSHBUTTON "Global/Local",IDGLOBAL,129,42,50,14
LTEXT "New:",IDC_STATIC,15,42,18,8
LTEXT "Old:",IDC_STATIC,16,10,14,8
END
IDD_DLG_FILETRANS DIALOGEX 0, 0, 494, 345
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP |
WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "ModelMigrate"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT2,125,7,261,13,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTON3,392,7,19,14
PUSHBUTTON "Edit Rules",IDC_BUTTON1,417,7,50,14
PUSHBUTTON "Process All",IDC_BUTTON4,7,25,50,14
PUSHBUTTON "Process Selected",IDC_BUTTON8,62,25,64,14
PUSHBUTTON "Add Dir",IDC_BUTTON2,146,25,50,14
PUSHBUTTON "Add File",IDC_BUTTON6,201,25,50,14
PUSHBUTTON "Clear Log",IDC_BUTTONCLEAR,361,26,50,14
PUSHBUTTON "Options",IDC_BUTTON5,417,26,50,14
PUSHBUTTON "Cancel",IDCANCEL,292,26,26,14,NOT WS_VISIBLE
PUSHBUTTON "OK",IDOK,323,26,20,14,NOT WS_VISIBLE
CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT |
LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,42,480,182,
WS_EX_ACCEPTFILES
LTEXT "Script to apply on selected files:",IDC_STATIC,15,8,106,
10
EDITTEXT IDC_EDIT4,7,228,480,110,ES_MULTILINE | ES_AUTOHSCROLL |
ES_READONLY | WS_VSCROLL | WS_HSCROLL
END
IDD_DLG_OPTIONS DIALOGEX 0, 0, 308, 149
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Options"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,17,21,192,15,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTON1,213,21,22,14
EDITTEXT IDC_EDIT2,17,53,192,15,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTON6,213,53,22,14
EDITTEXT IDC_EDIT5,17,84,192,15,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT6,17,115,192,15,ES_AUTOHSCROLL
PUSHBUTTON "...",IDC_BUTTON7,213,115,22,14
DEFPUSHBUTTON "OK",IDOK,251,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,251,24,50,14
LTEXT "Initial directory to load:",IDC_STATIC,20,10,126,8
LTEXT "Default script to apply:",IDC_STATIC,20,41,81,8
LTEXT "Appended string to filenames:",IDC_STATIC,20,73,128,8
LTEXT "Target directory (if empty then same directory as input)",
IDC_STATIC,20,104,185,8
END
IDD_DLG_RULEEDITOR DIALOGEX 0, 0, 261, 207
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Rule Editor"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Add Rule...",IDADDRULE,7,7,46,14
PUSHBUTTON "Generate All",IDGENERATE,60,7,47,14
PUSHBUTTON "Generate Selected",IDGENERATESEL,121,7,68,14
DEFPUSHBUTTON "OK",IDOK,204,7,50,14
CONTROL "",IDC_RULELIST,"SysListView32",LVS_REPORT |
LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER |
WS_TABSTOP,7,25,247,175
END
IDD_DLG_PROPMOVEUP DIALOGEX 0, 0, 228, 223
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Move Element Up In Hierarchy"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_TREE1,"SysTreeView32",TVS_HASBUTTONS |
TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS |
TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,7,26,155,155
PUSHBUTTON "OK",IDOK,171,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,171,24,50,14
PUSHBUTTON "Insert Child",IDC_BUTTON_INSERTNODE,171,48,50,14
PUSHBUTTON "Delete Child",IDC_BUTTON_DELETENODE,171,71,50,14
LTEXT "Please construct the hierarchy of elements to be matched. The lowest child will be moved up:",
IDC_STATIC,7,7,155,19
LTEXT "When the transformer meets such a construct it will move the lowest child up (its syblings remain there), so that it becomes a sybling of the highest element in this hierarchy.",
IDC_STATIC,7,187,214,27
END
IDD_DLG_PROPMOVEDOWN DIALOGEX 0, 0, 237, 193
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Move Down Element"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDITKIND,7,20,162,12,ES_AUTOHSCROLL
CONTROL "",IDC_TREETWO,"SysTreeView32",TVS_HASBUTTONS |
TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS |
TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER |
WS_TABSTOP,7,49,162,118
DEFPUSHBUTTON "OK",IDOK,180,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,180,24,50,14
PUSHBUTTON "Insert Child",IDC_BUTTON_INSERTNODE,180,50,50,14
PUSHBUTTON "Delete Child",IDC_BUTTON_DELETENODE,180,73,50,14
LTEXT "Element to move down:",IDC_STATIC,9,10,143,10
LTEXT "Wrap into:",IDC_STATIC,7,38,143,10
LTEXT "When specifying the wrapper elements, please indicate Models by appending a ':M' to the label.",
IDC_STATIC,7,168,167,18
END
IDD_DLG_PROPATTRTYPECHANGE DIALOGEX 0, 0, 299, 170
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Conversion Test of Attribute Values (string to number)"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,7,17,211,14,ES_AUTOHSCROLL
CONTROL "Terminate on conversion failure?",IDC_CHECK1,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,75,213,10
PUSHBUTTON "Generate Separate Script",IDC_BUTTON1,7,117,215,14
DEFPUSHBUTTON "OK",IDOK,242,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,242,24,50,14
PUSHBUTTON "Global/Local",IDGLOBAL,242,42,50,14
LTEXT "Attribute kind to be checked for conversion to number:",
IDC_STATIC,7,7,211,10
LTEXT "Note: Values are not really converted, just checked. This script is only checking if the conversion will succeed when GME will parse the file. If it doesn't, then a comment is introduced ('CONVERROR') into the target file.",
IDC_STATIC,7,36,211,35
LTEXT "Note: if unchecked please check manually the target file for 'CONVERROR's since the transformer will not show any error.",
IDC_STATIC,7,87,215,24
LTEXT "Note: By generating a separate script you can execute this stand-alone script and get as output a formatted text file containing the error occurences, if any.",
IDC_STATIC,7,135,214,29
END
IDD_DLG_PROPATTRGLOBALLOCAL DIALOGEX 0, 0, 237, 46
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Global or Local Attribute?"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,180,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,180,24,50,14
CONTROL "Global",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON |
WS_GROUP | WS_TABSTOP,13,11,35,10
CONTROL "Local",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,13,24,32,
10
EDITTEXT IDC_EDIT3,65,21,96,13,ES_AUTOHSCROLL
LTEXT "Owned by:",IDC_STATIC,66,11,36,8
END
IDD_DLG_PROPREMOVEELEM DIALOGEX 0, 0, 186, 46
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Remove Kind"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "Name:",-1,16,10,80,8
END
IDD_DLG_PROPREMOVELOCALATTR DIALOGEX 0, 0, 186, 87
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Remove Local Attribute"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT1,13,22,84,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,13,54,84,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
LTEXT "Owned by:",IDC_STATIC,15,42,36,8
LTEXT "Attribute:",IDC_STATIC,16,10,32,8
END
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "ISIS, Vanderbilt University, 2005"
VALUE "FileDescription", "TODO: <File description>"
VALUE "FileVersion", "1.0.0.1"
VALUE "InternalName", "FrontEnd.exe"
VALUE "LegalCopyright", "ISIS, Vanderbilt University, 2005"
VALUE "OriginalFilename", "FrontEnd.exe"
VALUE "ProductName", "ModelMigrate"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 228
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_DLG_PROPNAMECHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 80
END
IDD_DLG_ADDRULE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 88
END
IDD_DLG_PROPENATTRCHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 296
TOPMARGIN, 7
BOTTOMMARGIN, 115
END
IDD_DLG_PROPATTRCHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 79
END
IDD_DLG_FILETRANS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 487
TOPMARGIN, 7
BOTTOMMARGIN, 338
END
IDD_DLG_OPTIONS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 301
TOPMARGIN, 7
BOTTOMMARGIN, 142
END
IDD_DLG_RULEEDITOR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 254
TOPMARGIN, 7
BOTTOMMARGIN, 200
END
IDD_DLG_PROPMOVEUP, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 221
TOPMARGIN, 7
BOTTOMMARGIN, 216
END
IDD_DLG_PROPMOVEDOWN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 230
TOPMARGIN, 7
BOTTOMMARGIN, 186
END
IDD_DLG_PROPATTRTYPECHANGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 292
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
IDD_DLG_PROPATTRGLOBALLOCAL, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 230
TOPMARGIN, 7
BOTTOMMARGIN, 39
END
IDD_DLG_PROPREMOVEELEM, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 39
END
IDD_DLG_PROPREMOVELOCALATTR, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 80
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// XSL
//
Header.xsl XSL "res\\header.xsl"
Tail.xsl XSL "res\\tail.xsl"
TKindNameChange.xsl XSL "res\\TKindNameChange.xsl"
TAttrNameChange.xsl XSL "res\\TAttrNameChange.xsl"
TEnumAttrValueChange.xsl XSL "res\\TEnumAttrValueChange.xsl"
TAttrTypeChange.xsl XSL "res\\TAttrTypeChange.xsl"
TAttrTypeCheck2Text.xsl XSL "res\\TAttrTypeCheck2Text.xsl"
TRemoveGlobalAttr.xsl XSL "res\\TRemoveGlobalAttr.xsl"
TRemoveLocalAttr.xsl XSL "res\\TRemoveLocalAttr.xsl"
TRemoveKind.xsl XSL "res\\TRemoveKind.xsl"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_ABOUTBOX "&About ModelMigrate..."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#include "res\FrontEnd.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
--- NEW FILE: MoveDownElem.h ---
#pragma once
#include "afxcmn.h"
#include <vector>
#include <string>
// MoveDownElem dialog
class MoveDownElem : public CDialog
{
DECLARE_DYNAMIC(MoveDownElem)
public:
MoveDownElem(CWnd* pParent = NULL); // standard constructor
virtual ~MoveDownElem();
// Dialog Data
enum { IDD = IDD_DLG_PROPMOVEDOWN };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
virtual void OnCancel();
DECLARE_MESSAGE_MAP()
public:
void init( const std::vector< std::string>& pars);
CTreeCtrl m_tree;
CEdit m_editKind;
CEdit m_parentKind;
std::vector< std::string> getSequence();
protected:
HTREEITEM lastChild();
void addChild( const char * pLabel);
void remChild();
std::vector< std::string> getValues();
std::string getKindField();
std::string getParentField();
std::vector< std::string> m_storage;
void closeDlg( int pResult);
public:
afx_msg void OnTvnEndlabeleditTree1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnNMReturnTree1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedButtonInsertnode();
afx_msg void OnBnClickedButtonDeletenode();
virtual BOOL OnInitDialog();
};
--- NEW FILE: RuleListCtrl.cpp ---
// RuleListCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "RuleListCtrl.h"
#include "NewRuleDlg.h"
#include "SimpleRepl.h"
#include "AttrNameDlg.h"
#include "AttrTypeChangeDlg.h"
#include "EnumAttrValueDlg.h"
#include "MoveUpElem.h"
#include "MoveDownElem.h"
#include "RemoveDlg.h"
#include "RemoveLocAttrDlg.h"
#include "Script.h"
#include "Rule.h"
#include <fstream>
#include <algorithm>
// RuleListCtrl
#define EDIT_CMD 1501
#define DELESEL_CMD 1502
#define CLONE_CMD 1503
#define GENSEL_CMD 1504
#define GENALL_CMD 1505
#define MOVEUP_CMD 1506
#define MOVEDN_CMD 1507
#define ADD_CMD 1508
#define DELEALL_CMD 1509
// TODO: dependency with the other project in solution
IMPLEMENT_DYNAMIC(RuleListCtrl, CListCtrl)
RuleListCtrl::RuleListCtrl()
: rowID( 0)
, m_rules( 0)
{
}
RuleListCtrl::~RuleListCtrl()
{
m_rules.clear();
}
BEGIN_MESSAGE_MAP(RuleListCtrl, CListCtrl)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()
// RuleListCtrl message handlers
void RuleListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
CListCtrl::OnLButtonDown(nFlags, point);
}
// HitTestEx - Determine the row index and column index for a point
// Returns - the row index or -1 if point is not over a row
// point - point to be tested.
// col - to hold the column index
int RuleListCtrl::HitTestEx(CPoint &point, int *col) const
{
int colnum = 0;
int row = HitTest( point, NULL );
if( col ) *col = 0;
// Make sure that the ListView is in LVS_REPORT
if( (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
return row;
// Get the top and bottom row visible
row = GetTopIndex();
int bottom = row + GetCountPerPage();
if( bottom > GetItemCount() )
bottom = GetItemCount();
// Get the number of columns
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
// Loop through the visible rows
for( ;row <=bottom;row++)
{
// Get bounding rect of item and check whether point falls in it.
CRect rect;
GetItemRect( row, &rect, LVIR_BOUNDS );
if( rect.PtInRect(point) )
{
// Now find the column
for( colnum = 0; colnum < nColumnCount; colnum++ )
{
int colwidth = GetColumnWidth(colnum);
if( point.x >= rect.left
&& point.x <= (rect.left + colwidth ) )
{
if( col ) *col = colnum;
return row;
}
rect.left += colwidth;
}
}
}
return -1;
}
int RuleListCtrl::addRule( int chc, std::vector<std::string>& vec)
{
// append a new rule to the storage
Rule nR( (Rule::rule_type) chc, vec);
m_rules.push_back( nR);
return insertItem( nR);
}
void RuleListCtrl::addNewItem( int pChoice)
{
if( pChoice == Rule::KindNameChange)
{
SimpleReplace sr;
if( sr.DoModal() == IDOK)
{
std::vector<std::string> pars(2);
pars[0] = sr.getPar1();
pars[1] = sr.getPar2();
int idx = addRule( pChoice, pars);
}
}
else if( pChoice == Rule::AttrNameChange)
{
AttrNameDlg an;
if( an.DoModal() == IDOK)
{
std::vector<std::string> pars(4);
pars[0] = an.getPar1();
pars[1] = an.getPar2();
pars[2] = an.getPar3();
pars[3] = an.getPar4();
int idx = addRule( pChoice, pars);
}
}
else if( pChoice == Rule::AttrTypeChange)
{
AttrTypeChangeDlg tc;
if( tc.DoModal() == IDOK)
{
std::vector<std::string> pars(4);
pars[0] = tc.getPar1();
pars[1] = tc.getPar2();
pars[2] = tc.getPar3();
pars[3] = tc.getPar4();
int idx = addRule( pChoice, pars);
}
}
else if( pChoice == Rule::EnumAttrValueChange)
{
EnumAttrValueDlg ea;
if( ea.DoModal() == IDOK)
{
std::vector<std::string> pars(5);
pars[0] = ea.getPar1();
pars[1] = ea.getPar2();
pars[2] = ea.getPar3();
pars[3] = ea.getPar4();
pars[4] = ea.getPar5();
int idx = addRule( pChoice, pars);
}
}
else if( pChoice == Rule::MoveUpElem)
{
MoveUpElem mu;
if( mu.DoModal() == IDOK)
{
std::vector<std::string> pars = mu.getSequence();
addRule( pChoice, pars);
}
}
else if( pChoice == Rule::MoveDownElem)
{
MoveDownElem md;
if( md.DoModal() == IDOK)
{
std::vector< std::string> pars = md.getSequence();
addRule( pChoice, pars);
}
}
else if( pChoice == Rule::RemoveKind
|| pChoice == Rule::RemoveGlobalAttr)
{
RemoveDlg tc( pChoice == Rule::RemoveGlobalAttr);
if( tc.DoModal() == IDOK)
{
std::vector<std::string> pars(1);
pars[0] = tc.getPar1();
int idx = addRule( pChoice, pars);
}
}
else if( pChoice == Rule::RemoveLocalAttr)
{
RemoveLocalAttrDlg tc;
if( tc.DoModal() == IDOK)
{
std::vector<std::string> pars(2);
pars[0] = tc.getPar1();
pars[1] = tc.getPar2();
int idx = addRule( pChoice, pars);
}
}
}
void RuleListCtrl::showPropertyPage( int idx)
{
DWORD chc = (DWORD) GetItemData( idx);
if( chc == Rule::KindNameChange)
{
SimpleReplace sr;
ASSERT( idx < (int) m_rules.size());
ASSERT( m_rules[idx].m_params.size() >= 2);
sr.init( m_rules[idx].m_params[0].c_str(), m_rules[idx].m_params[1].c_str());
if( sr.DoModal() == IDOK)
{
m_rules[idx].m_params[0] = sr.getPar1();
m_rules[idx].m_params[1] = sr.getPar2();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
else if( chc == Rule::AttrNameChange)
{
AttrNameDlg an;
ASSERT( idx < (int) m_rules.size());
ASSERT( m_rules[idx].m_params.size() >= 4);
an.init( m_rules[idx].m_params[0].c_str(), m_rules[idx].m_params[1].c_str(), m_rules[idx].m_params[2].c_str(), m_rules[idx].m_params[3].c_str());
if( an.DoModal() == IDOK)
{
m_rules[idx].m_params[0] = an.getPar1();
m_rules[idx].m_params[1] = an.getPar2();
m_rules[idx].m_params[2] = an.getPar3();
m_rules[idx].m_params[3] = an.getPar4();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
else if( chc == Rule::AttrTypeChange)
{
AttrTypeChangeDlg tc;
ASSERT( idx < (int) m_rules.size());
ASSERT( m_rules[idx].m_params.size() >= 4);
tc.init( m_rules[idx].m_params[0].c_str(), m_rules[idx].m_params[1].c_str(), m_rules[idx].m_params[2].c_str(), m_rules[idx].m_params[3].c_str());
if( tc.DoModal() == IDOK)
{
m_rules[idx].m_params[0] = tc.getPar1();
m_rules[idx].m_params[1] = tc.getPar2();
m_rules[idx].m_params[2] = tc.getPar3();
m_rules[idx].m_params[3] = tc.getPar4();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
else if( chc == Rule::EnumAttrValueChange)
{
EnumAttrValueDlg ea;
ASSERT( idx < (int) m_rules.size());
ASSERT( m_rules[idx].m_params.size() >= 5);
ea.init( m_rules[idx].m_params[0].c_str(), m_rules[idx].m_params[1].c_str(), m_rules[idx].m_params[2].c_str(), m_rules[idx].m_params[3].c_str(), m_rules[idx].m_params[4].c_str());
if( ea.DoModal() == IDOK)
{
m_rules[idx].m_params[0] = ea.getPar1();
m_rules[idx].m_params[1] = ea.getPar2();
m_rules[idx].m_params[2] = ea.getPar3();
m_rules[idx].m_params[3] = ea.getPar4();
m_rules[idx].m_params[4] = ea.getPar5();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
else if( chc == Rule::MoveUpElem)
{
MoveUpElem mu;
mu.init( m_rules[idx].m_params );
if( mu.DoModal() == IDOK)
{
m_rules[idx].m_params = mu.getSequence();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
else if( chc == Rule::MoveDownElem)
{
MoveDownElem md;
md.init( m_rules[idx].m_params);
if( md.DoModal() == IDOK)
{
m_rules[idx].m_params = md.getSequence();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
else if( chc == Rule::RemoveKind
|| chc == Rule::RemoveGlobalAttr)
{
RemoveDlg tc( chc == Rule::RemoveGlobalAttr);
tc.init( m_rules[idx].m_params[0].c_str());
if( tc.DoModal() == IDOK)
{
m_rules[idx].m_params[0] = tc.getPar1();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
else if( chc == Rule::RemoveLocalAttr)
{
RemoveLocalAttrDlg tc;
tc.init( m_rules[idx].m_params[0].c_str(), m_rules[idx].m_params[1].c_str());
if( tc.DoModal() == IDOK)
{
m_rules[idx].m_params[0] = tc.getPar1();
m_rules[idx].m_params[1] = tc.getPar2();
setItem( Rule::ruleSummary( m_rules[idx]), idx, 0);
}
}
}
void RuleListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
int index;
CListCtrl::OnLButtonDblClk(nFlags, point);
int colnum;
if( ( index = HitTestEx( point, &colnum )) != -1 )
{
UINT flag = LVIS_FOCUSED;
if( (GetItemState( index, flag ) & flag) == flag )
{
if(colnum==0 || colnum != 0)
{
showPropertyPage( index);
}
}
else
SetItemState( index, LVIS_SELECTED | LVIS_FOCUSED ,
LVIS_SELECTED | LVIS_FOCUSED);
}
}
void RuleListCtrl::add()
{
NewRuleDlg nrd;
if( nrd.DoModal() == IDOK)
{
addNewItem( nrd.m_choice);
}
}
CString RuleListCtrl::genSelected()// const std::string& pOutputFileName)
{
std::vector< int> res; // vec constructed from the indices of the selected rows
for( int i = 0; i < GetItemCount(); ++i)
{
CString knd;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT | LVIF_STATE;
lvItem.iItem = i;
lvItem.iSubItem = 1;
lvItem.pszText = knd.GetBuffer( 1024);
lvItem.cchTextMax = 1024;
lvItem.stateMask = LVIS_SELECTED;
GetItem( &lvItem);
if( (lvItem.state & LVIS_SELECTED) == LVIS_SELECTED)
res.push_back( i );
}
CFileDialog dlg( FALSE, ".xsl", "script1", OFN_OVERWRITEPROMPT,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
if( gen( (LPCTSTR) dlg.GetPathName(), res))
return dlg.GetPathName();
}
return "";
}
CString RuleListCtrl::genAll()// const std::string& pOutputFileName)
{
CFileDialog dlg( FALSE, ".xsl", "script1", OFN_OVERWRITEPROMPT,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
std::vector< int> res( GetItemCount()); // like all rows were selected
for( unsigned int i = 0; i < res.size(); ++i)
res[i] = i;
if( gen( (LPCTSTR) dlg.GetPathName(), res))
return dlg.GetPathName();
}
return "";
}
int RuleListCtrl::gen( const std::string& pOutputFileName, const std::vector<int>& pSelectVec)
{
std::fstream f;
f.open( pOutputFileName.c_str(), std::ios_base::out|std::ios_base::binary); // write out as is (not to mess with additional CR-s)
ASSERT( f.is_open());
if( !f.is_open())
{
AfxMessageBox( "Could not create target file!");
return 0;
}
std::string h_part = Script::getXSLFromResource( "Header.xsl");
if( !h_part.empty())
{
f.write( h_part.c_str(), (std::streamsize) h_part.length());
}
f << "\r\n<!-- ******************************************* rules ******************************************* -->";
f << "\r\n";
for( unsigned int i = 0; i < m_rules.size(); ++i)
{
if( std::find( pSelectVec.begin(), pSelectVec.end(), i) == pSelectVec.end()) // not found
continue;
f << "\r\n";
f << "<!-- ~~~~~~~~~~~~ rule nb=\"" << i << "\" ~~~~~~~~~~~~ -->";
f << "\r\n";
m_rules[i].gen( f );
f << "\r\n";
f << "<!-- ~~~~~~~~~~~~ /rule ~~~~~~~~~~~~~~~~~~~ -->";
f << "\r\n";
f << "\r\n";
}
f << "<!-- ******************************************* /rules ******************************************* -->";
f << "\r\n\r\n\r\n";
std::string t_part = Script::getXSLFromResource( "Tail.xsl");
if( !t_part.empty())
{
f.write( t_part.c_str(), (std::streamsize) t_part.length());
}
f.close();
return 1;
}
void RuleListCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
CListCtrl::OnRButtonDown(nFlags, point);
ClientToScreen( &point);
createPopupMenu( point);
}
void RuleListCtrl::showPopupMenu()
{
// find the focused item to determine the position of the popup menu
int idx = -1;
for( int i = 0; idx == -1 && i < GetItemCount(); ++i)
{
UINT flag = LVIS_FOCUSED;// | LVIS_SELECTED;
if( (GetItemState( i, flag ) & flag) == flag )
{
idx = i;
}
}
CPoint point;
if( idx != -1)
GetItemPosition( idx, &point);
else
{
// no item found, use the top-left corner of the empty listcontrol
CRect rect;
GetClientRect(rect);
point = CPoint( rect.left, rect.top);
}
point.Offset( 10, 10);
ClientToScreen( &point);
createPopupMenu( point);
}
void RuleListCtrl::createPopupMenu( CPoint point)
{
CMenu m;
m.CreatePopupMenu();
m.AppendMenu( MF_ENABLED|MF_STRING, EDIT_CMD, "Edit");
m.AppendMenu( MF_ENABLED|MF_STRING, ADD_CMD, "Add");
m.AppendMenu( MF_ENABLED|MF_STRING, CLONE_CMD, "Clone");
m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
m.AppendMenu( MF_ENABLED|MF_STRING, DELEALL_CMD, "Delete All");
m.AppendMenu( MF_ENABLED|MF_STRING, DELESEL_CMD, "Delete Selected");
m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
m.AppendMenu( MF_ENABLED|MF_STRING, MOVEUP_CMD, "Move Up");
m.AppendMenu( MF_ENABLED|MF_STRING, MOVEDN_CMD, "Move Down");
m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
m.AppendMenu( MF_ENABLED|MF_STRING, GENALL_CMD, "Generate from All");
m.AppendMenu( MF_ENABLED|MF_STRING, GENSEL_CMD, "Generate from Selected");
m.TrackPopupMenu( TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x, point.y, this);
}
BOOL RuleListCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch( wParam)
{
case ADD_CMD: onAdd();break;
case EDIT_CMD: onEdit();break;
case DELEALL_CMD: onDeleAll();break;
case DELESEL_CMD: onDeleSel();break;
case CLONE_CMD: onClone();break;
case MOVEUP_CMD: onMoveUp();break;
case MOVEDN_CMD: onMoveDown();break;
case GENALL_CMD: onGenAll();break;
case GENSEL_CMD: onGenSel();break;
};
return CListCtrl::OnCommand(wParam, lParam);
}
void RuleListCtrl::onEdit()
{
int index = getFirstFocSel();
if( index != -1) showPropertyPage( index);
}
void RuleListCtrl::onClone()
{
int index = getFirstFocSel();
if( index != -1)
{
CString sum, typ;
getItem( sum, index, 0);
getItem( typ, index, 1);
addRule( m_rules[index].m_type, m_rules[index].m_params);
}
}
void RuleListCtrl::onDeleAll()
{
DeleteAllItems();
m_rules.clear();
}
void RuleListCtrl::onDeleSel()
{
for( int i = GetItemCount(); i > 0 ; --i)
{
UINT sel = GetItemState( i-1, LVIS_SELECTED);
if( sel & LVIS_SELECTED)
{
DeleteItem( i-1);
int index = i - 1;
// delete elem an index in m_rules
RULE_VEC_ITERATOR ri = m_rules.begin();
while( ri != m_rules.end() && index)
{ ++ri; --index; }
if( ri != m_rules.end()) // valid iterator
m_rules.erase( ri);
}
}
}
void RuleListCtrl::onMoveUp()
{
int index = getFirstFocSel();
if( index != -1 && index > 0)
{
CString sumI, typI, sumJ, typJ;
getItem( sumI, index, 0);
getItem( typI, index, 1);
getItem( sumJ, index-1, 0);
getItem( typJ, index-1, 1);
// swap the rule vector
Rule rl = m_rules[ index];
m_rules[ index] = m_rules[ index - 1];
m_rules[ index - 1] = rl; // simpler than an iter_swap
// swap the items in the list ctrl
setItem( (LPCTSTR) sumJ, index, 0);
setItem( (LPCTSTR) typJ, index, 1);
setItem( (LPCTSTR) sumI, index - 1, 0);
setItem( (LPCTSTR) typI, index - 1, 1);
DWORD data = (DWORD) GetItemData( index);
SetItemData( index, (DWORD) GetItemData( index - 1));
SetItemData( index - 1, data);
// set the focus and selection to the same item (in the upper line)
setFocSel( index - 1);
}
}
void RuleListCtrl::onMoveDown()
{
int index = getFirstFocSel();
if( index != -1 && index < GetItemCount() - 1)
{
CString sumI, typI, sumJ, typJ;
getItem( sumI, index, 0);
getItem( typI, index, 1);
getItem( sumJ, index+1, 0);
getItem( typJ, index+1, 1);
// swap the rule vector
Rule rl = m_rules[ index];
m_rules[ index] = m_rules[ index + 1];
m_rules[ index + 1] = rl; // simpler than an iter_swap
// swap the items in the list ctrl
setItem( (LPCTSTR) sumJ, index, 0);
setItem( (LPCTSTR) typJ, index, 1);
setItem( (LPCTSTR) sumI, index + 1, 0);
setItem( (LPCTSTR) typI, index + 1, 1);
DWORD data = (DWORD) GetItemData( index);
SetItemData( index, (DWORD) GetItemData( index + 1));
SetItemData( index + 1, data);
// set the focus and selection to the same item (in the lower line)
setFocSel( index + 1);
}
}
void RuleListCtrl::onGenAll()
{
genAll();
}
void RuleListCtrl::onGenSel()
{
genSelected();
}
void RuleListCtrl::onAdd()
{
add();
}
int RuleListCtrl::getFirstFocSel()
{
int index = -1;
UINT flag = LVIS_FOCUSED | LVIS_SELECTED;
for( int i = 0; index == -1 && i < GetItemCount(); ++i)
{
if( (GetItemState( i, flag) & flag) == flag) index = i;
}
return index;
}
void RuleListCtrl::setFocSel( int index)
{
UINT flag = LVIS_FOCUSED | LVIS_SELECTED;
for( int i = 0; i < GetItemCount(); ++i)
if( i == index) SetItemState( i, flag, flag);
else SetItemState( i, 0 , flag);
}
void RuleListCtrl::PreSubclassWindow()
{
int col0size = 2*GetStringWidth("KindNameChangeIsSo");
int col1size = 2*GetStringWidth("TypeOfIsAlso");
//int col2size = 2*GetStringWidth("Apply");
//int col3size = 2*GetStringWidth("Priority");
InsertColumn(0, _T("Rule"), LVCFMT_LEFT, col0size, -1);
InsertColumn(1, _T("Type"), LVCFMT_LEFT, col1size, -1);
//InsertColumn(2, _T("Apply"), LVCFMT_LEFT, col2size, -1);
//InsertColumn(3, _T("Priority"), LVCFMT_LEFT, col3size, -1);
SetExtendedStyle( LVS_EX_FULLROWSELECT );
CListCtrl::PreSubclassWindow();
}
int RuleListCtrl::insertItem( const Rule& pRule)
{
CString sum = Rule::ruleSummary( pRule);
CString typ = Rule::ruleTypeStr( (int) pRule.m_type);
// append an item to the control
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = GetItemCount();
lvItem.iSubItem = 0;
lvItem.pszText = sum.GetBuffer(sum.GetLength());
int index = InsertItem(&lvItem);
lvItem.iSubItem = 1;
lvItem.pszText = typ.GetBuffer(typ.GetLength());
SetItem(&lvItem);
//bool apply = true;
//lvItem.iSubItem = 2;
//lvItem.pszText = apply ? _T("yes"): _T("no");
//SetItem(&lvItem);
//lvItem.iSubItem = 3;
//lvItem.pszText = _T("1");
//SetItem(&lvItem);
DWORD data = pRule.m_type;
SetItemData(index, data);
return index;
}
void RuleListCtrl::getItem( CString& pStr, int idx, int subIdx)
{
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = idx;
lvItem.iSubItem = subIdx;
lvItem.pszText = pStr.GetBuffer( 256);
lvItem.cchTextMax = 256;
GetItem( &lvItem);
}
void RuleListCtrl::setItem( CString pStr, int idx, int subIdx)
{
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = idx;
lvItem.iSubItem = subIdx;
lvItem.pszText = pStr.GetBuffer( pStr.GetLength());
SetItem(&lvItem);
}
bool RuleListCtrl::erasable()
{
return m_rules.empty() && GetItemCount() <= 0;
}
void RuleListCtrl::fileNew()
{
m_rules.clear();
this->DeleteAllItems();
}
void RuleListCtrl::fileLoad()
{
CFileDialog dlg( TRUE, ".mm", "", 0,
"ModelMigrate Files (*.mm)|*.mm|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
CFile f( (LPCTSTR) dlg.GetPathName(), CFile::modeRead);
CArchive ar( &f, CArchive::load);
unsigned int loaded_size = 0;
ar >> loaded_size;
unsigned int size_before = (unsigned int) m_rules.size();
m_rules.resize( size_before + loaded_size); // enlarge it to the new size
for( unsigned int i = 0; i < loaded_size; ++i)
m_rules[size_before + i].Serialize( ar);
ar.Close();
f.Close();
for( unsigned int i = size_before; i < m_rules.size(); ++i)
{
insertItem( m_rules[i]);
}
}
}
void RuleListCtrl::fileSave()
{
CFileDialog dlg( FALSE, ".mm", "ruleset", OFN_OVERWRITEPROMPT,
"ModelMigrate Files (*.mm)|*.mm|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
CFile f( (LPCTSTR) dlg.GetPathName(), CFile::modeCreate | CFile::modeWrite);
CArchive ar( &f, CArchive::store);
ar << (unsigned int) m_rules.size();
for( unsigned int i = 0; i < m_rules.size(); ++i)
m_rules[i].Serialize( ar);
ar.Close();
f.Close();
}
}
--- NEW FILE: RemoveDlg.cpp ---
// SimpleRepl.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "RemoveDlg.h"
#include ".\removedlg.h"
// RemoveDlg dialog
IMPLEMENT_DYNAMIC(RemoveDlg, CDialog)
RemoveDlg::RemoveDlg( bool changeTitle, CWnd* pParent /*=NULL*/)
: CDialog(RemoveDlg::IDD, pParent)
, m_name(_T(""))
, m_title( changeTitle?_T("Remove Global Attribute"):_T("Remove Kind"))
{
}
RemoveDlg::~RemoveDlg()
{
}
void RemoveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_name);
}
BEGIN_MESSAGE_MAP(RemoveDlg, CDialog)
END_MESSAGE_MAP()
// RemoveDlg message handlers
const CString& RemoveDlg::getPar1() const
{
return m_name;
}
void RemoveDlg::init( const CString& par1)
{
m_name = par1;
}
BOOL RemoveDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText( (LPCTSTR) m_title);
return TRUE;
}
--- NEW FILE: AttrNameDlg.cpp ---
// AttrNameDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "AttrNameDlg.h"
#include ".\attrnamedlg.h"
#include "AttrGlobalDlg.h"
// AttrNameDlg dialog
IMPLEMENT_DYNAMIC(AttrNameDlg, CDialog)
AttrNameDlg::AttrNameDlg(CWnd* pParent /*=NULL*/)
: CDialog(AttrNameDlg::IDD, pParent)
, m_oldV(_T(""))
, m_newV(_T(""))
, m_global(_T("1"))
, m_owner(_T(""))
{
}
AttrNameDlg::~AttrNameDlg()
{
}
void AttrNameDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_oldV);
DDX_Text(pDX, IDC_EDIT2, m_newV);
}
BEGIN_MESSAGE_MAP(AttrNameDlg, CDialog)
ON_BN_CLICKED(IDGLOBAL, OnBnClickedGlobal)
END_MESSAGE_MAP()
// AttrNameDlg message handlers
const CString& AttrNameDlg::getPar1() const
{
return m_oldV;
}
const CString& AttrNameDlg::getPar2() const
{
return m_newV;
}
const CString& AttrNameDlg::getPar3() const
{
return m_global;
}
const CString& AttrNameDlg::getPar4() const
{
return m_owner;
}
void AttrNameDlg::init( const CString& par1, const CString& par2, const CString& par3, const CString& par4)
{
m_oldV = par1;
m_newV = par2;
m_global = par3;
m_owner = par4;
}
BOOL AttrNameDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void AttrNameDlg::OnBnClickedGlobal()
{
AttrGlobalDlg dlg( m_global, m_owner);
if( dlg.DoModal() == IDOK)
{
m_global = dlg.getGlobal();
m_owner = dlg.getOwner();
}
}
--- NEW FILE: Log.h ---
#pragma once
// Log
class Log : public CEdit
{
DECLARE_DYNAMIC(Log)
public:
Log();
virtual ~Log();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
void doClear();
protected:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
};
--- NEW FILE: resource.h ---
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by FrontEnd.rc
//
#define IDGENERATE 4
#define IDGLOBAL 4
#define IDADDRULE 5
#define IDGENERATESEL 6
#define IDSAVE 7
#define IDLOAD 9
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDR_MAINFRAME 128
#define IDD_DLG_PROPNAMECHANGE 129
#define IDD_DLG_ADDRULE 130
#define IDD_DLG_PROPENATTRCHANGE 131
#define IDD_DLG_PROPATTRCHANGE 132
#define IDD_DLG_FILETRANS 133
#define IDD_DLG_OPTIONS 134
#define IDR_REGISTRY1 135
#define IDD_DLG_RULEEDITOR 136
#define IDD_DLG_PROPMOVEUP 143
#define IDD_DLG_PROPMOVEDOWN 146
#define IDD_DLG_PROPATTRTYPECHANGE 148
#define IDD_DLG_PROPATTRGLOBALLOCAL 153
#define IDD_DLG_PROPREMOVEELEM 154
#define IDD_DLG_PROPREMOVELOCALATTR 155
#define IDR_MENU1 155
#define IDR_MENU2 158
#define IDC_LIST2 1001
#define IDC_LISTSCRIPT 1001
#define IDC_BUTTON1 1002
#define IDC_EDIT1 1003
#define IDC_BUTTON2 1003
#define IDC_EDIT2 1004
#define IDC_BUTTON6 1005
#define IDC_LIST1 1006
#define IDC_EDIT5 1006
#define IDC_EDIT3 1007
#define IDC_BUTTON7 1007
#define IDC_BUTTON3 1008
#define IDC_EDIT6 1008
#define IDC_BUTTON4 1009
#define IDC_BUTTON8 1010
#define IDOK2 1011
#define IDC_EDIT4 1012
#define IDC_BUTTON5 1013
#define IDCANCEL3 1014
#define IDC_RULELIST 1015
#define IDC_TREE1 1018
#define IDC_BUTTON_INSERTNODE 1019
#define IDC_BUTTON_DELETENODE 1020
#define IDC_EDITKIND 1021
#define IDC_TREETWO 1022
#define IDC_BUTTONCLEAR 1023
#define IDC_EDITPARENT 1023
#define IDC_CHECK1 1024
#define IDC_RADIO1 1025
#define IDC_RADIO2 1026
#define IDC_LISTFILES 1029
#define ID_SCRIPTS_ADD 32771
#define ID_SCRIPTS_ADDDIRECTORY 32772
#define ID_SCRIPTS_REMOVEALL 32773
#define ID_SCRIPTS_REMOVESELECTED 32774
#define ID_FILES_ADDFILE 32775
#define ID_FILES_ADDDIRECTORY 32776
#define ID_FILES_REMOVEALL 32777
#define ID_FILES_REMOVESELECTED 32778
#define ID_Menu 32779
#define ID_PROCESSING_PROCESSALL 32780
#define ID_PROCESSING_PROCESSSELECTED 32781
#define ID_MISC_OPTIONS 32783
#define ID_MISC_CLEARLOG 32784
#define ID_RULE_EDIT32799 32799
#define ID_RULE_CLONE 32800
#define ID_RULE_DELETESELECTED 32801
#define ID_RULE_DELETEALL 32802
#define ID_RULE_MOVEUP 32803
#define ID_RULE_MOVEDOWN 32804
#define ID_GENERATE_GENERATESELECTED 32805
#define ID_GENERATE_GENERATEALL 32806
#define ID_RULE_SAVE 32807
#define ID_RULE_LOAD 32808
#define ID_EDIT_MOVEDOWN 32811
#define ID_RULE_ADD 32812
#define ID_SCRIPT_GENERATEALL 32820
#define ID_SCRIPT_GENERATESELECTED 32821
#define ID_MYFILESAVE 32824
#define ID_MYFILELOAD 32825
#define ID_MYFILENEW 32826
#define ID_Menu32827 32827
#define ID_RULES_VALIDATE 32828
#define ID_RULES_EDITRULES 32829
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 159
#define _APS_NEXT_COMMAND_VALUE 32830
#define _APS_NEXT_CONTROL_VALUE 1030
#define _APS_NEXT_SYMED_VALUE 105
#endif
#endif
--- NEW FILE: ScriptMoveDown.cpp ---
#include "StdAfx.h"
#include ".\ScriptMoveDown.h"
//<!-- =============================================================================== -->
//<!-- This template rule will wrap a kind into other container kinds aka -->
//<!-- a kind moved down in the containment hierarchy -->
//<!-- This movement down inserts just a few objects (par3, par4, par5) -->
//<!-- because every par1 found in par2 is wrapped into the same par3/par4/par5 -->
//<!-- =============================================================================== -->
//
//<!-- each ##|par2|##/##|par1|## kind is put into a ##|par3|##/##|par4|##/##|par5|##/##|par1|## -->
//<xsl:template match="*[@kind='##|par2|##']">
// <xsl:copy>
// <xsl:apply-templates select="@*"/>
// <xsl:apply-templates select="*[ not(@kind) or @kind != '##|par1|##']"/>
// <##|typ3|## kind="##|par3|##">
// <name>New##|par3|##</name>
// <##|typ4|## kind="##|par4|##">
// <name>New##|par4|##</name>
// <##|typ5|## kind="##|par5|##">
// <name>New##|par5|##</name>
// <xsl:apply-templates select="*[ @kind = '##|par1|##']"/>
// </##|typ5|##>
// </##|typ4|##>
// </##|typ3|##>
// </xsl:copy>
//</xsl:template>
const char * strGeneralHeaderDown = "\
<!-- =============================================================================== -->\r\n\
<!-- Kind movement down in a hierarchy -->\r\n\
<!-- This template rule will wrap certain kinds into containers -->\r\n\
<!-- Objects found in parent are wrapped into the same object -->\r\n\
<!-- =============================================================================== -->\r\n\
\r\n\r\n";
//<!-- every ##|par1|## kind in ##|par2|## is put into a ##|par4|##/##|par3|## -->
const char * strComment2Begin = "\r\n<!-- every ";
const char * strComment2Mid1 = " kind in ";
const char * strComment2Mid2 = " is put into a ";
const char * strComment2End = " -->\r\n";
//<xsl:template match="*[@kind='##|par2|##']">
const char * strTemplateHeadBegin = "<xsl:template match=\"*[@kind='";
const char * strTemplateHeadEnd = "']\">\r\n";
const char * strTemplateTail = "</xsl:template>\r\n";
// <xsl:copy>
// <xsl:apply-templates select="@*"/>
// <xsl:apply-templates select="*[ not(@kind) or @kind != '##|par1|##']"/>
const char * strBody1 = "\
\t<xsl:copy>\r\n\
\t<xsl:apply-templates select=\"@*\"/>\r\n\
\t<xsl:apply-templates select=\"*[ not(@kind) or @kind != '";
const char * strBody2 = "']\"/>\r\n";
const char * strBody3 = "\t</xsl:copy>\r\n";
// <##|typ|## kind="##|par|##">
// <name>New##|par|##</name>
const char * strSkeletonOpen = "\
\t<##|typ|## kind=\"##|par|##\">\r\n\
\t\t<name>New##|par|##</name>\
\r\n";
// <xsl:apply-templates select="*[ @kind = '##|par1|##']"/>
const char * strInternals1 = "\
\t\t<xsl:apply-templates select=\"*[ @kind = '";
const char * strInternals2 = "\
']\"/>\r\n";
const char * strSkeletonClose = "\
\t</##|typ|##>\r\n";
ScriptMoveDown::ScriptMoveDown(void)
{
}
ScriptMoveDown::~ScriptMoveDown(void)
{
}
CString ScriptMoveDown::instantiat2( const std::vector< std::string >& pars, std::ostream& pstream)
{
// pars[2..len] contains the hierarchy that will be created
// pars[0] == pars.front() contains the element that will be wrapped (moved down)
// pars[1] contains the parent of the element (matching based on this)
ASSERT( pars.size() >= 3);
if( pars.size() < 3) return "";
std::string sequence;
std::string skeleton_head, skeleton_tail;
for( unsigned int i = 2; i < pars.size(); ++i)
{
if( sequence.length() != 0)
{
sequence += '/';
}
CString pi = pars[i].c_str();
CString type = "folder";
CString kind = pi;
if( pi.Right(2) == ":M")
{
type = "model";
kind = pi.Left( pi.GetLength() - 2);
} else if( pi.Right(2) == ":F")
{
kind = pi.Left( pi.GetLength() - 2);
}
sequence += kind;
CString open_tags( strSkeletonOpen);
CString clos_tags( strSkeletonClose);
open_tags.Replace( "##|typ|##", type);
open_tags.Replace( "##|par|##", kind);
clos_tags.Replace( "##|typ|##", type);
skeleton_head += open_tags;
skeleton_tail = (LPCTSTR) clos_tags + skeleton_tail;
}
// generic comment
pstream << strGeneralHeaderDown;
// specific comment
pstream << strComment2Begin;
pstream << pars[0]; // the node (element) moved
pstream << strComment2Mid1;
pstream << pars[1];
pstream << strComment2Mid2;
pstream << sequence; // the wrapper structure
pstream << strComment2End;
// template match =
pstream << strTemplateHeadBegin;
pstream << pars[1]; // the parent of the moved node
pstream << strTemplateHeadEnd;
// body
pstream << strBody1;
pstream << pars[0]; // the moved
pstream << strBody2;
// skeleton the moved to be wrapped into
pstream << skeleton_head;
pstream << strInternals1;
pstream << pars[0]; // the moved element
pstream << strInternals2;
pstream << skeleton_tail;
pstream << strBody3;
pstream << strTemplateTail;
return "";
}
--- NEW FILE: FrontEnd.vcproj ---
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="ModelMigrate"
ProjectGUID="{73E065E0-27FD-4D46-A483-EFB75438F74E}"
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
TreatWChar_tAsBuiltInType="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ole32.lib"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="FALSE"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
MinimalRebuild="FALSE"
RuntimeLibrary="2"
TreatWChar_tAsBuiltInType="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="FALSE"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\AboutDlg.cpp">
</File>
<File
RelativePath=".\AttrGlobalDlg.cpp">
</File>
<File
RelativePath=".\AttrNameDlg.cpp">
</File>
<File
RelativePath=".\AttrTypeChangeDlg.cpp">
</File>
<File
RelativePath=".\CMgaXslt.cpp">
</File>
<File
RelativePath=".\EnumAttrValueDlg.cpp">
</File>
<File
RelativePath=".\Extractor.cpp">
</File>
<File
RelativePath=".\FileListCtrl.cpp">
</File>
<File
RelativePath=".\FileTransDlg.cpp">
</File>
<File
RelativePath=".\Log.cpp">
</File>
<File
RelativePath=".\ModelMigrate.cpp">
</File>
<File
RelativePath=".\MoveDownElem.cpp">
</File>
<File
RelativePath=".\MoveUpElem.cpp">
</File>
<File
RelativePath=".\NewRuleDlg.cpp">
</File>
<File
RelativePath=".\OptionsDlg.cpp">
</File>
<File
RelativePath=".\RemoveDlg.cpp">
</File>
<File
RelativePath=".\RemoveLocAttrDlg.cpp">
</File>
<File
RelativePath=".\Rule.cpp">
</File>
<File
RelativePath=".\RuleEditorDlg.cpp">
</File>
<File
RelativePath=".\RuleListCtrl.cpp">
</File>
<File
RelativePath=".\Script.cpp">
</File>
<File
RelativePath=".\ScriptAbs.cpp">
</File>
<File
RelativePath=".\ScriptAttrName.cpp">
</File>
<File
RelativePath=".\ScriptAttrType.cpp">
</File>
<File
RelativePath=".\ScriptCmplx.cpp">
</File>
<File
RelativePath=".\ScriptEnumAttrValue.cpp">
</File>
<File
RelativePath=".\ScriptListCtrl.cpp">
</File>
<File
RelativePath=".\ScriptMoveDown.cpp">
</File>
<File
RelativePath=".\ScriptMoveUp.cpp">
</File>
<File
RelativePath=".\SimpleRepl.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
<File
RelativePath=".\Validator.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\AboutDlg.h">
</File>
<File
RelativePath=".\AttrGlobalDlg.h">
</File>
<File
RelativePath=".\AttrNameDlg.h">
</File>
<File
RelativePath=".\AttrTypeChangeDlg.h">
</File>
<File
RelativePath=".\CMgaXslt.h">
</File>
<File
RelativePath=".\EnumAttrValueDlg.h">
</File>
<File
RelativePath=".\Extractor.h">
</File>
<File
RelativePath=".\FileListCtrl.h">
</File>
<File
RelativePath=".\FileTransDlg.h">
</File>
<File
RelativePath=".\Log.h">
</File>
<File
RelativePath=".\ModelMigrate.h">
</File>
<File
RelativePath=".\MoveDownElem.h">
</File>
<File
RelativePath=".\MoveUpElem.h">
</File>
<File
RelativePath=".\NewRuleDlg.h">
</File>
<File
RelativePath=".\OptionsDlg.h">
</File>
<File
RelativePath=".\RemoveDlg.h">
</File>
<File
RelativePath=".\RemoveLocAttrDlg.h">
</File>
<File
RelativePath=".\Resource.h">
</File>
<File
RelativePath=".\Rule.h">
</File>
<File
RelativePath=".\RuleEditorDlg.h">
</File>
<File
RelativePath=".\RuleListCtrl.h">
</File>
<File
RelativePath=".\Script.h">
</File>
<File
RelativePath=".\ScriptAbs.h">
</File>
<File
RelativePath=".\ScriptAttrName.h">
</File>
<File
RelativePath=".\ScriptAttrType.h">
</File>
<File
RelativePath=".\ScriptCmplx.h">
</File>
<File
RelativePath=".\ScriptEnumAttrValue.h">
</File>
<File
RelativePath=".\ScriptListCtrl.h">
</File>
<File
RelativePath=".\ScriptMoveDown.h">
</File>
<File
RelativePath=".\ScriptMoveUp.h">
</File>
<File
RelativePath=".\SimpleRepl.h">
</File>
<File
RelativePath=".\stdafx.h">
</File>
<File
RelativePath=".\Validator.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
<File
RelativePath=".\res\FrontEnd.ico">
</File>
<File
RelativePath=".\FrontEnd.rc">
</File>
<File
RelativePath=".\res\FrontEnd.rc2">
</File>
</Filter>
<File
RelativePath=".\res\FrontEnd.manifest">
</File>
<File
RelativePath=".\res\header.xsl">
</File>
<File
RelativePath=".\res\tail.xsl">
</File>
<File
RelativePath=".\res\TAttrNameChange.xsl">
</File>
<File
RelativePath=".\res\TAttrTypeChange.xsl">
</File>
<File
RelativePath=".\res\TAttrTypeCheck2Text.xsl">
</File>
<File
RelativePath=".\res\TEnumAttrValueChange.xsl">
</File>
<File
RelativePath=".\res\TKindNameChange.xsl">
</File>
<File
RelativePath=".\res\TRemoveGlobalAttr.xsl">
</File>
<File
RelativePath=".\res\TRemoveKind.xsl">
</File>
<File
RelativePath=".\res\TRemoveLocalAttr.xsl">
</File>
</Files>
<Globals>
<Global
Name="RESOURCE_FILE"
Value="FrontEnd.rc"/>
</Globals>
</VisualStudioProject>
--- NEW FILE: AboutDlg.h ---
#pragma once
#include "afxwin.h"
#include "resource.h"
class AboutDlg : public CDialog
{
public:
AboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
--- NEW FILE: MoveUpElem.h ---
#pragma once
#include "afxcmn.h"
#include <vector>
#include <string>
// MoveUpElem dialog
class MoveUpElem : public CDialog
{
DECLARE_DYNAMIC(MoveUpElem)
public:
MoveUpElem(CWnd* pParent = NULL); // standard constructor
virtual ~MoveUpElem();
// Dialog Data
enum { IDD = IDD_DLG_PROPMOVEUP };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
virtual void OnCancel();
DECLARE_MESSAGE_MAP()
public:
void init( const std::vector< std::string>& pars);
CTreeCtrl m_tree;
std::vector< std::string> getSequence();
protected:
HTREEITEM lastChild();
void addChild( const char * pLabel);
void remChild();
std::vector< std::string> getValues();
std::vector< std::string> m_storage;
void closeDlg( int pResult);
public:
afx_msg void OnTvnEndlabeleditTree1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnNMReturnTree1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedButtonInsertnode();
afx_msg void OnBnClickedButtonDeletenode();
virtual BOOL OnInitDialog();
};
--- NEW FILE: ScriptListCtrl.cpp ---
// ScriptListCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "ScriptListCtrl.h"
#include "FileTransDlg.h"
#include <algorithm>
#define ADD_FILE_CMD 2101
#define ADD_DIR_CMD 2102
#define REMOVE_SEL_CMD 2103
#define REMOVE_ALL_CMD 2104
#define PROCESS_SEL_CMD 2105
#define PROCESS_ALL_CMD 2106
// ScriptListCtrl
IMPLEMENT_DYNAMIC(ScriptListCtrl, CListCtrl)
ScriptListCtrl::ScriptListCtrl()
: m_rowID(0)
{
}
ScriptListCtrl::~ScriptListCtrl()
{
}
BEGIN_MESSAGE_MAP(ScriptListCtrl, CListCtrl)
ON_WM_CREATE()
ON_WM_DROPFILES()
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()
// ScriptListCtrl message handlers
int ScriptListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CListCtrl::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
BOOL ScriptListCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= WS_CHILD|WS_VISIBLE|WS_BORDER|WS_TABSTOP|LVS_REPORT|LVS_NOSORTHEADER;//|LVS_SINGLESEL;
return CListCtrl::PreCreateWindow(cs);
}
void ScriptListCtrl::addFile(const CString& file, const CString& path)
{
CString knd = file, ttt = path;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = GetItemCount();
lvItem.iSubItem = 0;
lvItem.pszText = knd.GetBuffer(knd.GetLength());
int index = InsertItem(&lvItem);
lvItem.iSubItem = 1;
lvItem.pszText = ttt.GetBuffer(ttt.GetLength());
SetItem(&lvItem);
//lvItem.iSubItem = 2;
//lvItem.pszText = _T("");
//SetItem(&lvItem);
//lvItem.iSubItem = 3;
//lvItem.pszText = _T("");
//SetItem(&lvItem);
SetItemData(index, ++m_rowID);
}
void ScriptListCtrl::PreSubclassWindow()
{
int col0size = 2*GetStringWidth("FileName.xme");
int col1size = 2*GetStringWidth("Full Path To File Is Very Long");
//int col2size = 2*GetStringWidth("Status");
//int col3size = 2*GetStringWidth("MessageWillBeVeryLong");
InsertColumn(0, _T("Scripts to apply"), LVCFMT_LEFT, col0size, -1);
InsertColumn(1, _T("Full Path"), LVCFMT_LEFT, col1size, -1);
//InsertColumn(2, _T("Status"), LVCFMT_LEFT, col2size, -1);
//InsertColumn(3, _T(" "), LVCFMT_LEFT, col3size, -1);
SetExtendedStyle( LVS_EX_FULLROWSELECT );
CListCtrl::PreSubclassWindow();
}
void ScriptListCtrl::OnDropFiles(HDROP hDropInfo)
{
UINT nFiles = DragQueryFile( hDropInfo, 0xFFFFFFFF, NULL, 0);
if( nFiles < 1)
AfxMessageBox( "No file dropped!");
for( UINT iF = 0; iF < nFiles; ++iF)
{
TCHAR szFileName[_MAX_PATH];
UINT res = DragQueryFile( hDropInfo, iF, szFileName, _MAX_PATH);
if (res > 0)
{
CString conn( szFileName);
int pos = conn.ReverseFind('\\');
if( pos != -1)
addFile( conn.Right( conn.GetLength() - pos - 1), szFileName);
else
addFile( szFileName, "");
}
else
AfxMessageBox( "File name error!");
}
CListCtrl::OnDropFiles(hDropInfo);
}
std::vector<std::string> ScriptListCtrl::getSelFiles()
{
std::vector< std::string> res;
for( int i = 0; i < GetItemCount(); ++i)
{
CString knd;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT | LVIF_STATE;
lvItem.iItem = i;
lvItem.iSubItem = 1;
lvItem.pszText = knd.GetBuffer( 1024);
lvItem.cchTextMax = 1024;
lvItem.stateMask = LVIS_SELECTED;
GetItem( &lvItem);
// reset 'status'
//lvItem.iSubItem = 2;
//lvItem.pszText = "";
//SetItem( &lvItem);
if( (lvItem.state & LVIS_SELECTED) == LVIS_SELECTED)
res.push_back( (LPCTSTR) knd );
}
return res;
}
std::vector<std::string> ScriptListCtrl::getAllFiles()
{
std::vector< std::string> res;
for( int i = 0; i < GetItemCount(); ++i)
{
CString knd;
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = i;
lvItem.iSubItem = 1;
lvItem.pszText = knd.GetBuffer( 1024);
lvItem.cchTextMax = 1024;
GetItem( &lvItem);
//lvItem.iSubItem = 2;
//lvItem.pszText = "";
//SetItem( &lvItem);
res.push_back( (LPCTSTR) knd );
}
return res;
}
void ScriptListCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
{
bool sent = false;
CListCtrl::OnLButtonDblClk(nFlags, point);
}
void ScriptListCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
CListCtrl::OnRButtonDown(nFlags, point);
ClientToScreen( &point);
createPopupMenu( point);
}
void ScriptListCtrl::showPopupMenu()
{
// find the focused item to determine the position of the popup menu
int idx = -1;
for( int i = 0; idx == -1 && i < GetItemCount(); ++i)
{
UINT flag = LVIS_FOCUSED;// | LVIS_SELECTED;
if( (GetItemState( i, flag ) & flag) == flag )
{
idx = i;
}
}
CPoint point;
if( idx != -1)
GetItemPosition( idx, &point);
else
{
// no item found, use the top-left corner of the empty listcontrol
CRect rect;
GetClientRect(rect);
point = CPoint( rect.left, rect.top);
}
point.Offset( 10, 10);
ClientToScreen( &point);
createPopupMenu( point);
}
void ScriptListCtrl::createPopupMenu( CPoint pnt)
{
CMenu m;
m.CreatePopupMenu();
m.AppendMenu( MF_ENABLED|MF_STRING, ADD_FILE_CMD, "Add Script...");
m.AppendMenu( MF_ENABLED|MF_STRING, ADD_DIR_CMD, "Add Directory...");
m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
m.AppendMenu( MF_ENABLED|MF_STRING, REMOVE_ALL_CMD, "Remove All");
m.AppendMenu( MF_ENABLED|MF_STRING, REMOVE_SEL_CMD, "Remove Selected");
//m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
//m.AppendMenu( MF_ENABLED|MF_STRING, PROCESS_ALL_CMD, "Process All");
//m.AppendMenu( MF_ENABLED|MF_STRING, PROCESS_SEL_CMD, "Process Selected");
m.TrackPopupMenu( TPM_LEFTALIGN |TPM_RIGHTBUTTON, pnt.x, pnt.y, this);
}
BOOL ScriptListCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch( wParam)
{
case ADD_FILE_CMD: m_parent->selScript();break;
case ADD_DIR_CMD: m_parent->selScriptDir();break;
case REMOVE_ALL_CMD: removeAll();break;
case REMOVE_SEL_CMD: removeSel();break;
//case PROCESS_SEL_CMD: m_parent->processSel();break;
//case PROCESS_ALL_CMD: m_parent->processAll();break;
};
return CListCtrl::OnCommand(wParam, lParam);
}
void ScriptListCtrl::mark( std::vector< std::string>& vecs)
{
}
void ScriptListCtrl::removeAll()
{
DeleteAllItems();
}
void ScriptListCtrl::removeSel()
{
for( int i = GetItemCount(); i > 0 ; --i)
{
UINT sel = GetItemState( i-1, LVIS_SELECTED);
if( sel & LVIS_SELECTED)
{
DeleteItem( i-1);
}
}
}
--- NEW FILE: AttrNameDlg.h ---
#pragma once
// AttrNameDlg dialog
class AttrNameDlg : public CDialog
{
DECLARE_DYNAMIC(AttrNameDlg)
public:
AttrNameDlg(CWnd* pParent = NULL); // standard constructor
virtual ~AttrNameDlg();
// Dialog Data
enum { IDD = IDD_DLG_PROPATTRCHANGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
CString m_oldV;
CString m_newV;
CString m_global;
CString m_owner;
DECLARE_MESSAGE_MAP()
public:
void init( const CString& par1, const CString& par2, const CString& par3, const CString& par4);
const CString& getPar1() const;
const CString& getPar2() const;
const CString& getPar3() const;
const CString& getPar4() const;
afx_msg void OnBnClickedRadio1();
afx_msg void OnBnClickedRadio2();
afx_msg void OnBnClickedGlobal();
virtual BOOL OnInitDialog();
};
--- NEW FILE: Script.h ---
#pragma once
#include <string>
#include <vector>
#include <ostream>
class Script
{
public:
Script(void);
Script( const std::string& file);
virtual ~Script(void);
void init( const std::string& file);
bool instantiate( const std::vector< std::string >& pars, std::ostream& pstream);
virtual CString instantiat2( const std::vector< std::string >& pars, std::ostream& pstream);
protected:
std::string m_file;
std::string m_content;
public:
static std::string getXSLFromResource( const char *idr);
static std::string getXSLFromLocalFile( const char * filename);
};
--- NEW FILE: FrontEndDlg.cpp ---
// FrontEndDlg.cpp : implementation file
//
#include "stdafx.h"
#include "FrontEnd.h"
#include "FrontEndDlg.h"
#include ".\frontenddlg.h"
#include "NewRuleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CFrontEndDlg dialog
CFrontEndDlg::CFrontEndDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFrontEndDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CFrontEndDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_LIST2, m_choice);
}
BEGIN_MESSAGE_MAP(CFrontEndDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_WM_CREATE()
ON_LBN_DBLCLK(IDC_LIST2, OnLbnDblclkList2)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
ON_BN_CLICKED(IDOK2, OnBnClickedOk)
ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
END_MESSAGE_MAP()
// CFrontEndDlg message handlers
BOOL CFrontEndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
//CRect loc(10, 10, 100, 100);
//m_list.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT|LVS_SINGLESEL, loc, this, 1);
//m_list.ShowWindow
m_choice.AddString("Kind");
m_choice.AddString("AttrName");
m_choice.AddString("AttrType");
m_choice.AddString("AttrItem");
m_choice.AddString("Position");
return TRUE; // return TRUE unless you set the focus to a control
}
void CFrontEndDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CFrontEndDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CFrontEndDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
int CFrontEndDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
CRect loc(10, 10, 100, 100);
GetClientRect( &loc);
loc.DeflateRect( 5, 5, 90, 5);
m_list.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|WS_TABSTOP|LVS_REPORT|LVS_SINGLESEL, loc, this, 1);
return 0;
}
void CFrontEndDlg::OnLbnDblclkList2()
{
int chc = m_choice.GetCurSel();
CString txt;
m_choice.GetText( chc, txt);
m_list.addRule(chc, txt);
}
void CFrontEndDlg::OnBnClickedButton1()
{
NewRuleDlg nrd;
if( nrd.DoModal() == IDOK)
{
m_list.addRule( nrd.m_choice, nrd.m_choiceStr);
}
}
void CFrontEndDlg::OnOK()
{
if( AfxMessageBox( "Close dialog and discard changes?", MB_YESNOCANCEL) == IDYES)
closeDlg( IDOK);
}
void CFrontEndDlg::OnCancel()
{
if( AfxMessageBox( "Close dialog and discard changes?", MB_YESNOCANCEL) == IDYES)
closeDlg( IDCANCEL);
}
void CFrontEndDlg::closeDlg( int pResult)
{
EndDialog( pResult);
DestroyWindow();
}
void CFrontEndDlg::OnBnClickedOk()
{
closeDlg(IDOK);
}
void CFrontEndDlg::OnBnClickedButton2()
{
CFileDialog dlg( FALSE, ".xsl", "script1", OFN_OVERWRITEPROMPT,
"XSLT Files (*.xsl;*.xslt)|*.xsl; *.xslt|All Files (*.*)|*.*||");
if( dlg.DoModal() == IDOK)
{
std::string my_target = (LPCTSTR) dlg.GetPathName();
m_list.gen( my_target);
}
}
--- NEW FILE: MoveUpElem.cpp ---
// MoveUpElem.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "MoveUpElem.h"
#include ".\moveupelem.h"
// MoveUpElem dialog
IMPLEMENT_DYNAMIC(MoveUpElem, CDialog)
MoveUpElem::MoveUpElem(CWnd* pParent /*=NULL*/)
: CDialog(MoveUpElem::IDD, pParent)
{
}
MoveUpElem::~MoveUpElem()
{
}
void MoveUpElem::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TREE1, m_tree);
}
BEGIN_MESSAGE_MAP(MoveUpElem, CDialog)
ON_BN_CLICKED(IDC_BUTTON_INSERTNODE, OnBnClickedButtonInsertnode)
ON_NOTIFY(TVN_ENDLABELEDIT, IDC_TREE1, OnTvnEndlabeleditTree1)
ON_NOTIFY(NM_RETURN, IDC_TREE1, OnNMReturnTree1)
ON_BN_CLICKED(IDC_BUTTON_DELETENODE, OnBnClickedButtonDeletenode)
END_MESSAGE_MAP()
// MoveUpElem message handlers
void MoveUpElem::addChild( const char * pLabel)
{
HTREEITEM hLastGoodItem = lastChild();
HTREEITEM hNewItem = m_tree.InsertItem( _T(pLabel), hLastGoodItem);
m_tree.Expand( hLastGoodItem, TVE_EXPAND);
m_tree.EnsureVisible( hNewItem);
}
void MoveUpElem::OnBnClickedButtonInsertnode()
{
addChild( "Node");
HTREEITEM lc = lastChild();
if( lc) m_tree.EditLabel( lc);
}
void MoveUpElem::OnBnClickedButtonDeletenode()
{
remChild();
}
HTREEITEM MoveUpElem::lastChild()
{
HTREEITEM hLastGoodItem = TVI_ROOT;
HTREEITEM h = m_tree.GetRootItem();
while ( h != NULL)
{
m_tree.Expand( h, TVE_EXPAND);
hLastGoodItem = h;
h = m_tree.GetChildItem( h);
}
return hLastGoodItem;
}
void MoveUpElem::remChild()
{
HTREEITEM hLastGoodItem = lastChild();
if( hLastGoodItem && hLastGoodItem != TVI_ROOT) m_tree.DeleteItem( hLastGoodItem);
else
AfxMessageBox( "No more elements to delete!");
}
void MoveUpElem::closeDlg( int pResult)
{
EndDialog( pResult);
DestroyWindow();
}
void MoveUpElem::OnOK()
{
if( AfxMessageBox( "Close dialog and save changes?", MB_YESNOCANCEL) == IDYES)
{
m_storage = getValues();
closeDlg( IDOK);
}
}
void MoveUpElem::OnCancel()
{
if( AfxMessageBox( "Close dialog and discard changes?", MB_YESNOCANCEL) == IDYES)
closeDlg( IDCANCEL);
}
void MoveUpElem::OnTvnEndlabeleditTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTVDISPINFO pTVDispInfo = reinterpret_cast<LPNMTVDISPINFO>(pNMHDR);
if( !pTVDispInfo->item.pszText) return; // if 0 means edit cancelled
m_tree.SetItem( &pTVDispInfo->item);
*pResult = 0;
}
void MoveUpElem::OnNMReturnTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
*pResult = 0;
}
std::vector< std::string> MoveUpElem::getValues()
{
std::vector< std::string> res;
HTREEITEM h = m_tree.GetRootItem();
while ( h != NULL)
{
res.push_back( (LPCTSTR) m_tree.GetItemText( h));
h = m_tree.GetChildItem( h);
}
return res;
}
std::vector< std::string> MoveUpElem::getSequence()
{
return m_storage;
}
void MoveUpElem::init( const std::vector< std::string>& pars)
{
m_storage = pars;
}
BOOL MoveUpElem::OnInitDialog()
{
CDialog::OnInitDialog();
for( unsigned int i = 0; i < m_storage.size(); ++i)
{
addChild( m_storage[i].c_str());
}
m_storage.clear();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
--- NEW FILE: ScriptAbs.cpp ---
#include "StdAfx.h"
#include ".\scriptabs.h"
ScriptAbs::ScriptAbs(void)
{
}
ScriptAbs::~ScriptAbs(void)
{
}
--- NEW FILE: ScriptMoveDown.h ---
#pragma once
#include "Script.h"
class ScriptMoveDown :
public Script
{
public:
ScriptMoveDown(void);
~ScriptMoveDown(void);
virtual CString instantiat2( const std::vector< std::string >& pars, std::ostream& pstream);
};
--- NEW FILE: Script.cpp ---
#include "StdAfx.h"
#include ".\script.h"
#include <fstream>
Script::Script(void)
{
}
Script::Script( const std::string& file)
: m_file( file)
{
}
Script::~Script(void)
{
}
void Script::init( const std::string& file)
{
m_file = file;
}
CString Script::instantiat2( const std::vector< std::string >& pars, std::ostream& pstream)
{
std::string content = getXSLFromResource( m_file.c_str());
CString cnt( content.c_str());
for( unsigned int i = 0; i < pars.size(); ++i)
{
CString old_i;//##|pari|##
old_i.Format("##|par%d|##", i + 1);
cnt.Replace( old_i, pars[i].c_str());
}
return cnt;
}
bool Script::instantiate( const std::vector< std::string >& pars, std::ostream& pstream)
{
ASSERT(m_file.length() > 0);
std::ifstream templ( m_file.c_str(), std::ios_base::in);
ASSERT( templ.is_open());
char c;
while( templ.get( c))
{
if( c != '#')
pstream.put( c);
else
{
std::ifstream::pos_type fpos = templ.tellg();
bool good = false;
// par_i format : ##|pari|##
char buff[3];
if( templ.get( buff, 3) && buff[0] == '#' && buff[1] == '|')
{
std::string par_i;
while( templ.get(c) && c != '|')
par_i += c;
if( par_i.length() > 3 && par_i.substr(0, 3) == "par")
{
int idx = atoi( par_i.substr(3).c_str());
if( idx > 0 && idx <= (int) pars.size())
{
pstream.write( pars[ idx - 1].c_str(), (std::streamsize) pars[ idx - 1].length());
good = true;
}
}
if( good && ( !templ.get( buff, 3) || buff[0] != '#' || buff[1] != '#'))
good = false;
}
if( !good)
{
pstream.put( '#'); // false alarm
templ.seekg( fpos);
}
}
}
templ.close();
return true;
}
std::string Script::getXSLFromResource( const char *idr)
{
HMODULE hm = 0;//GetModuleHandle("PARSER.DLL");
//if( !hm) return "";
HRSRC res1 = FindResource(hm, idr, "XSL");
if( !res1) return getXSLFromLocalFile( idr);
HGLOBAL res2 = LoadResource(hm, res1);
if( !res2) return getXSLFromLocalFile( idr);
char *data = ( char* )LockResource( res2);
if( !data) return getXSLFromLocalFile( idr);
DWORD uLen = SizeofResource(hm, res1);
return std::string( data, uLen);
}
std::string Script::getXSLFromLocalFile( const char * filename)
{
std::fstream head;
head.open( filename, std::ios_base::in);
ASSERT( head.is_open());
if( !head.is_open())
{
AfxMessageBox( CString("Could not open ") + filename + " template file!");
return "";
}
//copy byte by byte
std::string res;
char ch;
while( head.get( ch))
res += ch;
//copy byte by byte
//char ch;
//while( head.get( ch))
// f.put( ch);
head.close();
return res;
}
--- NEW FILE: ScriptMoveUp.h ---
#pragma once
#include "Script.h"
class ScriptMoveUp :
public Script
{
public:
ScriptMoveUp(void);
~ScriptMoveUp(void);
virtual CString instantiat2( const std::vector< std::string >& pars, std::ostream& pstream);
};
--- NEW FILE: ScriptCmplx.h ---
#pragma once
#include "ScriptAbs.h"
#include "Extractor.h"
class ScriptCmplx
: public ScriptAbs
{
public:
static const char * header;
static const char * tail;
static const char * kind_removed_log_cmd;
static const char * attr_removed_log_cmd;
static const char * output_log_file;
ScriptCmplx();
~ScriptCmplx();
void gen( const Extractor::NAMES& pNames, const Extractor::ATTRS& pAttrs, const char * pfName);
protected:
void genPredKinds( std::ostream& ostr, const Extractor::NAMES& pNames);
void genPredAttrs( std::ostream& ostr, const Extractor::ATTRS::const_iterator& iter);
};
--- NEW FILE: Log.cpp ---
// Log.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "Log.h"
#include ".\log.h"
// Log
#define CLEAR_CMD 3001
IMPLEMENT_DYNAMIC(Log, CEdit)
Log::Log()
{
}
Log::~Log()
{
}
BEGIN_MESSAGE_MAP(Log, CEdit)
ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()
// Log message handlers
void Log::OnRButtonDown(UINT nFlags, CPoint point)
{
CMenu m;
m.CreatePopupMenu();
m.AppendMenu( MF_ENABLED|MF_STRING, CLEAR_CMD, "Clear");
//m.AppendMenu( MF_ENABLED|MF_SEPARATOR, 0, "");
ClientToScreen( &point);
m.TrackPopupMenu( TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x, point.y, this);
// base impl not called
//CEdit::OnRButtonDown(nFlags, point);
}
BOOL Log::OnCommand(WPARAM wParam, LPARAM lParam)
{
if( wParam == CLEAR_CMD)
{
doClear();
}
return CEdit::OnCommand(wParam, lParam);
}
void Log::doClear()
{
SetWindowText("");
}
--- NEW FILE: SimpleRepl.cpp ---
// SimpleRepl.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "SimpleRepl.h"
// SimpleReplace dialog
IMPLEMENT_DYNAMIC(SimpleReplace, CDialog)
SimpleReplace::SimpleReplace(CWnd* pParent /*=NULL*/)
: CDialog(SimpleReplace::IDD, pParent)
, m_oldV(_T(""))
, m_newV(_T(""))
{
}
SimpleReplace::~SimpleReplace()
{
}
void SimpleReplace::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_oldV);
DDX_Text(pDX, IDC_EDIT2, m_newV);
}
BEGIN_MESSAGE_MAP(SimpleReplace, CDialog)
END_MESSAGE_MAP()
// SimpleReplace message handlers
const CString& SimpleReplace::getPar1() const
{
return m_oldV;
}
const CString& SimpleReplace::getPar2() const
{
return m_newV;
}
void SimpleReplace::init( const CString& par1, const CString& par2)
{
m_oldV = par1;
m_newV = par2;
}
--- NEW FILE: ScriptAttrName.h ---
#pragma once
#include "script.h"
class ScriptAttrName :
public Script
{
public:
ScriptAttrName(void);
~ScriptAttrName(void);
virtual CString instantiat2( const std::vector< std::string >& pars, std::ostream& pstream);
};
--- NEW FILE: EnumAttrValueDlg.h ---
#pragma once
// EnumAttrValueDlg dialog
class EnumAttrValueDlg : public CDialog
{
DECLARE_DYNAMIC(EnumAttrValueDlg)
public:
EnumAttrValueDlg(CWnd* pParent = NULL); // standard constructor
virtual ~EnumAttrValueDlg();
// Dialog Data
enum { IDD = IDD_DLG_PROPENATTRCHANGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
protected:
CString m_enumAttr;
CString m_oldEnumV;
CString m_newEnumV;
CString m_global;
CString m_owner;
public:
void init( const CString& par1, const CString& par2, const CString& par3, const CString& par4, const CString& par5);
const CString& getPar1() const;
const CString& getPar2() const;
const CString& getPar3() const;
const CString& getPar4() const;
const CString& getPar5() const;
afx_msg void OnBnClickedGlobal();
};
--- NEW FILE: ScriptAttrType.h ---
#pragma once
#include "script.h"
class ScriptAttrType :
public Script
{
public:
ScriptAttrType(void);
~ScriptAttrType(void);
virtual CString instantiat2( const std::vector< std::string >& pars, std::ostream& pstream);
};
--- NEW FILE: AboutDlg.cpp ---
// CAboutDlg dialog used for App About
#include "stdafx.h"
#include "AboutDlg.h"
BEGIN_MESSAGE_MAP(AboutDlg, CDialog)
END_MESSAGE_MAP()
AboutDlg::AboutDlg() : CDialog(AboutDlg::IDD)
{
}
void AboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
--- NEW FILE: NewRuleDlg.cpp ---
// NewRuleDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ModelMigrate.h"
#include "NewRuleDlg.h"
#include ".\newruledlg.h"
#include "Rule.h"
// NewRuleDlg dialog
IMPLEMENT_DYNAMIC(NewRuleDlg, CDialog)
NewRuleDlg::NewRuleDlg(CWnd* pParent /*=NULL*/)
: CDialog(NewRuleDlg::IDD, pParent)
{
}
NewRuleDlg::~NewRuleDlg()
{
}
void NewRuleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_rules);
}
BEGIN_MESSAGE_MAP(NewRuleDlg, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
END_MESSAGE_MAP()
// NewRuleDlg message handlers
BOOL NewRuleDlg::OnInitDialog()
{
CDialog::OnInitDialog();
for( int i = 0; i < Rule::rule_nmb; ++i)
{
m_rules.AddString( Rule::ruleTypeStr( i));
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void NewRuleDlg::OnBnClickedOk()
{
m_choice = m_rules.GetCurSel();
if( m_choice != -1)
{
m_rules.GetText( m_choice, m_choiceStr);
OnOK();
}
}
void NewRuleDlg::OnLbnDblclkList1()
{
OnBnClickedOk();
}
--- NEW FILE: ScriptAbs.h ---
#pragma once
#include "Extractor.h"
class ScriptAbs
{
public:
ScriptAbs();
~ScriptAbs();
virtual void gen( const Extractor::NAMES& pNames, const Extractor::ATTRS& pAttrs, const char * pfName) = 0;
};
--- NEW FILE: SimpleRepl.h ---
#pragma once
#include "afxwin.h"
// SimpleReplace dialog
class SimpleReplace : public CDialog
{
DECLARE_DYNAMIC(SimpleReplace)
public:
SimpleReplace(CWnd* pParent = NULL); // standard constructor
virtual ~SimpleReplace();
// Dialog Data
enum { IDD = IDD_DLG_PROPNAMECHANGE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
void init( const CString& par1, const CString& par2);
const CString& getPar1() const;
const CString& getPar2() const;
protected:
CString m_oldV;
CString m_newV;
};
--- NEW FILE: RuleEditorDlg.h ---
#pragma once
#include "afxcmn.h"
#include "RuleListCtrl.h"
#include "afxwin.h"
// RuleEditorDlg dialog
class RuleEditorDlg : public CDialog
{
DECLARE_DYNAMIC(RuleEditorDlg)
public:
RuleEditorDlg(CWnd* pParent = NULL); // standard constructor
virtual ~RuleEditorDlg();
// Dialog Data
enum { IDD = IDD_DLG_RULEEDITOR };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnInitDialog();
virtual void PostNcDestroy();
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedGenerate();
afx_msg void OnBnClickedGeneratesel();
afx_msg void OnBnClickedAddrule();
afx_msg void OnBnClickedSave();
afx_msg void OnBnClickedLoad();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnLvnKeydownRulelist(NMHDR *pNMHDR, LRESULT *pResult);
protected:
void closeDlg( int pResult);
void onReturn();
void onFileNew();
void onFileLoad();
void onFileSave();
public:
RuleListCtrl m_ruleList;
CString m_lastTarget;
bool m_closed;
};
--- NEW FILE: ScriptMoveDownEach.h ---
#pragma once
#include "Script.h"
class ScriptMoveDown :
public Script
{
public:
ScriptMoveDown(void);
~ScriptMoveDown(void);
virtual CString instantiat2( const std::vector< std::string >& pars, std::ostream& pstream);
};
- Previous message: [GME-commit] GMESRC/Tools/ModelMigrate ModelMigrate.sln,NONE,1.1
- Next message: [GME-commit]
GMESRC/Tools/ModelMigrate/FrontEnd/res FrontEnd.ico,NONE,1.1
FrontEnd.manifest,NONE,1.1 FrontEnd.rc2,NONE,1.1
TAttrNameChange.xsl,NONE,1.1 TAttrTypeChange.xsl,NONE,1.1
TAttrTypeCheck2Text.xsl,NONE,1.1 TEnumAttrValueChange.xsl,NONE,1.1
TKindNameChange.xsl,NONE,1.1 TRemoveGlobalAttr.xsl,NONE,1.1
TRemoveKind.xsl,NONE,1.1 TRemoveLocalAttr.xsl,NONE,1.1
header.xsl,NONE,1.1 tail.xsl,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the GME-commit
mailing list