Changeset 1079
- Timestamp:
- 11/21/06 02:21:08 (2 years ago)
- Files:
-
- gaphor/branches/new-canvas/gaphor/actions/mainactions.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/adapters/connectors.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/diagram/diagramline.py (modified) (1 diff)
- gaphor/branches/new-canvas/gaphor/parser.py (modified) (2 diffs)
- gaphor/branches/new-canvas/gaphor/tests/test_storage.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/branches/new-canvas/gaphor/actions/mainactions.py
r1006 r1079 92 92 gc.collect() 93 93 model = factory.create(UML.Package) 94 model.name = 'New model'94 model.name = _('New model') 95 95 diagram = factory.create(UML.Diagram) 96 96 diagram.package = model gaphor/branches/new-canvas/gaphor/adapters/connectors.py
r1028 r1079 107 107 """Connect a comment line to a comment item. 108 108 Connect Comment.annotatedElement to any element 109 110 TODO: adapt both ElementItem and DiagramLine 111 use component.provideAdapter? 109 112 """ 110 113 component.adapts(items.ElementItem, items.CommentLineItem) 114 component.adapts(items.DiagramLine, items.CommentLineItem) 111 115 112 116 def glue(self, handle, x, y): gaphor/branches/new-canvas/gaphor/diagram/diagramitem.py
r1074 r1079 79 79 def load(self, name, value): 80 80 if name == 'subject': 81 print self, 'loading subject', value82 81 type(self).subject.load(self, value) 83 print self, 'subject =', self.subject 84 else: 85 log.debug('Setting unknown property "%s" -> "%s"' % (name, value)) 82 else: 83 #log.debug('Setting unknown property "%s" -> "%s"' % (name, value)) 86 84 try: 87 85 setattr(self, name.replace('-', '_'), eval(value)) gaphor/branches/new-canvas/gaphor/diagram/diagramline.py
r1078 r1079 116 116 if hasattr(self, '_load_head_connection'): 117 117 adapter = component.queryMultiAdapter((self._load_head_connection, self), IConnect) 118 #self._load_head_connection.connect_handle(self.handles[0])119 h = self.h andles()[0]118 assert adapter, 'No IConnect adapter to connect %s to %s' % (self._load_head_connection, self) 119 h = self.head 120 120 121 121 x, y = self.canvas.get_matrix_i2w(self, calculate=True).transform_point(h.x, h.y) 122 122 x, y = self.canvas.get_matrix_w2i(self._load_head_connection, calculate=True).transform_point(x, y) 123 adapter.connect( self.handles()[0], x, y)123 adapter.connect(h, x, y) 124 124 del self._load_head_connection 125 125 if hasattr(self, '_load_tail_connection'): 126 #self._load_tail_connection.connect_handle(self.handles[-1])127 126 adapter = component.queryMultiAdapter((self._load_tail_connection, self), IConnect) 128 h = self.handles()[0] 127 assert adapter, 'No IConnect adapter to connect %s to %s' % (self._load_tail_connection, self) 128 h = self.tail 129 129 130 130 x, y = self.canvas.get_matrix_i2w(self, calculate=True).transform_point(h.x, h.y) 131 131 x, y = self.canvas.get_matrix_w2i(self._load_tail_connection, calculate=True).transform_point(x, y) 132 adapter.connect( self.handles()[0], x, y)132 adapter.connect(h, x, y) 133 133 del self._load_tail_connection 134 134 LineItem.postload(self) gaphor/branches/new-canvas/gaphor/parser.py
r1066 r1079 179 179 e = element(id, name) 180 180 assert id not in self.elements.keys(), '%s already defined' % (id)#, self.elements[id]) 181 print 'Add model element %s' % id182 181 self.elements[id] = e 183 182 self.push(e, name == 'Diagram' and DIAGRAM or ELEMENT) … … 194 193 c = canvasitem(id, attrs['type']) 195 194 assert id not in self.elements.keys(), '%s already defined' % (id) #, self.elements[id]) 196 print 'Add item %s' % id197 195 self.elements[id] = c 198 196 self.peek().canvasitems.append(c) gaphor/branches/new-canvas/gaphor/tests/test_storage.py
r1077 r1079 189 189 d1 = d.canvas.select(lambda e: isinstance(e, items.ClassItem))[0] 190 190 assert d1 191 print d1, d1.subject191 #print d1, d1.subject 192 192 193 193 def test_connection(self): … … 196 196 (Should count for all line-like objects alike if this works). 197 197 """ 198 filename = '%s .gaphor' % __module__198 filename = '%s_c.gaphor' % __module__ 199 199 200 200 diagram = UML.create(UML.Diagram) … … 236 236 237 237 assert len(UML.lselect(lambda e: e.isKindOf(UML.Diagram))) == 1 238 d = UML. select(lambda e: e.isKindOf(UML.Diagram)).next()239 a ssert len(d.canvas.select(lambda i: isinstance(i, items.AssociationItem))) == 1240 a = d.canvas.select(lambda i: isinstance(i, items.AssociationItem))[0]241 print a.head.connected_to,a.tail.connected_to238 d = UML.lselect(lambda e: e.isKindOf(UML.Diagram))[0] 239 a = d.canvas.select(lambda e: isinstance(e, items.AssociationItem))[0] 240 assert a.head.connected_to 241 assert a.tail.connected_to 242 242 assert not a.head.connected_to is a.tail.connected_to 243 243
