def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.ptcontac = ContactInfoPointOfContact(parent=self) self.taxonomy = Taxonomy(parent=self) self.keywords = Keywords(parent=self) self.accconst = Accconst(parent=self) self.useconst = Useconst(parent=self) self.status = Status(parent=self) self.timeperd = Timeperd(parent=self) self.citation = Citeinfo(parent=self) self.citation.ui.btn_import_doi.hide() self.datacredit = Datacred(parent=self) self.descript = Descript(parent=self) self.purpose = Purpose(parent=self) self.supplinf = SupplInf(parent=self) self.native = Native(parent=self) self.ui.fgdc_citation.layout().addWidget(self.citation) #bottom to top in layout time_hbox = QHBoxLayout() time_hbox.addWidget(self.status) time_hbox.addWidget(self.timeperd) self.ui.two_column_left.layout().insertWidget(0, self.native) self.ui.two_column_left.layout().insertLayout(0, time_hbox) self.ui.two_column_left.layout().insertWidget(0, self.datacredit) self.ui.two_column_left.layout().insertWidget(0, self.taxonomy) self.ui.two_column_left.layout().insertWidget(0, self.ptcontac) self.ui.two_column_left.layout().insertWidget(0, self.useconst) self.ui.two_column_left.layout().insertWidget(0, self.accconst) self.ui.two_column_right.layout().insertWidget(0, self.supplinf) self.ui.two_column_right.layout().insertWidget(0, self.keywords) self.ui.two_column_right.layout().insertWidget(0, self.purpose) self.ui.two_column_right.layout().insertWidget(0, self.descript) self.crossref_list = Crossref_list() self.ui.help_crossref.layout().addWidget(self.crossref_list)
def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.ptcontac = ContactInfoPointOfContact(parent=self) self.taxonomy = Taxonomy(parent=self) self.keywords = Keywords(parent=self) self.accconst = AccessConstraints(parent=self) self.useconst = UseConstraints(parent=self) self.status = Status(parent=self) self.timeperd = Timeperd(parent=self) self.citation = Citation(parent=self) self.datacredit = DataCredit(parent=self) self.abstract = Abstract(parent=self) self.purpose = Purpose(parent=self) self.supplinf = SupplInf(parent=self) self.ui.fgdc_citation.layout().addWidget(self.citation) #bottom to top in layout time_hbox = QHBoxLayout() time_hbox.addWidget(self.status) time_hbox.addWidget(self.timeperd) self.ui.two_column_left.layout().insertLayout(0, time_hbox) self.ui.two_column_left.layout().insertWidget(0, self.datacredit) self.ui.two_column_left.layout().insertWidget(0, self.taxonomy) self.ui.two_column_left.layout().insertWidget(0, self.ptcontac) self.ui.two_column_left.layout().insertWidget(0, self.useconst) self.ui.two_column_left.layout().insertWidget(0, self.accconst) self.ui.two_column_right.layout().insertWidget(0, self.supplinf) self.ui.two_column_right.layout().insertWidget(0, self.keywords) self.ui.two_column_right.layout().insertWidget(0, self.purpose) self.ui.two_column_right.layout().insertWidget(0, self.abstract)
class IdInfo(WizardWidget): drag_label = "Identification Information <idinfo>" acceptable_tags = ['abstract'] ui_class = UI_IdInfo.Ui_fgdc_idinfo def __init__(self, root_widget=None, parent=None): super(self.__class__, self).__init__(parent=parent) self.schema = 'bdp' self.root_widget = root_widget def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.ptcontac = ContactInfoPointOfContact(parent=self) self.taxonomy = Taxonomy(parent=self) self.keywords = Keywords(parent=self) self.accconst = AccessConstraints(parent=self) self.useconst = UseConstraints(parent=self) self.status = Status(parent=self) self.timeperd = Timeperd(parent=self) self.citation = Citeinfo(parent=self) self.datacredit = DataCredit(parent=self) self.descript = Descript(parent=self) self.purpose = Purpose(parent=self) self.supplinf = SupplInf(parent=self) self.ui.fgdc_citation.layout().addWidget(self.citation) #bottom to top in layout time_hbox = QHBoxLayout() time_hbox.addWidget(self.status) time_hbox.addWidget(self.timeperd) self.ui.two_column_left.layout().insertLayout(0, time_hbox) self.ui.two_column_left.layout().insertWidget(0, self.datacredit) self.ui.two_column_left.layout().insertWidget(0, self.taxonomy) self.ui.two_column_left.layout().insertWidget(0, self.ptcontac) self.ui.two_column_left.layout().insertWidget(0, self.useconst) self.ui.two_column_left.layout().insertWidget(0, self.accconst) self.ui.two_column_right.layout().insertWidget(0, self.supplinf) self.ui.two_column_right.layout().insertWidget(0, self.keywords) self.ui.two_column_right.layout().insertWidget(0, self.purpose) self.ui.two_column_right.layout().insertWidget(0, self.descript) def dragEnterEvent(self, e): """ Parameters ---------- e : qt event Returns ------- """ print("idinfo drag enter") mime_data = e.mimeData() if e.mimeData().hasFormat('text/plain'): parser = etree.XMLParser(ns_clean=True, recover=True, encoding='utf-8') element = etree.fromstring(mime_data.text(), parser=parser) if element is not None and element.tag == 'idinfo': e.accept() else: e.ignore() def children(self): return super(IdInfo, self).children() + [self.root_widget.spatial_tab.spdom] def switch_schema(self, schema): self.schema = schema if schema == 'bdp': self.taxonomy.show() else: self.taxonomy.hide() def clear_widget(self): self.root_widget.spatial_tab.spdom.clear_widget() WizardWidget.clear_widget(self) def _to_xml(self): # add code here to translate the form into xml representation idinfo_node = xml_utils.xml_node('idinfo') citation_node = xml_utils.xml_node('citation', parent_node=idinfo_node) citeinfo_node = self.citation._to_xml() citation_node.append(citeinfo_node) idinfo_node.append(citation_node) descript_node = xml_utils.xml_node('descript', parent_node=idinfo_node) abstract_node = self.descript._to_xml() descript_node.append(abstract_node) purpose_node = self.purpose._to_xml() descript_node.append(purpose_node) supplinf_node = self.supplinf._to_xml() if supplinf_node.text is not None: descript_node.append(supplinf_node) idinfo_node.append(descript_node) timeperd_node = self.timeperd._to_xml() idinfo_node.append(timeperd_node) status_node = self.status._to_xml() idinfo_node.append(status_node) spdom_node = self.root_widget.spatial_tab.spdom._to_xml() idinfo_node.append(spdom_node) keywords = self.keywords._to_xml() idinfo_node.append(keywords) if self.schema == 'bdp' and self.taxonomy.has_content(): taxonomy = self.taxonomy._to_xml() idinfo_node.append(taxonomy) accconst_node = self.accconst._to_xml() idinfo_node.append(accconst_node) useconst_node = self.useconst._to_xml() idinfo_node.append(useconst_node) if self.ptcontac.has_content(): ptcontac = self.ptcontac._to_xml() idinfo_node.append(ptcontac) datacredit_node = self.datacredit._to_xml() if datacredit_node.text: idinfo_node.append(datacredit_node) if self.original_xml is not None: secinfo = xml_utils.search_xpath(self.original_xml, 'secinfo') if secinfo is not None: idinfo_node.append(deepcopy(secinfo)) native = xml_utils.search_xpath(self.original_xml, 'native') if native is not None: idinfo_node.append(deepcopy(native)) crossref_list = xml_utils.search_xpath(self.original_xml, 'crossref', only_first=False) for crossref in crossref_list: idinfo_node.append(deepcopy(crossref)) tool = xml_utils.search_xpath(self.original_xml, 'tool') if tool is not None: idinfo_node.append(deepcopy(tool)) return idinfo_node def _from_xml(self, xml_idinfo): self.original_xml = (xml_idinfo) citation = xml_utils.search_xpath(xml_idinfo, 'citation') if citation is not None: self.citation._from_xml(citation) abstract = xml_utils.search_xpath(xml_idinfo, 'descript/abstract') if abstract is not None: self.descript._from_xml(abstract) purpose = xml_utils.search_xpath(xml_idinfo, 'descript/purpose') if purpose is not None: self.purpose._from_xml(purpose) supplinf = xml_utils.search_xpath(xml_idinfo, 'descript/supplinf') if supplinf is not None: self.supplinf._from_xml(supplinf) timeperd = xml_utils.search_xpath(xml_idinfo, 'timeperd') if timeperd is not None: self.timeperd._from_xml(timeperd) status = xml_utils.search_xpath(xml_idinfo, 'status') if status is not None: self.status._from_xml(status) spdom = xml_utils.search_xpath(xml_idinfo, 'spdom') if spdom is not None: self.root_widget.spatial_tab.spdom._from_xml(spdom) keywords = xml_utils.search_xpath(xml_idinfo, 'keywords') if keywords is not None: self.keywords._from_xml(keywords) taxonomy = xml_utils.search_xpath(xml_idinfo, 'taxonomy') if taxonomy is not None: self.taxonomy._from_xml(taxonomy) accconst = xml_utils.search_xpath(xml_idinfo, 'accconst') if accconst is not None: self.accconst._from_xml(accconst) useconst = xml_utils.search_xpath(xml_idinfo, 'useconst') if useconst is not None: self.useconst._from_xml(useconst) ptcontac = xml_utils.search_xpath(xml_idinfo, 'ptcontac') if ptcontac is not None: self.ptcontac._from_xml(ptcontac) datacred = xml_utils.search_xpath(xml_idinfo, 'datacred') if datacred is not None: self.datacredit._from_xml(datacred)
class IdInfo(WizardWidget): drag_label = "Identification Information <idinfo>" acceptable_tags = ['idinfo'] ui_class = UI_IdInfo.Ui_fgdc_idinfo def __init__(self, root_widget=None, parent=None): super(self.__class__, self).__init__(parent=parent) self.schema = 'bdp' self.root_widget = root_widget self.scroll_area = self.ui.idinfo_scroll_area def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.ptcontac = ContactInfoPointOfContact(parent=self) self.taxonomy = Taxonomy(parent=self) self.keywords = Keywords(parent=self) self.accconst = Accconst(parent=self) self.useconst = Useconst(parent=self) self.status = Status(parent=self) self.timeperd = Timeperd(parent=self) self.citation = Citeinfo(parent=self) self.citation.ui.btn_import_doi.hide() self.datacredit = Datacred(parent=self) self.descript = Descript(parent=self) self.purpose = Purpose(parent=self) self.supplinf = SupplInf(parent=self) self.native = Native(parent=self) self.ui.fgdc_citation.layout().addWidget(self.citation) #bottom to top in layout time_hbox = QHBoxLayout() time_hbox.addWidget(self.status) time_hbox.addWidget(self.timeperd) self.ui.two_column_left.layout().insertWidget(0, self.native) self.ui.two_column_left.layout().insertLayout(0, time_hbox) self.ui.two_column_left.layout().insertWidget(0, self.datacredit) self.ui.two_column_left.layout().insertWidget(0, self.taxonomy) self.ui.two_column_left.layout().insertWidget(0, self.ptcontac) self.ui.two_column_left.layout().insertWidget(0, self.useconst) self.ui.two_column_left.layout().insertWidget(0, self.accconst) self.ui.two_column_right.layout().insertWidget(0, self.supplinf) self.ui.two_column_right.layout().insertWidget(0, self.keywords) self.ui.two_column_right.layout().insertWidget(0, self.purpose) self.ui.two_column_right.layout().insertWidget(0, self.descript) self.crossref_list = Crossref_list() self.ui.help_crossref.layout().addWidget(self.crossref_list) def children(self): return super(IdInfo, self).children() + [self.root_widget.spatial_tab.spdom] def switch_schema(self, schema): self.schema = schema if schema == 'bdp': self.taxonomy.show() else: self.taxonomy.hide() def clear_widget(self): self.root_widget.spatial_tab.spdom.clear_widget() self.taxonomy.clear_widget() self.taxonomy.ui.rbtn_no.setChecked(True) WizardWidget.clear_widget(self) def to_xml(self): # add code here to translate the form into xml representation idinfo_node = xml_utils.xml_node('idinfo') citation_node = xml_utils.xml_node('citation', parent_node=idinfo_node) citeinfo_node = self.citation.to_xml() citation_node.append(citeinfo_node) idinfo_node.append(citation_node) descript_node = xml_utils.xml_node('descript', parent_node=idinfo_node) abstract_node = self.descript.to_xml() descript_node.append(abstract_node) purpose_node = self.purpose.to_xml() descript_node.append(purpose_node) supplinf_node = self.supplinf.to_xml() if supplinf_node.text is not None: descript_node.append(supplinf_node) idinfo_node.append(descript_node) timeperd_node = self.timeperd.to_xml() idinfo_node.append(timeperd_node) status_node = self.status.to_xml() idinfo_node.append(status_node) if self.root_widget.use_spatial: spdom_node = self.root_widget.spatial_tab.spdom.to_xml() idinfo_node.append(spdom_node) keywords = self.keywords.to_xml() idinfo_node.append(keywords) if self.schema == 'bdp' and self.taxonomy.has_content(): taxonomy = self.taxonomy.to_xml() idinfo_node.append(taxonomy) accconst_node = self.accconst.to_xml() idinfo_node.append(accconst_node) useconst_node = self.useconst.to_xml() idinfo_node.append(useconst_node) if self.ptcontac.has_content(): ptcontac = self.ptcontac.to_xml() idinfo_node.append(ptcontac) if self.original_xml is not None: browse = xml_utils.search_xpath(self.original_xml, 'browse') if browse is not None: browse.tail = None idinfo_node.append(deepcopy(browse)) datacredit_node = self.datacredit.to_xml() if datacredit_node.text: idinfo_node.append(datacredit_node) if self.original_xml is not None: secinfo = xml_utils.search_xpath(self.original_xml, 'secinfo') if secinfo is not None: secinfo.tail = None idinfo_node.append(deepcopy(secinfo)) if self.native.has_content(): idinfo_node.append(self.native.to_xml()) if self.crossref_list.has_content(): for crossref in self.crossref_list.get_children(): idinfo_node.append(crossref.to_xml()) if self.original_xml is not None: tools = xml_utils.search_xpath(self.original_xml, 'tool', only_first=False) for tool in tools: tool.tail = None idinfo_node.append(deepcopy(tool)) return idinfo_node def from_xml(self, xml_idinfo): self.original_xml = xml_idinfo citation = xml_utils.search_xpath(xml_idinfo, 'citation') if citation is not None: self.citation.from_xml(citation) abstract = xml_utils.search_xpath(xml_idinfo, 'descript/abstract') if abstract is not None: self.descript.from_xml(abstract) purpose = xml_utils.search_xpath(xml_idinfo, 'descript/purpose') if purpose is not None: self.purpose.from_xml(purpose) supplinf = xml_utils.search_xpath(xml_idinfo, 'descript/supplinf') if supplinf is not None: self.supplinf.from_xml(supplinf) timeperd = xml_utils.search_xpath(xml_idinfo, 'timeperd') if timeperd is not None: self.timeperd.from_xml(timeperd) status = xml_utils.search_xpath(xml_idinfo, 'status') if status is not None: self.status.from_xml(status) spdom = xml_utils.search_xpath(xml_idinfo, 'spdom') if spdom is not None: self.root_widget.spatial_tab.spdom.from_xml(spdom) keywords = xml_utils.search_xpath(xml_idinfo, 'keywords') if keywords is not None: self.keywords.from_xml(keywords) taxonomy = xml_utils.search_xpath(xml_idinfo, 'taxonomy') if taxonomy is not None: self.taxonomy.from_xml(taxonomy) accconst = xml_utils.search_xpath(xml_idinfo, 'accconst') if accconst is not None: self.accconst.from_xml(accconst) useconst = xml_utils.search_xpath(xml_idinfo, 'useconst') if useconst is not None: self.useconst.from_xml(useconst) ptcontac = xml_utils.search_xpath(xml_idinfo, 'ptcontac') if ptcontac is not None: self.ptcontac.from_xml(ptcontac) datacred = xml_utils.search_xpath(xml_idinfo, 'datacred') if datacred is not None: self.datacredit.from_xml(datacred) native = xml_utils.search_xpath(xml_idinfo, 'native') if native is not None: self.native.from_xml(native) crossref = xml_utils.search_xpath(xml_idinfo, 'crossref') if crossref is not None: self.crossref_list.from_xml(xml_idinfo)
class IdInfo(WizardWidget): drag_label = "Identification Information <idinfo>" # This dictionary provides a mechanism for crosswalking between # gui elements (pyqt widgets) and the xml document xpath_lookup = {'cntper': 'cntinfo/cntperp/cntper', 'cntorg': 'cntinfo/cntperp/cntorg', 'cntpos': 'cntinfo/cntpos',} ui_class = UI_IdInfo.Ui_fgdc_idinfo def __init__(self, root_widget=None): super(self.__class__, self).__init__() self.schema = 'bdp' self.root_widget = root_widget def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.ptcontac = ContactInfoPointOfContact(parent=self) self.taxonomy = Taxonomy(parent=self) self.keywords = Keywords(parent=self) self.accconst = AccessConstraints(parent=self) self.useconst = UseConstraints(parent=self) self.status = Status(parent=self) self.timeperd = Timeperd(parent=self) self.citation = Citation(parent=self) self.datacredit = DataCredit(parent=self) self.abstract = Abstract(parent=self) self.purpose = Purpose(parent=self) self.supplinf = SupplInf(parent=self) self.ui.fgdc_citation.layout().addWidget(self.citation) #bottom to top in layout time_hbox = QHBoxLayout() time_hbox.addWidget(self.status) time_hbox.addWidget(self.timeperd) self.ui.two_column_left.layout().insertLayout(0, time_hbox) self.ui.two_column_left.layout().insertWidget(0, self.datacredit) self.ui.two_column_left.layout().insertWidget(0, self.taxonomy) self.ui.two_column_left.layout().insertWidget(0, self.ptcontac) self.ui.two_column_left.layout().insertWidget(0, self.useconst) self.ui.two_column_left.layout().insertWidget(0, self.accconst) self.ui.two_column_right.layout().insertWidget(0, self.supplinf) self.ui.two_column_right.layout().insertWidget(0, self.keywords) self.ui.two_column_right.layout().insertWidget(0, self.purpose) self.ui.two_column_right.layout().insertWidget(0, self.abstract) def dragEnterEvent(self, e): """ Parameters ---------- e : qt event Returns ------- """ print("idinfo drag enter") mime_data = e.mimeData() if e.mimeData().hasFormat('text/plain'): parser = etree.XMLParser(ns_clean=True, recover=True, encoding='utf-8') element = etree.fromstring(mime_data.text(), parser=parser) if element.tag == 'idinfo': e.accept() else: e.ignore() def children(self): return super(IdInfo, self).children() + [self.root_widget.spatial_tab.spdom] def switch_schema(self, schema): self.schema = schema if schema == 'bdp': self.taxonomy.show() else: self.taxonomy.hide() self.citation.switch_schema(self.schema) def _to_xml(self): # add code here to translate the form into xml representation idinfo_node = xml_utils.xml_node('idinfo') citation_node = xml_utils.xml_node('citation', parent_node=idinfo_node) citeinfo_node = self.citation._to_xml() citation_node.append(citeinfo_node) idinfo_node.append(citation_node) descript_node = xml_utils.xml_node('descript', parent_node=idinfo_node) abstract_node = self.abstract._to_xml() descript_node.append(abstract_node) purpose_node = self.purpose._to_xml() descript_node.append(purpose_node) supplinf_node = self.supplinf._to_xml() if supplinf_node.text is not None: descript_node.append(supplinf_node) idinfo_node.append(descript_node) timeperd_node = self.timeperd._to_xml() idinfo_node.append(timeperd_node) status_node = self.status._to_xml() idinfo_node.append(status_node) spdom_node = self.root_widget.spatial_tab.spdom._to_xml() idinfo_node.append(spdom_node) keywords = self.keywords._to_xml() idinfo_node.append(keywords) if self.schema == 'bdp' and self.taxonomy.has_content(): taxonomy = self.taxonomy._to_xml() idinfo_node.append(taxonomy) accconst_node = self.accconst._to_xml() idinfo_node.append(accconst_node) useconst_node = self.useconst._to_xml() idinfo_node.append(useconst_node) datacredit_node = self.datacredit._to_xml() if len(datacredit_node.text): idinfo_node.append(datacredit_node) if self.ptcontac.has_content(): ptcontac = self.ptcontac._to_xml() idinfo_node.append(ptcontac) datacredit_node = self.datacredit._to_xml() if datacredit_node.text: idinfo_node.append(datacredit_node) return idinfo_node def _from_xml(self, xml_idinfo): try: citation = xml_idinfo.xpath('citation')[0] self.citation._from_xml(citation) except IndexError: pass try: abstract = xml_idinfo.xpath('descript/abstract')[0] self.abstract._from_xml(abstract) except IndexError: pass try: purpose = xml_idinfo.xpath('descript/purpose')[0] self.purpose._from_xml(purpose) except IndexError: pass try: supplinf = xml_idinfo.xpath('descript/supplinf')[0] self.supplinf._from_xml(supplinf) except IndexError: pass try: timeperd = xml_idinfo.xpath('timeperd')[0] self.timeperd._from_xml(timeperd) except IndexError: pass try: status = xml_idinfo.xpath('status')[0] self.status._from_xml(status) except IndexError: pass try: spdom = xml_idinfo.xpath('spdom')[0] self.root_widget.spatial_tab.spdom._from_xml(spdom) except IndexError: pass try: keywords = xml_idinfo.xpath('keywords')[0] self.keywords._from_xml(keywords) except IndexError: pass try: taxonomy = xml_idinfo.xpath('taxonomy')[0] self.taxonomy._from_xml(taxonomy) except IndexError: pass try: accconst = xml_idinfo.xpath('accconst')[0] self.accconst._from_xml(accconst) except IndexError: pass try: useconst = xml_idinfo.xpath('useconst')[0] self.useconst._from_xml(useconst) except IndexError: pass try: ptcontac = xml_idinfo.xpath('ptcontac')[0] self.ptcontac._from_xml(ptcontac) except IndexError: pass