Пример #1
0
 def app_startup(app):
     try:
         Application.init()
         apply_application_actions(Application, app)
     except Exception:
         app.quit()
         raise
Пример #2
0
def launch(model=None):
    """Start the main application by initiating and running Application.
    
    The file_manager service is used here to load a Gaphor model if one was
    specified on the command line.  Otherwise, a new model is created and
    the Gaphor GUI is started."""

    # Make sure gui is loaded ASAP.
    # This prevents menu items from appearing at unwanted places.
    Application.essential_services.append('main_window')

    Application.init()

    main_window = Application.get_service('main_window')

    main_window.open()

    file_manager = Application.get_service('file_manager')

    if model:
        file_manager.load(model)
    else:
        file_manager.action_new()

    Application.run()
Пример #3
0
 def setUp(self):
     Application.init(services=[
         'file_manager', 'element_factory', 'properties', 'main_window',
         'action_manager', 'ui_manager'
     ])
     self.recent_files_backup = Application.get_service('properties').get(
         'recent-files')
Пример #4
0
 def setUp(self):
     Application.init(services=[
         "event_manager",
         "component_registry",
         "element_factory",
         "main_window",
         "action_manager",
         "properties",
         "namespace",
         "diagrams",
         "toolbox",
     ])
     main_window = Application.get_service("main_window")
     main_window.open()
     self.element_factory = Application.get_service("element_factory")
     self.diagram = self.element_factory.create(UML.Diagram)
     self.page = DiagramPage(
         self.diagram,
         Application.get_service("event_manager"),
         self.element_factory,
         Application.get_service("properties"),
     )
     self.page.construct()
     assert self.page.diagram == self.diagram
     assert self.page.view.canvas == self.diagram.canvas
     assert len(self.element_factory.lselect()) == 1
Пример #5
0
def launch(model=None):
    """Start the main application by initiating and running Application.
    
    The file_manager service is used here to load a Gaphor model if one was
    specified on the command line.  Otherwise, a new model is created and
    the Gaphor GUI is started."""

    # Make sure gui is loaded ASAP.
    # This prevents menu items from appearing at unwanted places.
    Application.essential_services.append('main_window')

    Application.init()

    main_window = Application.get_service('main_window')

    main_window.open()

    file_manager = Application.get_service('file_manager')

    if model:
        file_manager.load(model)
    else:
        file_manager.action_new()

    Application.run()
Пример #6
0
    def test_service_load(self):
        """Test loading services and querying utilities."""

        Application.init(["undo_manager", "file_manager", "properties"])

        self.assertTrue(
            Application.get_service("undo_manager") is not None,
            "Failed to load the undo manager service",
        )

        self.assertTrue(
            Application.get_service("file_manager") is not None,
            "Failed to load the file manager service",
        )

        self.assertTrue(
            component.queryUtility(IService, "undo_manager") is not None,
            "Failed to query the undo manager utility",
        )

        self.assertTrue(
            component.queryUtility(IService, "file_manager") is not None,
            "Failed to query the file manager utility",
        )

        Application.shutdown()
Пример #7
0
 def setUp(self):
     Application.init(services=self.services)
     self.element_factory = Application.get_service('element_factory')
     assert len(list(self.element_factory.select())) == 0, list(
         self.element_factory.select())
     self.diagram = self.element_factory.create(UML.Diagram)
     assert len(list(self.element_factory.select())) == 1, list(
         self.element_factory.select())
Пример #8
0
 def setUp(self):
     Application.init(services=[
         "main_window",
         "properties",
         "element_factory",
         "diagram_export_manager",
         "action_manager",
     ])
Пример #9
0
    def setUp(self):
        Application.init()
        element_factory = Application.get_service("element_factory")
        from gaphor.storage.storage import load

        dist = pkg_resources.get_distribution("gaphor")
        path = os.path.join(dist.location, "test-diagrams/issue_53.gaphor")
        load(path, element_factory)
Пример #10
0
    def setUp(self):
        Application.init()
        element_factory = Application.get_service("element_factory")
        from gaphor.storage.storage import load

        dist = pkg_resources.get_distribution("gaphor")
        path = os.path.join(dist.location, "test-diagrams/issue_53.gaphor")
        load(path, element_factory)
