Author: kmachalkova
Date: Tue Jul 1 17:55:52 2008
New Revision: 48740
URL: http://svn.opensuse.org/viewcvs/yast?rev=48740&view=rev
Log:
Feeding webpin search results to UI (backup commit)
Modified:
trunk/packager/src/clients/webpin_package_search.ycp
Modified: trunk/packager/src/clients/webpin_package_search.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/clients/webpin_package_search.ycp?rev=48740&r1=48739&r2=48740&view=diff
==============================================================================
--- trunk/packager/src/clients/webpin_package_search.ycp (original)
+++ trunk/packager/src/clients/webpin_package_search.ycp Tue Jul 1 17:55:52 2008
@@ -1,9 +1,15 @@
{
textdomain "packager";
- import "Wizard";
+ import "Label";
+ import "Popup";
import "Progress";
import "Sequencer";
+ import "WebpinPackageSearch";
+ import "Wizard";
+
+ list <map> search_results = [];
+ map index = $[];
boolean AbortFunction() {
any ret = UI::PollInput();
@@ -14,10 +20,59 @@
return false;
}
+ term CreateSummary() {
+ string repo_heading = _("<h1>The following repositories will be added:</h1>");
+ string pkg_heading = _("<h1>The following packages will be installed:</h1>");
+ return `RichText(`id(`summary), repo_heading + pkg_heading);
+ }
+
+ string SearchExpression() {
+ string ret = (string) UI::QueryWidget(`id("search_text"), `Value);
+
+ if (ret == "") {
+ Popup::Message(_("Search expression must not be empty!"));
+ UI::SetFocus(`id("search_text"));
+ }
+ return ret;
+ }
+
+ map SearchParameters() {
+ list p = (list) UI::QueryWidget(`id("search_in"), `SelectedItems);
+
+ map ret = listmap ( string key, [ "name", "description", "contents" ], {
+ return $[ key : contains (p, key)];
+ });
+ //y2internal("%1", ret);
+ return ret;
+ }
+
+ void CreatePackageDescription( ) {
+ string checksum = (string) UI::QueryWidget(`id("results"), `CurrentItem );
+ map citem = search_results [ index[checksum]: 0 ]: $[];
+
+ string descr = sformat(_("<b>Repository URL:</b> %1<br>"), citem["repoURL"]:"");
+ string version = sformat(_("<b>Version</b> %1<br>"), citem["version"]:"");
+
+ UI::ChangeWidget(`id("description"),`Value, descr+version);
+ }
+
+ list CreatePackageList( list < map > results ) {
+ list pkg_items = [];
+ integer i = 0;
+
+ foreach ( map it, results, {
+ pkg_items = add( pkg_items, `item(`id(it["checksum"]:""),it["name"]:"" + " - " + it["summary"]:"" ));
+ index = add( index, it["checksum"]:"", i);
+ i = i+1;
+ });
+ y2internal("%1", pkg_items);
+ return pkg_items;
+ }
+
symbol ReadDialog() {
list <string> steps = [
_("Check Network Configuration"),
- _("Initialize Package Manager (nebo tak neco")
+ _("Initialize Package Manager")
];
list <string> actions = [
@@ -55,13 +110,17 @@
`VBox(
`MinWidth(20, `TextEntry (`id ("search_text"), "Search &Expression")),
// TRANSLATORS: push button
- `Left(`PushButton (`id ("search"), `opt(`default), _("&Search"))),
+ `Left(`PushButton (`id ("search"), _("&Search"))),
`VStretch()
),
`MultiSelectionBox(
`id("search_in"),
_("Search in"),
- [ _("Name"), _("Description"), _("Contents") ]
+ [
+ `item( `id("name"),_("Name"), true ),
+ `item( `id("description"), _("Description"), true ),
+ `item( `id("contents"), _("Contents"))
+ ]
)//,
),
//`RadioButtonGroup(
@@ -90,7 +149,7 @@
`Left( `Label( _("Package Description")) ),
`VWeight(
1,
- `RichText(`id("description"), "Some very boring pkg descr")
+ `RichText(`id("description"), "")
)
),
_("Some very boring help text"),
@@ -99,22 +158,68 @@
true
);
- Wizard::SetNextButton(`next, _("Install"));
+ UI::SetFocus(`id("search_text"));
any dialog_ret = nil;
while (true) {
dialog_ret = UI::UserInput();
- break;
+ if (dialog_ret == `next)
+ break;
+ else if (dialog_ret == "search") {
+ string search_expr = SearchExpression();
+
+ if (search_expr != "") {
+ search_results =
+ WebpinPackageSearch::SearchForPackages(
+ search_expr,
+ nil,
+ SearchParameters()
+ );
+ list items = CreatePackageList( search_results );
+
+ if (items != nil) {
+ UI::ChangeWidget(`id("results"), `Items, items);
+ UI::SetFocus(`id("results"));
+ CreatePackageDescription();
+ }
+ }
+ else
+ continue;
+ }
+ else if (dialog_ret == "results") {
+ CreatePackageDescription();
+ }
}
-
return (symbol) dialog_ret;
}
+ symbol SummaryDialog() {
+ Wizard::SetContentsButtons(
+ _("Summary"),
+ CreateSummary(),
+ _("Some very boring help text"),
+ Label::BackButton(),
+ Label::FinishButton()
+ );
+
+ any sum_ret = nil;
+
+ while(true) {
+ sum_ret = UI::UserInput();
+ if (sum_ret == `next)
+ break;
+ }
+
+ return (symbol) sum_ret;
+ }
+
symbol MainSequence () {
map aliases = $[
"read" : ``( ReadDialog() ),
"main" : ``( MainDialog() ),
+ "summary" : ``(SummaryDialog() ),
+// "write" : ``(WriteDialog())
];
map sequence = $[
@@ -125,7 +230,16 @@
],
"main" : $[
`abort : `abort,
+ `next : "summary"
],
+ "summary" : $[
+ `abort : `abort,
+ `next : `next//"write"
+ ],
+// "write" : $[
+// `abort : `abort,
+// `next : `next
+// ],
];
any seq_ret = Sequencer::Run( aliases, sequence );
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org