Ejemplo n.º 1
0
 def creator(prop_obj):
     if not prop_obj:
         return
     prop, obj = prop_obj
     if not prop or not obj:
         return
     p = props[prop]['uri']
     self.doc << actions.AddProperty(self.doc, ObjectTriple.of(self.parent.uri, p, uri))
Ejemplo n.º 2
0
    def MakeAction(self):
        if self.nodemark == NODE_DEFAULT or not self.change:
            return

        if self.change[0] and self.change[1]:
            return actions.ChangeProperty(self.doc, self.change[1],
                                          self.change[0])
        elif self.change[1]:
            return actions.AddProperty(self.doc, self.change[1])
        elif self.change[0]:
            return actions.RemoveProperty(self.doc, self.change[0])
Ejemplo n.º 3
0
 def creator(prop_value):
     if not prop_value:
         return
     prop, value = prop_value
     if not prop or not value:
         return
     p = props[prop]['uri']
     datatype = props[prop].get('type_uri')
     if datatype:
         k = DatatypeQuad.of(self.parent.uri, p, value, datatype)
     else:
         k = LiteralTriple.of(self.parent.uri, p, value)
     self.doc << actions.AddProperty(self.doc, k)
Ejemplo n.º 4
0
 def OnDblClick(self):
     if getattr(self, 'change', None):
         action = self.MakeAction()
         if action:
             self.doc << action
     else:
         lst = []
         props = set(self.doc.grTriplesForSubj(self.uri))
         diff = self.tree.view.diff
         props_del = set(diff.deletions.grTriplesForSubj(self.uri)) & props
         props_add = set(diff.insertions.grTriplesForSubj(self.uri)) - props
         for t in props_del:
             lst.append(actions.RemoveProperty(self.doc, t))
         for t in props_add:
             lst.append(actions.AddProperty(self.doc, t))
         self.doc << MultiAction(lst)
     return True
Ejemplo n.º 5
0
    def OnAcceptAll(self):
        if len(self.subjects) > 1000:
            if dialogs.Choice(tm.main.apply_diff_warning):
                self.pnode.DestroyChildren()
                for v in self.subjects:
                    for t in self.diff.deletions.grTriplesForSubj(
                            expand_uri(v)):
                        t.deletefrom(self.document)
                    for t in self.diff.insertions.grTriplesForSubj(
                            expand_uri(v)):
                        t.insertto(self.document)
                self.document.ChangeState(self.document.state_changed)
                self.Seed()
            return

        lst = []
        for v in self.subjects:
            for t in self.diff.deletions.grTriplesForSubj(expand_uri(v)):
                lst.append(actions.RemoveProperty(self.document, t))
            for t in self.diff.insertions.grTriplesForSubj(expand_uri(v)):
                lst.append(actions.AddProperty(self.document, t))

        self.document << MultiAction(lst)