Author: jsrain
Date: Fri Jul 27 11:09:01 2007
New Revision: 39735
URL: http://svn.opensuse.org/viewcvs/yast?rev=39735&view=rev
Log:
redesigned the repository management dialog (Fate #302072)
Modified:
trunk/packager/package/yast2-packager.changes
trunk/packager/src/clients/inst_source.ycp
trunk/packager/src/modules/SourceDialogs.ycp
Modified: trunk/packager/package/yast2-packager.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/package/yast2-packager.changes?rev=39735&r1=39734&r2=39735&view=diff
==============================================================================
--- trunk/packager/package/yast2-packager.changes (original)
+++ trunk/packager/package/yast2-packager.changes Fri Jul 27 11:09:01 2007
@@ -1,4 +1,9 @@
-------------------------------------------------------------------
+Fri Jul 27 11:06:56 CEST 2007 - jsrain@suse.cz
+
+- redesigned the repository management dialog (Fate #302072)
+
+-------------------------------------------------------------------
Thu Jul 26 07:51:50 CEST 2007 - lslezak@suse.cz
- inst_source - use product name or URL as alias for a new
Modified: trunk/packager/src/clients/inst_source.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/clients/inst_source.ycp?rev=39735&r1=39734&r2=39735&view=diff
==============================================================================
--- trunk/packager/src/clients/inst_source.ycp (original)
+++ trunk/packager/src/clients/inst_source.ycp Fri Jul 27 11:09:01 2007
@@ -75,15 +75,38 @@
term item = `item(
`id( index ),
// corresponds to the "Enable/Disable" button
- source[ "enabled" ]:true ? _("On") : _("Off"),
- source["autorefresh"]:true ? _("On") : _("Off"),
+ source[ "enabled" ]:true ? UI::Glyph (`CheckMark) : "",
+// source["autorefresh"]:true ? _("On") : _("Off"),
// translators: unknown name for a given source
- alias,
- generalData[ "url" ]:""
+ alias
+// generalData[ "url" ]:""
);
return item;
}
+ map getSourceInfo (integer index, map source) {
+ integer id = source[ "SrcId" ]:0;
+ map generalData = Pkg::SourceGeneralData( id );
+ map productData = Pkg::SourceProductData( id );
+ y2milestone("generalData: %1", generalData);
+ y2milestone("productData: %1", productData);
+
+ string alias = haskey(sourceStatesOut[index]:$[], "name") ?
+ sourceStatesOut[index,"name"]:"" :
+ // unkown name (alias) of the source
+ generalData[ "alias" ]:productData["label"]:generalData[ "type" ]: _("Unknown Name");
+
+ map out = $[
+ "enabled" : source["enabled"]:true,
+ "autorefresh" : source["autorefresh"]:true,
+ "name" : alias,
+ "url" : generalData[ "url" ]:"",
+ "type" : generalData["type"]:"",
+ ];
+ return out;
+
+ }
+
/**
* Fill sources table with entries from the InstSrcManager agent.
*/
@@ -102,6 +125,32 @@
UI::ChangeWidget( `id( `table ), `Items, items );
}
+ void fillRepoInfo(integer index, map source) {
+ map info = getSourceInfo (index, source);
+ UI::ReplaceWidget (`id (`repo_rp), `VBox (
+ // heading - in case repo name not found
+ `Left (`Heading (info["name"]:_("Unknown repository name"))),
+ // label, %1 is URL
+ `Left (`Label (sformat (_("URL: %1"),
+ // label to be used instead of URL if not found
+ info["url"]:_("Unknown")))),
+ // label, %1 is repo category (eg. YUM)
+ `Left (`Label (sformat (_("Category: %1"),
+ // label to be used instead of repo category if not known
+ info["type"]:_("Unknown"))))
+ ));
+ UI::ChangeWidget (`id (`enable), `Value, info["enabled"]:true);
+ UI::ChangeWidget (`id (`autorefresh), `Value, info["autorefresh"]:true);
+ }
+
+ void fillCurrentRepoInfo () {
+ integer selected = (integer)UI::QueryWidget (`id (`table), `CurrentItem);
+ if (selected == nil)
+ return;
+ map data = sourceStatesOut[selected]:$[];
+ fillRepoInfo (selected, data);
+ }
+
boolean LicenseAccepted (integer id) {
Wizard::CreateDialog ();
boolean ret = AddOnProduct::AcceptedLicenseAndInfoFile (id);
@@ -109,7 +158,7 @@
return ret;
}
- define symbol createSource( string url, boolean download ) ``{
+ define symbol createSource( string url, boolean download, string preffered_name ) ``{
y2milestone("createSource: %1", url);
if ( url != "" )
@@ -163,6 +212,8 @@
continue;
string name = repo[0]:"";
+ if (preffered_name != nil && preffered_name != "")
+ name = preffered_name;
string prod_dir = repo[1]:"/";
string prod_url = url;
@@ -413,22 +464,36 @@
`HBox(
`Table(`id(`table),`opt(`notify, `immediate),
// table header
- `header( _("Status"),
+ `header( _("Enabled"),
// table header
- _("Refresh"),
+// _("Refresh"),
// table header
- _("Name"),
+ _("Name")),
// table header
- _("URL") ),
+// _("URL") ),
items ),
`HSpacing()
- ),
- (have_rug) ?
- `Left (`CheckBox (`id (`zmdsync),
+ ),
+ `HBox (
+ `Frame ("", `HBox (`HSpacing (1), `VBox (
+ `ReplacePoint (`id (`repo_rp), `VBox (
+ `Left (`Heading ("Repo Name")),
+ `Left (`Label ("URL:")),
+ `Left (`Label ("Category:"))
+ )),
+ `VSpacing (0.4),
+ `Left (`Label (_("Properties"))),
+ `Left (`CheckBox (`id (`enable), `opt (`notify), _("Enabled"))),
+ `Left (`CheckBox (`id (`autorefresh), `opt (`notify), _("AutoRefresh"))),
+ (have_rug) ?
+ `Left (`CheckBox (`id (`zmdsync),
// Checkbox label
_("Synchronize Changes with &ZENworks"),
!norug && sync_zmd))
- : `Empty(),
+ : `Empty()
+ ))),
+ `HSpacing ()
+ ),
`HBox(
`PushButton (`id (`add), `opt(`key_F3),
Label::AddButton ()),
@@ -437,13 +502,16 @@
`PushButton (`id(`delete), `opt(`key_F5),
Label::DeleteButton ()),
`HStretch (),
+/*
// menu button label
`MenuButton (`id(`menu_button), `opt(`key_F6), _("Repository Settings"), [
- `item(`id(`enable), enableButtonLabel),
- `item(`id(`refresh_on_off), refreshOnOffButtonLabel),
+// `item(`id(`enable), enableButtonLabel),
+// `item(`id(`refresh_on_off), refreshOnOffButtonLabel),
`item(`id(`refresh), refreshButtonLabel ),
`item(`id(`set_alias), setAliasButtonLabel)
])
+*/
+ `PushButton (`id (`refresh), refreshButtonLabel )
),
`VSpacing( 0.5 )
);
@@ -511,6 +579,7 @@
Wizard::HideBackButton();
fillTable();
+ fillCurrentRepoInfo();
symbol input = nil;
@@ -524,6 +593,7 @@
if ( current >= 0 ) {
UI::ChangeWidget( `id( `table ), `CurrentItem, current );
+ fillCurrentRepoInfo ();
}
input = (symbol)Wizard::UserInput();
@@ -619,22 +689,39 @@
parsed["scheme"] = "pkg";
url = URL::Build(parsed);
}
-
+ SourceDialogs::SetRepoName (sourceState["name"]:"");
+ string old_url = url;
url = editUrl( url );
if ( size( url ) == 0 ) break;
- // copy the refresh flag
- createResult = createSource( url, sourceState["do_refresh"]:false );
- if ( createResult == `ok ) {
+ if (url != old_url)
+ {
+ y2milestone ("URL changed, recreating the source");
+ // copy the refresh flag
+ createResult = createSource( url, sourceState["do_refresh"]:false, SourceDialogs::GetRepoName ());
+ if ( createResult == `ok ) {
deleteSource( current );
fillTable();
- }
+ fillCurrentRepoInfo();
+ }
+ }
+ else
+ {
+ y2milestone ("URL is the same, not recreating the source");
+ sourceState["name"] = SourceDialogs::GetRepoName ();
+ sourceStatesOut[ current ] = sourceState;
+ fillTable();
+ fillCurrentRepoInfo();
+ createResult = `ok;
+ }
+
} while ( createResult == `again );
}
else if ( input == `refresh )
{
Pkg::SourceRefreshNow (id);
fillTable ();
+ fillCurrentRepoInfo();
}
else if ( input == `delete )
{
@@ -643,6 +730,7 @@
{
deleteSource( current );
fillTable();
+ fillCurrentRepoInfo();
}
}
else if ( input == `enable )
@@ -650,12 +738,12 @@
boolean state = sourceState[ "enabled" ]:true;
state = !state;
// corresponds to the "Enable/Disable" button
- string newstate = ( state ? _("On") : _("Off") );
+ string newstate = ( state ? UI::Glyph (`CheckMark) : "");
UI::ChangeWidget( `id( `table ), `Item( current, 0 ), newstate );
sourceState[ "enabled" ] = state;
sourceStatesOut[ current ] = sourceState;
}
- else if ( input == `refresh_on_off )
+ else if ( input == `autorefresh)
{
integer source_id = sourceState["SrcId"]:0;
map src_data = Pkg::SourceGeneralData (source_id);
@@ -673,11 +761,12 @@
state = !state;
}
// corresponds to the "Enable/Disable" button
- string newstate = ( state ? _("On") : _("Off") );
- UI::ChangeWidget( `id( `table ), `Item( current, 1 ), newstate );
+// string newstate = ( state ? _("On") : _("Off") );
+// UI::ChangeWidget( `id( `table ), `Item( current, 1 ), newstate );
sourceState["autorefresh"] = state;
sourceStatesOut[ current ] = sourceState;
}
+/* moved to source edit dialog
else if (input == `set_alias)
{
string src_alias = sourceState["name"]:"";
@@ -730,6 +819,7 @@
sourceStatesOut[ current ] = sourceState;
}
}
+*/
}
} until ( exit );
@@ -741,6 +831,7 @@
symbol StoreSource () {
string url = SourceDialogs::GetURL ();
+ string name = SourceDialogs::GetRepoName ();
// special case, bugzilla #238680
if (url == "slp://")
@@ -781,7 +872,7 @@
}
}
- if (createSource(url, download_meta) == `again)
+ if (createSource(url, download_meta, name) == `again)
return `back;
return `next;
}
@@ -796,6 +887,13 @@
return ret;
}
+symbol EditDialog()
+{
+ SourceDialogs::SetRepoName ("");
+ symbol ret = SourceDialogs::EditDialog ();
+ return ret;
+}
+
// main function - start the workflow
symbol StartInstSource()
{
@@ -841,7 +939,7 @@
map aliases = $[
"summary" : ``(SummaryDialog ()),
"type" : ``(TypeDialog()),
- "edit" : ``(SourceDialogs::EditDialog ()),
+ "edit" : ``(EditDialog ()),
"store" : ``(StoreSource ())
];
Modified: trunk/packager/src/modules/SourceDialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/src/modules/SourceDialogs.ycp?rev=39735&r1=39734&r2=39735&view=diff
==============================================================================
--- trunk/packager/src/modules/SourceDialogs.ycp (original)
+++ trunk/packager/src/modules/SourceDialogs.ycp Fri Jul 27 11:09:01 2007
@@ -36,6 +36,11 @@
*/
string _url = "";
+/**
+ * Repo name to work with
+ */
+string _repo_name = "";
+
// value of the "download" check box
boolean _download_metadata = true;
@@ -73,6 +78,22 @@
}
/**
+ * Set the RepoName to work with
+ * @param repo_name string RepoName to run the dialogs with
+ */
+global void SetRepoName (string repo_name) {
+ _repo_name = repo_name;
+}
+
+/**
+ * Return RepoName after the run of the dialog
+ * @return string the RepoName
+ */
+global string GetRepoName () {
+ return _repo_name;
+}
+
+/**
* Postprocess URL of an ISO image
* @param url string URL in the original form
* @return string postprocessed URL
@@ -181,6 +202,56 @@
return scheme;
}
+/**
+ * Init function of a widget
+ * @param key string widget key
+ */
+void RepoNameInit (string key) {
+ UI::ChangeWidget (`id (`repo_name), `Value, _repo_name);
+}
+
+/**
+ * Store function of a widget
+ * @param key string widget key
+ * @param event map which caused settings being stored
+ */
+void RepoNameStore (string key, map event) {
+ _repo_name = (string)UI::QueryWidget (`id (`repo_name), `Value);
+}
+
+boolean RepoNameValidate (string key, map event) {
+ string repo_name = (string)UI::QueryWidget (`id (`repo_name), `Value);
+ if (repo_name == "" && _repo_name != "") // do not fail on new repo creation
+ {
+ UI::SetFocus (`id (`repo_name));
+ // popup message
+ Popup::Message (_("Name of the repository cannot be empty."));
+ return false;
+ }
+ return true;
+}
+/**
+ * Get widget description map
+ * @return widget description map
+ */
+map RepoNameWidget () {
+ return $[
+ "widget" : `custom,
+ "custom_widget" : `VBox (
+ // text entry
+ `TextEntry( `id( `repo_name ), _("&Repository Name") )
+ ),
+ "init" : RepoNameInit,
+ "store" : RepoNameStore,
+ "validate_type" : `function,
+ "validate_function" : RepoNameValidate,
+ // help text
+ "help" : _("<p><big><b>Repository Name</b></big><br>
+Use <b>Repository Name</b> to specify the name of the repository.</p>")
+ ];
+
+}
+
// raw URL editation widget
/**
@@ -1258,6 +1329,7 @@
map > Widgets () {
if (size (_widgets) == 0)
_widgets = $[
+ "repo_name" : RepoNameWidget(),
"url" : PlainURLWidget (),
"nfs" : NFSWidget (),
"cd" : CDWidget (),
@@ -1318,6 +1390,7 @@
`HSpacing (50),
// label
`Heading(_caption[proto]:""),
+ "repo_name",
proto,
`VSpacing(0.5),
PopupButtons ()
@@ -1336,7 +1409,7 @@
y2milestone ("Displaying popup for protocol %1", proto);
- list