///<summary>
 /// Constructor
 /// </summary>
 /// <param name="factory">A  BoxModuleFactoryPrx</param>
 /// <param name="propertyClassIceId">A  string</param>
 /// <param name="propertyFunctionsIceIds">A  string[]</param>
 /// <param name="identifier">A  string</param>
 public PropertyBoxModuleI(BoxModuleFactoryPrx factory, string propertyClassIceId, string[] propertyFunctionsIceIds, Ice.ObjectAdapter adapter, Ice.Identity myIdentity, Modules.PropertyBoxModuleFactoryCreatorI.ValueFromPrx valueFromPrx, PropertyValue defaultValue)
 {
     this.factory = factory;
     this.propertyClassIceId = propertyClassIceId;
     this.propertyFunctionsIceIds = propertyFunctionsIceIds;
     this.myProxy = BoxModulePrxHelper.uncheckedCast(adapter.add(this,myIdentity));
     this.adapter = adapter;
     this.valueFromPrx = valueFromPrx;
     this.defaultValue = defaultValue;
     this.setProperty("value",defaultValue);
 }
 public override PropertyValue run(PropertyValue valueBefore, BoxModulePrx boxModuleParam, String[] localePrefs, ManagersEnginePrx manager, out String about, Ice.Current __current)
 {
     Ferda.FrontEnd.StringSeqForm f = new Ferda.FrontEnd.StringSeqForm();
     f.Items = ((StringSeqTI)valueBefore).stringSeqValue;
     f.ShowInTaskbar = false;
     System.Windows.Forms.DialogResult result = this.ownerOfAddIn.ShowDialog(f);
     if(result == System.Windows.Forms.DialogResult.OK)
     {
         PropertyValue resultValue = new StringSeqTI(f.Items);
         about = this.getPropertyAbout(resultValue);
         return resultValue;
     }
     else
     {
         about = this.getPropertyAbout(valueBefore);
         return valueBefore;
     }
 }
 public override PropertyValue run(PropertyValue valueBefore, BoxModulePrx boxModuleParam, String[] localePrefs, ManagersEnginePrx manager, out String about, Ice.Current __current)
 {
     about = "ttt";
     return new StringSeqTI(new string[]{"ttt"});
 }
 /// <summary>
 /// Method setConnection
 /// </summary>
 /// <param name="socketName">A  string</param>
 /// <param name="otherModule">A  Ferda.Modules.BoxModulePrx</param>
 /// <param name="__current">An Ice.Current</param>
 public override void setConnection(String socketName, BoxModulePrx otherModule, Current __current)
 {
     if (! (socketName == "value"))
     {
         throw new Ferda.Modules.NameNotExistError();
     }
     if(propertyValuePrx!= null && !propertySetByValue)
     {
         throw new Modules.ConnectionExistsError();
     }
     Ice.ObjectPrx prx = otherModule.getFunctions();
     if(!prx.ice_isA(this.propertyFunctionsIceIds[0]))
         throw new Ferda.Modules.BadTypeError();
     if(propertyValuePrx != null && propertySetByValue)
         adapter.remove(propertyValuePrx.ice_getIdentity());
     this.propertyValuePrx = prx;
     connectedBox = otherModule;
     this.propertySetByValue = false;
 }
 /// <summary>
 /// Ice run method
 /// </summary>
 /// <param name="valueBefore">Previous parameter value</param>
 /// <param name="boxModuleParam"></param>
 /// <param name="localePrefs"></param>
 /// <param name="manager"></param>
 /// <param name="about"></param>
 /// <param name="__current"></param>
 /// <returns>New property value</returns>
 public override PropertyValue run(PropertyValue valueBefore, BoxModulePrx boxModuleParam, string[] localePrefs, ManagersEnginePrx manager, out string about, Ice.Current __current)
 {
     PropertyValue propertyValue = valueBefore;
     string locale;
     try
     {
         locale = localePrefs[0];
         localizationString = locale;
         locale = "Ferda.FrontEnd.AddIns.EditCategories.Localization_" + locale;
         resManager = new ResourceManager(locale, Assembly.GetExecutingAssembly());
     }
     catch
     {
     }
     about = resManager.GetString("EditCategoriesAbout");
     try
     {
         Ferda.Modules.Boxes.DataMiningCommon.Attributes.AbstractAttributeFunctionsPrx prx =
        Ferda.Modules.Boxes.DataMiningCommon.Attributes.AbstractAttributeFunctionsPrxHelper.checkedCast(boxModuleParam.getFunctions());
         String[] distinctValues;
         PropertyValue returnValue = new PropertyValue();
         CategoriesT categories = (CategoriesT)valueBefore;
         try
         {
             BoxModulePrx boxModuleParamNew = boxModuleParam.getConnections("ColumnOrDerivedColumn")[0];
             Ferda.Modules.Boxes.DataMiningCommon.Column.ColumnFunctionsPrx prx1 =
                 Ferda.Modules.Boxes.DataMiningCommon.Column.ColumnFunctionsPrxHelper.checkedCast(boxModuleParamNew.getFunctions());
             distinctValues = prx1.getDistinctValues();
         }
         catch
         {
             distinctValues = null;
         }
         Ferda.FrontEnd.AddIns.EditCategories.MainListView listView = new Ferda.FrontEnd.AddIns.EditCategories.MainListView(localePrefs, categories.categoriesValue, distinctValues, ownerOfAddIn);
         listView.ShowInTaskbar = false;
         listView.Disposed += new EventHandler(SetCategories);
         System.Windows.Forms.DialogResult result = this.ownerOfAddIn.ShowDialog(listView);
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             PropertyValue resultValue = new CategoriesTI(this.categories);
             about = this.getPropertyAbout(resultValue);
             propertyValue = resultValue;
         }
         else
         {
             about = this.getPropertyAbout(valueBefore);
         }
     }
     catch (Ferda.Modules.BadParamsError ex)
     {
         if (ex.restrictionType == Ferda.Modules.restrictionTypeEnum.DbConnectionString)
         {
             MessageBox.Show(resManager.GetString("BadConnectionString"), resManager.GetString("Error"),
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else if (ex.restrictionType == Ferda.Modules.restrictionTypeEnum.DbTable)
         {
             MessageBox.Show(resManager.GetString("NoDataMatrix"), resManager.GetString("Error"),
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else if (ex.restrictionType == Ferda.Modules.restrictionTypeEnum.DbColumn)
         {
             MessageBox.Show(resManager.GetString("BadColumnSelectExpression"), resManager.GetString("Error"),
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             MessageBox.Show(resManager.GetString("InvalidParameters"), resManager.GetString("Error"),
                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Ferda.Modules.NoConnectionInSocketError)
     {
         MessageBox.Show(resManager.GetString("BoxNotConnected"), resManager.GetString("Error"),
                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     return propertyValue;
 }
 /// <summary>
 /// Similar to <see cref="M:Ferda.Modules.Boxes.SocketConnections.GetBoxModulePrx(Ferda.Modules.BoxModuleI,System.String)"/>
 /// </summary>
 /// <param name="boxModule">Box Module (having socket named <c>socketName</c>).</param>
 /// <param name="socketName">Name of socket.</param>
 /// <param name="boxModulePrx"><see cref="T:Ferda.Modules.BoxModulePrx"/> i.e. proxy 
 /// of box module connected in <c>socketName</c>.</param>
 /// <returns>True is returned iff there is just one box module object connected 
 /// in the socket. If true is returned than proxy of the box module is given
 /// in out parameter <c>boxModulePrx</c>.</returns>
 /// <exception cref="T:System.Exception">Thrown iff there 
 /// is connected more than one BoxModule in <c>socketName</c>.
 /// </exception>
 public static bool TryGetBoxModulePrx(BoxModuleI boxModule, string socketName, out BoxModulePrx boxModulePrx)
 {
     BoxModulePrx[] connections = boxModule.GetConnections(socketName);
     if (connections.Length == 0)
     {
         boxModulePrx = null;
         return false;
     }
     else if (connections.Length == 1)
     {
         foreach (BoxModulePrx prx in connections)
         {
             boxModulePrx = prx;
             return true;
         }
     }
     string message = "BoxInf17: There should be connected one box at maximum! in socket: \"" + socketName + "\".";
     System.Diagnostics.Debug.WriteLine(message);
     throw new Exception(message);
 }
        /// <summary>
        /// Initializes a new instance of the 
        /// <see cref="T:Ferda.Modules.BoxModuleI"/> class.
        /// </summary>
        /// <param name="boxInfo">The box info.</param>
        /// <param name="myIdentity">My identity.</param>
        /// <param name="myFactoryProxy">My factory proxy.</param>
        /// <param name="manager">The manager.</param>
        /// <param name="adapter">The adapter.</param>
        /// <param name="localePrefs">The localization preferences.</param>
        public BoxModuleI(IBoxInfo boxInfo,
            Ice.Identity myIdentity,
            BoxModuleFactoryPrx myFactoryProxy,
            Ferda.ModulesManager.ManagersEnginePrx manager,
            Ice.ObjectAdapter adapter,
            string[] localePrefs)
        {
            System.Diagnostics.Debug.WriteLine("BoxModuleI Constructor (entering): " + boxInfo.Identifier);

            // initializes inner fields by specified parameters
            this.boxInfo = boxInfo;
            this.iceIdentity = myIdentity;
            this.stringIceIdentity = Ice.Util.identityToString(IceIdentity);
            this.myFactoryProxy = myFactoryProxy;
            this.manager = manager;
            this.adapter = adapter;
            this.localePrefs = localePrefs;

            // add the new box module to the specified adapter
            adapter.add(this, this.iceIdentity);
            // get my proxy
            this.myProxy = BoxModulePrxHelper.uncheckedCast(adapter.createProxy(myIdentity));

            // initializes box module`s functions object
            this.boxInfo.CreateFunctions(this, out this.functionsIceObj, out this.functionsIObj);
            this.functionsIObj.setBoxModuleInfo(this, this.boxInfo);
            this.functionsObjPrx = Ice.ObjectPrxHelper.uncheckedCast(adapter.addWithUUID(this.functionsIceObj));

            // initializes properties
            this.properties = new Dictionary<string, PropertyValue>();
            foreach (string propertyName in boxInfo.GetPropertiesNames())
            {
                if (!boxInfo.IsPropertyReadOnly(propertyName))
                {
                    this.setProperty(propertyName, boxInfo.GetPropertyDefaultValue(propertyName));
                }
            }

            // initializes sockets (connections and functions)
            this.connections = new Dictionary<string, Dictionary<string, BoxModulePrx>>();
            foreach (string socketName in boxInfo.GetSocketNames())
            {
                connections[socketName] = new Dictionary<string, BoxModulePrx>();
            }

            System.Diagnostics.Debug.WriteLine("BoxModuleI Constructor (leaving): " + this.boxInfo.Identifier);
        }
 /// <summary>
 /// <para>
 /// Gets the boxes (proxies of the box modules) connected 
 /// to the socket of the specified name.
 /// </para>
 /// <para>
 /// Using of <see cref="T:Ferda.Modules.Boxes.SocketConnections">
 /// helper</see> is recommended.
 /// </para>
 /// </summary>
 /// <param name="socketName">Name of the socket.</param>
 /// <returns>
 /// Array of <see cref="T:Ferda.Modules.BoxModulePrx">
 /// proxies of box modules</see> connected in the specified socket.
 /// </returns>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 /// Thrown iff specified <c>socketName</c> doesn`t match any
 /// socket in the box module.
 /// </exception>
 /// <seealso cref="T:Ferda.Modules.Boxes.SocketConnections"/>
 public BoxModulePrx[] GetConnections(string socketName)
 {
     try
     {
         lock (this)
         {
             BoxModulePrx[] result = new BoxModulePrx[connections[socketName].Values.Count];
             connections[socketName].Values.CopyTo(result, 0);
             return result;
         }
     }
     catch (KeyNotFoundException ex)
     {
         string message = "BMI03: " + ex.Message;
         Debug.WriteLine(message);
         throw new ArgumentOutOfRangeException("socketName", socketName, message);
     }
 }
        /// <summary>
        /// Sets the connection to specified box module (<c>otherModule</c>)
        /// in specified socket (<c>socketName</c>).
        /// </summary>
        /// <param name="socketName">Name of the socket.</param>
        /// <param name="otherModule">The other module.</param>
        /// <param name="__current">The Ice.Current.</param>
        /// <exception cref="T:Ferda.Modules.NameNotExistError">
        /// Thrown if socket named <c>socketName</c> doesn`t exist in the box module.
        /// </exception>
        /// <exception cref="T:Ferda.Modules.BadTypeError">
        /// Thrown if the type of functions provided by 
        /// the <c>otherModule</c> is not accepted by the socket.
        /// </exception>
        /// <exception cref="T:Ferda.Modules.ConnectionExistsError">
        /// Thrown if the socket accept only one connection and it is already used.
        /// </exception>
        public override void setConnection(string socketName, BoxModulePrx otherModule, Ice.Current __current)
        {
            // tests specified socketName existence
            if (!this.boxInfo.TestSocketNameExistence(socketName))
            {
                throw Ferda.Modules.Exceptions.NameNotExistError(null, null, "BMI21", socketName);
            }

            // tests Ferda.Modules.BoxType of otherModule
            bool badTypeError = true;
            Ice.ObjectPrx objPrx = otherModule.getFunctions();
            SocketInfo[] otherModuleSocketInfos = otherModule.getMyFactory().getSockets();
            foreach (BoxType socketBoxType in
                this.boxInfo.GetSocketTypes(socketName))
            {
                // tests otherModule`s functions type (functionsPrx.ice_isA)
                // tests if otherModule has needed sockets
                if (hasBoxType(socketBoxType, objPrx, otherModuleSocketInfos))
                {
                    badTypeError = false;
                    break;
                }
            }
            if (badTypeError)
            {
                // type of otherModule`s functions is bad
                Debug.WriteLine("BMI22");
                throw new Ferda.Modules.BadTypeError();
            }

            string identity = Ice.Util.identityToString(otherModule.ice_getIdentity());

            lock (this)
            {
                // the socket is actually property (i.e. value of the property is set by its socket)
                if (boxInfo.TestPropertyNameExistence(socketName))
                {
                    properties.Remove(socketName);
                }
                else
                {
                    // tests if socket (accepting only one connection) is already full
                    if ((!this.boxInfo.IsSocketMoreThanOne(socketName)) &&
                        this.connections[socketName].Count != 0)
                    {
                        // the socket is already used -> exception is thrown
                        Debug.WriteLine("BMI23");
                        throw new ConnectionExistsError();
                    }
                }
                this.connections[socketName][identity] = otherModule;
            }
        }
 /// <summary>
 /// Removes <see cref="T:Ferda.ModulesManager.BoxModule"/> from
 /// internal collection of boxes.
 /// </summary>
 /// <param name="proxy">A <see cref="T:Ferda.Modules.BoxModulePrx"/></param>
 protected internal void removeBoxModuleWithProxy(BoxModulePrx proxy)
 {
     boxModuleByProxyIdentity.Remove(proxy.ice_getIdentity());
 }
 /// <summary>
 /// Adds <see cref="T:Ferda.ModulesManager.BoxModule"/> to internal collection of boxes
 /// </summary>
 /// <param name="box">A <see cref="T:Ferda.ModulesManager.BoxModule"/></param>
 /// <param name="proxy">A <see cref="T:Ferda.Modules.BoxModulePrx"/></param>
 protected internal void addBoxModuleWithProxy(Ferda.ModulesManager.BoxModule box, BoxModulePrx proxy)
 {
     boxModuleByProxyIdentity[proxy.ice_getIdentity()]=box;
 }
 /// <summary>
 /// Gets <see cref="T:Ferda.ModulesManager.BoxModule"/>
 /// by <see cref="T:Ferda.Modules.BoxModulePrx"/>.
 /// </summary>
 /// <returns>A <see cref="T:Ferda.ModulesManager.BoxModule"/></returns>
 /// <param name="proxy">A <see cref="T:Ferda.Modules.BoxModulePrx"/></param>
 protected internal Ferda.ModulesManager.BoxModule getBoxModuleByProxy(BoxModulePrx proxy)
 {
     return boxModuleByProxyIdentity[proxy.ice_getIdentity()];
 }
        /// <summary>
        /// Ice run
        /// </summary>
        /// <param name="valueBefore">Previous value</param>
        /// <param name="boxModuleParam">boxmoduleparam</param>
        /// <param name="localePrefs">localeprefs</param>
        /// <param name="manager">Manager proxy</param>
        /// <param name="about"></param>
        /// <param name="current__">Ice context</param>
        /// <returns>Modified property value</returns>
        public override PropertyValue run(PropertyValue valueBefore, BoxModulePrx boxModuleParam, string[] localePrefs, ManagersEnginePrx manager, out string about, global::Ice.Current current__)
        {
            string locale;
            try
            {
                locale = localePrefs[0];
                localizationString = locale;
                locale = "Ferda.FrontEnd.AddIns.ODBCConnectionString.Localization_" + locale;
                resManager = new ResourceManager(locale, Assembly.GetExecutingAssembly());
            }
            catch
            {
            }

            about = resManager.GetString("ConnectionStringAbout");
            StringT connectionString = (StringT)valueBefore;
            PropertyValue returnValue = new PropertyValue();
            PropertyValue propertyValue = valueBefore;
            Ferda.FrontEnd.AddIns.ODBCConnectionString.ODBCConnectionStringControl listView = new Ferda.FrontEnd.AddIns.ODBCConnectionString.ODBCConnectionStringControl(localePrefs, connectionString.getStringValue(),ownerOfAddIn);
            listView.ShowInTaskbar = false;
            listView.Disposed += new EventHandler(listView_Disposed);
            System.Windows.Forms.DialogResult result = this.ownerOfAddIn.ShowDialog(listView);
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                connectionString.stringValue = this.returnString;
                PropertyValue resultValue = connectionString;
                about = this.getPropertyAbout(resultValue);
                propertyValue = resultValue;
            }
            else
            {
                about = this.getPropertyAbout(valueBefore);
                return valueBefore;
            }

            return propertyValue;
        }