OSDN Git Service

Add url error message at syncdlg
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SyncDlg.cpp
index 8a52e21..0d5c108 100644 (file)
@@ -33,7 +33,7 @@ CSyncDlg::CSyncDlg(CWnd* pParent /*=NULL*/)
        : CResizableStandAloneDialog(CSyncDlg::IDD, pParent)\r
        , m_bAutoLoadPuttyKey(FALSE)\r
 {\r
-\r
+       m_pTooltip=&this->m_tooltips;\r
 }\r
 \r
 CSyncDlg::~CSyncDlg()\r
@@ -44,8 +44,6 @@ void CSyncDlg::DoDataExchange(CDataExchange* pDX)
 {\r
        CDialog::DoDataExchange(pDX);\r
        DDX_Check(pDX, IDC_CHECK_PUTTY_KEY, m_bAutoLoadPuttyKey);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_LOCAL_BRANCH, m_ctrlLocalBranch);\r
-       DDX_Control(pDX, IDC_COMBOBOXEX_REMOTE_BRANCH, m_ctrlRemoteBranch);\r
        DDX_Control(pDX, IDC_COMBOBOXEX_URL, m_ctrlURL);\r
        DDX_Control(pDX, IDC_BUTTON_TABCTRL, m_ctrlDumyButton);\r
        DDX_Control(pDX, IDC_BUTTON_PULL, m_ctrlPull);\r
@@ -53,6 +51,8 @@ void CSyncDlg::DoDataExchange(CDataExchange* pDX)
        DDX_Control(pDX, IDC_STATIC_STATUS, m_ctrlStatus);\r
        DDX_Control(pDX, IDC_PROGRESS_SYNC, m_ctrlProgress);\r
        DDX_Control(pDX, IDC_ANIMATE_SYNC, m_ctrlAnimate);\r
+\r
+       BRANCH_COMBOX_DDX;\r
 }\r
 \r
 \r
@@ -61,6 +61,10 @@ BEGIN_MESSAGE_MAP(CSyncDlg, CResizableStandAloneDialog)
        ON_BN_CLICKED(IDC_BUTTON_PUSH, &CSyncDlg::OnBnClickedButtonPush)\r
        ON_BN_CLICKED(IDC_BUTTON_APPLY, &CSyncDlg::OnBnClickedButtonApply)\r
        ON_BN_CLICKED(IDC_BUTTON_EMAIL, &CSyncDlg::OnBnClickedButtonEmail)\r
+       ON_BN_CLICKED(IDC_BUTTON_MANAGE, &CSyncDlg::OnBnClickedButtonManage)\r
+       BRANCH_COMBOX_EVENT\r
+       ON_NOTIFY(CBEN_ENDEDIT, IDC_COMBOBOXEX_URL, &CSyncDlg::OnCbenEndeditComboboxexUrl)\r
+       ON_CBN_EDITCHANGE(IDC_COMBOBOXEX_URL, &CSyncDlg::OnCbnEditchangeComboboxexUrl)\r
 END_MESSAGE_MAP()\r
 \r
 \r
@@ -93,9 +97,46 @@ BOOL CSyncDlg::OnInitDialog()
 {\r
        CResizableStandAloneDialog::OnInitDialog();\r
 \r
-       AddAnchor(IDC_STATIC_REMOTE_BRANCH,TOP_RIGHT);\r
-       AddAnchor(IDC_COMBOBOXEX_REMOTE_BRANCH,TOP_RIGHT);\r
-       AddAnchor(IDC_BUTTON_REMOTE_BRANCH,TOP_RIGHT);\r
+       //Create Tabctrl\r
+       CWnd *pwnd=this->GetDlgItem(IDC_BUTTON_TABCTRL);\r
+       CRect rectDummy;\r
+       pwnd->GetWindowRect(&rectDummy);\r
+       this->ScreenToClient(rectDummy);\r
+\r
+       if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_SYNC_TAB))\r
+       {\r
+               TRACE0("Failed to create output tab window\n");\r
+               return FALSE;      // fail to create\r
+       }\r
+       m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);\r
+\r
+       DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP;\r
+\r
+       if( !m_OutLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_LOGLIST))\r
+       {\r
+               TRACE0("Failed to create output commits window\n");\r
+               return FALSE;      // fail to create\r
+\r
+       }\r
+       m_ctrlTabCtrl.InsertTab(&m_OutLogList,_T("Out Commits"),0);\r
+\r
+       m_OutLogList.InsertGitColumn();\r
+\r
+       dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;\r
+       \r
+       if( !m_OutChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_CHANGELIST))\r
+       {\r
+               TRACE0("Failed to create output change files window\n");\r
+               return FALSE;      // fail to create\r
+       }\r
+       m_ctrlTabCtrl.InsertTab(&m_OutChangeFileList,_T("Out ChangeList"),1);\r
+\r
+       m_OutChangeFileList.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("RebaseDlg"),(SVNSLC_POPALL ^ SVNSLC_POPCOMMIT),false);\r
+\r
+       this->m_tooltips.Create(this);\r
+\r
+       AddAnchor(IDC_SYNC_TAB,TOP_LEFT,BOTTOM_RIGHT);\r
+\r
        AddAnchor(IDC_GROUP_INFO,TOP_LEFT,TOP_RIGHT);\r
        AddAnchor(IDC_COMBOBOXEX_URL,TOP_LEFT,TOP_RIGHT);\r
        AddAnchor(IDC_BUTTON_MANAGE,TOP_RIGHT);\r
