Author: aschnell
Date: Fri Feb 6 11:07:17 2009
New Revision: 55291
URL: http://svn.opensuse.org/viewcvs/yast?rev=55291&view=rev
Log:
- handle rounding and precision in size input fields (bnc #466304)
- some cleanup
Modified:
trunk/storage/VERSION
trunk/storage/package/yast2-storage.changes
trunk/storage/storage/src/include/ep-dialogs.ycp
trunk/storage/storage/src/include/ep-hd-dialogs.ycp
trunk/storage/storage/src/include/ep-loop-dialogs.ycp
trunk/storage/storage/src/include/ep-lvm-dialogs.ycp
trunk/storage/storage/src/include/ep-raid-dialogs.ycp
trunk/storage/storage/src/modules/Storage.ycp
trunk/storage/storage/src/modules/StorageFields.ycp
Modified: trunk/storage/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/VERSION?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/VERSION (original)
+++ trunk/storage/VERSION Fri Feb 6 11:07:17 2009
@@ -1 +1 @@
-2.18.4
+2.18.5
Modified: trunk/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/package/yast2-storage.changes?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/package/yast2-storage.changes (original)
+++ trunk/storage/package/yast2-storage.changes Fri Feb 6 11:07:17 2009
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Fri Feb 06 11:04:35 CET 2009 - aschnell@suse.de
+
+- handle rounding and precision in size input fields (bnc #466304)
+- 2.18.5
+
+-------------------------------------------------------------------
Wed Feb 4 13:12:30 CET 2009 - jsrain@suse.cz
- updated proposal to allow user to say how to split disk space
Modified: trunk/storage/storage/src/include/ep-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-dialogs.ycp?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-dialogs.ycp Fri Feb 6 11:07:17 2009
@@ -754,16 +754,7 @@
case `custom_size:
{
string tmp = (string) UI::QueryWidget(`id(`custom_size_input), `Value);
- if (!Storage::HumanStringToKByte(tmp, size_k))
- {
- // error popup, %1 and %2 are replaced by sizes
- Popup::Error(sformat(_("The size entered is invalid. Enter a value like \"%1\" or \"%2\"."),
- Storage::KByteToHumanString(500*1024),
- Storage::KByteToHumanString(1024*1024)));
- widget = `again;
- continue;
- }
- else if (size_k < min_size_k || size_k > max_size_k)
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, max_size_k))
{
// error popup, %1 and %2 are replaced by sizes
Popup::Error(sformat(_("The size entered is invalid. Enter a size between %1 and %2."),
Modified: trunk/storage/storage/src/include/ep-hd-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-hd-dialogs.ycp?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-hd-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-hd-dialogs.ycp Fri Feb 6 11:07:17 2009
@@ -187,17 +187,7 @@
case `manual_size:
{
string tmp = (string) UI::QueryWidget(`id(`size_input), `Value);
- if (!Storage::HumanStringToKByte(tmp, size_k))
- {
- // error popup, %1 and %2 are replaced by sizes
- Popup::Error(sformat(_("The size entered is invalid. Enter a value like \"%1\" or \"%2\"."),
- Storage::KByteToHumanString(500*1024),
- Storage::KByteToHumanString(1024*1024)));
- UI::SetFocus(`id(`size_input));
- widget = `again;
- continue;
- }
- else if (size_k < min_size_k || size_k > max_size_k)
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, max_size_k))
{
// error popup, %1 and %2 are replaced by sizes
Popup::Error(sformat(_("The size entered is invalid. Enter a size between %1 and %2."),
Modified: trunk/storage/storage/src/include/ep-loop-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-loop-dialogs.ycp?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-loop-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-loop-dialogs.ycp Fri Feb 6 11:07:17 2009
@@ -117,14 +117,7 @@
if (create_file)
{
string tmp = (string) UI::QueryWidget(`id(`size), `Value);
- if (!Storage::HumanStringToKByte(tmp, size_k))
- {
- // error popup, %1 and %2 are replaced by sizes
- Popup::Error(sformat(_("The size entered is invalid. Enter a value like \"%1\" or \"%2\"."),
- Storage::KByteToHumanString(500*1024), Storage::KByteToHumanString(1024*1024)));
- widget = `again;
- }
- else if (size_k < min_size_k)
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, nil))
{
// error popup, %1 is replaced by size
Popup::Error(sformat(_("The size entered is invalid. Enter a size of at least %1."),
Modified: trunk/storage/storage/src/include/ep-lvm-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-lvm-dialogs.ycp?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-lvm-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-lvm-dialogs.ycp Fri Feb 6 11:07:17 2009
@@ -43,7 +43,7 @@
ret = false;
}
if (!ret)
- UI::SetFocus(`id("vgname"));
+ UI::SetFocus(`id(`vgname));
return ret;
}
@@ -68,7 +68,7 @@
}
if (!ret)
- UI::SetFocus(`id("vgname"));
+ UI::SetFocus(`id(`vgname));
return ret;
}
@@ -78,10 +78,10 @@
return ConfirmRecursiveDelete( vgname, log_volumes,
//pop-up dialog title
_("Confirm Deleting of Volume Group"),
- //pop-up dialog message part 1: %1 is vol.group name
+ //pop-up dialog message part 1: %1 is vol.group name
sformat( _("The volume group \"%1\" contains at least one logical
volume. If you proceed, the following volumes will be deleted:"), vgname),
- //pop-up dialog message part 2: %1 is vol.group name
+ //pop-up dialog message part 2: %1 is vol.group name
sformat( _("Really delete volume group \"%1\" and all related logical volumes?"), vgname)
);
@@ -94,10 +94,10 @@
// error popup, %1, %2 and %3 are replaced by sizes
Popup::Error(sformat(_("The data entered is invalid. Insert a physical extent size larger than %1
in powers of 2, for example, \"%2\" or \"%3\""),
- Storage::KByteToHumanStringWithPrecision(1, 1, true),
- Storage::KByteToHumanStringWithPrecision(4, 1, true),
- Storage::KByteToHumanStringWithPrecision(4*1024, 1, true)));
- UI::SetFocus(`id("pesize"));
+ Storage::KByteToHumanStringOmitZeroes(1),
+ Storage::KByteToHumanStringOmitZeroes(4),
+ Storage::KByteToHumanStringOmitZeroes(4*1024)));
+ UI::SetFocus(`id(`pesize));
return false;
}
else
@@ -205,12 +205,12 @@
term contents = `VBox();
list<term> pesizes_list = maplist(integer i, Integer::RangeFrom(19, 26), {
- return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true));
+ return `item(`id(2 << i), Storage::ByteToHumanStringOmitZeroes(2 << i));
});
// label for input field
- contents = add(contents, `Left(`InputField(`id("vgname"), "Volume Group Name")));
- contents = add(contents, `Left(`ComboBoxSelected(`id("pesize"), `opt(`editable),
+ contents = add(contents, `Left(`InputField(`id(`vgname), "Volume Group Name")));
+ contents = add(contents, `Left(`ComboBoxSelected(`id(`pesize), `opt(`editable),
// label for combo box
_("&Physical Extent Size"), pesizes_list, `id(pesize))));
@@ -234,9 +234,9 @@
{
case `next:
{
- vgname = (string) UI::QueryWidget(`id("vgname"), `Value);
+ vgname = (string) UI::QueryWidget(`id(`vgname), `Value);
- any tmp = UI::QueryWidget(`id("pesize"), `Value);
+ any tmp = UI::QueryWidget(`id(`pesize), `Value);
if (is(tmp, integer))
pesize = (integer) tmp;
else if (!Storage::HumanStringToByte((string) tmp, pesize))
@@ -403,7 +403,7 @@
});
list<term> stripe_sizes_list = maplist(integer i, Integer::RangeFrom(11, 20), {
- return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true));
+ return `item(`id(2 << i), Storage::ByteToHumanStringOmitZeroes(2 << i));
});
// heading for frame
@@ -419,7 +419,7 @@
term contents = `HVSquash(frames);
- //A dialog title - %1 is a logical volume name, %2 is a volume group.
+ //A dialog title - %1 is a logical volume name, %2 is a volume group.
MiniWorkflow::SetTitle(sformat(_("Add Logical volume %1 on %2"), name, "/dev/" + data["vg_name"]:"error"));
MiniWorkflow::SetContents(Greasemonkey::Transform(contents), MiniWorkflowStepLvSizeHelptext());
MiniWorkflow::SetLastStep(false);
@@ -456,17 +456,11 @@
if (what == `manual_size)
{
string tmp = (string) UI::QueryWidget(`id(`size_input), `Value);
- if (!Storage::HumanStringToKByte(tmp, size_k))
- {
- Popup::Error(sformat(_("The size entered is invalid. Enter a value like \"%1\" or \"%2\"."),
- Storage::KByteToHumanString(500*1024), Storage::KByteToHumanString(1024*1024)));
- widget = `again;
- }
- else if (size_k < min_size_k || size_k > max_size_k)
+ if (!Storage::HumanStringToKByteWithRangeCheck(tmp, size_k, min_size_k, max_size_k))
{
Popup::Error(sformat(_("The size entered is invalid. Enter a size between %1 and %2."),
- Storage::KByteToHumanString(min_size_k),
- Storage::KByteToHumanString(max_size_k)));
+ Storage::KByteToHumanString(min_size_k),
+ Storage::KByteToHumanString(max_size_k)));
widget = `again;
}
}
Modified: trunk/storage/storage/src/include/ep-raid-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-raid-dialogs.ycp?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/storage/src/include/ep-raid-dialogs.ycp (original)
+++ trunk/storage/storage/src/include/ep-raid-dialogs.ycp Fri Feb 6 11:07:17 2009
@@ -212,7 +212,7 @@
symbol parity_algorithm = data["parity_algorithm"]:`left_asymmetric;
list<term> chunk_sizes_list = maplist(integer i, Integer::RangeFrom(11, 22), {
- return `item(`id(2 << i), Storage::ByteToHumanStringWithPrecision(2 << i, 2, true));
+ return `item(`id(2 << i), Storage::ByteToHumanStringOmitZeroes(2 << i));
});
term options = `VBox(
Modified: trunk/storage/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Storage.ycp?rev=55291&r1=55290&r2=55291&view=diff
==============================================================================
--- trunk/storage/storage/src/modules/Storage.ycp (original)
+++ trunk/storage/storage/src/modules/Storage.ycp Fri Feb 6 11:07:17 2009
@@ -373,21 +373,21 @@
}
-global string KByteToHumanString(integer kbytes)
+global string KByteToHumanString(integer bytes_k)
{
- return LibStorage::byteToHumanString(kbytes * 1024, false, 2, false);
+ return LibStorage::byteToHumanString(bytes_k * 1024, false, 2, false);
}
-global string ByteToHumanStringWithPrecision(integer bytes, integer precision, boolean omit_zeroes)
+global string ByteToHumanStringOmitZeroes(integer bytes)
{
- return LibStorage::byteToHumanString(bytes, false, precision, omit_zeroes);
+ return LibStorage::byteToHumanString(bytes, false, 2, true);
}
-global string KByteToHumanStringWithPrecision(integer kbytes, integer precision, boolean omit_zeroes)
+global string KByteToHumanStringOmitZeroes(integer bytes_k)
{
- return LibStorage::byteToHumanString(kbytes * 1024, false, precision, omit_zeroes);
+ return LibStorage::byteToHumanString(bytes_k * 1024, false, 2, true);
}
@@ -400,16 +400,45 @@
}
-global boolean HumanStringToKByte(string str, integer& kbytes)
+global boolean HumanStringToKByte(string str, integer& bytes_k)
{
integer bytes = 0; // bnc #408829
boolean ret = LibStorage::humanStringToByte(str, false, bytes);
- kbytes = bytes / 1024;
- y2milestone("HumanStringToKByte ret:%1 str:%2 kbytes:%3", ret, str, kbytes);
+ bytes_k = bytes / 1024;
+ y2milestone("HumanStringToKByte ret:%1 str:%2 bytes_k:%3", ret, str, bytes_k);
return ret;
}
+/**
+ * Converts a string into a integer and checks the allowed range for the
+ * integer. The range check is a bit sloppy to compensate rounding issues but
+ * it's guaranteed that the result lies within the allowed range.
+ */
+global boolean HumanStringToKByteWithRangeCheck(string str, integer& bytes_k, integer min_k,
+ integer max_k)
+{
+ if (!HumanStringToKByte(str, bytes_k))
+ return false;
+
+ if (min_k != nil && bytes_k < min_k)
+ {
+ if (KByteToHumanString(bytes_k) != KByteToHumanString(min_k))
+ return false;
+ bytes_k = min_k;
+ }
+
+ if (max_k != nil && bytes_k > max_k)
+ {
+ if (KByteToHumanString(bytes_k) != KByteToHumanString(max_k))
+ return false;
+ bytes_k = max_k;
+ }
+
+ return true;
+}
+
+
global define map