ó Ö@Qc@s5ddlZddlZdejfd„ƒYZdS(iÿÿÿÿNtDatabaseSchemaSelectorcBsVeZdZd„id„Zd„Zd„Zd„Zd„Zd„Zd„Z RS( sqWidget to select database schemata within a collection of catalogs (optional) and schemata This wigdet will help you to display a set of schemata in a nice tree structure, grouping them by catalogs (if the catalog information is supported/available). Next to each listed schema is a checkbox for the selection/unselection of the schema. The user can quickly select all of the schemata for a given catalog by clicking on the checkbox next to the catalog name. .. image:: ../../../library/python/workbench/doc/images/schema_selection_widget.png :param database_objects: Pass a list/tuple of schema names if you don't use catalogs. If you do use catalogs then pass a list of tuples of the form ``(catalog_name, schema_list)`` where :attr:`schema_list` is a list/tuple with the schemata that belongs to the given :attr:`catalog_name`. :type database_objects: list/tuple :param tree_checked_callback: A function object that will be called by this widget whenever a schema is checked/unchecked. It should accept an integer argument with the number of selected schemata. :type tree_checked_callback: callable :param ui_settings: A dictionary to customize the appearance of the widget. In case you need to customize something, just pass the relevant modifications in this dict. The other (default) settings are kept. Check the definition of :attr:`self.ui_settings` in the class implementation to see the configurable settings. :type ui_settings: dict .. rubric:: Sample usage: :: db_objects = [ ('catalog1', ('schema1', 'schema2')), ('catalog2', ('schema3', 'schema4')) ] content = mforms.newBox() object_selector = DatabaseObjectSelector(db_objects) content.add(object_selector, True) cCsdS(N(tNone(tn((s/..\workbench\database_schema_selector_widget.pyt?scCsTtt|ƒjtƒ||_||_iidd6td6d6idd6d6idd6td 6td 6d 6|_t|t ƒrØxV|j ƒD]E\}}||jksŒt|t ƒ r½qŒn|j|j |ƒqŒWnt|t t fƒot|ƒd kotd „|Dƒƒ|_|jrLt d„|Dƒƒ|_t |ƒ|_nd|_||_g|_g|_|jdƒtjtjƒ|_|jjtjddtƒ|jjtj|jrÌdnddtƒ|jjƒ|jj|j ƒ|jj!tƒ|j"|jttƒtj#tƒ}|jdƒtj$dƒ|_%|j"|j%ttƒ|jd d rËtj&ƒ|_'|j'j(dƒ|j'j)t*j+|j,dtƒƒ|j-|j'tƒn|jd d r3tj&ƒ|_.|j.j(dƒ|j.j)t*j+|j,dtƒƒ|j-|j.tƒn|j"|ttƒ|j/ƒdS(sConstructor. s"workbench.physical.Layer.16x16.pngticont should_expandtcatalogssdb.Schema.16x16.pngtschemass%(nSchemata)d schemata selectedt summary_texttshow_select_all_buttontshow_unselect_all_buttontgeneralicssh|]^}t|ttfƒo_t|ƒdko_t|dttfƒo_t|dttfƒVqdS(iiiN(t isinstancetlistttupletlentstrtunicode(t.0titem((s/..\workbench\database_schema_selector_widget.pys \scss|]}|dVqdS(iN((RR((s/..\workbench\database_schema_selector_widget.pys esitIncludei<sCatalog/SchematSchemai,i ts Unselect Alltcheckeds Select AllN(0tsuperRt__init__tFalsetdatabase_objectsttree_checked_callbacktTruet ui_settingsR tdictt iteritemstupdateR RRtallt use_catalogst _catalogst _schemataRt _schema_nodest_catalog_nodest set_spacingtmformstnewTreeNodeViewt TreeDefaulttschema_list_treet add_columntCheckColumnTypetIconColumnTypet end_columnstset_cell_edited_callbackt_schema_tree_checkedtset_allow_sortingtaddtnewBoxtnewLabeltselect_summary_labelt newButtontunselect_all_btntset_texttadd_clicked_callbackt functoolstpartialt_mark_all_schematatadd_endtselect_all_btnt_fill_schema_tree(tselfRRRtkeytvaluethelper_buttons_box((s/..\workbench\database_schema_selector_widget.pyR?sd            +  ""cCsàg|_g|_|jr;x˜|jD]}|jjƒ}|jdtƒ|jd|j ddƒ|j d|ƒ|j |ƒ|jj |ƒx|j |D]r}|jƒ}|jdtƒ|jd|j ddƒ|j d|ƒ|j |d|ƒ|jj |ƒq W|j ddr%|jƒq%q%Wn{xx|j D]m}|jjƒ}|jdtƒ|jd|j ddƒ|j d|ƒ|j |ƒ|jj |ƒqEW|jj|j dd idd 6ƒdS( NiiRRRt.RR Rt nSchemata(R&R'R#R$R,tadd_nodetset_boolRt set_icon_pathRt set_stringtset_tagtappendR%t add_childtexpandR7R:(RBt catalog_namet catalog_nodet schema_namet schema_node((s/..\workbench\database_schema_selector_widget.pyRAs6      c s†t|tƒs|g}nx|D] }|dkr"|dk}|jd|ƒ|jr,|jƒ‰ˆ|jjƒk}|r|jdƒn ˆjdƒ}t|j |ƒ}|rêxlt |ƒD]} |j | ƒjd|ƒqÄWq)ˆjd|o"t d„‡fd†t |ƒDƒDƒƒƒq,q"q"Wtt d„|jDƒƒƒ} |jj|jddi| d 6ƒ|j| ƒdS( Nit1icss|]}|jdƒVqdS(iN(tget_bool(RRS((s/..\workbench\database_schema_selector_widget.pys Ãsc3s|]}ˆj|ƒVqdS(N(t get_child(Rtidx(t parent_node(s/..\workbench\database_schema_selector_widget.pys Ãscss$|]}|jdƒr|VqdS(iN(RU(RRS((s/..\workbench\database_schema_selector_widget.pys ÅsR RRG(R R RIR#t get_parentR,t root_nodet get_stringRR%trangeRVR"RR&R7R:RR( RBt node_listtcoltdatatnodeRt is_catalogRPt schema_countRWtselected_schema_count((RXs/..\workbench\database_schema_selector_widget.pyR2±s$      $ F&cCsµ|jryi}xc|jD]X}|jdƒ|kr:qn|jƒjdƒ\}}}|j|gƒj|ƒqW|Sg|jD]*}|jdƒ|krƒ|jdƒ^qƒSdS(NiRFi(R#R&RUtget_tagt partitiont setdefaultRMR[(RBRtcatalog_schemataRSRPtdotRR((s/..\workbench\database_schema_selector_widget.pyt_select_objectsÉs cCs |jtƒS(N(RiR(RB((s/..\workbench\database_schema_selector_widget.pyt get_selectedÕscCs |jtƒS(N(RiR(RB((s/..\workbench\database_schema_selector_widget.pyt get_ignoredØscCs>|jr|jn|j}|j|d|r3dndƒdS(NiRTt0(R#R'R&R2(RBRtnodes((s/..\workbench\database_schema_selector_widget.pyR>Ûs( t__name__t __module__t__doc__RRAR2RiRjRkR>(((s/..\workbench\database_schema_selector_widget.pyRs'Q !   (R<R)tBoxR(((s/..\workbench\database_schema_selector_widget.pyts