OSDN Git Service

Use Shared Choose Version code
authorFrank Li <lznuaa@gmail.com>
Thu, 25 Dec 2008 05:22:48 +0000 (13:22 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 25 Dec 2008 05:22:48 +0000 (13:22 +0800)
src/TortoiseProc/ChooseVersion.h
src/TortoiseProc/CreateBranchTagDlg.cpp
src/TortoiseProc/CreateBranchTagDlg.h
src/TortoiseProc/MergeDlg.cpp
src/TortoiseProc/MergeDlg.h

index f39e99c..f4e51b1 100644 (file)
@@ -95,6 +95,7 @@ public:
                AddAnchor(IDC_COMBOBOXEX_TAGS, TOP_LEFT, TOP_RIGHT);    \\r
                AddAnchor(IDC_COMBOBOXEX_VERSION, TOP_LEFT, TOP_RIGHT); \\r
                AddAnchor(IDC_GROUP_BASEON, TOP_LEFT, TOP_RIGHT);               \\r
+               AddAnchor(IDC_BUTTON_SHOW,TOP_RIGHT);           \\r
        }       \r
 \r
 #define CHOOSE_EVENT_RADIO() \\r
index 3a54fbb..353fbd2 100644 (file)
@@ -2,9 +2,10 @@
 //\r
 \r
 #include "stdafx.h"\r
+#include "Git.h"\r
 #include "TortoiseProc.h"\r
 #include "CreateBranchTagDlg.h"\r
-#include "Git.h"\r
+\r
 #include "Messagebox.h"\r
 \r
 // CCreateBranchTagDlg dialog\r
@@ -12,7 +13,8 @@
 IMPLEMENT_DYNAMIC(CCreateBranchTagDlg, CResizableStandAloneDialog)\r
 \r
 CCreateBranchTagDlg::CCreateBranchTagDlg(CWnd* pParent /*=NULL*/)\r
-       : CResizableStandAloneDialog(CCreateBranchTagDlg::IDD, pParent)\r
+       : CResizableStandAloneDialog(CCreateBranchTagDlg::IDD, pParent),\r
+       CChooseVersion(this)\r
 {\r
        m_bIsTag=0;\r
 }\r
@@ -24,10 +26,9 @@ CCreateBranchTagDlg::~CCreateBranchTagDlg()
 void CCreateBranchTagDlg::DoDataExchange(CDataExchange* pDX)\r
 {\r
        CDialog::DoDataExchange(pDX);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_BRANCH, this->m_Branch);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_TAGS, this->m_Tags);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_VERSION, this->m_Version);\r
-                               \r
+\r
+       CHOOSE_VERSION_DDX;\r
+\r
        DDX_Text(pDX, IDC_BRANCH_TAG, this->m_BranchTagName);\r
        DDX_Check(pDX,IDC_CHECK_FORCE,this->m_bForce);\r
        DDX_Check(pDX,IDC_CHECK_TRACK,this->m_bTrack);\r
@@ -36,10 +37,7 @@ void CCreateBranchTagDlg::DoDataExchange(CDataExchange* pDX)
 \r
 \r
 BEGIN_MESSAGE_MAP(CCreateBranchTagDlg, CResizableStandAloneDialog)\r
-       ON_BN_CLICKED(IDC_RADIO_HEAD, &CCreateBranchTagDlg::OnBnClickedRadio)\r
-       ON_BN_CLICKED(IDC_RADIO_BRANCH, &CCreateBranchTagDlg::OnBnClickedRadio)\r
-       ON_BN_CLICKED(IDC_RADIO_TAGS, &CCreateBranchTagDlg::OnBnClickedRadio)\r
-       ON_BN_CLICKED(IDC_RADIO_VERSION, &CCreateBranchTagDlg::OnBnClickedRadio)\r
+       CHOOSE_VERSION_EVENT\r
        ON_BN_CLICKED(IDOK, &CCreateBranchTagDlg::OnBnClickedOk)\r
        ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH, &CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch)\r
 END_MESSAGE_MAP()\r
