示例#1
0
    def add_layers_from_ngw(self):
        #import pydevd
        #pydevd.settrace('localhost', port=5566, stdoutToServer=True, stderrToServer=True, suspend=False)

        conn_name = PluginSettings.get_selected_ngw_connection_name()
        if not conn_name:
            error_message = self.tr('You must configure at least one connection!')
            self.iface.messageBar().pushMessage(self.tr('WARNING'),
                                                error_message,
                                                level=QgsMessageBar.WARNING)
            QgsMessageLog.logMessage(error_message, level=QgsMessageLog.WARNING)
            return
        conn_sett = PluginSettings.get_ngw_connection(conn_name)

        #setup ngw api
        rsc_factory = NGWResourceFactory(conn_sett)
        types_reg = rsc_factory.resources_types_registry
        types_reg[NGWFoclStruct.type_id] = NGWFoclStruct
        types_reg[NGWFoclProject.type_id] = NGWFoclProject
        types_reg[NGWSituationPlan.type_id] = NGWSituationPlan

        try:
            root_rsc = rsc_factory.get_root_resource()
        except Exception, e:
            error_message = self.tr('Error on fetch resources: ') + e.message
            self.iface.messageBar().pushMessage(self.tr('ERROR'),
                                                error_message,
                                                level=QgsMessageBar.CRITICAL)
            QgsMessageLog.logMessage(error_message, level=QgsMessageLog.CRITICAL)
            return
示例#2
0
    def populate_connection_list(self):
        self.cmbConnections.clear()
        self.cmbConnections.addItems(PluginSettings.get_ngw_connection_names())

        last_connection = PluginSettings.get_selected_ngw_connection_name()
        idx = self.cmbConnections.findText(last_connection)
        if idx == -1 and self.cmbConnections.count() > 0:
            self.cmbConnections.setCurrentIndex(0)
        else:
            self.cmbConnections.setCurrentIndex(idx)

        if self.cmbConnections.count() == 0:
            self.btnEdit.setEnabled(False)
            self.btnDelete.setEnabled(False)
        else:
            self.btnEdit.setEnabled(True)
            self.btnDelete.setEnabled(True)