Пример #11
0
 def setUp(self):
     Application.init(services=[
         'adapter_loader', 'element_factory', 'main_window', 'ui_manager',
         'properties_manager', 'action_manager', 'properties',
         'element_dispatcher'
     ])
     self.main_window = Application.get_service('main_window')
     self.main_window.open()
Пример #12
0
    def setUp(self):
        Application.init()
        element_factory = Application.get_service('element_factory')
        from gaphor.storage.storage import load

        dist = pkg_resources.get_distribution('gaphor')
        path = os.path.join(dist.location, 'tests/issue_53.gaphor')
        load(path, element_factory)
Пример #13
0
def application():
    Application.init(services=[
        "event_manager",
        "component_registry",
        "properties",
        "diagram_export_manager",
    ])
    yield Application
    Application.shutdown()
Пример #14
0
 def setUp(self):
     Application.init(services=['adapter_loader', 'element_factory', 'main_window', 'properties_manager', 'action_manager', 'properties', 'element_dispatcher'])
     self.main_window = Application.get_service('main_window')
     self.element_factory = Application.get_service('element_factory')
     self.diagram = self.element_factory.create(UML.Diagram)
     self.comment = self.diagram.create(CommentItem,
             subject=self.element_factory.create(UML.Comment))
     self.commentline = self.diagram.create(CommentLineItem)
     self.view = self.main_window.show_diagram(self.diagram).view
Пример #15
0
def element_factory():
    Application.init()
    element_factory = Application.get_service("element_factory")
    dist = importlib_metadata.distribution("gaphor")
    path = dist.locate_file("test-diagrams/issue_53.gaphor")
    load(path, element_factory)
    yield element_factory
    Application.get_service("element_factory").shutdown()
    Application.shutdown()
Пример #16
0
 def setUp(self):
     Application.init(services=self.services)
     self.element_factory = Application.get_service("element_factory")
     assert len(list(self.element_factory.select())) == 0, list(
         self.element_factory.select()
     )
     self.diagram = self.element_factory.create(UML.Diagram)
     assert len(list(self.element_factory.select())) == 1, list(
         self.element_factory.select()
     )
Пример #17
0
 def setUp(self):
     Application.init(
         services=[
             "main_window",
             "properties",
             "element_factory",
             "diagram_export_manager",
             "action_manager",
         ]
     )
Пример #18
0
 def setUp(self):
     Application.init(services=[
         "file_manager",
         "element_factory",
         "properties",
         "main_window",
         "action_manager",
     ])
     self.recent_files_backup = Application.get_service("properties").get(
         "recent-files")
Пример #19
0
 def setUp(self):
     Application.init(services=['element_factory', 'main_window', 'ui_manager', 'action_manager', 'properties', 'element_dispatcher'])
     main_window = Application.get_service('main_window')
     main_window.open()
     element_factory = Application.get_service('element_factory')
     self.element_factory = element_factory
     self.diagram = element_factory.create(UML.Diagram)
     self.tab = main_window.show_diagram(self.diagram)
     self.assertEquals(self.tab.diagram, self.diagram)
     self.assertEquals(self.tab.view.canvas, self.diagram.canvas)
     self.assertEquals(len(element_factory.lselect()), 1)
Пример #20
0
 def setUp(self):
     Application.init(services=['element_factory', 'main_window', 'ui_manager', 'action_manager', 'properties', 'element_dispatcher'])
     main_window = Application.get_service('main_window')
     main_window.open()
     element_factory = Application.get_service('element_factory')
     self.element_factory = element_factory
     self.diagram = element_factory.create(uml2.Diagram)
     self.tab = main_window.show_diagram(self.diagram)
     self.assertEquals(self.tab.diagram, self.diagram)
     self.assertEquals(self.tab.view.canvas, self.diagram.canvas)
     self.assertEquals(len(element_factory.lselect()), 1)
Пример #21
0
def element_factory():
    Application.init(
        services=["event_manager", "component_registry", "element_factory"])
    event_manager = Application.get_service("event_manager")
    event_manager.subscribe(handler)
    clear_events()
    factory = Application.get_service("element_factory")
    yield factory
    del factory
    clear_events()
    Application.shutdown()