@@ -48,10 +46,7 @@ BOOL CCreateBranchTagDlg::OnInitDialog()
 {\r
        CResizableStandAloneDialog::OnInitDialog();\r
 \r
-       AddAnchor(IDC_COMBOBOXEX_BRANCH, TOP_LEFT, TOP_RIGHT);\r
-       AddAnchor(IDC_COMBOBOXEX_TAGS, TOP_LEFT, TOP_RIGHT);\r
-       AddAnchor(IDC_COMBOBOXEX_VERSION, TOP_LEFT, TOP_RIGHT);\r
-       AddAnchor(IDC_GROUP_BASEON, TOP_LEFT, TOP_RIGHT);\r
+       CHOOSE_VERSION_ADDANCHOR;\r
 \r
        AddAnchor(IDC_GROUP_BRANCH, TOP_LEFT, TOP_RIGHT);\r
        \r
@@ -61,22 +56,9 @@ BOOL CCreateBranchTagDlg::OnInitDialog()
        AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
 \r
 \r
-       CheckRadioButton(IDC_RADIO_HEAD,IDC_RADIO_VERSION,IDC_RADIO_HEAD);\r
-\r
-       CStringList list;\r
-       g_Git.GetTagList(list);\r
-       m_Tags.AddString(list);\r
-\r
-       list.RemoveAll();\r
-       int current;\r
-       g_Git.GetBranchList(list,&current,CGit::BRANCH_ALL);\r
-       m_Branch.AddString(list);\r
-       m_Branch.SetCurSel(current);\r
-\r
-       m_Version.LoadHistory(_T("Software\\TortoiseGit\\History\\VersionHash"), _T("hash"));\r
-       m_Version.SetCurSel(0);\r
+       this->SetDefaultChoose(IDC_RADIO_HEAD);\r
+       Init();\r
 \r
-       OnBnClickedRadio();\r
        this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
 \r
        if(this->m_bIsTag)\r
@@ -96,55 +78,16 @@ BOOL CCreateBranchTagDlg::OnInitDialog()
 }\r
 // CCreateBranchTagDlg message handlers\r
 \r
-void CCreateBranchTagDlg::OnBnClickedRadio()\r
-{\r
-       // TODO: Add your control notification handler code here\r
-       this->m_Branch.EnableWindow(FALSE);\r
-       this->m_Tags.EnableWindow(FALSE);\r
-       this->m_Version.EnableWindow(FALSE);\r
-       int radio=GetCheckedRadioButton(IDC_RADIO_HEAD,IDC_RADIO_VERSION);\r
-       switch (radio)\r
-       {\r
-       case IDC_RADIO_HEAD:\r
-               break;\r
-       case IDC_RADIO_BRANCH:\r
-               this->m_Branch.EnableWindow(TRUE);\r
-               break;\r
-       case IDC_RADIO_TAGS:\r
-               this->m_Tags.EnableWindow(TRUE);\r
-               break;\r
-       case IDC_RADIO_VERSION:\r
-               this->m_Version.EnableWindow(TRUE);\r
-               break;\r
-       }\r
-}\r
-\r
 void CCreateBranchTagDlg::OnBnClickedOk()\r
 {\r
        // TODO: Add your control notification handler code here\r
        this->UpdateData(TRUE);\r
        if(this->m_BranchTagName.Trim().IsEmpty())\r
        {\r
-               CMessageBox::Show(NULL,_T("Branch\Tag name can't empty"),_T("TortiseGit"),MB_OK);\r
+               CMessageBox::Show(NULL,_T("Branch\\Tag name can't empty"),_T("TortiseGit"),MB_OK);\r
                return;\r
        }\r
-       int radio=GetCheckedRadioButton(IDC_RADIO_HEAD,IDC_RADIO_VERSION);\r
-       switch (radio)\r
-       {\r
-       case IDC_RADIO_HEAD:\r
-               this->m_Base=_T("HEAD");\r
-               break;\r
-       case IDC_RADIO_BRANCH:\r
-               this->m_Base=m_Branch.GetString();\r
-               break;\r
-       case IDC_RADIO_TAGS:\r
-               this->m_Base=m_Tags.GetString();\r
-               break;\r
-       case IDC_RADIO_VERSION:\r
-               this->m_Base=m_Version.GetString();\r
-               break;\r
-       }\r
-       this->m_Version.SaveHistory();\r
+       this->UpdateRevsionName();\r
        OnOK();\r
 }\r
 \r
