def merge(self, obj):
        """
        Merge the selected sources.
        """
        mlist = self.selected_handles()

        if len(mlist) != 2:
            msg = _("Cannot merge sources.")
            msg2 = _("Exactly two sources must be selected to perform a merge. "
                     "A second source can be selected by holding down the "
                     "control key while clicking on the desired source.")
            ErrorDialog(msg, msg2, parent=self.uistate.window)
        else:
            MergeSource(self.dbstate, self.uistate, [], mlist[0], mlist[1])
Esempio n. 2
0
    def merge(self, obj):
        """
        Merge the selected citations.
        """
        mlist = self.selected_handles()

        if len(mlist) != 2:
            msg = _("Cannot merge citations.")
            msg2 = _("Exactly two citations must be selected to perform a "
                     "merge. A second citation can be selected by holding "
                     "down the control key while clicking on the desired "
                     "citation.")
            ErrorDialog(msg, msg2, parent=self.uistate.window)  # parent-OK
        else:
            source1 = self.dbstate.db.get_source_from_handle(mlist[0])
            citation1 = self.dbstate.db.get_citation_from_handle(mlist[0])
            if (not source1 and not citation1) or (source1 and citation1):
                raise ValueError("selection must be either source or citation")

            source2 = self.dbstate.db.get_source_from_handle(mlist[1])
            citation2 = self.dbstate.db.get_citation_from_handle(mlist[1])
            if (not source2 and not citation2) or (source2 and citation2):
                raise ValueError("selection must be either source or citation")

            if citation1 and citation2:
                if not citation1.get_reference_handle()  == \
                                citation2.get_reference_handle():
                    msg = _("Cannot merge citations.")
                    msg2 = _("The two selected citations must have the same "
                             "source to perform a merge. If you want to merge "
                             "these two citations, then you must merge the "
                             "sources first.")
                    ErrorDialog(
                        msg,
                        msg2,  # parent-OK
                        parent=self.uistate.window)
                else:
                    MergeCitation(self.dbstate, self.uistate, mlist[0],
                                  mlist[1])
            elif source1 and source2:
                MergeSource(self.dbstate, self.uistate, mlist[0], mlist[1])
            else:
                msg = _("Cannot perform merge.")
                msg2 = _("Both objects must be of the same type, either "
                         "both must be sources, or both must be "
                         "citations.")
                ErrorDialog(msg, msg2, parent=self.uistate.window)  # parent-OK
Esempio n. 3
0
    def merge(self, *obj):
        """
        Merge the selected citations.
        """
        mlist = self.selected_handles()

        if len(mlist) != 2:
            msg = _("Cannot merge citations.")
            msg2 = _("Exactly two citations must be selected to perform a "
                     "merge. A second citation can be selected by holding "
                     "down the control key while clicking on the desired "
                     "citation.")
            ErrorDialog(msg, msg2, parent=self.uistate.window)
        else:
            source1, citation1 = self.get_source_or_citation(mlist[0])
            source2, citation2 = self.get_source_or_citation(mlist[1])

            if citation1 and citation2:
                if not citation1.get_reference_handle()  == \
                                citation2.get_reference_handle():
                    msg = _("Cannot merge citations.")
                    msg2 = _("The two selected citations must have the same "
                             "source to perform a merge. If you want to merge "
                             "these two citations, then you must merge the "
                             "sources first.")
                    ErrorDialog(msg, msg2,
                                parent=self.uistate.window)
                else:
                    MergeCitation(self.dbstate, self.uistate, [], mlist[0],
                                  mlist[1])
            elif source1 and source2:
                MergeSource(self.dbstate, self.uistate, [], mlist[0], mlist[1])
            else:
                msg = _("Cannot perform merge.")
                msg2 = _("Both objects must be of the same type, either "
                         "both must be sources, or both must be "
                         "citations.")
                ErrorDialog(msg, msg2, parent=self.uistate.window)
            self.object_build()