def flush(self): """Flush all elements (remove them from the factory). This method will emit a single FlushFactoryEvent, all individual events are suppressed.""" self._handle(FlushFactoryEvent(self)) with self.block_events(): super(ElementFactoryService, self).flush()
def flush(self): """Flush all elements (remove them from the factory). Diagram elements are flushed first. This is so that canvas updates are blocked. The remaining elements are then flushed. """ self.handle(FlushFactoryEvent(self)) with self.block_events(): for element in self.lselect(lambda e: isinstance(e, Diagram)): element.canvas.block_updates = True element.unlink() for element in self.lselect(): element.unlink()
def flush(self): """Flush all elements (remove them from the factory). First test if the element factory has a Gaphor application instance. If yes, the application will handle a FlushFactoryEvent and will register a ElementChangedEventBlocker adapter. Diagram elements are flushed first. This is so that canvas updates are blocked. The remaining elements are then flushed. Finally, the ElementChangedEventBlocker adapter is unregistered if the factory has an application instance.""" self.component_registry.handle(FlushFactoryEvent(self)) self.component_registry.register_subscription_adapter(ElementChangedEventBlocker) try: super(ElementFactoryService, self).flush() finally: self.component_registry.unregister_subscription_adapter(ElementChangedEventBlocker)