@@ -152,7 +95,7 @@ void CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch()
 {\r
        // TODO: Add your control notification handler code here\r
        \r
-       if(this->m_Branch.GetString().Left(6)==_T("origin"))\r
+       if(this->m_ChooseVersioinBranch.GetString().Left(6)==_T("origin"))\r
                this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);\r
        else\r
                this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
index 737d508..9bf42ff 100644 (file)
@@ -2,10 +2,10 @@
 \r
 #include "StandAloneDlg.h"\r
 #include "HistoryCombo.h"\r
-\r
+#include "ChooseVersion.h"\r
 // CCreateBranchTagDlg dialog\r
 \r
-class CCreateBranchTagDlg : public CResizableStandAloneDialog\r
+class CCreateBranchTagDlg : public CResizableStandAloneDialog,public CChooseVersion\r
 {\r
        DECLARE_DYNAMIC(CCreateBranchTagDlg)\r
 \r
@@ -26,9 +26,7 @@ protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        virtual BOOL OnInitDialog();\r
        \r
-       CHistoryCombo m_Branch;\r
-       CHistoryCombo m_Tags;\r
-       CHistoryCombo m_Version;\r
+       CHOOSE_EVENT_RADIO();\r
        \r
        DECLARE_MESSAGE_MAP()\r
 public:\r
index 0d9d646..c9481c7 100644 (file)
@@ -2,17 +2,20 @@
 //\r
 \r
 #include "stdafx.h"\r
+\r
+#include "Git.h"\r
 #include "TortoiseProc.h"\r
 #include "MergeDlg.h"\r
 \r
-#include "Git.h"\r
+\r
 #include "Messagebox.h"\r
 // CMergeDlg dialog\r
 \r
 IMPLEMENT_DYNAMIC(CMergeDlg, CResizableStandAloneDialog)\r
 \r
 CMergeDlg::CMergeDlg(CWnd* pParent /*=NULL*/)\r
-       : CResizableStandAloneDialog(CMergeDlg::IDD, pParent)\r
+       : CResizableStandAloneDialog(CMergeDlg::IDD, pParent),\r
+       CChooseVersion(this)\r
 {\r
 \r
 }\r
@@ -24,9 +27,8 @@ CMergeDlg::~CMergeDlg()
 void CMergeDlg::DoDataExchange(CDataExchange* pDX)\r
 {\r
        CDialog::DoDataExchange(pDX);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_BRANCH, this->m_Branch);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_TAGS, this->m_Tags);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_VERSION, this->m_Version);\r
+\r
+       CHOOSE_VERSION_DDX;\r
 \r
        DDX_Check(pDX,IDC_CHECK_NOFF,this->m_bNoFF);\r
        DDX_Check(pDX,IDC_CHECK_SQUASH,this->m_bSquash);\r
@@ -34,9 +36,7 @@ void CMergeDlg::DoDataExchange(CDataExchange* pDX)
 \r
 \r
 BEGIN_MESSAGE_MAP(CMergeDlg, CResizableStandAloneDialog)\r
-       ON_BN_CLICKED(IDC_RADIO_BRANCH, &CMergeDlg::OnBnClickedRadio)\r
-       ON_BN_CLICKED(IDC_RADIO_TAGS, &CMergeDlg::OnBnClickedRadio)\r
-       ON_BN_CLICKED(IDC_RADIO_VERSION, &CMergeDlg::OnBnClickedRadio)\r
+       CHOOSE_VERSION_EVENT\r
        ON_BN_CLICKED(IDOK, &CMergeDlg::OnBnClickedOk)\r
 END_MESSAGE_MAP()\r
 \r
@@ -45,14 +45,11 @@ BOOL CMergeDlg::OnInitDialog()
 {\r
        CResizableStandAloneDialog::OnInitDialog();\r
 \r
-       AddAnchor(IDC_COMBOBOXEX_BRANCH, TOP_LEFT, TOP_RIGHT);\r
-       AddAnchor(IDC_COMBOBOXEX_TAGS, TOP_LEFT, TOP_RIGHT);\r
-       AddAnchor(IDC_COMBOBOXEX_VERSION, TOP_LEFT, TOP_RIGHT);\r
 \r
-       AddAnchor(IDC_GROUP_BASEON, TOP_LEFT, TOP_RIGHT);\r
+       CHOOSE_VERSION_ADDANCHOR;\r
+\r
        AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);\r
 \r