Пример #22
0
def test_service_load():
    """Test loading services and querying utilities."""

    Application.init()

    assert (Application.get_service("undo_manager")
            is not None), "Failed to load the undo manager service"

    assert (Application.get_service("file_manager")
            is not None), "Failed to load the file manager service"

    Application.shutdown()
Пример #23
0
 def setUp(self):
     Application.init(services=[
         "adapter_loader",
         "element_factory",
         "main_window",
         "properties_manager",
         "action_manager",
         "properties",
         "element_dispatcher",
     ])
     self.main_window = Application.get_service("main_window")
     self.main_window.open()
Пример #24
0
    def testLoadAll(self):
        from gaphor.application import Application

        Application.init()
        am = Application.get_service("action_manager")
        ui = am.ui_manager.get_ui()

        assert '<menuitem name="file-quit" action="file-quit"/>' in ui, ui
        # From filemanager:
        assert '<menuitem name="file-new" action="file-new"/>' in ui, ui
        # From Undomanager
        assert '<toolitem name="edit-undo" action="edit-undo"/>' in ui, ui
Пример #25
0
 def setUp(self):
     Application.init(
         services=[
             "file_manager",
             "element_factory",
             "properties",
             "main_window",
             "action_manager",
         ]
     )
     self.recent_files_backup = Application.get_service("properties").get(
         "recent-files"
     )
Пример #26
0
 def setUp(self):
     Application.init(
         services=[
             "element_factory",
             "main_window",
             "properties_manager",
             "action_manager",
             "properties",
             "element_dispatcher",
         ]
     )
     self.main_window = Application.get_service("main_window")
     self.main_window.open()
Пример #27
0
 def setUp(self):
     Application.init(services=['element_factory', 'main_window', 'action_manager', 'properties', 'element_dispatcher'])
     main_window = Application.get_service('main_window')
     element_factory = Application.get_service('element_factory')
     self.element_factory = element_factory
     self.diagram = element_factory.create(UML.Diagram)
     self.tab = DiagramTab(main_window)
     self.tab.set_diagram(self.diagram)
     self.assertEquals(self.tab.diagram, self.diagram)
     widget = self.tab.construct()
     main_window.add_tab(self.tab, widget, 'title')
     self.assertEquals(self.tab.view.canvas, self.diagram.canvas)
     self.assertEquals(len(element_factory.lselect()), 1)
Пример #28
0
def application():
    Application.init(services=[
        "event_manager",
        "component_registry",
        "element_factory",
        "properties",
        "main_window",
        "action_manager",
        "namespace",
        "diagrams",
        "toolbox",
    ])
    yield Application
    Application.shutdown()
Пример #29
0
    def test_service_load(self):
        """
        Load services. At lease the undo_manager should be available after that.
        """
        Application.init(['undo_manager', 'file_manager', 'properties'])

        self.assertTrue(Application.get_service('undo_manager') is not None)
        self.assertTrue(Application.get_service('file_manager') is not None)

        # After that, services are also available as Utilities:
        self.assertTrue(component.queryUtility(IService, 'undo_manager') is not None)
        self.assertTrue(component.queryUtility(IService, 'file_manager') is not None)

        Application.shutdown()
Пример #30
0
 def setUp(self):
     """Initialize Gaphor services and register transaction event
     handlers."""
     
     Application.init(services=['component_registry'])
     
     component_registry = Application.get_service('component_registry')
     
     component_registry.register_handler(handle_begins, [TransactionBegin])
     component_registry.register_handler(handle_commits, [TransactionCommit])
     component_registry.register_handler(handle_rollback, [TransactionRollback])
     
     del begins[:]
     del commits[:]
     del rollbacks[:]
Пример #31
0
    def test_service_load(self):
        """Test loading services and querying utilities."""

        Application.init(["undo_manager", "file_manager", "properties"])

        self.assertTrue(
            Application.get_service("undo_manager") is not None,
            "Failed to load the undo manager service",
        )

        self.assertTrue(
            Application.get_service("file_manager") is not None,
            "Failed to load the file manager service",
        )

        Application.shutdown()
