@@ -163,12 +163,7 @@ private void OnButtonBarGUI()
163
163
{
164
164
if ( GUILayout . Button ( DeleteBranchButton , EditorStyles . miniButton , GUILayout . ExpandWidth ( false ) ) )
165
165
{
166
- var selectedBranchName = treeLocals . SelectedNode . Name ;
167
- var dialogMessage = string . Format ( DeleteBranchMessageFormatString , selectedBranchName ) ;
168
- if ( EditorUtility . DisplayDialog ( DeleteBranchTitle , dialogMessage , DeleteBranchButton , CancelButtonLabel ) )
169
- {
170
- GitClient . DeleteBranch ( selectedBranchName , true ) . Start ( ) ;
171
- }
166
+ DeleteLocalBranch ( treeLocals . SelectedNode . Name ) ;
172
167
}
173
168
}
174
169
EditorGUI . EndDisabledGroup ( ) ;
@@ -284,29 +279,11 @@ private void OnTreeGUI(Rect rect)
284
279
285
280
rect = treeLocals . Render ( rect , scroll ,
286
281
node => { } ,
287
- node =>
288
- {
289
- if ( EditorUtility . DisplayDialog ( ConfirmSwitchTitle , String . Format ( ConfirmSwitchMessage , node . Name ) , ConfirmSwitchOK ,
290
- ConfirmSwitchCancel ) )
291
- {
292
- GitClient . SwitchBranch ( node . Name )
293
- . FinallyInUI ( ( success , e ) =>
294
- {
295
- if ( success )
296
- {
297
- Redraw ( ) ;
298
- }
299
- else
300
- {
301
- EditorUtility . DisplayDialog ( Localization . SwitchBranchTitle ,
302
- String . Format ( Localization . SwitchBranchFailedDescription , node . Name ) ,
303
- Localization . Ok ) ;
304
- }
305
- } ) . Start ( ) ;
306
- }
282
+ node => {
283
+ SwitchBranch ( node . Name ) ;
307
284
} ,
308
285
node => {
309
- GenericMenu menu = CreateContextMenuForLocalBranchNode ( node ) ;
286
+ var menu = CreateContextMenuForLocalBranchNode ( node ) ;
310
287
menu . ShowAsContext ( ) ;
311
288
} ) ;
312
289
@@ -399,18 +376,46 @@ private GenericMenu CreateContextMenuForLocalBranchNode(TreeNode node)
399
376
}
400
377
else
401
378
{
402
- genericMenu . AddItem ( deleteGuiContent , false , ( userData ) => {
403
- Debug . Log ( "Delete Branch" ) ;
404
- } , node ) ;
379
+ genericMenu . AddItem ( deleteGuiContent , false , ( ) => {
380
+ DeleteLocalBranch ( node . Name ) ;
381
+ } ) ;
405
382
406
- genericMenu . AddItem ( switchGuiContent , false , ( userData ) => {
407
- Debug . Log ( "Switch Branch" ) ;
408
- } , node ) ;
383
+ genericMenu . AddItem ( switchGuiContent , false , ( ) => {
384
+ SwitchBranch ( node . Name ) ;
385
+ } ) ;
409
386
}
410
387
411
388
return genericMenu ;
412
389
}
413
390
391
+ private void SwitchBranch ( string branchName )
392
+ {
393
+ if ( EditorUtility . DisplayDialog ( ConfirmSwitchTitle , String . Format ( ConfirmSwitchMessage , branchName ) , ConfirmSwitchOK ,
394
+ ConfirmSwitchCancel ) )
395
+ {
396
+ GitClient . SwitchBranch ( branchName ) . FinallyInUI ( ( success , e ) => {
397
+ if ( success )
398
+ {
399
+ Redraw ( ) ;
400
+ }
401
+ else
402
+ {
403
+ EditorUtility . DisplayDialog ( Localization . SwitchBranchTitle ,
404
+ String . Format ( Localization . SwitchBranchFailedDescription , branchName ) , Localization . Ok ) ;
405
+ }
406
+ } ) . Start ( ) ;
407
+ }
408
+ }
409
+
410
+ private void DeleteLocalBranch ( string branchName )
411
+ {
412
+ var dialogMessage = string . Format ( DeleteBranchMessageFormatString , branchName ) ;
413
+ if ( EditorUtility . DisplayDialog ( DeleteBranchTitle , dialogMessage , DeleteBranchButton , CancelButtonLabel ) )
414
+ {
415
+ GitClient . DeleteBranch ( branchName , true ) . Start ( ) ;
416
+ }
417
+ }
418
+
414
419
private GenericMenu CreateContextMenuForRemoteBranchNode ( TreeNode node )
415
420
{
416
421
var genericMenu = new GenericMenu ( ) ;
0 commit comments