| | 386 | class DependencyPropertyPage(object): |
|---|
| | 387 | """ |
|---|
| | 388 | An editor for tagged values associated with elements. |
|---|
| | 389 | |
|---|
| | 390 | Tagged values are stored in a ListSore: tag, value, taggedValue. taggedValue |
|---|
| | 391 | is an UML model element (hidden). |
|---|
| | 392 | """ |
|---|
| | 393 | |
|---|
| | 394 | interface.implements(IPropertyPage) |
|---|
| | 395 | component.adapts(items.DependencyItem) |
|---|
| | 396 | |
|---|
| | 397 | dependency_types = ( |
|---|
| | 398 | (_('Dependency'), UML.Dependency), |
|---|
| | 399 | (_('Usage'), UML.Usage), |
|---|
| | 400 | (_('Realization'), UML.Realization)) |
|---|
| | 401 | |
|---|
| | 402 | def __init__(self, context): |
|---|
| | 403 | super(DependencyPropertyPage, self).__init__() |
|---|
| | 404 | self.context = context |
|---|
| | 405 | self.size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) |
|---|
| | 406 | |
|---|
| | 407 | def construct(self): |
|---|
| | 408 | page = gtk.VBox() |
|---|
| | 409 | |
|---|
| | 410 | hbox = gtk.HBox() |
|---|
| | 411 | label = gtk.Label(_('Dependency type')) |
|---|
| | 412 | label.set_justify(gtk.JUSTIFY_LEFT) |
|---|
| | 413 | self.size_group.add_widget(label) |
|---|
| | 414 | hbox.pack_start(label, expand=False) |
|---|
| | 415 | |
|---|
| | 416 | dependency_type = gtk.ListStore(str) |
|---|
| | 417 | |
|---|
| | 418 | for t, l in self.dependency_types: |
|---|
| | 419 | dependency_type.append([t]) |
|---|
| | 420 | |
|---|
| | 421 | self.dependency_type = dependency_type |
|---|
| | 422 | |
|---|
| | 423 | combo = gtk.ComboBox(dependency_type) |
|---|
| | 424 | cell = gtk.CellRendererText() |
|---|
| | 425 | combo.pack_start(cell, True) |
|---|
| | 426 | combo.add_attribute(cell, 'text', 0) |
|---|
| | 427 | combo.connect('changed', self._on_dependency_type_change) |
|---|
| | 428 | self.combo = combo |
|---|
| | 429 | |
|---|
| | 430 | hbox.pack_start(combo, expand=False) |
|---|
| | 431 | |
|---|
| | 432 | page.pack_start(hbox, expand=False) |
|---|
| | 433 | |
|---|
| | 434 | hbox = gtk.HBox() |
|---|
| | 435 | |
|---|
| | 436 | label = gtk.Label(_('Automatic')) |
|---|
| | 437 | label.set_justify(gtk.JUSTIFY_LEFT) |
|---|
| | 438 | self.size_group.add_widget(label) |
|---|
| | 439 | hbox.pack_start(label, expand=False) |
|---|
| | 440 | |
|---|
| | 441 | button = gtk.CheckButton() |
|---|
| | 442 | button.set_active(self.context.auto_dependency) |
|---|
| | 443 | button.connect('toggled', self._on_auto_dependency_change) |
|---|
| | 444 | hbox.pack_start(button) |
|---|
| | 445 | |
|---|
| | 446 | page.pack_start(hbox, expand=False) |
|---|
| | 447 | |
|---|
| | 448 | page.show_all() |
|---|
| | 449 | |
|---|
| | 450 | self.update() |
|---|
| | 451 | |
|---|
| | 452 | return page |
|---|
| | 453 | |
|---|
| | 454 | def update(self): |
|---|
| | 455 | for index, (_, dep_type) in enumerate(self.dependency_types): |
|---|
| | 456 | if dep_type is self.context.dependency_type: |
|---|
| | 457 | self.combo.set_active(index) |
|---|
| | 458 | break |
|---|
| | 459 | |
|---|
| | 460 | def _on_dependency_type_change(self, combo): |
|---|
| | 461 | self.context.dependency_type = self.dependency_types[combo.get_active()][1] |
|---|
| | 462 | |
|---|
| | 463 | def _on_auto_dependency_change(self, button): |
|---|
| | 464 | self.context.auto_dependency = button.get_active() |
|---|
| | 465 | |
|---|
| | 466 | |
|---|
| | 467 | component.provideAdapter(DependencyPropertyPage, name='Properties') |
|---|
| | 468 | |
|---|
| | 469 | |
|---|
| | 470 | class AssociationPropertyPage(NamedItemPropertyPage): |
|---|
| | 471 | """ |
|---|
| | 472 | """ |
|---|
| | 473 | |
|---|
| | 474 | interface.implements(IPropertyPage) |
|---|
| | 475 | component.adapts(items.AssociationItem) |
|---|
| | 476 | |
|---|
| | 477 | def __init__(self, context): |
|---|
| | 478 | super(AssociationPropertyPage, self).__init__() |
|---|
| | 479 | self.context = context |
|---|
| | 480 | self.size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) |
|---|
| | 481 | |
|---|
| | 482 | def construct(self): |
|---|
| | 483 | page = super(AssociationPropertyPage, self).construct() |
|---|
| | 484 | return page |
|---|
| | 485 | |
|---|
| | 486 | hbox = gtk.HBox() |
|---|
| | 487 | label = gtk.Label(_('Dependency type')) |
|---|
| | 488 | label.set_justify(gtk.JUSTIFY_LEFT) |
|---|
| | 489 | self.size_group.add_widget(label) |
|---|
| | 490 | hbox.pack_start(label, expand=False) |
|---|
| | 491 | |
|---|
| | 492 | dependency_type = gtk.ListStore(str) |
|---|
| | 493 | |
|---|
| | 494 | for t, l in self.dependency_types: |
|---|
| | 495 | dependency_type.append([t]) |
|---|
| | 496 | |
|---|
| | 497 | self.dependency_type = dependency_type |
|---|
| | 498 | |
|---|
| | 499 | combo = gtk.ComboBox(dependency_type) |
|---|
| | 500 | cell = gtk.CellRendererText() |
|---|
| | 501 | combo.pack_start(cell, True) |
|---|
| | 502 | combo.add_attribute(cell, 'text', 0) |
|---|
| | 503 | combo.connect('changed', self._on_dependency_type_change) |
|---|
| | 504 | self.combo = combo |
|---|
| | 505 | |
|---|
| | 506 | hbox.pack_start(combo, expand=False) |
|---|
| | 507 | |
|---|
| | 508 | page.pack_start(hbox, expand=False) |
|---|
| | 509 | |
|---|
| | 510 | hbox = gtk.HBox() |
|---|
| | 511 | |
|---|
| | 512 | label = gtk.Label(_('Automatic')) |
|---|
| | 513 | label.set_justify(gtk.JUSTIFY_LEFT) |
|---|
| | 514 | self.size_group.add_widget(label) |
|---|
| | 515 | hbox.pack_start(label, expand=False) |
|---|
| | 516 | |
|---|
| | 517 | button = gtk.CheckButton() |
|---|
| | 518 | button.set_active(self.context.auto_dependency) |
|---|
| | 519 | button.connect('toggled', self._on_auto_dependency_change) |
|---|
| | 520 | hbox.pack_start(button) |
|---|
| | 521 | |
|---|
| | 522 | page.pack_start(hbox, expand=False) |
|---|
| | 523 | |
|---|
| | 524 | page.show_all() |
|---|
| | 525 | |
|---|
| | 526 | self.update() |
|---|
| | 527 | |
|---|
| | 528 | return page |
|---|
| | 529 | |
|---|
| | 530 | def update(self): |
|---|
| | 531 | for index, (_, dep_type) in enumerate(self.dependency_types): |
|---|
| | 532 | if dep_type is self.context.dependency_type: |
|---|
| | 533 | self.combo.set_active(index) |
|---|
| | 534 | break |
|---|
| | 535 | |
|---|
| | 536 | def _on_dependency_type_change(self, combo): |
|---|
| | 537 | self.context.dependency_type = self.dependency_types[combo.get_active()][1] |
|---|
| | 538 | |
|---|
| | 539 | def _on_auto_dependency_change(self, button): |
|---|
| | 540 | self.context.auto_dependency = button.get_active() |
|---|
| | 541 | |
|---|
| | 542 | component.provideAdapter(AssociationPropertyPage, name='Properties') |
|---|
| | 543 | |
|---|
| | 544 | |
|---|
| | 545 | class LineStylePage(object): |
|---|
| | 546 | """ |
|---|
| | 547 | Basic line style properties: color, orthogonal, etc. |
|---|
| | 548 | """ |
|---|
| | 549 | |
|---|
| | 550 | interface.implements(IPropertyPage) |
|---|
| | 551 | component.adapts(gaphas.item.Line) |
|---|
| | 552 | |
|---|
| | 553 | def __init__(self, context): |
|---|
| | 554 | super(LineStylePage, self).__init__() |
|---|
| | 555 | self.context = context |
|---|
| | 556 | self.size_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) |
|---|
| | 557 | |
|---|
| | 558 | def construct(self): |
|---|
| | 559 | page = gtk.VBox() |
|---|
| | 560 | |
|---|
| | 561 | hbox = gtk.HBox() |
|---|
| | 562 | label = gtk.Label(_('Orthogonal')) |
|---|
| | 563 | label.set_justify(gtk.JUSTIFY_LEFT) |
|---|
| | 564 | self.size_group.add_widget(label) |
|---|
| | 565 | hbox.pack_start(label, expand=False) |
|---|
| | 566 | |
|---|
| | 567 | button = gtk.CheckButton() |
|---|
| | 568 | button.set_active(self.context.orthogonal) |
|---|
| | 569 | button.connect('toggled', self._on_orthogonal_change) |
|---|
| | 570 | hbox.pack_start(button) |
|---|
| | 571 | |
|---|
| | 572 | page.pack_start(hbox, expand=False) |
|---|
| | 573 | |
|---|
| | 574 | hbox = gtk.HBox() |
|---|
| | 575 | label = gtk.Label(_('horizontal')) |
|---|
| | 576 | label.set_justify(gtk.JUSTIFY_LEFT) |
|---|
| | 577 | self.size_group.add_widget(label) |
|---|
| | 578 | hbox.pack_start(label, expand=False) |
|---|
| | 579 | |
|---|
| | 580 | button = gtk.CheckButton() |
|---|
| | 581 | button.set_active(self.context.horizontal) |
|---|
| | 582 | button.connect('toggled', self._on_horizontal_change) |
|---|
| | 583 | hbox.pack_start(button) |
|---|
| | 584 | |
|---|
| | 585 | page.pack_start(hbox, expand=False) |
|---|
| | 586 | |
|---|
| | 587 | page.show_all() |
|---|
| | 588 | |
|---|
| | 589 | return page |
|---|
| | 590 | |
|---|
| | 591 | def _on_orthogonal_change(self, button): |
|---|
| | 592 | self.context.orthogonal = button.get_active() |
|---|
| | 593 | |
|---|
| | 594 | def _on_horizontal_change(self, button): |
|---|
| | 595 | self.context.horizontal = button.get_active() |
|---|
| | 596 | |
|---|
| | 597 | component.provideAdapter(LineStylePage, name='Style') |
|---|
| | 598 | |
|---|
| | 599 | |
|---|