def map_element(self, obj, name, event):
canvas = self.diagram.diagram_canvas<EOL>parser = XDotParser()<EOL>for element in event.added:<EOL><INDENT>logger.debug("<STR_LIT>" % element)<EOL>for node_mapping in self.nodes:<EOL><INDENT>ct = name[:-<NUM_LIT:6>] <EOL>if node_mapping.containment_trait == ct:<EOL><INDENT>dot_attrs = node_mapping.dot_node<EOL>dot = Dot()<EOL>graph_node = Node(str(id(element)))<EOL>self._style_node(graph_node, dot_attrs)<EOL>dot.add_node(graph_node)<EOL>xdot = graph_from_dot_data(dot.create(self.program,"<STR_LIT>"))<EOL>diagram_nodes = parser.parse_nodes(xdot)<EOL>for dn in diagram_nodes:<EOL><INDENT>if dn is not None:<EOL><INDENT>dn.element = element<EOL>for tool in node_mapping.tools:<EOL><INDENT>dn.tools.append(tool(dn))<EOL><DEDENT>canvas.add(dn)<EOL>canvas.request_redraw()<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>for element in event.removed:<EOL><INDENT>logger.debug("<STR_LIT>" % element)<EOL>for component in canvas.components:<EOL><INDENT>if element == component.element:<EOL><INDENT>canvas.remove(component)<EOL>canvas.request_redraw()<EOL>break<EOL><DEDENT><DEDENT><DEDENT>
Handles mapping elements to diagram components