4 #include "BrowseRefsDlg.h"
13 CHistoryCombo m_ChooseVersioinBranch
;
14 CHistoryCombo m_ChooseVersioinTags
;
15 CHistoryCombo m_ChooseVersioinVersion
;
17 //Notification when version changed. Can be implemented in derived classes.
18 virtual void OnVersionChanged(){}
20 afx_msg
void OnBnClickedChooseRadio()
22 this->m_ChooseVersioinTags
.EnableWindow(FALSE
);
23 this->m_ChooseVersioinBranch
.EnableWindow(FALSE
);
24 this->m_ChooseVersioinVersion
.EnableWindow(FALSE
);
25 int radio
=m_pWin
->GetCheckedRadioButton(IDC_RADIO_HEAD
,IDC_RADIO_VERSION
);
30 case IDC_RADIO_BRANCH
:
31 this->m_ChooseVersioinBranch
.EnableWindow(TRUE
);
34 this->m_ChooseVersioinTags
.EnableWindow(TRUE
);
36 case IDC_RADIO_VERSION
:
37 this->m_ChooseVersioinVersion
.EnableWindow(TRUE
);
40 // enable version browse button if Version is selected
41 m_pWin
->GetDlgItem(IDC_BUTTON_SHOW
)->EnableWindow(radio
== IDC_RADIO_VERSION
);
45 void OnBnClickedChooseVersion()
47 // use the git log to allow selection of a version
49 // tell the dialog to use mode for selecting revisions
51 // only one revision must be selected however
52 dlg
.SingleSelection(true);
53 if ( dlg
.DoModal() == IDOK
)
55 // get selected hash if any
56 CString selectedHash
= dlg
.GetSelectedHash();
57 // load into window, do this even if empty so that it is clear that nothing has been selected
58 m_ChooseVersioinVersion
.SetWindowText( selectedHash
);
63 void UpdateRevsionName()
65 int radio
=m_pWin
->GetCheckedRadioButton(IDC_RADIO_HEAD
,IDC_RADIO_VERSION
);
69 this->m_VersionName
=_T("HEAD");
71 case IDC_RADIO_BRANCH
:
72 this->m_VersionName
=m_ChooseVersioinBranch
.GetString();
75 this->m_VersionName
=m_ChooseVersioinTags
.GetString();
77 case IDC_RADIO_VERSION
:
78 this->m_VersionName
=m_ChooseVersioinVersion
.GetString();
82 void SetDefaultChoose(int id
)
84 m_pWin
->CheckRadioButton(IDC_RADIO_HEAD
,IDC_RADIO_VERSION
,id
);
85 OnBnClickedChooseRadio();
88 void OnBnClickedButtonBrowseRef()
92 CString resultRef
= CBrowseRefsDlg::PickRef(false, m_VersionName
, gPickRef_All
);
93 if(resultRef
.IsEmpty())
95 if(wcsncmp(resultRef
,L
"refs/",5)==0)
96 resultRef
= resultRef
.Mid(5);
97 if(wcsncmp(resultRef
,L
"heads/",6)==0)
99 resultRef
= resultRef
.Mid(6);
100 SetDefaultChoose(IDC_RADIO_BRANCH
);
101 m_ChooseVersioinBranch
.SetCurSel(
102 m_ChooseVersioinBranch
.FindStringExact(-1, resultRef
));
104 else if(wcsncmp(resultRef
,L
"remotes/",8)==0)
106 SetDefaultChoose(IDC_RADIO_BRANCH
);
107 m_ChooseVersioinBranch
.SetCurSel(
108 m_ChooseVersioinBranch
.FindStringExact(-1, resultRef
));
110 else if(wcsncmp(resultRef
,L
"tags/",5)==0)
112 resultRef
= resultRef
.Mid(5);
113 SetDefaultChoose(IDC_RADIO_TAGS
);
114 m_ChooseVersioinTags
.SetCurSel(
115 m_ChooseVersioinTags
.FindStringExact(-1, resultRef
));
123 m_ChooseVersioinBranch
.SetMaxHistoryItems(0x7FFFFFFF);
124 m_ChooseVersioinTags
.SetMaxHistoryItems(0x7FFFFFFF);
127 g_Git
.GetTagList(list
);
128 m_ChooseVersioinTags
.AddString(list
);
132 g_Git
.GetBranchList(list
,¤t
,CGit::BRANCH_ALL
);
133 m_ChooseVersioinBranch
.AddString(list
);
134 m_ChooseVersioinBranch
.SetCurSel(current
);
140 CString m_VersionName
;
141 CChooseVersion(CWnd
*win
)
149 #define CHOOSE_VERSION_DDX \
150 DDX_Control(pDX, IDC_COMBOBOXEX_BRANCH, m_ChooseVersioinBranch); \
151 DDX_Control(pDX, IDC_COMBOBOXEX_TAGS, m_ChooseVersioinTags); \
152 DDX_Control(pDX, IDC_COMBOBOXEX_VERSION, m_ChooseVersioinVersion);
154 #define CHOOSE_VERSION_EVENT\
155 ON_BN_CLICKED(IDC_RADIO_HEAD, OnBnClickedChooseRadioHost)\
156 ON_BN_CLICKED(IDC_RADIO_BRANCH, OnBnClickedChooseRadioHost)\
157 ON_BN_CLICKED(IDC_RADIO_TAGS, OnBnClickedChooseRadioHost)\
158 ON_BN_CLICKED(IDC_BUTTON_SHOW, OnBnClickedShow)\
159 ON_BN_CLICKED(IDC_RADIO_VERSION, OnBnClickedChooseRadioHost)\
160 ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, OnBnClickedButtonBrowseRefHost)
162 #define CHOOSE_VERSION_ADDANCHOR \
164 AddAnchor(IDC_COMBOBOXEX_BRANCH, TOP_LEFT, TOP_RIGHT); \
165 AddAnchor(IDC_COMBOBOXEX_TAGS, TOP_LEFT, TOP_RIGHT); \
166 AddAnchor(IDC_COMBOBOXEX_VERSION, TOP_LEFT, TOP_RIGHT); \
167 AddAnchor(IDC_GROUP_BASEON, TOP_LEFT, TOP_RIGHT); \
168 AddAnchor(IDC_BUTTON_SHOW,TOP_RIGHT); \
169 AddAnchor(IDC_BUTTON_BROWSE_REF,TOP_RIGHT); \
172 #define CHOOSE_EVENT_RADIO() \
173 afx_msg void OnBnClickedChooseRadioHost(){OnBnClickedChooseRadio();}\
174 afx_msg void OnBnClickedShow(){OnBnClickedChooseVersion();}\
175 afx_msg void OnBnClickedButtonBrowseRefHost(){OnBnClickedButtonBrowseRef();}