@@ -108,6 +149,13 @@ BOOL CSyncDlg::OnInitDialog()
        AddAnchor(IDHELP,BOTTOM_RIGHT);\r
        AddAnchor(IDC_STATIC_STATUS,BOTTOM_LEFT);\r
        AddAnchor(IDC_ANIMATE_SYNC,TOP_RIGHT);\r
+       \r
+       BRANCH_COMBOX_ADD_ANCHOR();\r
+\r
+       CString WorkingDir=g_Git.m_CurrentDir;\r
+       WorkingDir.Replace(_T(':'),_T('_'));\r
+       m_RegKeyRemoteBranch = CString(_T("Software\\TortoiseGit\\History\\SyncBranch\\"))+WorkingDir;\r
+\r
 \r
        this->AddOthersToAnchor();\r
        // TODO:  Add extra initialization here\r
@@ -120,7 +168,7 @@ BOOL CSyncDlg::OnInitDialog()
        this->m_ctrlPull.AddEntry(CString(_T("&Fetch")));\r
        this->m_ctrlPull.AddEntry(CString(_T("Fetch&&Rebase")));\r
 \r
-       CString WorkingDir=g_Git.m_CurrentDir;\r
+       \r
        WorkingDir.Replace(_T(':'),_T('_'));\r
 \r
        CString regkey ;\r
@@ -139,6 +187,90 @@ BOOL CSyncDlg::OnInitDialog()
 \r
        EnableSaveRestore(_T("SyncDlg"));\r
 \r
+       this->LoadBranchInfo();\r
+\r
+       \r
        return TRUE;  // return TRUE unless you set the focus to a control\r
        // EXCEPTION: OCX Property Pages should return FALSE\r
 }\r
+\r
+void CSyncDlg::OnBnClickedButtonManage()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       CAppUtils::LaunchRemoteSetting();\r
+}\r
+\r
+BOOL CSyncDlg::PreTranslateMessage(MSG* pMsg)\r
+{\r
+       // TODO: Add your specialized code here and/or call the base class\r
+       m_tooltips.RelayEvent(pMsg);\r
+       return __super::PreTranslateMessage(pMsg);\r
+}\r
+void CSyncDlg::FetchOutList()\r
+{\r
+       m_OutChangeFileList.Clear();\r
+       this->m_OutLogList.Clear();\r
+\r
+       CString remote;\r
+       this->m_ctrlURL.GetWindowText(remote);\r
+       CString remotebranch;\r
+       this->m_ctrlRemoteBranch.GetWindowText(remotebranch);\r
+       remotebranch=remote+_T("/")+remotebranch;\r
+\r
+       if(IsURL())\r
+       {\r
+               CString str;\r
+               str=_T("Don't know what will push befause you enter URL");\r
+               m_OutLogList.ShowText(str);\r
+               this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);\r
+               m_OutLocalBranch.Empty();\r
+               m_OutRemoteBranch.Empty();\r
+               return ;\r
+       \r
+       }else if(g_Git.GetHash(remotebranch).GetLength()<40)\r
+       {\r
+               CString str;\r
+               str.Format(_T("Don't know what will push befause unkown \"%s\""),remotebranch);\r
+               m_OutLogList.ShowText(str);\r
+               this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);\r
+               m_OutLocalBranch.Empty();\r
+               m_OutRemoteBranch.Empty();\r
+               return ;\r
+       }\r
+       else\r
+       {\r
+               CString localbranch;\r
+               localbranch=this->m_ctrlLocalBranch.GetString();\r
+\r
+               if(localbranch != m_OutLocalBranch && m_OutRemoteBranch != remotebranch)\r
+               {\r
+                       m_OutLogList.ClearText();\r
+                       m_OutLogList.FillGitLog(NULL,CGit::     LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,\r
+                               &remotebranch,&localbranch);\r
+               }\r
+               this->m_OutLocalBranch=localbranch;\r
+               this->m_OutRemoteBranch=remotebranch;\r
+       }\r
+\r
+}\r
+\r
+bool CSyncDlg::IsURL()\r
+{\r
+       CString str;\r
+       this->m_ctrlURL.GetWindowText(str);\r
+       if(str.Find(_T('\\'))>=0 || str.Find(_T('/'))>=0)\r
+               return true;\r
+       else\r
+               return false;\r
+}\r
+void CSyncDlg::OnCbenEndeditComboboxexUrl(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       *pResult = 0;\r
+}\r
+\r
+void CSyncDlg::OnCbnEditchangeComboboxexUrl()\r
+{\r
+       this->FetchOutList();\r
+       // TODO: Add your control notification handler code here\r
+}\r