ACC SHELL

Path : /usr/share/YaST2/include/partitioning/
File Upload :
Current File : //usr/share/YaST2/include/partitioning/ep-dm.ycp

/**
 * File:	ep-dm.ycp
 * Package:	yast2-storage
 * Summary:	Expert Partitioner
 * Authors:	Arvin Schnell <aschnell@suse.de>
 *
 * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
 */
{
    textdomain "storage";

    include "partitioning/ep-dm-dialogs.ycp";
    include "partitioning/ep-dm-lib.ycp";


    void EpContextMenuDm(string device)
    {
	symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")) ]);

	switch (widget)
	{
	    case `edit:
		EpEditDmDevice(device);
		break;
	}
    }


    void CreateDmMainPanel(any user_data)
    {
	symbol Predicate(map disk, map partition)
	{
	    return StorageFields::PredicateDiskType(disk, partition, [`CT_DM]);
	}

	list<symbol> fields = StorageSettings::FilterTable([ `device, `size, `format, `encrypted, `type,
							     `fs_type, `label, `mount_point, `mount_by,
							     `used_by ]);

	map<string, map> target_map = Storage::GetTargetMap();

	term table_header = StorageFields::TableHeader(fields);
	list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);

	UI::ReplaceWidget(`tree_panel,
			  Greasemonkey::Transform(
			      `VBox(
				  `HStretch(),
				  // heading
				  `IconAndHeading(_("Device Mapper (DM)"), StorageIcons::dm_icon),
				  `Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
					 table_header, table_contents)
				  )
			      )
	    );

	// helptext
	string helptext = _("<p>This view shows all Device Mapper devices
except for those already included in some other view. Thus Multipath Disks,
BIOS RAIDs and LVM logical volumes are not shown here.</p>");

	Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
    }


    void HandleDmMainPanel(any user_data, map event)
    {
	string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);

	switch (Event::IsWidgetContextMenuActivated(event))
	{
	    case `table:
		EpContextMenuDevice(device);
		break;
	}

	UI::SetFocus(`id(`table));
    }


    void CreateDmOverviewTab(any user_data)
    {
	string dm_device = (string) user_data;

	map<string, map> target_map = Storage::GetTargetMap();

	list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size, `used_by,
								`heading_filesystem, `fs_type, `mount_point,
								`mount_by, `uuid, `label ]);

	UI::ReplaceWidget(`tab_panel,
			  Greasemonkey::Transform(
			      `VBox(
				  StorageFields::Overview(fields, target_map, dm_device),
				  `HBox(
				      // push button text
				      `PushButton(`id(`edit), _("Edit...")),
				      `HStretch()
				      )
				  )
			      )
	    );

	// helptext
	string helptext = _("<p>This view shows detailed information about the
selected Device Mapper device.</p>");

	Wizard::RestoreHelp(helptext + StorageFields::OverviewHelptext(fields));
    }


    void HandleDmOverviewTab(any user_data, map event)
    {
	string dm_device = (string) user_data;

	switch (Event::IsWidgetActivated(event))
	{
	    case `edit:
		EpEditDmDevice(dm_device);
		break;
	}
    }


    void CreateDmDevicesTab(any user_data)
    {
	string part_device = (string) user_data;

	symbol Predicate(map disk, map partition)
	{
	    return StorageFields::PredicateUsedByDevice(disk, partition, [ part_device ]);
	}

	list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size,
							     `format, `encrypted, `type, `used_by ]);

	map<string, map> target_map = Storage::GetTargetMap();

	term table_header = StorageFields::TableHeader(fields);
	list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);

	UI::ReplaceWidget(`tab_panel,
			  `VBox(
			      `Table(`id(`table), `opt(`keepSorting, `notify),
				     table_header, table_contents)
			      )
	    );

	// helptext
	string helptext = _("<p>This view shows all devices used by the
selected Device Mapper device.</p>");

	Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
    }


    void CreateDmPanel(any user_data)
    {
	string device = (string) user_data;

	map<symbol, map> data = $[ `overview : $[ `create : CreateDmOverviewTab, `handle : HandleDmOverviewTab, `user_data : user_data ],
				   `devices : $[ `create : CreateDmDevicesTab, `user_data : user_data ] ];

	UI::ReplaceWidget(`tree_panel,
			  Greasemonkey::Transform(
			      `VBox(
				  // heading
				  `IconAndHeading(sformat(_("DM Device: %1"), device), StorageIcons::dm_icon),
				  `DumbTab(`id(`tab), [
					       // push button text
					       `item(`id(`overview), _("&Overview")),
					       // push button text
					       `item(`id(`devices), _("&Used Devices"))
					       ],
					   `ReplacePoint(`id(`tab_panel), TabPanel::empty_panel)
				      )
				  )
			      )
	    );

	TabPanel::Init(data, `overview);
    }


    void HandleDmPanel(any user_data, map event)
    {
	TabPanel::Handle(event);
    }
}

ACC SHELL 2018