Esempio n. 1
0
    def Do(cls):
        doctype = GraphDocument if not cls.doctype else cls.doctype

        if cls.is_new_file:
            name = framework.dialogs.EnterText(tm.main.new_data_source,
                                               tm.main.data_source_name_field)
            if not name:
                return
            doc = doctype()
            doc.NewFile([], name=name, **cls.params)
        elif cls.appconfig_file_path:
            path = cls.appconfig_file_path
            if not appconfig.get(cls.appconfig_file_path).decode('utf-8'):
                path, wildcard = framework.dialogs.SelectFiles(cls.vis_label)
            if not path:
                return
            paths = [path]
            if not Document.VerifyEditablePaths([
                    appconfig.get(v).decode('utf-8')
                    if v.startswith('cfg://') else v for v in paths
            ]):
                return
            doc = doctype()
            doc.OpenFiles(paths, **cls.params)
        elif not cls.sparql_path and not cls.is_other_sparql:
            # unknown file
            paths, wildcard = framework.dialogs.SelectFiles(cls.vis_label,
                                                            multi=True)
            if not paths:
                return
            if not Document.VerifyEditablePaths(paths):
                return

            for p in list(paths):
                if paths[0].endswith('.patt'):
                    doc = PatternsDocument()
                    doc.OpenFiles([p], **params)
                    self.AddDocument(doc)
                    paths.remove(p)

            if paths:
                doc = doctype()
                doc.OpenFiles(paths, **cls.params)
        elif cls.sparql_path:
            doc = doctype()
            doc.OpenSparql(SparqlConnection(cls.sparql_path), **cls.params)
        elif cls.is_other_sparql:
            dlg = iso15926.common.dialogs.OpenEndpoint(cls.vis_label)
            if not dlg.connection:
                return
            doc = doctype()
            doc.OpenSparql(dlg.connection, **cls.params)

        appdata.project.AddDocument(doc)
Esempio n. 2
0
 def SaveProjectAs(self):
     path, wildcard = SelectFiles(tm.main.save_project_as,
                                  save=True,
                                  wildcard=tm.main.project_wildcard)
     if not path or not Document.VerifyEditablePaths([path]):
         return
     self.SaveProjectToFile(path)
Esempio n. 3
0
    def OpenPaths(self, paths, node):
        for p in paths:
            if p.endswith('.15926'):
                self.OpenProjectFile(p)
                return

        if not Document.VerifyEditablePaths(paths):
            return

        unresolved = []
        for p in paths:
            if p.endswith('.patt'):
                doc = PatternsDocument()
                doc.OpenFiles([p], {})
                self.AddDocument(doc, node)
            else:
                unresolved.append(p)

        if unresolved:
            doc = GraphDocument()
            params = dict(chosen_part2=kb.ns_dm_rds,
                          namespaces=kb.namespaces_std,
                          annotations=kb.annotations_rdfs +
                          kb.annotations_meta,
                          roles=kb.roles_std)
            doc.OpenFiles(unresolved, **params)
            self.AddDocument(doc, node)