Пример #32
0
    def test_service_load(self):
        """Test loading services and querying utilities."""

        Application.init(['undo_manager', 'file_manager', 'properties'])

        self.assertTrue(Application.get_service('undo_manager') is not None, 'Failed to load the undo manager service')

        self.assertTrue(Application.get_service('file_manager') is not None, 'Failed to load the file manager service')

        self.assertTrue(component.queryUtility(IService, 'undo_manager') is not None, (
            'Failed to query the undo manager utility'))

        self.assertTrue(component.queryUtility(IService, 'file_manager') is not None, (
            'Failed to query the file manager utility'))

        Application.shutdown()
Пример #33
0
 def setUp(self):
     Application.init(services=[
         'adapter_loader', 'element_factory', 'main_window', 'ui_manager',
         'properties_manager', 'action_manager', 'properties',
         'element_dispatcher'
     ])
     self.main_window = Application.get_service('main_window')
     self.main_window.init()
     self.main_window.open()
     self.element_factory = Application.get_service('element_factory')
     self.diagram = self.element_factory.create(UML.Diagram)
     self.comment = self.diagram.create(CommentItem,
                                        subject=self.element_factory.create(
                                            UML.Comment))
     self.commentline = self.diagram.create(CommentLineItem)
     self.view = self.main_window.show_diagram(self.diagram).view
Пример #34
0
def application():
    Application.init(services=[
        "event_manager",
        "component_registry",
        "file_manager",
        "element_factory",
        "properties",
        "main_window",
        "action_manager",
    ])
    recent_files_backup = Application.get_service("properties").get(
        "recent-files")
    yield Application
    Application.get_service("properties").set("recent-files",
                                              recent_files_backup)
    Application.shutdown()
Пример #35
0
    def setUp(self):
        """Initialize Gaphor services and register transaction event
        handlers."""

        Application.init(services=['component_registry'])

        component_registry = Application.get_service('component_registry')

        component_registry.register_handler(handle_begins, [TransactionBegin])
        component_registry.register_handler(handle_commits,
                                            [TransactionCommit])
        component_registry.register_handler(handle_rollback,
                                            [TransactionRollback])

        del begins[:]
        del commits[:]
        del rollbacks[:]
Пример #36
0
 def setUp(self):
     Application.init(services=[
         "element_factory",
         "main_window",
         "action_manager",
         "properties",
         "element_dispatcher",
     ])
     main_window = Application.get_service("main_window")
     main_window.open()
     self.element_factory = Application.get_service("element_factory")
     self.diagram = self.element_factory.create(UML.Diagram)
     self.page = DiagramPage(self.diagram)
     self.page.construct()
     self.assertEqual(self.page.diagram, self.diagram)
     self.assertEqual(self.page.view.canvas, self.diagram.canvas)
     self.assertEqual(len(self.element_factory.lselect()), 1)
Пример #37
0
    def setUp(self):
        Application.init(services=[
            "event_manager",
            "component_registry",
            "element_factory",
            "main_window",
            "properties_manager",
            "action_manager",
            "properties",
            "namespace",
            "diagrams",
            "toolbox",
        ])
        self.component_registry = Application.get_service("component_registry")
        self.event_manager = Application.get_service("event_manager")

        self.main_window = Application.get_service("main_window")
        self.main_window.open()
Пример #38
0
 def setUp(self):
     Application.init(
         services=[
             "element_factory",
             "main_window",
             "action_manager",
             "properties",
             "element_dispatcher",
         ]
     )
     main_window = Application.get_service("main_window")
     main_window.open()
     self.element_factory = Application.get_service("element_factory")
     self.diagram = self.element_factory.create(UML.Diagram)
     self.page = DiagramPage(self.diagram)
     self.page.construct()
     self.assertEqual(self.page.diagram, self.diagram)
     self.assertEqual(self.page.view.canvas, self.diagram.canvas)
     self.assertEqual(len(self.element_factory.lselect()), 1)
Пример #39
0
 def setUp(self):
     Application.init(
         services=[
             "element_factory",
             "main_window",
             "properties_manager",
             "action_manager",
             "properties",
             "element_dispatcher",
         ]
     )
     self.main_window = Application.get_service("main_window")
     self.main_window.open()
     self.element_factory = Application.get_service("element_factory")
     self.diagram = self.element_factory.create(UML.Diagram)
     self.comment = self.diagram.create(
         CommentItem, subject=self.element_factory.create(UML.Comment)
     )
     self.commentline = self.diagram.create(CommentLineItem)
