| 1 |
""" |
|---|
| 2 |
This module describes the interfaces specific to the gaphor.diagram module. |
|---|
| 3 |
These interfaces are: |
|---|
| 4 |
|
|---|
| 5 |
- IConnect |
|---|
| 6 |
Use to define adapters for connecting |
|---|
| 7 |
- IEditor |
|---|
| 8 |
Text editor interface |
|---|
| 9 |
|
|---|
| 10 |
""" |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
from zope import interface |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
class IEditor(interface.Interface): |
|---|
| 17 |
""" |
|---|
| 18 |
Provide an interface for editing text with the TextEditTool. |
|---|
| 19 |
""" |
|---|
| 20 |
|
|---|
| 21 |
def is_editable(self, x, y): |
|---|
| 22 |
""" |
|---|
| 23 |
Is this item editable in it's current state. |
|---|
| 24 |
x, y represent the cursors (x, y) position. |
|---|
| 25 |
(this method should be called before get_text() is called. |
|---|
| 26 |
""" |
|---|
| 27 |
|
|---|
| 28 |
def get_text(self): |
|---|
| 29 |
""" |
|---|
| 30 |
Get the text to be updated |
|---|
| 31 |
""" |
|---|
| 32 |
|
|---|
| 33 |
def get_bounds(self): |
|---|
| 34 |
""" |
|---|
| 35 |
Get the bounding box of the (current) text. The edit tool is not |
|---|
| 36 |
required to do anything with this information but it might help for |
|---|
| 37 |
some nicer displaying of the text widget. |
|---|
| 38 |
|
|---|
| 39 |
Returns: a gaphas.geometry.Rectangle |
|---|
| 40 |
""" |
|---|
| 41 |
|
|---|
| 42 |
def update_text(self, text): |
|---|
| 43 |
""" |
|---|
| 44 |
Update with the new text. |
|---|
| 45 |
""" |
|---|
| 46 |
|
|---|
| 47 |
def key_pressed(self, pos, key): |
|---|
| 48 |
""" |
|---|
| 49 |
Called every time a key is pressed. Allows for 'Enter' as escape |
|---|
| 50 |
character in single line editing. |
|---|
| 51 |
""" |
|---|
| 52 |
|
|---|
| 53 |
class IConnect(interface.Interface): |
|---|
| 54 |
""" |
|---|
| 55 |
This interface is used by the HandleTool to allow connecting |
|---|
| 56 |
lines to element items. For each specific case (Element, Line) an |
|---|
| 57 |
adapter could be written. |
|---|
| 58 |
""" |
|---|
| 59 |
|
|---|
| 60 |
def connect(self, handle): |
|---|
| 61 |
""" |
|---|
| 62 |
Connect a line's handle to element. |
|---|
| 63 |
|
|---|
| 64 |
Note that at the moment of the connect, handle.connected_to may point |
|---|
| 65 |
to some other item. The implementor should do the disconnect of |
|---|
| 66 |
the other element themselves. |
|---|
| 67 |
""" |
|---|
| 68 |
|
|---|
| 69 |
def disconnect(self, handle): |
|---|
| 70 |
""" |
|---|
| 71 |
The true disconnect. Disconnect a handle.connected_to from an |
|---|
| 72 |
element. This requires that the relationship is also removed at |
|---|
| 73 |
model level. |
|---|
| 74 |
""" |
|---|
| 75 |
|
|---|
| 76 |
def connect_constraints(self, handle): |
|---|
| 77 |
""" |
|---|
| 78 |
Connect a handle to the element. |
|---|
| 79 |
""" |
|---|
| 80 |
|
|---|
| 81 |
def disconnect_constraints(self, handle): |
|---|
| 82 |
""" |
|---|
| 83 |
Disconnect a line's handle from an element. |
|---|
| 84 |
This is called whenever a handle is dragged. |
|---|
| 85 |
""" |
|---|
| 86 |
|
|---|
| 87 |
def glue(self, handle): |
|---|
| 88 |
""" |
|---|
| 89 |
Determine if a handle can glue to a specific element. |
|---|
| 90 |
|
|---|
| 91 |
Returns a tuple (x, y) if the line and element may connect, None |
|---|
| 92 |
otherwise. |
|---|
| 93 |
""" |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
class IGroup(interface.Interface): |
|---|
| 97 |
""" |
|---|
| 98 |
Provide interface for adding one UML object to another, i.e. |
|---|
| 99 |
interactions contain lifelines and components contain classes objects. |
|---|
| 100 |
""" |
|---|
| 101 |
|
|---|
| 102 |
def pre_can_contain(self): |
|---|
| 103 |
""" |
|---|
| 104 |
Determine if parent can contain item, which is instance of given |
|---|
| 105 |
class. Method called before item creation. |
|---|
| 106 |
""" |
|---|
| 107 |
|
|---|
| 108 |
def can_contain(self): |
|---|
| 109 |
""" |
|---|
| 110 |
Determine if parent can contain item. |
|---|
| 111 |
""" |
|---|
| 112 |
|
|---|
| 113 |
def group(self): |
|---|
| 114 |
""" |
|---|
| 115 |
Perform grouping of items. |
|---|
| 116 |
""" |
|---|
| 117 |
|
|---|
| 118 |
def ungroup(self): |
|---|
| 119 |
""" |
|---|
| 120 |
Perform ungrouping of items. |
|---|
| 121 |
""" |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|