[yast-commit] r59582 - in /trunk/autoinstallation: doc/RulesAndClasses.xml package/autoyast2.changes src/modules/AutoInstallRules.ycp
Author: ug Date: Tue Nov 17 16:23:37 2009 New Revision: 59582 URL: http://svn.opensuse.org/viewcvs/yast?rev=59582&view=rev Log: dialogs for rules added Modified: trunk/autoinstallation/doc/RulesAndClasses.xml trunk/autoinstallation/package/autoyast2.changes trunk/autoinstallation/src/modules/AutoInstallRules.ycp Modified: trunk/autoinstallation/doc/RulesAndClasses.xml URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/doc/RulesAndClasses.xml?rev=59582&r1=59581&r2=59582&view=diff ============================================================================== --- trunk/autoinstallation/doc/RulesAndClasses.xml (original) +++ trunk/autoinstallation/doc/RulesAndClasses.xml Tue Nov 17 16:23:37 2009 @@ -482,8 +482,146 @@ </tgroup> </table> </section> + <section id="rules_dialogs"> + <title>Rules with Dialogs</title> + <para> + Since openSUSE 11.3 (not SLES11 SP1) you can use dialog popups where you can select which rules you want to match and which not by checkboxes. + </para> + <para> + The following elements must be between the <rules config:type="list"><rule><dialog> ... </dialog></rule></rules> tags in the rules.xml file. + </para> + <table frame='top'> + <tgroup cols="3"> + <thead> + <row> + <entry>Attribute</entry> + <entry>Values</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>dialog_nr</entry> + <entry>all rules with the same dialog_nr are presented on the same popup dialog so the same dialog_nr can appear in multiple rules. + <para><screen><dialog_nr config:type="integer">3</dialog_nr></screen></para> + </entry> + <entry>This element is optional and the default for a missing dialog_nr is always "0". If you have one popup only anyway, you don't need to specify the dialog_nr</entry> + </row> + <row> + <entry>element</entry> + <entry>each element needs a uniq id. Even if you have more than one dialog, you must not use the same id twice like an id "1" on dialog 1 and and id "1" on dialog 2. That's different than with <ask> dialogs, where you can have the same <element> id on multiple dialogs. + <para><screen><element config:type="integer">3</element></screen></para> + </entry> + <entry>optional. If left out, autoyast adds his own id's internally but you can't use conflicts then (see below)</entry> + </row> + <row> + <entry>title</entry> + <entry>the caption of the popup dialog + <para><screen><title>Desktop Selection</title></screen></para> + </entry> + <entry>optional</entry> + </row> + <row> + <entry>question</entry> + <entry>the question text is shown in the popup behind the checkbox. + <para><screen><question>KDE Desktop</question></screen></para> + </entry> + <entry>optional. If you don't configure a text here, the name of the XML file that is triggered by this rule will be shown instead.</entry> + </row> + <row> + <entry>timeout</entry> + <entry>a timeout in seconds after which the dialog will automatically "press" the okay button. Useful for a non blocking installation in combination with rules-dialogs. + <para><screen><timeout config:type="integer">30</timeout></screen></para> + </entry> + <entry>optional. A missing timeout will stop the installation process until the dialog is confirmed by the user.</entry> + </row> + <row> + <entry>conflicts</entry> + <entry>a list of element id's (rules) that conflict with this rule. If this rule matches or is selected by the user, all conflicting rules are deselected and disabled in the popup. Take care that you don't create deadlocks. + <para><screen><conflicts config:type="list"> + <element config:type="integer">1</element> + <element config:type="integer">5</element> + ... +</conflicts></screen></para> + </entry> + <entry>optional</entry> + </row> + </tbody> + </tgroup> + </table> + <para> + Here is an example of how to use dialogs with rules: + </para> + <para> + <screen> +<![CDATA[ + <rules config:type="list"> + <rule> + <custom1> + <script> +echo -n 100 + </script> + <match>100</match> + <match_type>exact</match_type> + </custom1> + <result> + <profile>rules/kde.xml</profile> + <continue config:type="boolean">true</continue> + </result> + <dialog> + <element config:type="integer">0</element> + <question>KDE Desktop</question> + <title>Desktop Selection</title> + <conflicts config:type="list"> + <element config:type="integer">1</element> + </conflicts> + <dialog_nr config:type="integer">0</dialog_nr> + </dialog> + </rule> + <rule> + <custom1> + <script> +echo -n 100 + </script> + <match>101</match> + <match_type>exact</match_type> + </custom1> + <result> + <profile>rules/gnome.xml</profile> + <continue config:type="boolean">true</continue> + </result> + <dialog> + <element config:type="integer">1</element> + <dialog_nr config:type="integer">0</dialog_nr> + <question>Gnome Desktop</question> + <conflicts config:type="list"> + <element config:type="integer">0</element> + </conflicts> + </dialog> + </rule> + <rule> + <custom1> + <script> +echo -n 100 + </script> + <match>100</match> + <match_type>exact</match_type> + </custom1> + <result> + <profile>rules/all_the_rest.xml</profile> + <continue config:type="boolean">false</continue> + </result> + </rule> + </rules> +]]> + </screen> + </para> </section> - + </section> + + + + <section id="classes"> <title>Classes</title> <para> Modified: trunk/autoinstallation/package/autoyast2.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/package/autoyast2.changes?rev=59582&r1=59581&r2=59582&view=diff ============================================================================== --- trunk/autoinstallation/package/autoyast2.changes (original) +++ trunk/autoinstallation/package/autoyast2.changes Tue Nov 17 16:23:37 2009 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Tue Nov 17 11:35:10 CET 2009 - ug@suse.de + +- dialogs for rules added + +------------------------------------------------------------------- Wed Nov 11 10:39:13 CET 2009 - ug@suse.de - added CLI to clone_system Modified: trunk/autoinstallation/src/modules/AutoInstallRules.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/autoinstallation/src/modules/AutoInstallRules.ycp?rev=59582&r1=59581&r2=59582&view=diff ============================================================================== --- trunk/autoinstallation/src/modules/AutoInstallRules.ycp (original) +++ trunk/autoinstallation/src/modules/AutoInstallRules.ycp Tue Nov 17 16:23:37 2009 @@ -602,6 +602,114 @@ }); } }); + + list<integer> dialogOrder = []; + + foreach( map<string, map> rule, rulelist, ``{ + if( haskey(rule, "dialog") && ! contains( dialogOrder, rule["dialog","dialog_nr"]:0 ) ) + dialogOrder = add( dialogOrder, rule["dialog","dialog_nr"]:0 ); + }); + dialogOrder = sort( dialogOrder ); + + integer dialogIndex = 0; + while( dialogIndex <= size(dialogOrder)-1 ) { + integer dialogNr = dialogOrder[dialogIndex]:0; + term dialog_term = `VBox(); + integer element_nr = 0; + integer timeout = 0; + string title = "Choose XML snippets to merge"; + map<integer,integer> conflictsCounter = $[]; + foreach ( map<string, map> rule, rulelist, ``{ + if( haskey( rule, "dialog" ) ) { + string file = rule["result","profile"]:""; + if( contains(tomerge, file) ) { + foreach( integer c, rule["dialog","conflicts"]:[], ``{ + conflictsCounter[c] = conflictsCounter[c]:0 + 1; + }); + } + } + }); + + map<integer,string> element2file = $[]; + + foreach ( map<string, map> rule, rulelist, ``{ + if( haskey( rule, "dialog" ) && rule["dialog","dialog_nr"]:0 == dialogNr ) { + element_nr = rule["dialog","element"]:element_nr; + title = rule["dialog","title"]:title; + string file = rule["result","profile"]:""; + element2file[element_nr] = file; + boolean on = ( contains(tomerge, file) ? true : false ); + term button = `Left( `CheckBox(`id(element_nr), `opt(`notify), rule["dialog","question"]:file, on ) ); + timeout = rule["dialog","timeout"]:0; + dialog_term = add( dialog_term, button ); + element_nr = element_nr + 1; + } + }); + + if( element_nr > 0 ) { + UI::OpenDialog( `opt( `decorated ), + `VBox( + `Label( title ), + `VSpacing(1), + dialog_term, + `VSpacing(1), + `HBox( + `HStretch(), + `PushButton(`id(`back), "Back" ), + `PushButton(`id(`ok), "Okay" ) + ) + ) + ); + if( dialogIndex == 0 ) + UI::ChangeWidget(`id(`back) , `Enabled, false); + foreach( integer c, integer n, conflictsCounter, ``{ + UI::ChangeWidget(`id(c) , `Enabled, n>0 ? false : true ); + UI::ChangeWidget(`id(c) , `Value, n>0 ? false : true ); + }); + while (true) { + any ret = nil; + if( timeout == 0 ) + ret = UI::UserInput(); + else + ret = UI::TimeoutUserInput( timeout * 1000 ); + timeout = 0; + element_nr = 0; + if( ret == `ok || ret == `timeout || ret == `back ) { + if( ret == `back ) + dialogIndex = dialogIndex - 2; + break; + } else { + if( (boolean)(UI::QueryWidget(`id(ret), `Value)) ) { + tomerge = add( tomerge, element2file[tointeger(ret)]:"" ); + } else { + string file = element2file[tointeger(ret)]:""; + tomerge = filter (string f , tomerge, { return file != f; }); + } + list<integer> conflicts = rulelist[tointeger(ret),"dialog","conflicts"]:[]; + foreach( integer element, conflicts, ``{ + if( (boolean)(UI::QueryWidget(`id(ret), `Value)) ) + conflictsCounter[element] = conflictsCounter[element]:0 + 1; + else if( conflictsCounter[element]:0 > 0 ) + conflictsCounter[element] = conflictsCounter[element]:0 - 1; + }); + foreach( integer e, integer v, conflictsCounter, ``{ + if( v > 0 ) { + UI::ChangeWidget(`id(e) , `Enabled, false); + UI::ChangeWidget(`id(e) , `Value, false ); + } else { + UI::ChangeWidget(`id(e) , `Enabled, true); + } + }); + } + y2milestone("tomerge is now = %1", tomerge); + y2milestone("conflictsCounter is now = %1", conflictsCounter); + } + UI::CloseDialog(); + dialogIndex = dialogIndex + 1; + } + y2milestone("changing rules to merge to %1 because of user selection", tomerge); + } + return; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
ug@svn.opensuse.org