mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-08 21:18:00 +03:00
Updated DinamycFieldsManager to get new "EditList" format (as simple list)
Updated to be version 1.4 There is intention to remove this administration client once the Web admin interface is finished & usable. Probable, half of 2013 this admin interface will be removed and will only keep the "Web version"
This commit is contained in:
parent
ad69d8fa6c
commit
3c7a0b82d7
@ -46,7 +46,7 @@ namespace UdsAdmin
|
||||
{
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
//UdsAdmin.Properties.Settings.Default.debug = true;
|
||||
UdsAdmin.Properties.Settings.Default.debug = true;
|
||||
foreach (string arg in args)
|
||||
{
|
||||
if (arg == "--enabledebug" || arg == "--enabledevel")
|
||||
|
@ -7,11 +7,11 @@ using System.Resources;
|
||||
// conjunto de atributos. Cambie estos atributos para modificar la información
|
||||
// asociada con un ensamblado.
|
||||
[assembly: AssemblyTitle("UDS Administration Client")]
|
||||
[assembly: AssemblyDescription("(c) 2012 Virtual Cable S.L.\nXML-RPC.NET Copyright (c) 2006 Charles Cook")]
|
||||
[assembly: AssemblyDescription("(c) 2012-2014 Virtual Cable S.L.\nXML-RPC.NET Copyright (c) 2006 Charles Cook")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Virtual Cable S.L.")]
|
||||
[assembly: AssemblyProduct("UDS Administration Client")]
|
||||
[assembly: AssemblyCopyright("Copyright © Virtual Cable 2012")]
|
||||
[assembly: AssemblyCopyright("Copyright © Virtual Cable 2012-2014")]
|
||||
[assembly: AssemblyTrademark("UDS Admin")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -33,6 +33,6 @@ using System.Resources;
|
||||
// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión
|
||||
// mediante el asterisco ('*'), como se muestra a continuación:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||
[assembly: AssemblyVersion("1.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
|
@ -183,43 +183,50 @@ namespace UdsAdmin.gui
|
||||
int row = 0;
|
||||
foreach (xmlrpc.GuiField fld in fields)
|
||||
{
|
||||
if (fld.gui.type != xmlrpc.Constants.HIDDEN_TYPE) // Hiden fields are textbox that don't appears and don't add rows..
|
||||
try
|
||||
{
|
||||
ToolTip tt = new ToolTip();
|
||||
// Creates the label
|
||||
Label label = new Label();
|
||||
label.AutoSize = true;
|
||||
label.Margin = new Padding(3, 6, 3, 6);
|
||||
label.Text = fld.gui.label;
|
||||
label.TextAlign = ContentAlignment.MiddleLeft;
|
||||
tt.SetToolTip(label, fld.gui.tooltip);
|
||||
panel.Controls.Add(label, 0, row);
|
||||
//panel.SetCellPosition(label, new TableLayoutPanelCellPosition(0, row));
|
||||
Control ctrl = ctrlTypeInfo[fld.gui.type].ctrlGenerator(fld, panel);
|
||||
ctrl.Dock = DockStyle.Fill;
|
||||
if (dict.ContainsKey(fld.name))
|
||||
if (fld.gui.type != xmlrpc.Constants.HIDDEN_TYPE) // Hiden fields are textbox that don't appears and don't add rows..
|
||||
{
|
||||
// We have it in order
|
||||
ordererValues.Add(dict[fld.name]);
|
||||
ToolTip tt = new ToolTip();
|
||||
// Creates the label
|
||||
Label label = new Label();
|
||||
label.AutoSize = true;
|
||||
label.Margin = new Padding(3, 6, 3, 6);
|
||||
label.Text = fld.gui.label;
|
||||
label.TextAlign = ContentAlignment.MiddleLeft;
|
||||
tt.SetToolTip(label, fld.gui.tooltip);
|
||||
panel.Controls.Add(label, 0, row);
|
||||
//panel.SetCellPosition(label, new TableLayoutPanelCellPosition(0, row));
|
||||
Control ctrl = ctrlTypeInfo[fld.gui.type].ctrlGenerator(fld, panel);
|
||||
ctrl.Dock = DockStyle.Fill;
|
||||
if (dict.ContainsKey(fld.name))
|
||||
{
|
||||
// We have it in order
|
||||
ordererValues.Add(dict[fld.name]);
|
||||
}
|
||||
if (fld.gui.rdonly == true && values != null)
|
||||
{
|
||||
label.Enabled = false;
|
||||
ctrl.Enabled = false;
|
||||
}
|
||||
panel.Controls.Add(ctrl, 1, row);
|
||||
// panel.SetCellPosition(ctrl, new TableLayoutPanelCellPosition(1, row));
|
||||
row++;
|
||||
}
|
||||
if (fld.gui.rdonly == true && values != null)
|
||||
{
|
||||
label.Enabled = false;
|
||||
ctrl.Enabled = false;
|
||||
}
|
||||
panel.Controls.Add(ctrl, 1, row);
|
||||
// panel.SetCellPosition(ctrl, new TableLayoutPanelCellPosition(1, row));
|
||||
row++;
|
||||
}
|
||||
else
|
||||
{
|
||||
TextBox hidden = new TextBox();
|
||||
if (fld.value != "")
|
||||
hidden.Text = fld.value;
|
||||
else
|
||||
hidden.Text = fld.gui.defvalue;
|
||||
hidden.Name = fld.name; hidden.Tag = fld; hidden.Visible = false;
|
||||
panel.Controls.Add(hidden, 0, 0);
|
||||
{
|
||||
TextBox hidden = new TextBox();
|
||||
if (fld.value != "")
|
||||
hidden.Text = fld.value;
|
||||
else
|
||||
hidden.Text = fld.gui.defvalue;
|
||||
hidden.Name = fld.name; hidden.Tag = fld; hidden.Visible = false;
|
||||
panel.Controls.Add(hidden, 0, 0);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UdsAdmin.gui.UserNotifier.notifyError(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,7 +372,7 @@ namespace UdsAdmin.gui
|
||||
Size sz = ctrlTypeInfo[fld.gui.type].sizeCalculator(fld);
|
||||
box.Width = sz.Width;
|
||||
box.Height = sz.Height;
|
||||
foreach (xmlrpc.Choice ch in fld.gui.values)
|
||||
foreach (xmlrpc.Choice ch in xmlrpc.Choice.fromValues(fld.gui.values))
|
||||
{
|
||||
box.Items.Add(ch);
|
||||
if (ch.id == fld.gui.defvalue)
|
||||
@ -377,26 +384,33 @@ namespace UdsAdmin.gui
|
||||
// We create a delegate to support the callback for this combo box
|
||||
box.SelectedIndexChanged += delegate(object sender, EventArgs args)
|
||||
{
|
||||
xmlrpc.GuiFieldValue[] data = new xmlrpc.GuiFieldValue[fld.gui.fills.parameters.Length];
|
||||
int pos = 0;
|
||||
foreach (string parameter in fld.gui.fills.parameters)
|
||||
try
|
||||
{
|
||||
Control[] ctrlParameter = container.Controls.Find(parameter, true);
|
||||
if (ctrlParameter.Length > 0)
|
||||
xmlrpc.GuiFieldValue[] data = new xmlrpc.GuiFieldValue[fld.gui.fills.parameters.Length];
|
||||
int pos = 0;
|
||||
foreach (string parameter in fld.gui.fills.parameters)
|
||||
{
|
||||
xmlrpc.GuiField field = (xmlrpc.GuiField)ctrlParameter[0].Tag;
|
||||
data[pos++] = ctrlTypeInfo[field.gui.type].dataExtractor(ctrlParameter[0], field, false);
|
||||
Control[] ctrlParameter = container.Controls.Find(parameter, true);
|
||||
if (ctrlParameter.Length > 0)
|
||||
{
|
||||
xmlrpc.GuiField field = (xmlrpc.GuiField)ctrlParameter[0].Tag;
|
||||
data[pos++] = ctrlTypeInfo[field.gui.type].dataExtractor(ctrlParameter[0], field, false);
|
||||
}
|
||||
}
|
||||
xmlrpc.GuiFieldValue[] newData = xmlrpc.UdsAdminService.InvokeChooseCallback(fld.gui.fills.callbackName, data);
|
||||
foreach (xmlrpc.GuiFieldValue val in newData)
|
||||
{
|
||||
Control[] ctrlResult = container.Controls.Find(val.name, true);
|
||||
if (ctrlResult.Length > 0)
|
||||
{
|
||||
xmlrpc.GuiField field = (xmlrpc.GuiField)ctrlResult[0].Tag;
|
||||
ctrlTypeInfo[field.gui.type].dataWriter(ctrlResult[0], val);
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlrpc.GuiFieldValue[] newData = xmlrpc.UdsAdminService.InvokeChooseCallback(fld.gui.fills.callbackName, data);
|
||||
foreach (xmlrpc.GuiFieldValue val in newData)
|
||||
catch (Exception e)
|
||||
{
|
||||
Control[] ctrlResult = container.Controls.Find(val.name, true);
|
||||
if (ctrlResult.Length > 0)
|
||||
{
|
||||
xmlrpc.GuiField field = (xmlrpc.GuiField)ctrlResult[0].Tag;
|
||||
ctrlTypeInfo[field.gui.type].dataWriter(ctrlResult[0], val);
|
||||
}
|
||||
UdsAdmin.gui.UserNotifier.notifyError(e.Message);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -414,7 +428,7 @@ namespace UdsAdmin.gui
|
||||
Size sz = ctrlTypeInfo[fld.gui.type].sizeCalculator(fld);
|
||||
box.Width = sz.Width;
|
||||
box.Height = sz.Height;
|
||||
foreach (xmlrpc.Choice ch in fld.gui.values)
|
||||
foreach (xmlrpc.Choice ch in xmlrpc.Choice.fromValues(fld.gui.values))
|
||||
{
|
||||
box.Items.Add(ch);
|
||||
if (fld.gui.defvalue == ch.id)
|
||||
@ -433,8 +447,8 @@ namespace UdsAdmin.gui
|
||||
Size sz = ctrlTypeInfo[fld.gui.type].sizeCalculator(fld);
|
||||
lst.Width = sz.Width;
|
||||
List<string> vals = new List<string>();
|
||||
foreach (xmlrpc.Choice ch in fld.gui.values)
|
||||
vals.Add(ch.id);
|
||||
foreach (String ch in fld.gui.values)
|
||||
vals.Add(ch);
|
||||
lst.Items = vals;
|
||||
|
||||
return lst;
|
||||
@ -564,12 +578,9 @@ namespace UdsAdmin.gui
|
||||
{
|
||||
controls.ListEditor lst = (controls.ListEditor)ctrl;
|
||||
List<string> vals = lst.Items;
|
||||
xmlrpc.Choice[] selected = new xmlrpc.Choice[vals.Count];
|
||||
for (int i = 0; i < vals.Count; i++)
|
||||
selected[i] = new xmlrpc.Choice(vals[i], ""); // Returned values goes inside ids (the significant part of choices, text are used to display data to user)
|
||||
if ( validate && fld.gui.required && selected.Length == 0)
|
||||
if ( validate && fld.gui.required && vals.Count == 0)
|
||||
throw new ValidationError(fld);
|
||||
return new xmlrpc.GuiFieldValue(fld.name, selected);
|
||||
return new xmlrpc.GuiFieldValue(fld.name, vals.ToArray());
|
||||
}
|
||||
|
||||
private static xmlrpc.GuiFieldValue CheckBoxExtractor(Control ctrl, xmlrpc.GuiField fld, bool validate)
|
||||
@ -605,7 +616,7 @@ namespace UdsAdmin.gui
|
||||
{
|
||||
ComboBox box = (ComboBox)ctrl;
|
||||
box.Items.Clear();
|
||||
foreach (xmlrpc.Choice ch in value.values)
|
||||
foreach (xmlrpc.Choice ch in xmlrpc.Choice.fromValues(value.values))
|
||||
{
|
||||
box.Items.Add(ch);
|
||||
}
|
||||
@ -619,7 +630,7 @@ namespace UdsAdmin.gui
|
||||
{
|
||||
ListBox box = (ListBox)ctrl;
|
||||
box.Items.Clear();
|
||||
foreach (xmlrpc.Choice ch in value.values)
|
||||
foreach (xmlrpc.Choice ch in xmlrpc.Choice.fromValues(value.values))
|
||||
{
|
||||
box.Items.Add(ch);
|
||||
}
|
||||
@ -629,8 +640,8 @@ namespace UdsAdmin.gui
|
||||
{
|
||||
controls.ListEditor lst = (controls.ListEditor)ctrl;
|
||||
List<string> vals = new List<string>();
|
||||
foreach (xmlrpc.Choice ch in value.values)
|
||||
vals.Add(ch.text);
|
||||
foreach (string ch in value.values)
|
||||
vals.Add(ch);
|
||||
lst.Items = vals;
|
||||
}
|
||||
|
||||
@ -670,7 +681,7 @@ namespace UdsAdmin.gui
|
||||
ListBox box = (ListBox)ctrl;
|
||||
box.BeginUpdate();
|
||||
box.ClearSelected();
|
||||
foreach (xmlrpc.Choice val in value.values)
|
||||
foreach (xmlrpc.Choice val in xmlrpc.Choice.fromValues(value.values))
|
||||
box.SelectedItems.Add(val);
|
||||
box.EndUpdate();
|
||||
}
|
||||
@ -680,8 +691,8 @@ namespace UdsAdmin.gui
|
||||
// All items are "Selected" in editlist, i mean, we fill the list with this items
|
||||
controls.ListEditor lst = (controls.ListEditor)ctrl;
|
||||
List<string> vals = new List<string>();
|
||||
foreach (xmlrpc.Choice ch in value.values)
|
||||
vals.Add(ch.id);
|
||||
foreach (String ch in value.values)
|
||||
vals.Add(ch);
|
||||
lst.Items = vals;
|
||||
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ namespace UdsAdmin.xmlrpc
|
||||
public string type;
|
||||
// Choice values (available only for choices)
|
||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
||||
public Choice[] values;
|
||||
public Object[] values;
|
||||
|
||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
||||
public ChoiceCallback fills;
|
||||
@ -153,7 +153,7 @@ namespace UdsAdmin.xmlrpc
|
||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
||||
public string value;
|
||||
[XmlRpcMissingMapping(MappingAction.Ignore)]
|
||||
public Choice[] values;
|
||||
public Object[] values;
|
||||
|
||||
public GuiFieldValue(string name, string value)
|
||||
{
|
||||
@ -166,9 +166,21 @@ namespace UdsAdmin.xmlrpc
|
||||
{
|
||||
this.name = name;
|
||||
this.value = null;
|
||||
this.values = values;
|
||||
this.values = new Object[values.Length];
|
||||
for (int i = values.Length - 1; i >= 0; i--)
|
||||
this.values[i] = values[i];
|
||||
}
|
||||
|
||||
public GuiFieldValue(string name, string[] values)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = null;
|
||||
this.values = new Object[values.Length];
|
||||
for (int i = values.Length - 1; i >= 0; i--)
|
||||
this.values[i] = values[i];
|
||||
}
|
||||
|
||||
|
||||
static public string getData(GuiFieldValue[] fields, string field)
|
||||
{
|
||||
foreach( GuiFieldValue g in fields )
|
||||
@ -455,6 +467,12 @@ namespace UdsAdmin.xmlrpc
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Choice(XmlRpcStruct s)
|
||||
{
|
||||
this.id = (string)s["id"];
|
||||
this.text = (string)s["text"];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return text;
|
||||
@ -471,6 +489,17 @@ namespace UdsAdmin.xmlrpc
|
||||
}
|
||||
|
||||
public override int GetHashCode() { return 0; }
|
||||
|
||||
public static List<Choice> fromValues(Object[] values)
|
||||
{
|
||||
List<Choice> res = new List<Choice>(values.Length);
|
||||
foreach (Object o in values)
|
||||
{
|
||||
Choice ch = new Choice((CookComputing.XmlRpc.XmlRpcStruct)o);
|
||||
res.Add(ch);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
// Comparators
|
||||
|
Loading…
Reference in New Issue
Block a user