1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
|
'''
====================================================================
Copyright (c) 2003-2009 Barry A Scott. All rights reserved.
This software is licensed as described in the file LICENSE.txt,
which you should have received as part of this distribution.
====================================================================
wb_dialogs.py
'''
import wx
import os
import pysvn
import wb_subversion_utils
id_log_message_text = wx.NewId()
id_last_log_message = wx.NewId()
class DialogBuildingBlock(wx.Dialog):
def __init__( self, parent, title ):
wx.Dialog.__init__( self, parent, -1, title )
self.title = title
self.all_filenames = []
self.add_filename_list_field = False
self.add_log_message_field = False
self.add_force_field = False
def initControls( self ):
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.h_sizer = wx.BoxSizer( wx.HORIZONTAL )
self.filename_list = None
if self.add_filename_list_field:
self.filename_list = wx.ListCtrl( self, -1, wx.DefaultPosition, wx.Size( 600, 200 ), wx.LC_REPORT|wx.NO_BORDER )
self.filename_list.InsertColumn( 0, T_("Status") )
self.filename_list.SetColumnWidth( 0, 50 )
self.filename_list.InsertColumn( 1, T_("Filename") )
self.filename_list.SetColumnWidth( 1, 1000 )
for index, _ in enumerate( self.all_filenames ):
self.filename_list.InsertStringItem( index, self.all_filenames[index][0] )
self.filename_list.SetStringItem( index, 1, self.all_filenames[index][1] )
self.log_message_ctrl = None
if self.add_log_message_field:
self.log_message_ctrl = wx.TextCtrl( self, id_log_message_text, size=wx.Size( 600, 200 ), style=wx.TE_MULTILINE )
self.log_message_ctrl.SetFocus()
self.force_checkbox_ctrl = None
if self.add_force_field:
self.force_checkbox_ctrl = wx.CheckBox( self, -1, T_("Force") )
self.force_checkbox_ctrl.SetValue( False )
self.button_ok = wx.Button( self, wx.ID_OK, T_(" OK ") )
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(" Cancel ") )
self.button_ok.SetDefault()
self.initExtraButtons()
self.h_sizer.Add( (60, 20), 1, wx.EXPAND)
self.h_sizer.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15)
self.h_sizer.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
if self.add_filename_list_field:
self.v_sizer.Add( self.filename_list, 0, wx.EXPAND|wx.ALL, 5 )
if self.add_log_message_field:
self.v_sizer.Add( self.log_message_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
if self.add_force_field:
self.v_sizer.Add( self.force_checkbox_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
def initExtraButtons( self ):
pass
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getLogMessage( self ):
return self.log_message_ctrl.GetValue()
def getForce( self ):
return self.force_checkbox_ctrl.GetValue() != 0
class ConfirmAction(DialogBuildingBlock):
def __init__( self, parent, title, all_filenames, force_field=False ):
DialogBuildingBlock.__init__( self, parent, title )
self.all_filenames = all_filenames
self.add_filename_list_field = True
self.add_force_field = force_field
self.initControls()
class LogMessage(DialogBuildingBlock):
def __init__( self, parent, title, all_filenames, message_filename=None, force_field=False ):
DialogBuildingBlock.__init__( self, parent, title )
self.all_filenames = all_filenames
self.add_filename_list_field = True
self.add_log_message_field = True
self.add_force_field = force_field
self.message_filename = message_filename
self.last_log_message_text = None
if self.message_filename is not None:
try:
self.last_log_message_text = file( self.message_filename, 'r' ).read().decode('utf-8').strip()
except EnvironmentError:
self.last_log_message_text = ''
self.initControls()
def initExtraButtons( self ):
if self.last_log_message_text is not None:
self.button_last_log_message = wx.Button( self, id_last_log_message, T_("Insert Last Message") )
self.button_last_log_message.Enable( len(self.last_log_message_text) > 0 )
self.h_sizer.Add( self.button_last_log_message )
self.button_ok.Enable( False )
wx.EVT_BUTTON( self, id_last_log_message, self.OnInsertLastLogMessage )
wx.EVT_TEXT( self, id_log_message_text, self.OnLogMessageChanged )
def OnInsertLastLogMessage( self, event ):
self.log_message_ctrl.WriteText( self.last_log_message_text )
self.button_ok.Enable( True )
def OnLogMessageChanged( self, event ):
self.button_ok.Enable( len( self.log_message_ctrl.GetValue().strip() ) > 0 )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
try:
file( self.message_filename, 'w' ).write( self.getLogMessage().encode('utf-8') )
except (IOError,OSError):
pass
class GetCredentials(wx.Dialog):
def __init__( self, parent, title, username, may_save ):
wx.Dialog.__init__( self, parent, -1, title )
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.border = wx.StaticBox( self, -1, T_('Credentials') )
self.box = wx.StaticBoxSizer( self.border, wx.VERTICAL )
self.box.Add( self.g_sizer, 0, wx.EXPAND )
self.username_label = wx.StaticText( self, -1, T_('Username:') )
self.username_ctrl = wx.TextCtrl( self, -1, username )
self.username_ctrl.SetFocus()
self.username_ctrl.SetSelection( -1, -1 )
self.g_sizer.Add( self.username_label, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( self.username_ctrl, 0, wx.EXPAND|wx.EAST, 5 )
self.password_label = wx.StaticText(self, -1, T_('Password:') )
self.password_ctrl = wx.TextCtrl(self, -1, '', style=wx.TE_PASSWORD )
self.g_sizer.Add( self.password_label, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( self.password_ctrl, 0, wx.EXPAND|wx.EAST, 5 )
self.save_ctrl = wx.CheckBox( self, -1, T_("Always uses these credentials") )
self.save_ctrl.SetValue( may_save )
self.g_sizer.Add( self.save_ctrl, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( (1, 1) )
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (250, 20), 1, wx.EXPAND)
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getUsername( self ):
return self.username_ctrl.GetValue()
def getPassword( self ):
return self.password_ctrl.GetValue()
def getSaveCredentials( self ):
return self.save_ctrl.GetValue() != 0
class GetServerTrust(wx.Dialog):
def __init__( self, parent, realm, info_list, may_save ):
wx.Dialog.__init__( self, parent, -1, T_('Trust server %s') % realm )
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.border = wx.StaticBox( self, -1, T_('Server Certificate') )
self.box = wx.StaticBoxSizer( self.border, wx.VERTICAL )
self.box.Add( self.g_sizer, 0, wx.EXPAND )
for key, value in info_list:
self.addRow( key, value )
self.save_ctrl = wx.CheckBox( self, -1, T_("Always trust this server") )
self.save_ctrl.SetValue( may_save )
self.g_sizer.Add( self.save_ctrl, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( (1, 1) )
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (250, 20), 1, wx.EXPAND)
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
def addRow( self, label, value ):
label_ctrl = wx.StaticText( self, -1, label, style=wx.ALIGN_RIGHT )
value_ctrl = wx.TextCtrl( self, -1, str(value), style=wx.TE_READONLY )
self.g_sizer.Add( label_ctrl, 1, wx.EXPAND|wx.ALL|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( value_ctrl, 0, wx.EXPAND, 5 )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getSaveTrust( self ):
return self.save_ctrl.GetValue() != 0
class AddDialog(wx.Dialog):
def __init__( self, parent, title, filename, force=False, recursive=None ):
wx.Dialog.__init__( self, parent, -1, title )
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.add_border = wx.StaticBox( self, -1, T_('Add') )
self.add_box = wx.StaticBoxSizer( self.add_border, wx.VERTICAL )
self.add_box.Add( self.g_sizer, 0, wx.EXPAND )
self.filename_text = wx.StaticText( self, -1, T_('From:') )
self.filename_ctrl = wx.StaticText( self, -1, filename )
self.g_sizer.Add( self.filename_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( self.filename_ctrl, 0, wx.EXPAND|wx.EAST, 5 )
self.force_ctrl = wx.CheckBox( self, -1, T_('Force Add') )
self.force_ctrl.SetValue( force )
self.g_sizer.Add( self.force_ctrl, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( (1, 1) )
if recursive is not None:
self.recursive_ctrl = wx.CheckBox( self, -1, T_('Recursive Add') )
self.recursive_ctrl.SetValue( recursive )
self.g_sizer.Add( self.recursive_ctrl, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( (1, 1) )
else:
self.recursive_ctrl = None
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (150, 20), 1, wx.EXPAND )
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.add_box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getForce( self ):
if self.force_ctrl is None:
return False
return self.force_ctrl.GetValue() != 0
def getRecursive( self ):
if self.recursive_ctrl is None:
return False
return self.recursive_ctrl.GetValue() != 0
class RenameFile(wx.Dialog):
def __init__( self, parent, title, old_filename, force=None ):
wx.Dialog.__init__( self, parent, -1, title )
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.rename_border = wx.StaticBox( self, -1, T_('Rename') )
self.rename_box = wx.StaticBoxSizer( self.rename_border, wx.VERTICAL )
self.rename_box.Add( self.g_sizer, 0, wx.EXPAND )
self.old_filename_text = wx.StaticText( self, -1, T_('From:') )
self.old_filename_ctrl = wx.StaticText( self, -1, old_filename )
self.g_sizer.Add( self.old_filename_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( self.old_filename_ctrl, 0, wx.EXPAND|wx.EAST, 5 )
self.new_filename_text = wx.StaticText( self, -1, T_('To:') )
self.new_filename_ctrl = wx.TextCtrl( self, -1, old_filename )
self.new_filename_ctrl.SetSelection( -1, -1 )
self.new_filename_ctrl.SetFocus()
self.g_sizer.Add( self.new_filename_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( self.new_filename_ctrl, 0, wx.EXPAND|wx.EAST, 5 )
if force is None:
self.force_ctrl = None
else:
self.force_ctrl = wx.CheckBox( self, -1, T_("Force rename") )
self.force_ctrl.SetValue( force )
self.g_sizer.Add( self.force_ctrl, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( (1, 1) )
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (150, 20), 1, wx.EXPAND )
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.rename_box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getNewFilename( self ):
return self.new_filename_ctrl.GetValue()
def getForce( self ):
if self.force_ctrl is None:
return False
return self.force_ctrl.GetValue() != 0
class GetFilename(wx.Dialog):
def __init__( self, parent, title, border_title ):
wx.Dialog.__init__( self, parent, -1, title )
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.rename_border = wx.StaticBox( self, -1, border_title )
self.rename_box = wx.StaticBoxSizer( self.rename_border, wx.VERTICAL )
self.rename_box.Add( self.g_sizer, 0, wx.EXPAND )
self.new_filename_text = wx.StaticText( self, -1, T_('Name:') )
self.new_filename_ctrl = wx.TextCtrl( self, -1, T_('New Folder') )
self.new_filename_ctrl.SetSelection( -1, -1 )
self.new_filename_ctrl.SetFocus()
self.g_sizer.Add( self.new_filename_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 3 )
self.g_sizer.Add( self.new_filename_ctrl, 0, wx.EXPAND|wx.EAST, 5 )
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (150, 20), 1, wx.EXPAND )
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.rename_box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getNewFilename( self ):
return self.new_filename_ctrl.GetValue()
class NewFile(wx.Dialog):
template_suffix = '.template'
def __init__( self, parent, template_dir ):
wx.Dialog.__init__( self, parent, -1, T_('New File') )
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.newfile_border = wx.StaticBox( self, -1, T_('New File') )
self.newfile_box = wx.StaticBoxSizer( self.newfile_border, wx.VERTICAL )
self.newfile_box.Add( self.g_sizer, 0, wx.EXPAND )
self.newfile_text = wx.StaticText( self, -1, T_('New Filename:') )
self.newfile_ctrl = wx.TextCtrl( self, -1, '' )
self.newfile_ctrl.SetFocus()
self.newfile_ctrl.SetSelection( -1, -1 )
self.g_sizer.Add( self.newfile_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 5 )
self.g_sizer.Add( self.newfile_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
try:
self.template_file_list = [filename[:-len(self.template_suffix)]
for filename in os.listdir( template_dir )
if filename.lower().endswith( self.template_suffix )]
except EnvironmentError:
self.template_file_list = []
self.template_text = wx.StaticText( self, -1, T_('Template:') )
self.template_list = wx.Choice( self, -1, choices=self.template_file_list )
self.template_list.SetSelection( 0 )
self.g_sizer.Add( self.template_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 5 )
self.g_sizer.Add( self.template_list, 0, wx.EXPAND|wx.ALL, 5 )
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (150, 20), 1, wx.EXPAND )
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.newfile_box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getNewFilename( self ):
return self.newfile_ctrl.GetValue()
def getTemplateFilename( self ):
index = self.template_list.GetCurrentSelection()
if index >= 0 and len(self.template_file_list) > index:
return self.template_file_list[ index ] + self.template_suffix
else:
return None
class UpdateTo(wx.Dialog):
def __init__( self, parent, title ):
wx.Dialog.__init__( self, parent, -1, title )
self.all_depth_types = [(pysvn.depth.empty, T_('Empty directory'))
#,(pysvn.depth.exclude, T_('Exclude (not used yet)'))
,(pysvn.depth.files, T_('Children files only'))
,(pysvn.depth.immediates, T_('Immediate children'))
,(pysvn.depth.unknown, T_('Only already checked out descendants'))
,(pysvn.depth.infinity, T_('All descendants (Full recursion)'))]
self.depth_enabled = wb_subversion_utils.version_info.has_depth
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.revision_border = wx.StaticBox( self, -1, title )
self.revision_box = wx.StaticBoxSizer( self.revision_border, wx.VERTICAL )
# Line 1: checkbox for head revision
self.head_checkbox_ctrl = wx.CheckBox( self, -1, T_("HEAD revision") )
self.head_checkbox_ctrl.SetValue( True )
self.revision_box.Add( self.head_checkbox_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
# Line 2: text entry for giving a revision no. manually
self.revision_box.Add( self.g_sizer, 0, wx.EXPAND )
self.revision_text = wx.StaticText( self, -1, T_('Revision:') )
self.revision_ctrl = wx.TextCtrl( self, -1, '' )
self.revision_ctrl.SetSelection( -1, -1 )
self.revision_ctrl.Enable( False )
self.g_sizer.Add( self.revision_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 5 )
self.g_sizer.Add( self.revision_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
if self.depth_enabled:
self.r_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.r_sizer.AddGrowableCol( 1 )
self.recursive_border = wx.StaticBox( self, -1, T_('Apply on') )
self.recursive_box = wx.StaticBoxSizer( self.recursive_border, wx.VERTICAL )
self.recursive_checkbox_ctrl = wx.CheckBox( self, -1, T_('Recursive (all)') )
self.recursive_checkbox_ctrl.SetValue( True )
self.recursive_box.Add( self.recursive_checkbox_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
self.recursive_box.Add( self.r_sizer, 0, wx.EXPAND )
self.depth_text = wx.StaticText( self, -1, T_('Depth:') )
self.depth_ctrl = wx.Choice( self, -1, choices=[name for depth, name in self.all_depth_types] )
for index, (depth, name) in enumerate( self.all_depth_types ):
if depth == pysvn.depth.unknown:
self.depth_ctrl.SetSelection( index )
self.depth_ctrl.Enable( False )
self.r_sizer.Add( self.depth_text, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 5 )
self.r_sizer.Add( self.depth_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
# Line 3: Ok/Cancel button
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (150, 20), 1, wx.EXPAND )
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.revision_box, 0, wx.EXPAND|wx.ALL, 5 )
if self.depth_enabled:
self.v_sizer.Add( self.recursive_box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
# Catch button events
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
# Catch checkbox events
wx.EVT_CHECKBOX ( self, self.head_checkbox_ctrl.GetId(), self.onHeadRevisionClicked )
if self.depth_enabled:
wx.EVT_CHECKBOX ( self, self.recursive_checkbox_ctrl.GetId(), self.recursiveClicked )
def OnOk( self, event ):
# Check revision value
if not self.head_checkbox_ctrl.GetValue():
try:
val = int( self.revision_ctrl.GetValue() )
if val < 1:
wx.MessageBox( T_('Please enter a revision number > 0!'),
style=wx.OK|wx.ICON_ERROR )
return
except ValueError:
wx.MessageBox( T_('Please enter digits only!'),
style=wx.OK|wx.ICON_ERROR )
return
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def onHeadRevisionClicked( self, event ):
self.revision_ctrl.Enable( not self.head_checkbox_ctrl.GetValue() )
def getRevision( self ):
if self.head_checkbox_ctrl.GetValue():
return pysvn.Revision( pysvn.opt_revision_kind.head )
else:
rev = int( self.revision_ctrl.GetValue() )
return pysvn.Revision( pysvn.opt_revision_kind.number, rev )
def getSvnDepth( self ):
if self.depth_enabled:
return (self.getRecursive(), self.getDepth( pysvn.depth.unknown ))
else:
return (True, None)
def recursiveClicked( self, event ):
self.depth_ctrl.Enable( not self.recursive_checkbox_ctrl.GetValue() )
def getRecursive( self ):
return self.recursive_checkbox_ctrl.GetValue()
def getDepth( self, default ):
if self.recursive_checkbox_ctrl.GetValue():
return default
else:
return self.all_depth_types[ self.depth_ctrl.GetSelection() ][0]
class CopyUrl(wx.Dialog):
def __init__( self, parent, app, title, copy_from_url, copy_to_url ):
wx.Dialog.__init__( self, parent, -1, '%s %s' % (title, copy_from_url) )
self.app = app
self.copy_to_url = copy_to_url
p = self.app.prefs.getAdvanced()
self.arbitrary_path = p.arbitrary_tag_branch
self.g_sizer = wx.FlexGridSizer( 0, 2, 0, 0 )
self.g_sizer.AddGrowableCol( 1 )
self.copyurl_border = wx.StaticBox( self, -1, title )
self.copyurl_box = wx.StaticBoxSizer( self.copyurl_border, wx.VERTICAL )
self.copyurl_box.Add( self.g_sizer, 0, wx.EXPAND )
self.copy_from_label = wx.StaticText( self, -1, T_('Copy From:') )
self.copy_from_value = wx.StaticText( self, -1, copy_from_url )
self.copy_to_label = wx.StaticText( self, -1, T_('Copy To:') )
if not self.arbitrary_path:
self.copy_to_root = wx.StaticText( self, -1, copy_to_url + '/' )
self.copy_to_leaf = wx.TextCtrl( self, -1, '', size=(300, -1) )
else:
# should place repos_root_URL as a static prefix
self.copy_to_browse = wx.StaticText( self, -1, '' )
self.copy_to_leaf = wx.TextCtrl( self, -1, copy_to_url + '/', size=(500, -1) )
self.copy_to_leaf.SetFocus()
self.h_sizer_copy_to = wx.BoxSizer( wx.HORIZONTAL )
if not self.arbitrary_path:
self.h_sizer_copy_to.Add( self.copy_to_root, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_copy_to.Add( self.copy_to_leaf, 0, wx.EXPAND|wx.EAST, 2 )
else:
self.h_sizer_copy_to.Add( self.copy_to_leaf, 1, wx.EXPAND|wx.EAST, 2 )
self.h_sizer_copy_to.Add( self.copy_to_browse, 0, wx.EXPAND|wx.EAST, 2 )
self.g_sizer.Add( self.copy_from_label, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 5 )
self.g_sizer.Add( self.copy_from_value, 0, wx.EXPAND|wx.ALL, 5 )
self.g_sizer.Add( self.copy_to_label, 1, wx.EXPAND|wx.NORTH|wx.ALIGN_RIGHT, 5 )
self.g_sizer.Add( self.h_sizer_copy_to, 0, wx.EXPAND|wx.ALL, 5 )
self.label_ctrl = wx.StaticText( self, -1, T_('Log message'), style=wx.ALIGN_LEFT )
self.log_message_ctrl = wx.TextCtrl( self, -1, style=wx.TE_MULTILINE )
self.button_ok = wx.Button( self, wx.ID_OK, T_(' OK ') )
self.button_ok.SetDefault()
self.button_ok.Enable( False )
self.button_cancel = wx.Button( self, wx.ID_CANCEL, T_(' Cancel ') )
self.h_sizer_buttons = wx.BoxSizer( wx.HORIZONTAL )
self.h_sizer_buttons.Add( (150, 20), 1, wx.EXPAND )
self.h_sizer_buttons.Add( self.button_ok, 0, wx.EXPAND|wx.EAST, 15 )
self.h_sizer_buttons.Add( self.button_cancel, 0, wx.EXPAND|wx.EAST, 2 )
self.v_sizer = wx.BoxSizer( wx.VERTICAL )
self.v_sizer.Add( self.copyurl_box, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.label_ctrl, 0, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.log_message_ctrl, 1, wx.EXPAND|wx.ALL, 5 )
self.v_sizer.Add( self.h_sizer_buttons, 0, wx.EXPAND|wx.ALL, 5 )
self.SetAutoLayout( True )
self.SetSizer( self.v_sizer )
self.v_sizer.Fit( self )
self.Layout()
self.CentreOnParent()
wx.EVT_TEXT( self, self.log_message_ctrl.GetId(), self.OnLogMessageChanged )
wx.EVT_BUTTON( self, wx.ID_OK, self.OnOk )
wx.EVT_BUTTON( self, wx.ID_CANCEL, self.OnCancel )
self.copy_to_label.SetFocus()
def OnLogMessageChanged( self, event ):
self.button_ok.Enable(
len( self.log_message_ctrl.GetValue().strip() ) > 0
and len( self.copy_to_leaf.GetValue().strip() ) > 0 )
def OnOk( self, event ):
self.EndModal( wx.ID_OK )
def OnCancel( self, event ):
self.EndModal( wx.ID_CANCEL )
def getCopyTo( self ):
if not self.arbitrary_path:
return '%s/%s' % (self.copy_to_url, self.copy_to_leaf.GetValue().strip())
else:
return self.copy_to_leaf.GetValue().strip()
def getCopyToLeaf( self ):
return self.copy_to_leaf.GetValue().strip()
def getLogMessage( self ):
return self.log_message_ctrl.GetValue()
class CreateTag(CopyUrl):
def __init__( self, parent, app, copy_from_url, copy_to_url ):
CopyUrl.__init__( self, parent, app, T_('Create Tag'), copy_from_url, copy_to_url )
class CreateBranch(CopyUrl):
def __init__( self, parent, app, copy_from_url, copy_to_url ):
CopyUrl.__init__( self, parent, app, T_('Create Branch'), copy_from_url, copy_to_url )
|