Exemple #1
0
    def executeUiEvent(self, evName, cmd):
        if "PublishCommandEvent" != evName:
            return

        sernaDoc = self.sernaDoc()
        structEditor = sernaDoc.structEditor()

        widget = sernaDoc.widget()

        if structEditor and not structEditor.groveEditor is None:
            saveAction = structEditor.findAction("saveDocument")
            if saveAction and saveAction.isEnabled():
                buttons = QMessageBox.Ok | QMessageBox.Cancel
                answer = QMessageBox.warning(widget, "Publishing", "Current "
                                             "document will be saved", buttons)
                if QMessageBox.Ok != answer:
                    return

                if not self.executeCommandEvent("SaveDocument"):
                    QMessageBox.critical(widget, "Publishing",
                                         "Document save failed")
                    return

        catMgr = structEditor.catalogManager()
        catalogFiles = unicode(catMgr.getCatalogsList())

        if os.pathsep in catalogFiles:
            cats = []
            for cat in catalogFiles.split(os.pathsep):
                cat = cat.replace(' ', '%20')
                cats.append(cat)
            catalogFiles = ' '.join(cats)

        sernaDoc.getDsi().getProperty("xml-catalogs").setString(catalogFiles.__str__())

        if not self._dialog:
            self._dialog = PublishDialog(self, widget, self.pluginProperties())

        self._dialog.showDialog()
        QApplication.setActiveWindow(self._dialog)
        self._dialog.setFocus(Qt.ActiveWindowFocusReason)
        self._dialog.exec_()