Author: aschnell
Date: Mon Feb 18 17:54:42 2008
New Revision: 44600
URL: http://svn.opensuse.org/viewcvs/yast?rev=44600&view=rev
Log:
- implemented DualMultiSelectionBox
Added:
branches/tmp/aschnell/part-redesign/storage/src/modules/DualMultiSelectionBox.ycp
Modified:
branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp
branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am
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=44600&r1=44599&r2=44600&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 Mon Feb 18 17:54:42 2008
@@ -9,22 +9,8 @@
textdomain "storage";
- // TODO: as module or even special widget
- term CreateDualMultiSelectionBox(list<term> l)
- {
- return `HBox(
- `MultiSelectionBox( "Available Physical Volumes:", l ),
- `VBox(
- `PushButton(`id(`add), "Add " + UI::Glyph(`ArrowRight)),
- `PushButton(`id(`add_all), "Add All " + UI::Glyph(`ArrowRight)),
- `VSpacing(1),
- `PushButton(`id(`remove), UI::Glyph(`ArrowLeft) + " Remove"),
- `PushButton(`id(`remove_all), UI::Glyph(`ArrowLeft) + " Remove All")
- ),
- `MultiSelectionBox( "Selected Physical Volumes:", [] )
- );
- }
-
+ import "DualMultiSelectionBox";
+
void hoho()
{
@@ -45,7 +31,7 @@
`InputField(`id("vgname"), "Volume Group Name:"),
`InputField(`id("pesize"), _("&Physical Extent Size:"), "4M"),
`CheckBox(`id("lvm1"), _("Use &Old LVM1 Compatible Metadata Format"), false),
- CreateDualMultiSelectionBox(unused_candidates),
+ DualMultiSelectionBox::Create(unused_candidates),
`HBox(
`PushButton(`id(`help), "Help"),
`HStretch(),
@@ -60,9 +46,12 @@
repeat
{
widget = UI::UserInput();
+ DualMultiSelectionBox::Handle(widget);
}
until (widget == `cancel || widget == `ok);
+ y2milestone("haha %1", DualMultiSelectionBox::GetSelectedItems());
+
UI::CloseDialog();
}
}
Added: branches/tmp/aschnell/part-redesign/storage/src/modules/DualMultiSelectionBox.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/modules/DualMultiSelectionBox.ycp?rev=44600&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/DualMultiSelectionBox.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/DualMultiSelectionBox.ycp Mon Feb 18 17:54:42 2008
@@ -0,0 +1,123 @@
+/**
+ * File: DualMultiSelectionBox.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ * The items in the item-list must contain these entries:
+ * 0: any id
+ * 1: string label
+ * 2: boolean selected (which side), optional, default is false
+ * 3: boolean selected (checkbox), optional, default is false
+ */
+{
+ module "DualMultiSelectionBox";
+
+ textdomain "storage";
+
+
+ list<term> items = [];
+
+
+ list<term> MakeLeftContent()
+ {
+ list<term> ret = filter(term item, items, { return item[2]:false == false; });
+ return maplist(term item, ret, { return `item(item[0]:nil, item[1]:nil, item[3]:false); });
+ }
+
+
+ list<term> MakeRightContent()
+ {
+ list<term> ret = filter(term item, items, { return item[2]:false == true; });
+ return maplist(term item, ret, { return `item(item[0]:nil, item[1]:nil, item[3]:false); });
+ }
+
+
+ global term Create(list<term> i)
+ {
+ items = i;
+
+ return `HBox(
+ `MultiSelectionBox(`id(`left), "Available Physical Volumes:", MakeLeftContent()),
+ `VBox(
+ `PushButton(`id(`add), "Add" + " " + UI::Glyph(`ArrowRight)),
+ `PushButton(`id(`add_all), "Add All" + " " + UI::Glyph(`ArrowRight)),
+ `VSpacing(1),
+ `PushButton(`id(`remove), UI::Glyph(`ArrowLeft) + " " + "Remove"),
+ `PushButton(`id(`remove_all), UI::Glyph(`ArrowLeft) + " " + "Remove All")
+ ),
+ `MultiSelectionBox(`id(`right), "Selected Physical Volumes:", MakeRightContent())
+ );
+ }
+
+
+ global void SetItems(list<term> i)
+ {
+ items = i;
+
+ UI::ChangeWidget(`id(`left), `Items, MakeLeftContent());
+ UI::ChangeWidget(`id(`right), `Items, MakeRightContent());
+ }
+
+
+ global list<term> GetItems()
+ {
+ list<term> tmp = (list<term>) merge((list<term>) UI::QueryWidget(`id(`left), `Items),
+ (list<term>) UI::QueryWidget(`id(`right), `Items));
+
+ items = maplist(term item, items, {
+ any id = item[0]:nil;
+ term t = find(term item, tmp, { return item[0]:nil == id; });
+ return `item(item[0]:nil, item[1]:nil, item[2]:false, t[2]:false);
+ });
+
+ return items;
+ }
+
+
+ global list<term> GetSelectedItems()
+ {
+ return filter(term item, GetItems(), { return item[2]:false == true; });
+ }
+
+
+ global void Handle(any widget)
+ {
+ if (widget == `add)
+ {
+ SetItems(maplist(term item, GetItems(), {
+ if (item[2]:false == false && item[3]:false == true)
+ return `item(item[0]:nil, item[1]:nil, true, false);
+ else
+ return item;
+ }));
+ }
+ else if (widget == `remove)
+ {
+ SetItems(maplist(term item, GetItems(), {
+ if (item[2]:false == true && item[3]:false == true)
+ return `item(item[0]:nil, item[1]:nil, false, false);
+ else
+ return item;
+ }));
+ }
+ else if (widget == `add_all)
+ {
+ SetItems(maplist(term item, GetItems(), {
+ if (item[2]:false == false)
+ return `item(item[0]:nil, item[1]:nil, true, false);
+ else
+ return item;
+ }));
+ }
+ else if (widget == `remove_all)
+ {
+ SetItems(maplist(term item, GetItems(), {
+ if (item[2]:false == true)
+ return `item(item[0]:nil, item[1]:nil, false, false);
+ else
+ return item;
+ }));
+ }
+ }
+}
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=44600&r1=44599&r2=44600&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/modules/Makefile.am Mon Feb 18 17:54:42 2008
@@ -20,7 +20,8 @@
StorageControllers.ycp \
StorageDevices.ycp \
TreePanel.ycp \
- TabPanel.ycp
+ TabPanel.ycp \
+ DualMultiSelectionBox.ycp
EXTRA_DIST = $(module_DATA) $(ynclude_DATA)
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org