/// <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>
 /// 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>
        /// 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;
            }
        }