def save_dialog(self, diagram, title, ext): filename = (diagram.name or "export") + ext file_dialog = FileDialog(title, action="save", filename=filename) save = False while True: filename = file_dialog.selection if os.path.exists(filename): question = (_("The file %s already exists. Do you want to " "replace it with the file you are exporting " "to?") % filename) question_dialog = QuestionDialog(question) answer = question_dialog.answer question_dialog.destroy() if answer: save = True break else: save = True break file_dialog.destroy() if save and filename: return filename
def save_dialog(self, diagram, title, ext): filename = (diagram.name or "export") + ext file_dialog = FileDialog(title, action="save", filename=filename) save = False while True: filename = file_dialog.selection if os.path.exists(filename): question = ( _( "The file %s already exists. Do you want to " "replace it with the file you are exporting " "to?" ) % filename ) question_dialog = QuestionDialog(question) answer = question_dialog.answer question_dialog.destroy() if answer: save = True break else: save = True break file_dialog.destroy() if save and filename: return filename
def action_new(self): """The new model menu action. This action will create a new UML model. This will trigger a FileManagerStateChange event.""" element_factory = self.element_factory main_window = self.main_window if element_factory.size(): dialog = QuestionDialog(_("Opening a new model will flush the"\ " currently loaded model.\nAny changes"\ " made will not be saved. Do you want to"\ " continue?"),\ parent=main_window.window) answer = dialog.answer dialog.destroy() if not answer: return element_factory.flush() model = element_factory.create(uml2.Package) model.name = _('New model') diagram = element_factory.create(uml2.Diagram) diagram.package = model diagram.name= _('main') self.filename = None element_factory.notify_model() #main_window.select_element(diagram) #main_window.show_diagram(diagram) self.component_registry.handle(FileManagerStateChanged(self))
def verify_orphans(self): """Verify that no orphaned elements are saved. This method checks of there are any orphan references in the element factory. If orphans are found, a dialog is displayed asking the user if it is OK to unlink them.""" orphans = verify.orphan_references(self.element_factory) if orphans: main_window = self.main_window dialog = QuestionDialog( _( "The model contains some references" " to items that are not maintained." " Do you want to clean this before" " saving the model?" ), parent=main_window.window, ) answer = dialog.answer dialog.destroy() if not answer: for orphan in orphans: orphan.unlink()
def verify_orphans(self): """Verify that no orphaned elements are saved. This method checks of there are any orphan references in the element factory. If orphans are found, a dialog is displayed asking the user if it is OK to unlink them.""" orphans = verify.orphan_references(self.element_factory) if orphans: main_window = self.main_window dialog = QuestionDialog( _("The model contains some references" " to items that are not maintained." " Do you want to clean this before" " saving the model?"), parent=main_window.window, ) answer = dialog.answer dialog.destroy() if not answer: for orphan in orphans: orphan.unlink()
def save_dialog(self, diagram, title, ext): filename = (diagram.name or "export") + ext file_dialog = FileDialog(title, action="save", filename=filename) save = False while True: filename = file_dialog.selection if os.path.exists(filename): question = gettext( "The file {filename} already exists. Do you want to replace it?" ).format(filename=filename) question_dialog = QuestionDialog(question) answer = question_dialog.answer question_dialog.destroy() if answer: save = True break else: save = True break file_dialog.destroy() if save and filename: return filename
def action_new(self): """The new model menu action. This action will create a new UML model. This will trigger a FileManagerStateChange event.""" element_factory = self.element_factory main_window = self.main_window if element_factory.size(): dialog = QuestionDialog( gettext("Opening a new model will flush the" " currently loaded model.\nAny changes" " made will not be saved. Do you want to" " continue?"), parent=main_window.window, ) answer = dialog.answer dialog.destroy() if not answer: return element_factory.flush() with element_factory.block_events(): model = element_factory.create(UML.Package) model.name = gettext("New model") diagram = element_factory.create(UML.Diagram) diagram.package = model diagram.name = gettext("main") self.filename = None element_factory.model_ready()
def action_new(self): """The new model menu action. This action will create a new UML model. This will trigger a FileManagerStateChange event.""" element_factory = self.element_factory main_window = self.main_window if element_factory.size(): dialog = QuestionDialog(_("Opening a new model will flush the"\ " currently loaded model.\nAny changes"\ " made will not be saved. Do you want to"\ " continue?"),\ parent=main_window.window) answer = dialog.answer dialog.destroy() if not answer: return element_factory.flush() model = element_factory.create(UML.Package) model.name = _('New model') diagram = element_factory.create(UML.Diagram) diagram.package = model diagram.name= _('main') self.filename = None element_factory.notify_model() #main_window.select_element(diagram) #main_window.show_diagram(diagram) self.component_registry.handle(FileManagerStateChanged(self))