Пример #40
0
 def setUp(self):
     Application.init(services=[
         "adapter_loader",
         "element_factory",
         "main_window",
         "properties_manager",
         "action_manager",
         "properties",
         "element_dispatcher",
     ])
     self.main_window = Application.get_service("main_window")
     self.main_window.init()
     self.main_window.open()
     self.element_factory = Application.get_service("element_factory")
     self.diagram = self.element_factory.create(UML.Diagram)
     self.comment = self.diagram.create(CommentItem,
                                        subject=self.element_factory.create(
                                            UML.Comment))
     self.commentline = self.diagram.create(CommentLineItem)
Пример #41
0
def application():
    Application.init(services=[
        "event_manager",
        "component_registry",
        "element_factory",
        "main_window",
        "properties_manager",
        "properties",
        "namespace",
        "diagrams",
        "toolbox",
        "elementeditor",
        "export_menu",
        "tools_menu",
    ])
    main_window = Application.get_service("main_window")
    main_window.open()
    yield Application
    Application.shutdown()
Пример #42
0
 def setUp(self):
     Application.init()
     element_factory = Application.get_service('element_factory')
     from gaphor.storage.storage import load
     load('tests/issue_53.gaphor', element_factory)
Пример #43
0
 def setUp(self):
     Application.init(services=[
         'main_window', 'properties', 'element_factory',
         'diagram_export_manager', 'action_manager', 'ui_manager'
     ])
Пример #44
0
 def setUp(self):
     Application.init(
         services=["element_factory", "properties", "main_window", "action_manager"]
     )
Пример #45
0
 def setUp(self):
     Application.init(["element_factory"])
     self.factory = Application.get_service("element_factory")
     component_registry = Application.get_service("component_registry")
     component_registry.register_handler(handler)
     clearEvents()
Пример #46
0
 def testLoadAll(self):
     from gaphor.application import Application
     Application.init()
     am = Application.get_service('action_manager')
     ui = am.ui_manager.get_ui()
     print ui
Пример #47
0
def application(services=["element_factory", "action_manager"]):
    Application.init(services=services)
    yield Application
    Application.shutdown()
Пример #48
0
 def setUp(self):
     Application.init(services=['main_window', 'properties', 'element_factory', 'diagram_export_manager', 'action_manager' ])
Пример #49
0
 def setUp(self):
     Application.init(['element_factory'])
     self.factory = Application.get_service('element_factory')
Пример #50
0
    "-r",
    "--regex",
    dest="regex",
    metavar="regex",
    help="process diagrams which name matches given regular expresion;"
    " name includes package name; regular expressions are case insensitive",
)

(options, args) = parser.parse_args()

if not args:
    parser.print_help()
    sys.exit(1)


Application.init()
factory = UML.ElementFactory()


name_re = None
if options.regex:
    name_re = re.compile(options.regex, re.I)

# we should have some gaphor files to be processed at this point
for model in args:
    message("loading model %s" % model)
    storage.load(model, factory)
    message("\nready for rendering\n")

    for diagram in factory.select(lambda e: e.isKindOf(UML.Diagram)):
        odir = pkg2dir(diagram.package)
Пример #51
0
 def setUp(self):
     Application.init(services=['file_manager', 'element_factory', 'properties', 'main_window', 'action_manager', 'ui_manager'])
     self.recent_files_backup = Application.get_service('properties').get('recent-files')
Пример #52
0
 def setUp(self):
     Application.init(services=['adapter_loader', 'element_factory', 'main_window', 'ui_manager', 'properties_manager', 'action_manager', 'properties', 'element_dispatcher'])
     self.main_window = Application.get_service('main_window')
     self.main_window.open()
Пример #53
0
 def setUp(self):
     Application.init(services=self.services)
     self.element_factory = Application.get_service('element_factory')
     self.backup_service = Application.get_service('backup_service')
Пример #54
0
 def setUp(self):
     Application.init(services=self.services)
     self.element_factory = Application.get_service('element_factory')
     self.backup_service = Application.get_service('backup_service')
Пример #55
0
 def setUp(self):
     Application.init(services=['element_factory', 'properties', 'action_manager'])