Author: aschnell
Date: Sat Mar 1 20:13:46 2008
New Revision: 45147
URL: http://svn.opensuse.org/viewcvs/yast?rev=45147&view=rev
Log:
- restructured table and overview generation
Added:
branches/tmp/aschnell/part-redesign/storage/src/modules/StorageFields.ycp
Modified:
branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp
branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp
branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am
branches/tmp/aschnell/part-redesign/storage/src/modules/Partitions.ycp
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp Sat Mar 1 20:13:46 2008
@@ -39,15 +39,17 @@
}
- list<symbol> columns = [ `device, `id, `size, `format, `fs, `mount, `mount_by, `cyl, `used_by ];
+ list<symbol> fields = StorageFields::Filter([ `device, `size, `format, `type,
+ `mount_point, `mount_by, `start_cyl,
+ `end_cyl, `used_by ]);
void CreateAllPanel(any user_data)
{
- term header = GetTableHeaderNew(columns);
+ term header = StorageFields::TableHeader(fields);
map tg = Storage::GetTargetMap();
- list table_list = MakePartitionList(tg, columns, predicate_all);
+ list table_list = StorageFields::TableContent(tg, fields, predicate_all);
UI::ReplaceWidget(`tree_panel,
`VBox(
@@ -75,14 +77,14 @@
void HandleAllPanel(any user_data, any widget)
{
if (widget == `filter)
- {
- filter_ = UI::QueryWidget(`filter, `Value);
+ {
+ filter_ = UI::QueryWidget(`filter, `Value);
- map tg = Storage::GetTargetMap();
- list table_list = MakePartitionList(tg, columns, predicate_all);
+ map tg = Storage::GetTargetMap();
+ list table_list = StorageFields::TableContent(tg, fields, predicate_all);
- UI::ChangeWidget(`table, `Items, table_list);
- }
+ UI::ChangeWidget(`table, `Items, table_list);
+ }
}
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=45147&r1=45146&r2=45147&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 Sat Mar 1 20:13:46 2008
@@ -72,194 +72,6 @@
}
- // TODO: somehow use in MakePartitionList
- string MakeSubInfo(map disk, map part, symbol what)
- {
- map data = (part == nil ? disk : part);
-
- switch (what)
- {
- case `size:
- {
- return "Size: " + ByteToHumanStringWithZero(data["size_k"]:0*1024) + "\n";
- }
-
- case `type:
- {
- string value = "";
- // TODO: see ep-main.ycp
- return value;
- }
-
- case `format:
- {
- string value = "";
- if (part == nil) {
- if (disk["dasdfmt"]:false)
- value = value + "X";
- } else {
- if (part["enc_type"]:`none != `none)
- value = value + "C";
- if (part["format"]:false)
- value = value + "F";
- }
- return "Format: " + value + "\n";
- }
-
- case `encrypted:
- {
- string value = data["enc_type"]:`none != `none ? "Yes" : "No";
- return "Encrypted: " + value;
- }
-
- case `fs_type:
- {
- return "File System: " + FileSystems::GetName(data["used_fs"]:`unknown, "") + "\n";
- }
-
- case `mount_point:
- {
- string value = data["mount"]:"";
- if (Mode::normal() && data["inactive"]:false )
- value = value + " *";
- return "Mount Point: " + value + "\n";
- }
-
- case `mount_by:
- {
- string value = "";
- if (data["mount"]:"" != "") {
- map tmp = $[ `device : "K", `uuid : "U", `label : "L", `id : "I", `path : "P" ];
- symbol mount_by = data["mountby"]:`device;
- value = tmp[mount_by]:"";
- }
- return "Mount By: " + value + "\n";
- }
-
- case `used_by:
- {
- return "Used By: " + usedByString(data["used_by_type"]:`UB_NONE, data["used_by"]:"") + "\n";
- }
-
- case `device:
- {
- return "Kernel Name: " + data["device"]:"" + "\n";
- }
-
- case `uuid:
- {
- return "UUID: " + data["uuid"]:"" + "\n";
- }
-
- case `label:
- {
- return "Label: " + data["label"]:"" + "\n";
- }
-
- case `udev_path:
- {
- return "Path: " + data["udev_path"]:"" + "\n";
- }
-
- case `udev_id:
- {
- string ret = "";
- integer i = 1;
- foreach(string id, data["udev_id"]:[], {
- ret = ret + "ID " + i + ": " + id + "\n";
- i = i + 1;
- });
- return ret;
- }
-
- case `bios_id:
- {
- return "BIOS ID: " + data["bios_id"]:"" + "\n";
- }
-
- case `vendor:
- {
- return "Vendor: " + data["vendor"]:"" + "\n";
- }
-
- case `model:
- {
- return "Model: " + data["model"]:"" + "\n";
- }
-
- case `bus:
- {
- return "Bus: " + data["bus"]:"" + "\n";
- }
-
- case `lvm_type:
- {
- return "Metadata Type: " + (data["lvm2"]:true ? "LVM2" : "LVM1") + "\n";
- }
-
- case `pe_size:
- {
- return "Physical Extend Size: " + ByteToHumanStringWithZero(data["pesize"]:0) + "\n";
- }
-
- case `stripes:
- {
- integer stripes = data["stripes"]:1;
- if (stripes == 1)
- return "Stripes: " + stripes + "\n";
- else
- return "Stripes: " + stripes + " (4 KB)" + "\n"; // FIXME
- }
-
- case `raid_type:
- {
- return "RAID Type: " + data["raid_type"]:"" + "\n";
- }
-
- case `cyl_start:
- {
- string value = "--";
- if (Storage::IsPartitionable(disk)) {
- if (part == nil)
- value = sformat("%1", 0);
- else
- value = sformat("%1", part["region", 0]:0);
- }
- return "Start Cyl: " + value + "\n";
- }
-
- case `cyl_end:
- {
- string value = "--";
- if (Storage::IsPartitionable(disk)) {
- if (part == nil)
- value = sformat("%1", disk["cyl_count"]:0 - 1);
- else
- value = sformat("%1", part["region", 0]:0 + part["region", 1]:0 - 1);
- }
- return "End Cyl: " + value + "\n";
- }
- }
-
- return nil;
- }
-
-
- term MakeInfo(map disk, map part, list<symbol> rows)
- {
- string ret = "";
-
- foreach(symbol row, rows, {
- if (row == `newline)
- ret = ret + "\n";
- else
- ret = ret + MakeSubInfo(disk, part, row);
- });
-
- return `Left(`RichText(`opt(`plainText), ret));
- }
-
-
map DlgResize(symbol flavour)
{
integer lv_used = 3500;
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp Sat Mar 1 20:13:46 2008
@@ -45,11 +45,14 @@
map tg = Storage::GetTargetMap();
map disk = tg[device]:$[];
+ list<symbol> fields = StorageFields::Filter([ `device, `vendor, `model, `size,
+ `newline, `bus, `udev_path, `udev_id,
+ `start_cyl, `end_cyl ]);
+
UI::ReplaceWidget(`tab_panel,
`VBox(
`HStretch(),
- MakeInfo(disk, nil, [ `device, `vendor, `model, `size, `newline,
- `bus, `udev_path, `udev_id, `cyl_start, `cyl_end ]),
+ StorageFields::Overview(disk, nil, fields),
`VStretch(),
`HBox(
`PushButton(`id(`smart), "Smart..." ),
@@ -89,12 +92,14 @@
}
}
- list<symbol> columns = [ `device, `id, `size, `format, `fs, `mount, `mount_by, `cyl, `used_by ];
+ list<symbol> fields = StorageFields::Filter([ `device, `bios_id, `size, `format,
+ `type, `mount_point, `mount_by,
+ `start_cyl, `end_cyl, `used_by ]);
- term header = GetTableHeaderNew(columns);
+ term header = StorageFields::TableHeader(fields);
map tg = Storage::GetTargetMap();
- list table_list = MakePartitionList(tg, columns, predicate);
+ list table_list = StorageFields::TableContent(tg, fields, predicate);
UI::ReplaceWidget(`tab_panel,
`VBox(
@@ -184,13 +189,16 @@
map disk = Storage::GetDisk(tg, device);
map partition = Storage::GetPartition(tg, device);
+ list<symbol> fields = StorageFields::Filter([ `device, `mount_point, `mount_by, `size,
+ `fs_type, `newline, `uuid, `label, `udev_path,
+ `udev_id, `used_by, `start_cyl, `end_cyl,
+ `encrypted ]);
+
UI::ReplaceWidget(`tree_panel,
`VBox(
`HStretch(),
`Left(`Heading("Partition: " + device)),
- MakeInfo(disk, partition, [ `device, `mount_point, `mount_by, `size, `fs_type, `newline,
- `uuid, `label, `udev_path, `udev_id, `used_by, `cyl_start, `cyl_end,
- `encrypted ]),
+ StorageFields::Overview(disk, partition, fields),
`VStretch(),
`HBox(
`PushButton(`id(`edit), "Edit..."),
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp Sat Mar 1 20:13:46 2008
@@ -55,10 +55,12 @@
map tg = Storage::GetTargetMap();
map disk = tg[device]:$[];
+ list<symbol> fields = StorageFields::Filter([ `size, `pe_size, `lvm_metadata ]);
+
UI::ReplaceWidget(`tab_panel,
`VBox(
`HStretch(),
- MakeInfo(disk, nil, [ `size, `pe_size, `lvm_type ]),
+ StorageFields::Overview(disk, nil, fields),
`VStretch(),
`HBox(
`PushButton(`id(`delete), "Delete..."),
@@ -104,12 +106,14 @@
}
}
- list<symbol> columns = [ `device, `size, `format, `fs, `mount, `mount_by, `used_by ];
+ list<symbol> fields = StorageFields::Filter([ `device, `size, `format, `type,
+ `mount_point, `mount_by, `used_by,
+ `lvm_metadata, `pe_size, `stripes ]);
- term header = GetTableHeaderNew(columns);
+ term header = StorageFields::TableHeader(fields);
map tg = Storage::GetTargetMap();
- list table_list = MakePartitionList(tg, columns, predicate);
+ list table_list = StorageFields::TableContent(tg, fields, predicate);
UI::ReplaceWidget(`tab_panel,
`VBox(
@@ -174,10 +178,11 @@
}
}
- list<symbol> columns = [ `device, `size, `format, `fs, `used_by ];
+ list<symbol> fields = StorageFields::Filter([ `device, `size, `format, `type,
+ `used_by ]);
- term header = GetTableHeaderNew(columns);
- list table_list = MakePartitionList(tg, columns, predicate);
+ term header = StorageFields::TableHeader(fields);
+ list table_list = StorageFields::TableContent(tg, fields, predicate);
UI::ReplaceWidget(`tab_panel,
`VBox(
@@ -232,12 +237,14 @@
map disk = Storage::GetDisk(tg, device);
map partition = Storage::GetPartition(tg, device);
+ list<symbol> fields = StorageFields::Filter([ `mount_point, `mount_by, `size, `stripes,
+ `fs_type, `uuid, `label ]);
+
UI::ReplaceWidget(`tree_panel,
`VBox(
`HStretch(),
`Left(`Heading("Logical Volume: " + device)),
- MakeInfo(disk, partition, [ `mount_point, `mount_by, `size, `stripes, `fs_type,
- `uuid, `label ]),
+ StorageFields::Overview(disk, partition, fields),
`VStretch(),
`HBox(
`PushButton(`id(`edit), "Edit..."),
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp Sat Mar 1 20:13:46 2008
@@ -12,6 +12,7 @@
import "TabPanel";
import "TreePanel";
import "Popup";
+ import "StorageFields";
// useful for e.g. ComboBox, SelectionBox and DumbTab
@@ -34,350 +35,6 @@
}
- list<symbol> FilterColumns(list<symbol> columns)
- {
- if (Arch::ppc())
- {
- columns = filter(symbol s, columns, { return s != `cyl; });
- }
-
- if (!Arch::s390())
- {
- columns = filter(symbol s, columns, { return s != `id; });
- }
-
- return columns;
- }
-
-
- term GetTableHeaderNew(list<symbol> columns)
- {
- columns = FilterColumns(columns);
-
- term header = `header();
-
- // Column header
- if (contains(columns, `device)) header = add(header, _("Device"));
-
- // Column header
- if (contains(columns, `id)) header = add(header, _("ID"));
-
- // Column header: centered / minimum = 11 characters /
- // fill with space if needed
- if (contains(columns, `size)) header = add(header, `Right(_(" Size ")));
-
- // Column header: centered / minimum = 3 characters /
- // fill with space if needed
- if (contains(columns, `format)) header = add(header, `Right(_(" F ")));
-
- // Column header
- if (contains(columns, `fs)) header = add(header, _("Type"));
-
- // Column header: centered / minimum = 7 characters /
- // fill with space if needed
- if (contains(columns, `mount)) header = add(header, _(" Mount "));
-
- // Column header
- if (contains(columns, `mount_by)) header = add(header, _("Mount By"));
-
- // Column header: minimum = 5 characters fill with space if needed
- if (contains(columns, `cyl)) header = add(header, `Right(_("Start")));
-
- // Column header: minimum = 4 characters fill with space if needed
- if (contains(columns, `cyl)) header = add(header, `Right(_("End ")));
-
- // Column header
- if (contains(columns, `used_by)) header = add(header, `Left(_("Used By")));
-
- // Column header
- if (contains(columns, `label)) header = add(header, `Left(_("Label")));
-
- // Column header
- if (contains(columns, `udev_id)) header = add(header, `Left(_("Device ID")));
-
- // Column header
- if (contains(columns, `udev_path)) header = add(header, `Left(_("Device Path")));
-
- return header;
- }
-
-
- /**
- * Sorted call of disk_cb for every disk.
- */
- void IterateTargetMap(map targets, void(map, map) disk_cb)
- {
- // order should be md, then loop, then LVM, then EVMS
- map disk_order = $[ `CT_DMRAID : 0, `CT_DISK : 1, `CT_MD : 2, `CT_LOOP : 3,
- `CT_LVM : 4, `CT_EVMS : 5, `CT_DM : 6, `CT_NFS : 7 ];
- list<string> keys = maplist(string dev, map disk, targets, ``{ return dev; });
- keys = sort( string a, string b, keys, ``{
- integer oa = disk_order[targets[a,"type"]:`CT_UNKNOWN]:8;
- integer ob = disk_order[targets[b,"type"]:`CT_UNKNOWN]:8;
- return( (oa==ob) ? (a targets, map disk)
- {
- boolean real_disk = Storage::IsPartitionable(disk);
- symbol type = disk["type"]:`CT_UNKNOWN;
-
- if( !(type==`CT_DISK && !real_disk) &&
- (type==`CT_DISK || type==`CT_DMRAID || type==`CT_LVM ||
- (type==`CT_EVMS && size(disk["name"]:"")>0 &&
- (!haskey( targets, "/dev/"+substring( disk["name"]:"", search( disk["name"]:"", "/")+1 ))||
- disk["create"]:false))))
- return false;
-
- return true;
- }
-
-
- boolean AlwaysHidePartition(map targets, map disk, map partition)
- {
- boolean hide = partition["fsid"]:0 == Partitions::fsid_mac_hidden ||
- disk["used_by_type"]:`UB_NONE==`UB_DMRAID;
-
- if( !hide && search( partition["device"]:"", "/dev/evms/" )==0 )
- {
- y2milestone( "evms p: %1", partition );
- string d1 = evms_dev_disk( partition["device"]:"" );
- y2milestone( "evms d1:%1", d1 );
- integer val = search( d1, "/lvm/" );
- if( val!=nil && val>0 )
- {
- d1 = "/dev/" + substring( d1, 9 );
- }
- else
- {
- val = search( d1, "/lvm2/" );
- if( val!=nil && val>0 )
- {
- d1 = "/dev/" + substring( d1, 10 );
- }
- }
- hide = size(partition["mount"]:"")==0;
- if( hide )
- {
- y2milestone( "evms p: %1", Storage::GetPartition( targets, d1 ));
- hide = (size(Storage::GetPartition( targets, d1 ))>0||
- Storage::IsPartType(targets[d1,"type"]:`CT_UNKNOWN)) &&
- !partition["evms_native"]:false;
- }
- y2milestone( "evms d1:%1 hide:%2", d1, hide );
- }
-
- return hide;
- }
-
-
- /**
- * The predicate function determines whether the disk/partition is
- * included. The predicate function takes two arguments, disk and
- * partition. For disks predicate is called with the partitions set to
- * nil.
- *
- * Possible return values for predicate:
- * `show, `follow, `showandfollow, `ignore
- */
- list<term> MakePartitionList(map targets, list<symbol> columns, symbol(map, map) predicate)
- {
- columns = FilterColumns(columns);
-
- list<term> table_input = [];
-
- void disk_cb(map targets, map disk)
- {
- symbol disk_predicate = predicate(disk, nil);
-
- boolean real_disk = Storage::IsPartitionable(disk);
-
- string dev = disk["device"]:"";
-
- if (!AlwaysHideDisk(targets, disk) && contains([`show, `showandfollow], disk_predicate))
- {
- string vendor = disk["vendor"]:"";
- string model = disk["model"]:"";
- string dev_size = ByteToHumanString(disk["size_k"]:0*1024);
- string udev_id = mergestring( disk["udev_id"]:[], " ");
- string udev_path = disk["udev_path"]:"";
-
- if ( (model != "") && (vendor != "") )
- vendor = vendor + "-" + model;
- else
- vendor = vendor + model;
-
- // entry in column "Type" for a unknown disk
- if( vendor == "" )
- {
- if (disk["bus"]:"" == "RAID")
- {
- vendor = "RAID "+dev;
- }
- else if( disk["type"]:`CT_UNKNOWN==`CT_LVM )
- {
- vendor = "LVM" + (disk["lvm2"]:false ? "2 " : " ") +
- disk["name"]:"";
- }
- else if( disk["type"]:`CT_UNKNOWN==`CT_EVMS )
- {
- vendor = "EVMS " + disk["name"]:"";
- }
- else if( disk["type"]:`CT_UNKNOWN==`CT_DMRAID )
- {
- vendor = "BIOS RAID " + disk["name"]:"";
- }
- else
- // label text
- vendor = sformat( _("DISK %1"), substring( dev, 5 ));
- }
-
- term a = `item(`id(dev));
-
- if (contains(columns, `device)) a = add(a, dev );
- if (contains(columns, `id)) a = add(a, sformat( " (%1)", disk["bios_id"]:"" ) );
- if (contains(columns, `size)) a = add(a, dev_size );
- if (contains(columns, `format)) a = add(a, (disk["dasdfmt"]:false)?"X":" " );
- if (contains(columns, `fs)) a = add(a, vendor);
- if (contains(columns, `mount)) a = add(a, "" );
- if (contains(columns, `mount_by)) a = add(a, "");
-
- if (contains(columns, `cyl)) {
- string dev_start_cyl = " -- ";
- string dev_nb_cyl = " -- ";
- if (real_disk) {
- integer cyl_count = disk["cyl_count"]:0;
- dev_start_cyl = to4string(0);
- dev_nb_cyl = to4string(cyl_count==0?cyl_count:(cyl_count-1));
- }
- a = add(a, dev_start_cyl);
- a = add(a, dev_nb_cyl);
- }
-
- if (contains(columns, `used_by)) a = add(a, usedByString( disk["used_by_type"]:`UB_NONE,
- disk["used_by"]:"" ));
- if (contains(columns, `label)) a = add(a, "");
- if (contains(columns, `udev_id)) a = add(a, udev_id);
- if (contains(columns, `udev_path)) a = add(a, udev_path);
-
- table_input = add (table_input, a);
- }
-
- if (contains([`follow, `showandfollow], disk_predicate))
- {
- list<map> partitions = disk["partitions"]:[];
-
- foreach(map partition, partitions, ``{
-
- if (AlwaysHidePartition(targets, disk, partition))
- return;
-
- symbol part_predicate = predicate(disk, partition);
- if (!contains([`show, `showandfollow], part_predicate))
- return;
-
- string part_dev_name = partition["device"]:"";
-
- integer start_cyl = partition["region",0]:0;
- integer nb_cyl = partition["region",1]:0;
- symbol type = partition["type"]:`unknown;
- boolean format = partition["format"]:false;
- boolean crypt_fs = partition["enc_type"]:`none != `none;
- symbol used_fs = partition["used_fs"]:`unknown;
- string mount_point = partition["mount"]:"";
- symbol mount_by = partition["mountby"]:`device;
-
- string label = partition["label"]:"";
- string udev_id = mergestring( partition["udev_id"]:[], " ");
- string udev_path = partition["udev_path"]:"";
-
- string used_by = usedByString( partition["used_by_type"]:`UB_NONE,
- partition["used_by"]:"" );
-
- string bytes_of_part = ByteToHumanString( partition["size_k"]:0*1024 );
-
- term a = `item(`id(part_dev_name));
-
- if (contains(columns, `device)) a = add(a, part_dev_name );
- if (contains(columns, `id) ) a = add(a, "");
- if (contains(columns, `size) ) a = add(a, bytes_of_part);
- if (contains(columns, `format) )
- {
- string format_flag = "";
- if (format) format_flag = "F";
- if (crypt_fs) format_flag = "C" + format_flag;
- a = add(a, format_flag);
- }
- if (contains(columns, `fs) )
- {
- string filesystem_name = partition["fstype"]:"";
- if( format && partition["fsid"]:0 == Partitions::fsid_native)
- {
- string fs_name = FileSystems::GetName( used_fs, "Ext2" );
- filesystem_name = filesystem_name + " (" + fs_name + ") ";
- }
- a = add(a, filesystem_name);
- }
- if (contains(columns, `mount) )
- {
- string tmp = mount_point;
- if( Mode::normal() && partition["inactive"]:false )
- {
- tmp = tmp + " *";
- }
- a = add(a, tmp );
- }
- if(contains(columns, `mount_by))
- {
- if (mount_point != "")
- {
- map tmp = $[ `device : "K", `uuid : "U", `label : "L",
- `id : "I", `path : "P" ];
- a = add(a, tmp[mount_by]:"");
- }
- else
- a = add(a, "");
- }
- if(contains(columns, `cyl))
- {
- if( real_disk ) {
- a = add(a, to4string(start_cyl));
- integer num = start_cyl + nb_cyl - 1;
- if( num<0 )
- num=0;
- a = add(a, to4string(num));
- } else {
- a = add(a, " -- ");
- a = add(a, " -- ");
- }
- }
- if(contains(columns, `used_by)) a = add(a, used_by);
- if(contains(columns, `label)) a = add(a, label);
-
- if(contains(columns, `udev_id)) a = add(a, udev_id);
- if(contains(columns, `udev_path)) a = add(a, udev_path);
-
- table_input = add (table_input, a);
- });
-
- }
- }
-
- IterateTargetMap(targets, disk_cb);
-
- return table_input;
- }
-
-
void UpdateNavigationTree(any new_focus);
@@ -457,7 +114,7 @@
map tg = Storage::GetTargetMap();
- IterateTargetMap(tg, disk_cb);
+ StorageFields::IterateTargetMap(tg, disk_cb);
list<term> tree = [ `item(`id(`all), "pandora", [
`item(`id(`hd), "Hard Disks", subtree[`hd]:[]),
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid.ycp Sat Mar 1 20:13:46 2008
@@ -42,10 +42,12 @@
map disk = Storage::GetDisk(tg, part_device);
map partition = Storage::GetPartition(tg, part_device);
+ list<symbol> fields = StorageFields::Filter([ `mount_point, `size, `raid_type ]);
+
UI::ReplaceWidget(`tab_panel,
`VBox(
`HStretch(),
- MakeInfo(disk, partition, [ `mount_point, `size, `raid_type ]),
+ StorageFields::Overview(disk, partition, fields),
`VStretch(),
`HBox(
`PushButton(`id(`edit), "Edit..."),
@@ -89,12 +91,12 @@
}
}
- list<symbol> columns = [ `device, `size, `format, `fs, `used_by ];
+ list<symbol> fields = StorageFields::Filter([ `device, `size, `format, `type, `used_by ]);
- term header = GetTableHeaderNew(columns);
+ term header = StorageFields::TableHeader(fields);
map tg = Storage::GetTargetMap();
- list table_list = MakePartitionList(tg, columns, predicate);
+ list table_list = StorageFields::TableContent(tg, fields, predicate);
UI::ReplaceWidget(`tab_panel,
`VBox(
Modified: branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp Sat Mar 1 20:13:46 2008
@@ -856,42 +856,6 @@
};
- /*---------------------------------------------------------------------
- * returns for nonnegative numbers a string with a minimum of 4 characters:
- * 1 -> " 1"
- * 22 -> " 22"
- * 145 -> " 145"
- * 2134 -> "2134"
- * 34111 -> "34111"
- *----------------------------------------------------------------------
- */
-define string to4string( integer nb )
- ``{
- if ( nb < 10 ) return( sformat( " %1", nb ));
- if ( nb < 100 ) return( sformat( " %1", nb ));
- if ( nb < 1000 ) return( sformat( " %1", nb ));
- return( sformat( "%1", nb ));
- };
-
-define string usedByString( symbol ub_type, string used_by )
- {
- string ret = "";
- if( ub_type == `UB_LVM )
- ret = "LVM " + used_by;
- else if( ub_type == `UB_EVMS )
- ret = "EVMS " + used_by;
- else if( ub_type == `UB_DM )
- ret = "DM " + used_by;
- else if( ub_type == `UB_DMRAID )
- ret = "RAID " + used_by;
- else if( ub_type == `UB_MD )
- ret = "RAID " + used_by;
- else if( ub_type != `UB_NONE )
- ret = used_by;
- return ret;
- }
-
-
/*-------------------------------------------------------------------
*
* Now check start an end cylinder
Modified: branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am Sat Mar 1 20:13:46 2008
@@ -19,6 +19,7 @@
StorageClients.ycp \
StorageControllers.ycp \
StorageDevices.ycp \
+ StorageFields.ycp \
TreePanel.ycp \
TabPanel.ycp \
DualMultiSelectionBox.ycp
Modified: branches/tmp/aschnell/part-redesign/storage/src/modules/Partitions.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/Partitions.ycp?rev=45147&r1=45146&r2=45147&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/Partitions.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/Partitions.ycp Sat Mar 1 20:13:46 2008
@@ -754,27 +754,6 @@
return( text );
}
- /*---------------------------------------------------------------------
- * returns for a string a string with a minimum of 9 characters:
- * "1" -> " 1"
- * "22" -> " 22"
- * "145" -> " 145"
- * "2134" -> " 2134"
- *----------------------------------------------------------------------
- */
-define string sto8string( string str )
- ``{
- integer nb = size( str );
- if ( nb > 8 ) return( sformat( "%1", str ));
- if ( nb > 7 ) return( sformat( " %1", str ));
- if ( nb > 6 ) return( sformat( " %1", str ));
- if ( nb > 5 ) return( sformat( " %1", str ));
- if ( nb > 4 ) return( sformat( " %1", str ));
- if ( nb > 3 ) return( sformat( " %1", str ));
- if ( nb > 2 ) return( sformat( " %1", str ));
- if ( nb > 1 ) return( sformat( " %1", str ));
- return( sformat( " %1", str ));
- };
/*---------------------------------------------------------------------
* Convert <number-of-bytes> to XXX.X MB or XXX.X GB or XXX.X TB
@@ -785,7 +764,7 @@
*
* TODO: also defined in partition_defines.ycp, remove one
*/
-global define string ByteToHumanString ( integer number )
+global string ByteToHumanString(integer number)
``{
// column description, if disk space is not known
if( number == 0 ) return( _("unknown") );
@@ -795,23 +774,39 @@
// < 1 GB
integer MB = number / 1048576;
integer hunKB = (number - (MB * 1048576)) / 104858;
- return( sto8string(sformat( "%1.%2 MB", MB,hunKB )));
+ return sformat("%1.%2 MB", MB, hunKB);
}
else if ( number < 1099511627776 )
{
// < 1 TB
integer GB = number / 1073741824;
integer hunMB = (number - (GB * 1073741824)) / 107374183;
- return( sto8string(sformat( "%1.%2 GB", GB,hunMB )));
+ return sformat("%1.%2 GB", GB, hunMB);
}
else
{
// >= 1 TB
integer TB = number / 1099511627776;
integer hunGB = (number - (TB * 1099511627776)) / 109951162778;
- return( sto8string(sformat( "%1.%2 TB", TB,hunGB )));
+ return sformat("%1.%2 TB", TB, hunGB);
}
};
+/*---------------------------------------------------------------------
+ * Convert <number-of-bytes> to XXX.X MB or XXX.X GB or XXX.X TB
+ *
+ * see also ByteToHumanString !
+ * Return value: string "0" if input == 0
+ *----------------------------------------------------------------------
+ */
+global string ByteToHumanStringWithZero(integer number)
+{
+ if (number == 0)
+ return sformat("%1.%2 MB", 0, 0);
+
+ return ByteToHumanString(number);
+};
+
+
}
Added: branches/tmp/aschnell/part-redesign/storage/src/modules/StorageFields.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/StorageFields.ycp?rev=45147&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/StorageFields.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/StorageFields.ycp Sat Mar 1 20:13:46 2008
@@ -0,0 +1,643 @@
+/**
+ * File: StorageFields.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ module "StorageFields";
+
+
+ textdomain "storage";
+
+
+ import "Storage";
+ import "FileSystems";
+ import "Partitions";
+ import "Arch";
+ import "Mode";
+
+
+ global list<symbol> Filter(list<symbol> fields)
+ {
+ if (Arch::ppc())
+ {
+ fields = filter(symbol field, fields, {
+ return field != `start_cyl && field != `end_cyl;
+ });
+ }
+
+ if (!Arch::s390())
+ {
+ fields = filter(symbol field, fields, {
+ return field != `bios_id;
+ });
+ }
+
+ return fields;
+ }
+
+
+ /**
+ * Sorted call of disk_cb for every disk.
+ */
+ global void IterateTargetMap(map targets, void(map, map) disk_cb)
+ {
+ map disk_order = $[ `CT_DMRAID : 0, `CT_DISK : 1, `CT_MD : 2, `CT_LOOP : 3,
+ `CT_LVM : 4, `CT_EVMS : 5, `CT_DM : 6, `CT_NFS : 7 ];
+ list<string> keys = maplist(string dev, map disk, targets, { return dev; });
+ keys = sort(string a, string b, keys, {
+ integer oa = disk_order[targets[a,"type"]:`CT_UNKNOWN]:8;
+ integer ob = disk_order[targets[b,"type"]:`CT_UNKNOWN]:8;
+ return (oa==ob) ? (a target_map, map disk)
+ {
+ boolean real_disk = Storage::IsPartitionable(disk);
+ symbol type = disk["type"]:`CT_UNKNOWN;
+
+ if( !(type==`CT_DISK && !real_disk) &&
+ (type==`CT_DISK || type==`CT_DMRAID || type==`CT_LVM ||
+ (type==`CT_EVMS && size(disk["name"]:"")>0 &&
+ (!haskey(target_map, "/dev/"+substring(disk["name"]:"", search( disk["name"]:"", "/")+1))||
+ disk["create"]:false))))
+ return false;
+
+ return true;
+ }
+
+
+ boolean AlwaysHidePartition(map target_map, map disk, map partition)
+ {
+ boolean hide = partition["fsid"]:0 == Partitions::fsid_mac_hidden ||
+ disk["used_by_type"]:`UB_NONE==`UB_DMRAID;
+
+ if( !hide && search( partition["device"]:"", "/dev/evms/" )==0 )
+ {
+ y2milestone( "evms p: %1", partition );
+ string d1 = Storage::EvmsDevDisk(partition["device"]:"");
+ y2milestone( "evms d1:%1", d1 );
+ integer val = search( d1, "/lvm/" );
+ if( val!=nil && val>0 )
+ {
+ d1 = "/dev/" + substring( d1, 9 );
+ }
+ else
+ {
+ val = search( d1, "/lvm2/" );
+ if( val!=nil && val>0 )
+ {
+ d1 = "/dev/" + substring( d1, 10 );
+ }
+ }
+ hide = size(partition["mount"]:"")==0;
+ if( hide )
+ {
+ y2milestone( "evms p: %1", Storage::GetPartition(target_map, d1));
+ hide = (size(Storage::GetPartition(target_map, d1))>0||
+ Storage::IsPartType(target_map[d1,"type"]:`CT_UNKNOWN)) &&
+ !partition["evms_native"]:false;
+ }
+ y2milestone( "evms d1:%1 hide:%2", d1, hide );
+ }
+
+ return hide;
+ }
+
+
+ /**
+ * The predicate function determines whether the disk/partition is
+ * included. The predicate function takes two arguments, disk and
+ * partition. For disks predicate is called with the partitions set to
+ * nil.
+ *
+ * Possible return values for predicate:
+ * `show, `follow, `showandfollow, `ignore
+ */
+ global list<term> TableContent(map target_map, list<symbol> fields,
+ symbol(map, map) predicate)
+ {
+ list<term> content = [];
+
+ void callback(map target_map, map disk)
+ {
+ symbol disk_predicate = predicate(disk, nil);
+
+ if (!AlwaysHideDisk(target_map, disk) &&
+ contains([`show, `showandfollow], disk_predicate))
+ {
+ term row = StorageFields::TableRow(disk, nil, fields);
+ content = add(content, row);
+ }
+
+ if (contains([`follow, `showandfollow], disk_predicate))
+ {
+ list<map> partitions = disk["partitions"]:[];
+
+ foreach(map partition, partitions, {
+
+ symbol part_predicate = predicate(disk, partition);
+
+ if (!AlwaysHidePartition(target_map, disk, partition) &&
+ contains([`show, `showandfollow], part_predicate))
+ {
+ term row = StorageFields::TableRow(disk, partition, fields);
+ content = add(content, row);
+ }
+ });
+ }
+ }
+
+ IterateTargetMap(target_map, callback);
+
+ return content;
+ }
+
+
+ global term Overview(map disk, map part, list<symbol> fields)
+ {
+ string ret = mergestring(maplist(symbol field, fields, {
+ if (field == `newline)
+ return "\n";
+ else
+ return MakeSubInfo(disk, part, field, `overview);
+ }), "");
+ return `RichText(`opt(`plainText), ret);
+ }
+}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org