OSDN Git Service

BrowseRefs: Simplified some code
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / PullFetchDlg.cpp
1 // PullFetchDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "TortoiseProc.h"\r
6 #include "PullFetchDlg.h"\r
7 #include "Git.h"\r
8 #include "AppUtils.h"\r
9 \r
10 // CPullFetchDlg dialog\r
11 \r
12 IMPLEMENT_DYNAMIC(CPullFetchDlg, CResizableStandAloneDialog)\r
13 \r
14 CPullFetchDlg::CPullFetchDlg(CWnd* pParent /*=NULL*/)\r
15         : CResizableStandAloneDialog(CPullFetchDlg::IDD, pParent)\r
16 {\r
17         m_IsPull=TRUE;\r
18     m_bAutoLoad = CAppUtils::IsSSHPutty();\r
19     m_bAutoLoadEnable=true;\r
20 }\r
21 \r
22 CPullFetchDlg::~CPullFetchDlg()\r
23 {\r
24 }\r
25 \r
26 void CPullFetchDlg::DoDataExchange(CDataExchange* pDX)\r
27 {\r
28         CDialog::DoDataExchange(pDX);\r
29         DDX_Control(pDX, IDC_REMOTE_COMBO, this->m_Remote);\r
30         DDX_Control(pDX, IDC_OTHER, this->m_Other);\r
31         DDX_Control(pDX, IDC_REMOTE_BRANCH, this->m_RemoteBranch);\r
32     DDX_Control(pDX,IDC_REMOTE_MANAGE, this->m_RemoteManage);\r
33     DDX_Check(pDX,IDC_PUTTYKEY_AUTOLOAD,m_bAutoLoad);\r
34 \r
35 }\r
36 \r
37 \r
38 BEGIN_MESSAGE_MAP(CPullFetchDlg,CResizableStandAloneDialog )\r
39         ON_BN_CLICKED(IDC_REMOTE_RD, &CPullFetchDlg::OnBnClickedRd)\r
40         ON_BN_CLICKED(IDC_OTHER_RD, &CPullFetchDlg::OnBnClickedRd)\r
41         ON_BN_CLICKED(IDOK, &CPullFetchDlg::OnBnClickedOk)\r
42     ON_STN_CLICKED(IDC_REMOTE_MANAGE, &CPullFetchDlg::OnStnClickedRemoteManage)\r
43 END_MESSAGE_MAP()\r
44 \r
45 BOOL CPullFetchDlg::OnInitDialog()\r
46 {\r
47         CResizableStandAloneDialog::OnInitDialog();\r
48         AddAnchor(IDC_REMOTE_COMBO, TOP_LEFT, TOP_RIGHT);\r
49         AddAnchor(IDC_OTHER, TOP_LEFT,TOP_RIGHT);\r
50 \r
51         AddAnchor(IDC_REMOTE_BRANCH, TOP_LEFT,TOP_RIGHT);\r
52         \r
53         AddAnchor(IDOK,BOTTOM_RIGHT);\r
54         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
55     AddAnchor(IDC_GROUPT_REMOTE,TOP_LEFT,BOTTOM_RIGHT);\r
56     AddAnchor(IDC_PUTTYKEY_AUTOLOAD,BOTTOM_LEFT);\r
57     AddAnchor(IDC_REMOTE_MANAGE,BOTTOM_LEFT);\r
58         AddAnchor(IDHELP, BOTTOM_RIGHT);\r
59 \r
60     this->AddOthersToAnchor();\r
61 \r
62     this->GetDlgItem(IDC_PUTTYKEY_AUTOLOAD)->EnableWindow(m_bAutoLoadEnable);\r
63 \r
64         CheckRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD,IDC_REMOTE_RD);\r
65         m_Remote.EnableWindow(TRUE);\r
66         m_Other.EnableWindow(FALSE);\r
67         m_RemoteBranch.EnableWindow(FALSE);\r
68 \r
69         m_Other.SetURLHistory(TRUE);\r
70         m_Other.LoadHistory(_T("Software\\TortoiseGit\\History\\PullURLS"), _T("url"));\r
71         CString clippath=CAppUtils::GetClipboardLink();\r
72         if(clippath.IsEmpty())\r
73                 m_Other.SetCurSel(0);\r
74         else\r
75                 m_Other.SetWindowText(clippath);\r
76 \r
77         m_RemoteBranch.LoadHistory(_T("Software\\TortoiseGit\\History\\PullRemoteBranch"), _T("br"));\r
78         m_RemoteBranch.SetCurSel(0);\r
79 \r
80         CString WorkingDir=g_Git.m_CurrentDir;\r
81 \r
82         if(m_IsPull)\r
83                 this->SetWindowTextW(CString(_T("Pull - "))+WorkingDir);\r
84         else\r
85                 this->SetWindowTextW(CString(_T("Fetch - "))+WorkingDir);\r
86 \r
87         STRING_VECTOR list;\r
88         \r
89         CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PullRemote\\")+WorkingDir));\r
90         m_RemoteReg = remote;\r
91         int sel=0;\r
92 \r
93         if(!g_Git.GetRemoteList(list))\r
94         {       \r
95                 for(unsigned int i=0;i<list.size();i++)\r
96                 {\r
97                         m_Remote.AddString(list[i]);\r
98                         if(list[i] == remote)\r
99                                 sel = i;\r
100                 }\r
101         }\r
102         m_Remote.SetCurSel(sel);\r
103 \r
104         EnableSaveRestore(_T("PullFetchDlg"));\r
105     this->m_RemoteManage.SetURL(CString());\r
106         return TRUE;\r
107 }\r
108 // CPullFetchDlg message handlers\r
109 \r
110 void CPullFetchDlg::OnBnClickedRd()\r
111 {\r
112 \r
113         // TODO: Add your control notification handler code here\r
114         if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_REMOTE_RD)\r
115         {\r
116                 m_Remote.EnableWindow(TRUE);\r
117                 m_Other.EnableWindow(FALSE);\r
118                 m_RemoteBranch.EnableWindow(FALSE);\r
119 \r
120         }\r
121         if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_OTHER_RD)\r
122         {\r
123                 m_Remote.EnableWindow(FALSE);\r
124                 m_Other.EnableWindow(TRUE);;\r
125                 m_RemoteBranch.EnableWindow(TRUE);\r
126         }\r
127         \r
128 \r
129 }\r
130 \r
131 void CPullFetchDlg::OnBnClickedOk()\r
132 {\r
133         // TODO: Add your control notification handler code here\r
134         if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_REMOTE_RD)\r
135         {\r
136                 m_RemoteURL=m_Remote.GetString();\r
137                 m_RemoteBranchName.Empty();\r
138                 \r
139         }\r
140         if( GetCheckedRadioButton(IDC_REMOTE_RD,IDC_OTHER_RD) == IDC_OTHER_RD)\r
141         {\r
142                 m_Other.GetWindowTextW(m_RemoteURL);\r
143                 m_RemoteBranchName=m_RemoteBranch.GetString();\r
144                 \r
145         }\r
146 \r
147         m_RemoteReg = m_Remote.GetString();\r
148 \r
149         m_Other.SaveHistory();\r
150         m_RemoteBranch.SaveHistory();\r
151         this->OnOK();\r
152 }\r
153 \r
154 void CPullFetchDlg::OnStnClickedRemoteManage()\r
155 {\r
156     // TODO: Add your control notification handler code here\r
157     CAppUtils::LaunchRemoteSetting();\r
158 }\r