Author: aschnell
Date: Wed Feb 13 11:14:36 2008
New Revision: 44411
URL: http://svn.opensuse.org/viewcvs/yast?rev=44411&view=rev
Log:
- first steps for partitioner redesign
Added:
branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.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-settings.ycp
branches/tmp/aschnell/part-redesign/storage/src/modules/TabPanel.ycp
branches/tmp/aschnell/part-redesign/storage/src/modules/TreePanel.ycp
Modified:
branches/tmp/aschnell/part-redesign/storage/src/inst_custom_part.ycp
branches/tmp/aschnell/part-redesign/storage/src/inst_disk.ycp
branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am
branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp
Added: 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=44411&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-all.ycp Wed Feb 13 11:14:36 2008
@@ -0,0 +1,73 @@
+/**
+ * File: ep-all.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ textdomain "storage";
+
+
+ any filter_ = `all;
+
+
+ boolean predicate_all(map disk)
+ {
+ if (filter_ == `all)
+ return true;
+
+ // TODO include `CT_DMRAID in `disks
+
+ map tmp = $[ `disks : `CT_DISK, `lvm : `CT_LVM, `nfs : `CT_NFS ];
+ return disk["type"]:`none == tmp[filter_]:`none;
+ }
+
+
+ list<symbol> columns = [ `device, `size, `format, `fs, `mount, `mby, `cyl, `used ];
+
+
+ void CreateAllPanel(any user_data)
+ {
+ term header = GetTableHeaderNew(columns);
+
+ map tg = Storage::GetTargetMap();
+ list table_list = MakePartitionList(tg, columns, predicate_all);
+
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `Left(`Heading("Available Storage on pandora")),
+ `HBox(`HStretch(),
+ `ComboBox(`id(`filter), `opt(`notify), "Show",
+ huhu([`item(`id(`all), "All"),
+ `item(`id(`disks), "Disks"),
+ `item(`id(`lvm), "LVM"),
+ `item(`id(`nfs), "NFS")], `id(filter_)))),
+ `Table(`id(`table), `opt(`keepSorting),
+ header, table_list
+ )
+ ));
+
+ Wizard::RestoreHelp("Help about view with all devices");
+ }
+
+
+ void HandleAllPanel(any user_data, any widget)
+ {
+ if (widget == `filter)
+ {
+ filter_ = UI::QueryWidget(`filter, `Value);
+
+ map tg = Storage::GetTargetMap();
+ list table_list = MakePartitionList(tg, columns, predicate_all);
+
+ UI::ChangeWidget(`table, `Items, table_list);
+ }
+ }
+
+
+ void SaveAllPanel(any user_data)
+ {
+ filter_ = UI::QueryWidget(`filter, `Value);
+ }
+}
Added: 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=44411&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp Wed Feb 13 11:14:36 2008
@@ -0,0 +1,163 @@
+/**
+ * File: ep-hd.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ textdomain "storage";
+
+
+ void CreateHdPanel(any user_data)
+ {
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `HStretch(),
+ `Left(`Heading("Hard Disks")),
+ `VStretch()
+ )
+ );
+ }
+
+
+ void HandleHdPanel(any user_data, any widget)
+ {
+
+ }
+
+
+ void CreateHdDiskOverviewTab(any user_data)
+ {
+ string device = (string) user_data;
+
+ map tg = Storage::GetTargetMap();
+ map disk = tg[device]:$[];
+
+ UI::ReplaceWidget(`tab_panel,
+ `VBox(
+ `HStretch(),
+ `Left(`Label("Kernel Name: " + disk["device"]:"")),
+ `Left(`Label("Vendor: " + disk["vendor"]:"")),
+ `Left(`Label("Model: " + disk["model"]:"")),
+ `Left(`Label("Size: " + ByteToHumanString(disk["size_k"]:0*1024))),
+ `Left(`Label("Bus: " + disk["bus"]:"")),
+ `Left(`Label("Path: " + disk["udev_path"]:"")),
+ `VStretch(),
+ `HBox(
+ `PushButton(`id(`smart), "Smart..." ),
+ `PushButton( "HD Param..." ),
+ `HStretch()
+ )
+ )
+ );
+ }
+
+
+ void HandleHdDiskOverviewTab(any user_data, any widget)
+ {
+ if (widget == `smart)
+ {
+ Popup::YesNo (_("Smart whatever"));
+ }
+ }
+
+
+ void CreateHdDiskPartitionsTab(any user_data)
+ {
+ boolean predicate(map disk)
+ {
+ return disk["device"]:"" == user_data;
+ }
+
+ list<symbol> columns = [ `device, `size, `format, `fs, `mount, `mount_by, `cyl, `used_by ];
+
+ term header = GetTableHeaderNew(columns);
+
+ map tg = Storage::GetTargetMap();
+ list table_list = MakePartitionList(tg, columns, predicate);
+
+ UI::ReplaceWidget(`tab_panel,
+ `VBox(
+ `Table(`opt(`keepSorting),
+ header, table_list
+ ),
+ `HBox(
+ `PushButton(`id(`add), "Add..."),
+ `PushButton(`id(`edit), "Edit..."),
+ `PushButton(`id(`resize), "Resize..."),
+ `PushButton(`id(`delete), "Delete..."),
+ `HStretch(),
+ `MenuButton("Expert...",
+ [
+ `item( `id (`delete_parttable), "Delete Partition &Table and Disk Label")
+ ])
+ )
+ ));
+ }
+
+
+ void HandleHdDiskPartitionsTab(any user_data, any widget)
+ {
+ if (widget == `add)
+ {
+ Popup::YesNo(tostring(user_data));
+ }
+ else if (widget == `delete)
+ {
+ Popup::YesNo(_("Delete partition?"));
+ }
+ }
+
+
+ void CreateHdDiskPanel(any user_data)
+ {
+ string device = (string) user_data;
+
+ map data = $[ `overview : $[ `create : CreateHdDiskOverviewTab,
+ `handle : HandleHdDiskOverviewTab,
+ `user_data : user_data ],
+ `partitions : $[ `create : CreateHdDiskPartitionsTab,
+ `handle : HandleHdDiskPartitionsTab,
+ `user_data : user_data ] ];
+
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `Left(`Heading("Hard Disk: " + device)),
+ `DumbTab( `id(`tab), [
+ `item(`id(`overview), "&Overview"),
+ `item(`id(`partitions), "&Partitions")
+ ],
+ `ReplacePoint(`id(`tab_panel), TabPanel::empty_panel)
+ )
+ ));
+
+ TabPanel::Init(data);
+ }
+
+
+ void HandleHdDiskPanel(any user_data, any widget)
+ {
+ TabPanel::Handle(widget);
+ }
+
+
+ void CreateHdPartitionPanel(any user_data)
+ {
+ string device = (string) user_data;
+
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `HStretch(),
+ `Left(`Heading("Partition: " + device)),
+ `VStretch(),
+ `HBox(
+ `PushButton(`id(`edit), "Edit..."),
+ `PushButton(`id(`resize), "Resize..."),
+ `PushButton(`id(`delete), "Delete..."),
+ `HStretch()
+ )
+ )
+ );
+ }
+}
Added: 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=44411&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp Wed Feb 13 11:14:36 2008
@@ -0,0 +1,181 @@
+/**
+ * File: ep-lvm.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ textdomain "storage";
+
+
+
+ void hoho()
+ {
+ // TODO: use Wizard:: ?
+ UI::OpenDialog(`opt(`defaultsize),
+ `VBox(
+ `Label( "Top level dialog" ),
+ `PushButton( `opt(`default), "OK\nLevel 1" )
+ )
+ );
+
+ UI::UserInput();
+
+ UI::CloseDialog();
+ }
+
+
+
+
+ void CreateLvmPanel(any user_data)
+ {
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `HStretch(),
+ `Left(`Heading("Volume Managment")),
+ `VBox(
+ `PushButton(`id(`create_vg), "Create Volume Group..."),
+ `PushButton(`id(`create_lv), "Create Logical Volume...")
+ ),
+ `VStretch()
+ )
+ );
+
+ Wizard::RestoreHelp("Help about LVM");
+ }
+
+
+ void HandleLvmPanel(any user_data, any widget)
+ {
+ if (widget == `create_vg)
+ {
+ hoho();
+ }
+ }
+
+
+ void CreateLvmVgOverviewTab(any user_data)
+ {
+ string device = (string) user_data;
+
+ map tg = Storage::GetTargetMap();
+ map disk = tg[device]:$[];
+
+ UI::ReplaceWidget(`tab_panel,
+ `VBox(
+ `HStretch(),
+ `Left(`Label("Size: " + ByteToHumanString(disk["size_k"]:0*1024))),
+ `Left(`Label("Metadata Type: " + (disk["lvm2"]:true ? "LVM2" : "LVM1"))),
+ `VStretch(),
+ `HBox(
+ `PushButton(`id(`delete), "Delete..."),
+ `HStretch()
+ )
+ )
+ );
+ }
+
+
+ void CreateLvmVgLvsTab(any user_data)
+ {
+ boolean predicate(map disk)
+ {
+ return disk["device"]:"" == user_data;
+ }
+
+ list<symbol> columns = [ `device, `size, `format, `fs, `mount, `mount_by, `used_by ];
+
+ term header = GetTableHeaderNew(columns);
+
+ map tg = Storage::GetTargetMap();
+ list table_list = MakePartitionList(tg, columns, predicate);
+
+ UI::ReplaceWidget(`tab_panel,
+ `VBox(
+ `Table(`opt(`keepSorting),
+ header, table_list
+ ),
+ `HBox(
+ `PushButton(`id(`add), "Add..."),
+ `PushButton(`id(`edit), "Edit..."),
+ `PushButton(`id(`resize), "Resize..."),
+ `PushButton(`id(`delete), "Delete..."),
+ `HStretch()
+ )
+ )
+ );
+ }
+
+
+ void CreateLvmVgPvsTab(any user_data)
+ {
+ list<symbol> columns = [ `device, `size, `format, `fs, `mount, `mount_by, `used_by ];
+
+ term header = GetTableHeaderNew(columns);
+
+ UI::ReplaceWidget(`tab_panel,
+ `VBox(
+ `Table(`opt(`keepSorting),
+ header, []
+ ),
+ `HBox(
+ // `PushButton(`id(`add), "Add..."),
+ // `PushButton(`id(`delete), "Delete..."),
+ `HStretch()
+ )
+ )
+ );
+ }
+
+
+ void CreateLvmVgPanel(any user_data)
+ {
+ string device = (string) user_data;
+
+ map data = $[ `overview : $[ `create : CreateLvmVgOverviewTab, `user_data : user_data ],
+ `lvs : $[ `create : CreateLvmVgLvsTab, `user_data : user_data ],
+ `pvs : $[ `create : CreateLvmVgPvsTab, `user_data : user_data ] ];
+
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `Left(`Heading("Volume Group: " + device)),
+ `DumbTab( `id(`tab), [
+ `item(`id(`overview), "&Overview"),
+ `item(`id(`lvs), "&Logical Volumes"),
+ `item(`id(`pvs), "&Physical Volumes")
+ ],
+ `ReplacePoint(`id(`tab_panel), TabPanel::empty_panel)
+ )
+ )
+ );
+
+ TabPanel::Init(data);
+ }
+
+
+ void HandleLvmVgPanel(any user_data, any widget)
+ {
+ TabPanel::Handle(widget);
+ }
+
+
+ void CreateLvmLvPanel(any user_data)
+ {
+ string device = (string) user_data;
+
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `HStretch(),
+ `Left(`Heading("Logical Volume: " + device)),
+ `VStretch(),
+ `HBox(
+ `PushButton(`id(`delete), "Edit..."),
+ `PushButton(`id(`resize), "Resize..."),
+ `PushButton(`id(`delete), "Delete..."),
+ `HStretch()
+ )
+ )
+ );
+ }
+}
Added: 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=44411&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp Wed Feb 13 11:14:36 2008
@@ -0,0 +1,460 @@
+/**
+ * File: ep-main.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ textdomain "storage";
+
+
+ import "TabPanel";
+ import "TreePanel";
+ import "Popup";
+
+
+ // useful for e.g. ComboBox, SelectionBox and DumbTab
+ list<term> huhu(list<term> items, any id)
+ {
+ return maplist(term item, items,
+ ``(`item(item[0]:nil, item[1]:nil, item[0]:nil == id)));
+ }
+
+
+ term GetTableHeaderNew(list<symbol> 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 GoOverTargetMap(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;
+ }
+
+
+ list<term> MakePartitionList(map targets, list columns, boolean(map) predicate)
+ {
+ list<term> table_input = [];
+
+ void disk_cb(map targets, map disk)
+ {
+ if (!predicate(disk))
+ return;
+
+ boolean real_disk = Storage::IsPartitionable(disk);
+
+ string dev = disk["device"]:"";
+
+ if (!AlwaysHideDisk(targets, disk))
+ {
+ 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);
+ }
+
+ list<map> partitions = disk["partitions"]:[];
+
+ foreach(map partition, partitions, ``{
+
+ if (AlwaysHidePartition(targets, disk, partition))
+ 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);
+ });
+
+ }
+
+ GoOverTargetMap(targets, disk_cb);
+
+ return table_input;
+ }
+
+
+
+
+ include "partitioning/ep-all.ycp";
+ include "partitioning/ep-hd.ycp";
+ include "partitioning/ep-lvm.ycp";
+ include "partitioning/ep-settings.ycp";
+
+
+ map data = $[];
+
+ list<term> MakeNavigationTree()
+ {
+ data = $[ `all : $[ `create : CreateAllPanel, `handle : HandleAllPanel, `save : SaveAllPanel ],
+ `hd : $[ `create : CreateHdPanel, `handle : HandleHdPanel ],
+ `lvm : $[ `create : CreateLvmPanel, `handle : HandleLvmPanel ],
+ `settings : $[ `create : CreateSettingsPanel, `save : SaveSettingsPanel ] ];
+
+ map haha = $[];
+
+ void disk_cb(map targets, map disk)
+ {
+ string device = disk["device"]:"";
+ symbol type = disk["type"]:`CT_UNKNOWN;
+ list<map> partitions = disk["partitions"]:[];
+
+ // TODO: make somehow generic
+
+ if (type == `CT_DISK || type == `CT_DMRAID) {
+ list<term> tmp = [];
+ foreach(map partition, partitions, ``{
+ string d = partition["device"]:"";
+ tmp = add(tmp, `item(`id(d), d));
+ data = add(data, d, $[ `create : CreateHdPartitionPanel, `user_data : d ]);
+ });
+ haha[`hd] = add(haha[`hd]:[], `item(`id(device), device, tmp));
+ data = add(data, device, $[ `create : CreateHdDiskPanel, `handle : HandleHdDiskPanel, `user_data : device ]);
+ }
+ else if (type == `CT_LVM) {
+ list<term> tmp = [];
+ foreach(map partition, partitions, ``{
+ string d = partition["device"]:"";
+ tmp = add(tmp, `item(`id(d), d));
+ data = add(data, d, $[ `create : CreateLvmLvPanel, `user_data : d ]);
+ });
+ haha[`lvm] = add(haha[`lvm]:[], `item(`id(device), device, tmp));
+ data = add(data, device, $[ `create : CreateLvmVgPanel, `handle : HandleLvmVgPanel, `user_data : device ]);
+ }
+ else if (type == `CT_NFS) {
+ list<term> tmp = [];
+ foreach(map partition, partitions, ``{
+ string d = partition["device"]:"";
+ tmp = add(tmp, `item(`id(d), d));
+ data = add(data, d, $[ `user_data : d ]);
+ });
+ haha[`nfs] = merge(haha[`nfs]:[], tmp);
+ }
+ }
+
+ map tg = Storage::GetTargetMap();
+ GoOverTargetMap(tg, disk_cb);
+
+ list<term> tree = [ `item(`id(`all), "pandora",
+ [
+ `item(`id(`hd), "Hard Disks", haha[`hd]:[]),
+ `item(`id(`lvm), "Volume Management", haha[`lvm]:[]),
+ `item(`id(`raid), "RAID" ),
+ `item(`id(`cryptfile), "Crypt Files" ),
+ `item(`id(`nfs), "NFS", haha[`nfs]:[] ),
+ `item(`id(`unused), "Unused Devices" )
+ ]),
+ `item(`id(`settings), "Settings") ];
+
+ return tree;
+ }
+
+
+ term systemViewTreePanel =
+ `VBox(
+ `Tree( `id(`tree), `opt(`notify), "System View", MakeNavigationTree() ),
+ `HBox(
+ `HStretch(),
+ `PushButton(`id(`search), "Search")
+ )
+ );
+
+
+ any test_new_ep()
+ {
+ string back_label = Label::BackButton();
+ string next_label = Label::AcceptButton();
+
+ term content = `MarginBox(0.7, 0.5,
+ `HBox(
+ `HWeight(30, systemViewTreePanel ),
+ `HWeight(70, `ReplacePoint(`id(`tree_panel),
+ TreePanel::empty_panel))
+ )
+ );
+
+ // heading text
+ Wizard::SetContentsButtons(_("Expert Partitioner"), content, "", back_label, next_label);
+
+ TreePanel::Init(data);
+
+ any widget = nil;
+
+ repeat
+ {
+ widget = Wizard::UserInput();
+ TreePanel::Handle(widget);
+
+ if (widget == `back || widget == `abort)
+ {
+ if (!Popup::ReallyAbort(true))
+ {
+ widget = nil;
+ }
+ }
+ }
+ until (widget == `back || widget == `abort || widget == `next);
+
+ TreePanel::Save();
+
+ return `abort;
+ }
+}
Added: branches/tmp/aschnell/part-redesign/storage/src/include/ep-settings.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-settings.ycp?rev=44411&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-settings.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-settings.ycp Wed Feb 13 11:14:36 2008
@@ -0,0 +1,38 @@
+/**
+ * File: ep-settings.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ textdomain "storage";
+
+
+ any default_fs = `ext2;
+
+
+ void CreateSettingsPanel(any user_data)
+ {
+ UI::ReplaceWidget(`tree_panel,
+ `VBox(
+ `Left(`Heading("Settings")),
+ `HBox(`ComboBox(`id(`default_fs), "Default Filesystem",
+ huhu([`item(`id(`ext2), "Ext2"),
+ `item(`id(`ext3), "Ext3"),
+ `item(`id(`reiserfs), "ReiserFS"),
+ `item(`id(`xfs), "XFS")
+ ], `id(default_fs)))
+ ),
+ `VStretch()
+ ));
+
+ Wizard::RestoreHelp("Settings help");
+ }
+
+
+ void SaveSettingsPanel(any user_data)
+ {
+ default_fs = UI::QueryWidget(`id(`default_fs), `Value);
+ }
+}
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=44411&r1=44410&r2=44411&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 Wed Feb 13 11:14:36 2008
@@ -2503,6 +2503,18 @@
// MAIN:
/////////////////////////////////////////////////////////////////
+
+
+
+ if (true)
+ {
+ include "partitioning/ep-main.ycp";
+ return test_new_ep();
+ }
+
+
+
+
symbol ret = nil;
y2milestone( "Custom partitioner started" );
Modified: branches/tmp/aschnell/part-redesign/storage/src/inst_disk.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/inst_disk.ycp?rev=44411&r1=44410&r2=44411&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/inst_disk.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/inst_disk.ycp Wed Feb 13 11:14:36 2008
@@ -128,7 +128,7 @@
`finish : "PrepDiskEnd",
`apply : "PrepDiskApply" ],
- "Custom" : $[ `abort : "abort",
+ "Custom" : $[ `abort : `abort,
`cancel : `cancel,
`raid_wizard : "RaidTypeWizard",
`raid_settings : "RaidDeviceSettings",
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=44411&r1=44410&r2=44411&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am Wed Feb 13 11:14:36 2008
@@ -18,7 +18,9 @@
Storage.ycp \
StorageClients.ycp \
StorageControllers.ycp \
- StorageDevices.ycp
+ StorageDevices.ycp \
+ TreePanel.ycp \
+ TabPanel.ycp
EXTRA_DIST = $(module_DATA) $(ynclude_DATA)
Modified: branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp?rev=44411&r1=44410&r2=44411&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/Storage.ycp Wed Feb 13 11:14:36 2008
@@ -286,7 +286,8 @@
define any createInterface()
{
- any ret = LibStorage::createStorageInterface(false, Mode::test(), true);
+ // temporarily for testing use readonly mode of libstorage
+ any ret = LibStorage::createStorageInterface(true, Mode::test(), true);
if( ZeroNewPartitions )
LibStorage::StorageInterface::setZeroNewPartitions(ret,true);
Added: branches/tmp/aschnell/part-redesign/storage/src/modules/TabPanel.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/TabPanel.ycp?rev=44411&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/TabPanel.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/TabPanel.ycp Wed Feb 13 11:14:36 2008
@@ -0,0 +1,84 @@
+/**
+ * File: TabPanel.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ * The DumbTab widget must have id `tab.
+ */
+{
+ module "TabPanel";
+
+
+ map data = nil;
+
+ any current_item = nil;
+
+
+ global const term empty_panel = `VBox(`VStretch(), `HStretch());
+
+
+ void CallCreate()
+ {
+ map tmp = (map) data[current_item]:nil;
+ void(any) create_func = (void(any)) tmp[`create]:nil;
+ if (create_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ create_func(user_data);
+ }
+ }
+
+ void CallHandle(any widget)
+ {
+ map tmp = (map) data[current_item]:nil;
+ void(any, any) handle_func = (void(any, any)) tmp[`handle]:nil;
+ if (handle_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ handle_func(user_data, widget);
+ }
+ }
+
+ void CallSave()
+ {
+ map tmp = (map) data[current_item]:nil;
+ void(any) save_func = (void(any)) tmp[`save]:nil;
+ if (save_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ save_func(user_data);
+ }
+ }
+
+
+ /**
+ * When calling this function the DumbTab widget must already exist.
+ */
+ global void Init(map d)
+ {
+ data = d;
+
+ current_item = UI::QueryWidget(`tab, `CurrentItem);
+ CallCreate();
+ }
+
+ global void Handle(any widget)
+ {
+ if (haskey(data, widget))
+ {
+ CallSave();
+ current_item = widget;
+ CallCreate();
+ }
+ else
+ {
+ CallHandle(widget);
+ }
+ }
+
+ global void Save()
+ {
+ CallSave();
+ }
+}
Added: branches/tmp/aschnell/part-redesign/storage/src/modules/TreePanel.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/TreePanel.ycp?rev=44411&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/TreePanel.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/TreePanel.ycp Wed Feb 13 11:14:36 2008
@@ -0,0 +1,109 @@
+/**
+ * File: TabPanel.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ * The Tree widget must have id `tree.
+ */
+{
+ module "TreePanel";
+
+
+ map data = nil;
+
+ any current_item = nil;
+
+
+ global const term empty_panel = `VBox(`VStretch(), `HStretch());
+
+
+ void CallCreate()
+ {
+ map tmp = (map) data[current_item]:nil;
+ void(any) create_func = (void(any)) tmp[`create]:nil;
+ if (create_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ create_func(user_data);
+ }
+ }
+
+ void CallHandle(any widget)
+ {
+ map tmp = (map) data[current_item]:nil;
+ void(any, any) handle_func = (void(any, any)) tmp[`handle]:nil;
+ if (handle_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ handle_func(user_data, (any) widget);
+ }
+ }
+
+ void CallSave()
+ {
+ map tmp = (map) data[current_item]:nil;
+ void(any) save_func = (void(any)) tmp[`save]:nil;
+ if (save_func != nil)
+ {
+ any user_data = tmp[`user_data]:nil;
+ save_func(user_data);
+ }
+ }
+
+
+ /**
+ * Initialises internal data and calls the create function of the
+ * selected panel.
+ *
+ * When calling this function the Tree widget must already exist.
+ */
+ global void Init(map d)
+ {
+ data = d;
+
+ current_item = UI::QueryWidget(`tree, `CurrentItem);
+ CallCreate();
+ }
+
+ /**
+ * Update the content of the Tree widget.
+ */
+ global void Update(map d, list tree)
+ {
+ data = d;
+
+ any open_items = UI::QueryWidget(`tree, `OpenItems);
+ UI::ChangeWidget(`tree, `Items, tree);
+ UI::ChangeWidget(`tree, `CurrentItem, current_item);
+ UI::ChangeWidget(`tree, `OpenItems, open_items);
+
+ // TODO: if old current_item does not exist anymore do a save and a create
+ }
+
+ /**
+ * Handle user input by either switching the panel or delegating the input
+ * to the selected panel.
+ */
+ global void Handle(any widget)
+ {
+ if (widget == `tree)
+ {
+ CallSave();
+ current_item = UI::QueryWidget(`tree, `CurrentItem);
+ CallCreate();
+ }
+ else
+ {
+ CallHandle(widget);
+ }
+ }
+
+ /**
+ * Delegating saving to the selected panel.
+ */
+ global void Save()
+ {
+ CallSave();
+ }
+}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org