Author: aschnell Date: Thu Jun 19 11:50:06 2008 New Revision: 48418 URL: http://svn.opensuse.org/viewcvs/yast?rev=48418&view=rev Log: - work on size input Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp?rev=48418&r1=48417&r2=48418&view=diff ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp Thu Jun 19 11:50:06 2008 @@ -104,7 +104,7 @@ integer max_size = data["max_size"]:0; integer stripes = data["stripes"]:1; - integer stripe_size = data["stripesize"]:64; + integer stripe_size = data["stripesize"]:64*1024; string tmp = Storage::ByteToHumanString(max_size); @@ -123,20 +123,18 @@ ))); - list<term> stripes_list = maplist(integer i, Integer::Range(8), { - integer j = i + 1; - return `item(`id(j), tostring(j), stripes == j); - }); - - list<term> stripe_sizes_list = maplist(integer i, Integer::Range(8), { - integer j = 2 << (i + 1); - return `item(`id(j), Storage::ByteToHumanStringWithPrecision(j*1024, 2, true), stripe_size == j); - }); + list<term> stripes_list = maplist(integer i, Integer::RangeFrom(1, 9), { + return `item(`id(i), tostring(i)); + }); + + list<term> stripe_sizes_list = maplist(integer i, Integer::RangeFrom(11, 20), { + return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true)); + }); frames = add(frames, `Frame("Stripes", `HBox( - `Left(`ComboBox(`id(`stripes), `opt(`notify), "Number", stripes_list)), - `Left(`ComboBox(`id(`stripe_size), "Size", stripe_sizes_list)), + `Left(`ComboBoxSelected(`id(`stripes), `opt(`notify), "Number", stripes_list, `id(stripes))), + `Left(`ComboBoxSelected(`id(`stripe_size), "Size", stripe_sizes_list, `id(stripe_size))), `HStretch()) ) ); Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp?rev=48418&r1=48417&r2=48418&view=diff ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp Thu Jun 19 11:50:06 2008 @@ -15,7 +15,7 @@ symbol mode = data["mode"]:`none; string vgname = ""; - string pesize = ""; + integer pesize = 4*1024*1024; list<string> pvs = []; @@ -66,8 +66,12 @@ if (mode == `create) { + list<term> pesizes_list = maplist(integer i, Integer::RangeFrom(19, 26), { + return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true)); + }); + contents = add(contents, `Left(`InputField(`id("vgname"), "Volume Group Name"))); - contents = add(contents, `Left(`InputField(`id("pesize"), _("&Physical Extent Size"), "4 MB"))); + contents = add(contents, `Left(`ComboBoxSelected(`id("pesize"), `opt(`editable), _("&Physical Extent Size"), pesizes_list, `id(pesize)))); } contents = add(contents, DualMultiSelectionBox::Create(candidates_list)); @@ -90,19 +94,39 @@ { UpdateTotalSizes(); } - else if (widget == `next) - { - vgname = deletechars((string) UI::QueryWidget(`id("vgname"), `Value), " \t"); - pesize = (string) UI::QueryWidget(`id("pesize"), `Value); - list<term> tmp1 = DualMultiSelectionBox::GetSelectedItems(); - list<map> candidates_selected = filter(map candidate, candidates, { - any id = `id(candidate["device"]:""); - return find (term t, tmp1, { return t[0]:nil == id; }) != nil; - }); - pvs = maplist(map candidate, candidates_selected, { return candidate["device"]:""; }); - - // TODO: checks + switch (widget) + { + case `next: + { + vgname = (string) UI::QueryWidget(`id("vgname"), `Value); + + any tmp = UI::QueryWidget(`id("pesize"), `Value); + if (is(tmp, string)) + pesize = pesize_str_to_byte((string) tmp); + else + pesize = (integer) tmp; + + list<term> tmp1 = DualMultiSelectionBox::GetSelectedItems(); + list<map> candidates_selected = filter(map candidate, candidates, { + any id = `id(candidate["device"]:""); + return find (term t, tmp1, { return t[0]:nil == id; }) != nil; + }); + pvs = maplist(map candidate, candidates_selected, { return candidate["device"]:""; }); + + // TODO: checks + + if (pesize == 0) + { + // error popup text + Popup::Error(_("The data entered is invalid. +Insert a physical extent size from 8kB to 512MB +in powers of 2, for example, \"4MB\" or \"512kB\" +")); + widget = `again; + } + } + break; } } until (widget == `abort || widget == `back || widget == `next); @@ -138,8 +162,7 @@ if (widget == `finish) { - if (Storage::CreateLvmVgWithDevs(data["vgname"]:"error", - pesize_str_to_byte(data["pesize"]:""), true, + if (Storage::CreateLvmVgWithDevs(data["vgname"]:"error", data["pesize"]:0, true, data["pvs"]:[])) { UpdateNavigationTree(nil); Modified: branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp?rev=48418&r1=48417&r2=48418&view=diff ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp Thu Jun 19 11:50:06 2008 @@ -15,8 +15,9 @@ * */ - { - +{ + import "Integer"; + include "partitioning/partition_defines.ycp"; include "partitioning/signatures.ycp"; @@ -56,35 +57,17 @@ // // return "0" if input is invalid // -// pesize is valid 8K to 512M in power of 2 -// 8 is 8k -// 16K == 16k == 16KB == 16kb -define integer pesize_str_to_byte( string input ) - ``{ - integer num = kmgt_str_to_byte( input ); - if( findfirstnotof( input, "0123456789 " ) == nil ) - num = num*1024; +// pesize is valid 8kB to 512MB in power of 2 +define integer pesize_str_to_byte(string input) +{ + integer ret = kmgt_str_to_byte(input); - integer ret = num; - - if( ret % 1024 != 0 ) + if (!Integer::IsPowerOfTwo(ret)) ret = 0; - else - { - while( num>1 && ret>0 ) - { - if( num%2 != 0 ) - ret = 0; - else - num = num/2; - } - } - if( ret < 8*1024 || ret > 524288*1024 ) - { + else if (ret < 8*1024 || ret > 512*1024*1024) ret = 0; - } - return( ret ); - }; + return ret; +}; ////////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org