-       AddAnchor(IDC_BUTTON_SHOW, TOP_RIGHT);\r
        \r
        AddAnchor(IDOK,BOTTOM_RIGHT);\r
        AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
@@ -60,71 +57,22 @@ BOOL CMergeDlg::OnInitDialog()
 \r
        CheckRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION,IDC_RADIO_BRANCH);\r
 \r
-       CStringList list;\r
-       g_Git.GetTagList(list);\r
-       m_Tags.AddString(list);\r
-\r
-       list.RemoveAll();\r
-       int current;\r
-       g_Git.GetBranchList(list,&current,CGit::BRANCH_ALL);\r
-       m_Branch.AddString(list);\r
-       //m_Branch.SetCurSel(current);\r
-\r
-       m_Version.LoadHistory(_T("Software\\TortoiseGit\\History\\VersionHash"), _T("hash"));\r
-       m_Version.SetCurSel(0);\r
+       Init();\r
+       \r
+       this->SetDefaultChoose(IDC_RADIO_BRANCH);\r
 \r
-       OnBnClickedRadio();\r
-                       \r
        return TRUE;\r
 }\r
 \r
 // CMergeDlg message handlers\r
 \r
-void CMergeDlg::OnBnClickedRadio()\r
-{\r
-       // TODO: Add your control notification handler code here\r
-       this->m_Branch.EnableWindow(FALSE);\r
-       this->m_Tags.EnableWindow(FALSE);\r
-       this->m_Version.EnableWindow(FALSE);\r
-       int radio=GetCheckedRadioButton(IDC_RADIO_HEAD,IDC_RADIO_VERSION);\r
-       switch (radio)\r
-       {\r
-       case IDC_RADIO_BRANCH:\r
-               this->m_Branch.EnableWindow(TRUE);\r
-               break;\r
-       case IDC_RADIO_TAGS:\r
-               this->m_Tags.EnableWindow(TRUE);\r
-               break;\r
-       case IDC_RADIO_VERSION:\r
-               this->m_Version.EnableWindow(TRUE);\r
-               break;\r
-       }\r
-}\r
 \r
 void CMergeDlg::OnBnClickedOk()\r
 {\r
        // TODO: Add your control notification handler code here\r
        this->UpdateData(TRUE);\r
        \r
-       int radio=GetCheckedRadioButton(IDC_RADIO_HEAD,IDC_RADIO_VERSION);\r
-       switch (radio)\r
-       {\r
-       case IDC_RADIO_BRANCH:\r
-               this->m_Base=m_Branch.GetString();\r
-               break;\r
-       case IDC_RADIO_TAGS:\r
-               this->m_Base=m_Tags.GetString();\r
-               break;\r
-       case IDC_RADIO_VERSION:\r
-               this->m_Base=m_Version.GetString();\r
-               break;\r
-       }\r
-\r
-       if(m_Base.Trim().IsEmpty())\r
-       {\r
-               CMessageBox::Show(NULL,_T("You must choose source"),_T("TortiseGit"),MB_OK);\r
-               return;\r
-       }\r
-       this->m_Version.SaveHistory();\r
+       this->UpdateRevsionName();\r
+\r
        OnOK();\r
 }\r
index 6485234..95a93d2 100644 (file)
@@ -2,10 +2,10 @@
 \r
 #include "StandAloneDlg.h"\r
 #include "HistoryCombo.h"\r
-\r
+#include "ChooseVersion.h"\r
 // CMergeDlg dialog\r
 \r
-class CMergeDlg : public CResizableStandAloneDialog\r
+class CMergeDlg : public CResizableStandAloneDialog,CChooseVersion\r
 {\r
        DECLARE_DYNAMIC(CMergeDlg)\r
 \r
@@ -26,12 +26,9 @@ protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        virtual BOOL OnInitDialog();\r
 \r
-       CHistoryCombo m_Branch;\r
-       CHistoryCombo m_Tags;\r
-       CHistoryCombo m_Version;\r
-\r
        DECLARE_MESSAGE_MAP()\r
+       CHOOSE_EVENT_RADIO() ;\r
 public:\r
-       afx_msg void OnBnClickedRadio();\r
+\r
        afx_msg void OnBnClickedOk();\r
 };\r