4 #include "BrowseRefsDlg.h"
9 CString m_initialRefName
;
14 CHistoryCombo m_ChooseVersioinBranch
;
15 CHistoryCombo m_ChooseVersioinTags
;
16 CHistoryCombo m_ChooseVersioinVersion
;
18 //Notification when version changed. Can be implemented in derived classes.
19 virtual void OnVersionChanged(){}
21 afx_msg
void OnBnClickedChooseRadio()
23 this->m_ChooseVersioinTags
.EnableWindow(FALSE
);
24 this->m_ChooseVersioinBranch
.EnableWindow(FALSE
);
25 this->m_ChooseVersioinVersion
.EnableWindow(FALSE
);
26 int radio
=m_pWin
->GetCheckedRadioButton(IDC_RADIO_HEAD
,IDC_RADIO_VERSION
);
31 case IDC_RADIO_BRANCH
:
32 this->m_ChooseVersioinBranch
.EnableWindow(TRUE
);
35 this->m_ChooseVersioinTags
.EnableWindow(TRUE
);
37 case IDC_RADIO_VERSION
:
38 this->m_ChooseVersioinVersion
.EnableWindow(TRUE
);
41 // enable version browse button if Version is selected
42 m_pWin
->GetDlgItem(IDC_BUTTON_SHOW
)->EnableWindow(radio
== IDC_RADIO_VERSION
);
46 void OnBnClickedChooseVersion()
48 // use the git log to allow selection of a version
50 // tell the dialog to use mode for selecting revisions
52 // only one revision must be selected however
53 dlg
.SingleSelection(true);
54 if ( dlg
.DoModal() == IDOK
)
56 // get selected hash if any
57 CString selectedHash
= dlg
.GetSelectedHash();
58 // load into window, do this even if empty so that it is clear that nothing has been selected
59 m_ChooseVersioinVersion
.SetWindowText( selectedHash
);
64 void UpdateRevsionName()
66 int radio
=m_pWin
->GetCheckedRadioButton(IDC_RADIO_HEAD
,IDC_RADIO_VERSION
);
70 this->m_VersionName
=_T("HEAD");
72 case IDC_RADIO_BRANCH
:
73 this->m_VersionName
=m_ChooseVersioinBranch
.GetString();
76 this->m_VersionName
=m_ChooseVersioinTags
.GetString();
78 case IDC_RADIO_VERSION
:
79 this->m_VersionName
=m_ChooseVersioinVersion
.GetString();
83 void SetDefaultChoose(int id
)
85 m_pWin
->CheckRadioButton(IDC_RADIO_HEAD
,IDC_RADIO_VERSION
,id
);
86 OnBnClickedChooseRadio();
89 void OnBnClickedButtonBrowseRef()
93 CString resultRef
= CBrowseRefsDlg::PickRef(false, m_VersionName
, gPickRef_All
);
94 if(resultRef
.IsEmpty())
96 SelectRef(resultRef
, false);
99 void SelectRef(CString refName
, bool bRefNameIsPossiblyNotFullName
= true)
101 if(bRefNameIsPossiblyNotFullName
)
103 //Make sure refName is a full ref name first
104 CString fullRefName
= g_Git
.GetFullRefName(refName
);
105 if(!fullRefName
.IsEmpty())
106 refName
= fullRefName
;
109 if(wcsncmp(refName
,L
"refs/",5)==0)
110 refName
= refName
.Mid(5);
111 if(wcsncmp(refName
,L
"heads/",6)==0)
113 refName
= refName
.Mid(6);
114 SetDefaultChoose(IDC_RADIO_BRANCH
);
115 m_ChooseVersioinBranch
.SetCurSel(
116 m_ChooseVersioinBranch
.FindStringExact(-1, refName
));
118 else if(wcsncmp(refName
,L
"remotes/",8)==0)
120 SetDefaultChoose(IDC_RADIO_BRANCH
);
121 m_ChooseVersioinBranch
.SetCurSel(
122 m_ChooseVersioinBranch
.FindStringExact(-1, refName
));
124 else if(wcsncmp(refName
,L
"tags/",5)==0)
126 refName
= refName
.Mid(5);
127 SetDefaultChoose(IDC_RADIO_TAGS
);
128 m_ChooseVersioinTags
.SetCurSel(
129 m_ChooseVersioinTags
.FindStringExact(-1, refName
));
132 SetDefaultChoose(IDC_RADIO_VERSION
);
133 m_ChooseVersioinVersion
.AddString(refName
);
141 m_ChooseVersioinBranch
.SetMaxHistoryItems(0x7FFFFFFF);
142 m_ChooseVersioinTags
.SetMaxHistoryItems(0x7FFFFFFF);
145 g_Git
.GetTagList(list
);
146 m_ChooseVersioinTags
.AddString(list
);
150 g_Git
.GetBranchList(list
,¤t
,CGit::BRANCH_ALL
);
151 m_ChooseVersioinBranch
.AddString(list
);
152 m_ChooseVersioinBranch
.SetCurSel(current
);
155 if(m_initialRefName
.IsEmpty())
158 SelectRef(m_initialRefName
);
161 CString m_VersionName
;
162 CChooseVersion(CWnd
*win
)
170 #define CHOOSE_VERSION_DDX \
171 DDX_Control(pDX, IDC_COMBOBOXEX_BRANCH, m_ChooseVersioinBranch); \
172 DDX_Control(pDX, IDC_COMBOBOXEX_TAGS, m_ChooseVersioinTags); \
173 DDX_Control(pDX, IDC_COMBOBOXEX_VERSION, m_ChooseVersioinVersion);
175 #define CHOOSE_VERSION_EVENT\
176 ON_BN_CLICKED(IDC_RADIO_HEAD, OnBnClickedChooseRadioHost)\
177 ON_BN_CLICKED(IDC_RADIO_BRANCH, OnBnClickedChooseRadioHost)\
178 ON_BN_CLICKED(IDC_RADIO_TAGS, OnBnClickedChooseRadioHost)\
179 ON_BN_CLICKED(IDC_BUTTON_SHOW, OnBnClickedShow)\
180 ON_BN_CLICKED(IDC_RADIO_VERSION, OnBnClickedChooseRadioHost)\
181 ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, OnBnClickedButtonBrowseRefHost)
183 #define CHOOSE_VERSION_ADDANCHOR \
185 AddAnchor(IDC_COMBOBOXEX_BRANCH, TOP_LEFT, TOP_RIGHT); \
186 AddAnchor(IDC_COMBOBOXEX_TAGS, TOP_LEFT, TOP_RIGHT); \
187 AddAnchor(IDC_COMBOBOXEX_VERSION, TOP_LEFT, TOP_RIGHT); \
188 AddAnchor(IDC_GROUP_BASEON, TOP_LEFT, TOP_RIGHT); \
189 AddAnchor(IDC_BUTTON_SHOW,TOP_RIGHT); \
190 AddAnchor(IDC_BUTTON_BROWSE_REF,TOP_RIGHT); \
193 #define CHOOSE_EVENT_RADIO() \
194 afx_msg void OnBnClickedChooseRadioHost(){OnBnClickedChooseRadio();}\
195 afx_msg void OnBnClickedShow(){OnBnClickedChooseVersion();}\
196 afx_msg void OnBnClickedButtonBrowseRefHost(){OnBnClickedButtonBrowseRef();}