// ---------------------------------------- /// <summary> /// Finding all ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">type of searched boxes (string identifier)</param> /// <returns></returns> public static IBoxModule[] ListAncestBoxesWithID(IBoxModule Box, string ID) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { if (b.MadeInCreator.Identifier == ID) // this ancestor has desired type MyBoxes.Add(b); else // ancestor doesn't have desired type. Further we searche among it's ancestors (recurse) { IBoxModule[] b_ancestors = ListAncestBoxesWithID(b, ID); // recurse foreach (IBoxModule bb in b_ancestors) MyBoxes.Add(bb); } } // eliminating the duplicites MyBoxes.Sort(); IBoxModule[] SortedBoxes = (IBoxModule[])MyBoxes.ToArray(typeof(IBoxModule)); ArrayList MyUniqueBoxes = new ArrayList(); foreach (IBoxModule bbb in SortedBoxes) { if (MyUniqueBoxes.BinarySearch(bbb) < 0) MyUniqueBoxes.Add(bbb); } IBoxModule[] resultArray = (IBoxModule[])MyUniqueBoxes.ToArray(typeof(IBoxModule)); return resultArray; }
/// <summary> /// Adds categorie and labels of box <paramref name="box"/> to class structures /// </summary> /// <param name="box">A box</param> private void addBoxCategories(IBoxModule box) { IBoxModuleFactoryCreator creator = box.MadeInCreator; foreach(string category in creator.BoxCategories) { if(!boxCategories.Contains(category)) { boxCategories.Add(category); boxesInCategory[category] = new List<IBoxModule>(); } boxesInCategory[category].Add(box); } string label = creator.Label; if(!boxLabels.Contains(label)) { boxLabels.Add(label); boxesWithLabel[label] = new List<IBoxModule>(); } boxesWithLabel[label].Add(box); foreach (string category in creator.BoxCategories) { if (!labelsInCategory.ContainsKey(category)) { labelsInCategory[category] = new StringCollection(); labelsInCategory[category].Add(label); } else { if (!labelsInCategory[category].Contains(label)) { labelsInCategory[category].Add(label); } } } }
/// <summary> /// Default constructor of the class /// </summary> /// <param name="mod">Modules manager of the application</param> /// <param name="resManager">Resource manager</param> /// <param name="box">Box that has thrown the exception</param> /// <param name="userMessage">Message to be displayed to the user</param> public BoxExceptionClass(IBoxModule box, string userMessage, Ferda.FrontEnd.AddIns.IOwnerOfAddIn ownerOfAddIn) { // this.resourceManager = resManager; this.box = box; this.userMessage = userMessage; this.modulesManager = ownerOfAddIn.ProjectManager.ModulesManager; this.ownerOfAddIn = ownerOfAddIn; }
/// <summary> /// Default constructor of the class /// </summary> /// <param name="menuItem">Modules manager of the application</param> /// <param name="resManager">Resource manager</param> /// <param name="box">Box that has thrown the exception</param> /// <param name="userMessage">Message to be displayed to the user</param> public BoxExceptionThreadClass(ModulesManager.ModulesManager mod, ResourceManager resManager, IBoxModule box, string userMessage) { this.resourceManager = resManager; this.box = box; this.userMessage = userMessage; this.modulesManager = mod; }
private void getBoxModuleProperties(IBoxModule boxModule) { Debug.WriteLine("enterint test get properties ..."); PropertyInfo[] properties = boxModule.MadeInCreator.Properties; foreach (PropertyInfo property in properties) { string propertyName = property.name; Debug.WriteLine("try to get property " + propertyName); switch (property.typeClassIceId) { case "::Ferda::Modules::BoolT": boxModule.GetPropertyBool(propertyName); break; case "::Ferda::Modules::DateT": boxModule.GetPropertyDate(propertyName); break; case "::Ferda::Modules::DateTimeT": boxModule.GetPropertyDateTime(propertyName); break; case "::Ferda::Modules::DoubleT": boxModule.GetPropertyDouble(propertyName); break; case "::Ferda::Modules::FloatT": boxModule.GetPropertyFloat(propertyName); break; case "::Ferda::Modules::IntT": boxModule.GetPropertyInt(propertyName); break; case "::Ferda::Modules::LongT": boxModule.GetPropertyLong(propertyName); break; case "::Ferda::Modules::ShortT": boxModule.GetPropertyShort(propertyName); break; case "::Ferda::Modules::StringT": boxModule.GetPropertyString(propertyName); if (property.selectBoxParams != null && property.selectBoxParams.Length > 0) boxModule.GetPropertyOptions(propertyName); break; case "::Ferda::Modules::TimeT": boxModule.GetPropertyTime(propertyName); break; case "::Ferda::Modules::OtherT": //TODO break; } } Debug.WriteLine("leaving test get properties ..."); }
// ---------------------------------------- /// <summary> /// Finding all direct ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">type of searched boxes (string identifier)</param> /// <returns></returns> public static IBoxModule[] ListDirectAncestBoxesWithID(IBoxModule Box, string ID) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { if (b.MadeInCreator.Identifier == ID) { MyBoxes.Add(b); } } return(MyBoxes.ToArray(typeof(IBoxModule)) as IBoxModule[]); }
/// <summary> /// generates one item (parcial cedent) to XML string /// </summary> /// <param name="box">box of parcial cedent</param> /// <param name="rCFCedent">record with CF cedent</param> /// <param name="CedentType">cedent type</param> /// <returns>XML string</returns> private static string getOneItemXML(IBoxModule box, Rec_CF_cedent rCFCedent, string CedentType) { string resultStr = ""; IBoxModule[] SubCedents = box.GetConnections(CedentType); // setting attribute "sub_cedent_cnt" (count of parcial cedents) rCFCedent.sub_cedent_cnt = SubCedents.Length; // adding CF cedent to XML if (rCFCedent.sub_cedent_cnt > 0) { resultStr = rCFCedent.ToXML(getOneCedentXML(SubCedents)); } return(resultStr); }
/// <summary> /// generates one cedent to XML string /// </summary> /// <param name="box">cedent box</param> /// <param name="rKLCedent">cedent record</param> /// <param name="CedentType">cedent type</param> /// <returns>XML string</returns> private static string getOneItemXML(IBoxModule box, Rec_KL_cedent rKLCedent, string CedentType) { string resultStr = ""; IBoxModule[] SubCedents = box.GetConnections(CedentType); rKLCedent.sub_cedent_cnt = SubCedents.Length; // adding KL cedent to XML if (rKLCedent.sub_cedent_cnt > 0) { resultStr = rKLCedent.ToXML(getOneCedentXML(SubCedents)); } return(resultStr); }
// ---------------------------------------- /// <summary> /// Finding all ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">type of searched boxes (string identifier)</param> /// <returns></returns> public static IBoxModule[] ListAncestBoxesWithID(IBoxModule Box, string ID) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { if (b.MadeInCreator.Identifier == ID) // this ancestor has desired type { MyBoxes.Add(b); } else // ancestor doesn't have desired type. Further we searche among it's ancestors (recurse) { IBoxModule[] b_ancestors = ListAncestBoxesWithID(b, ID); // recurse foreach (IBoxModule bb in b_ancestors) { MyBoxes.Add(bb); } } } // eliminating the duplicites MyBoxes.Sort(); IBoxModule[] SortedBoxes = (IBoxModule[])MyBoxes.ToArray(typeof(IBoxModule)); ArrayList MyUniqueBoxes = new ArrayList(); foreach (IBoxModule bbb in SortedBoxes) { if (MyUniqueBoxes.BinarySearch(bbb) < 0) { MyUniqueBoxes.Add(bbb); } } IBoxModule[] resultArray = (IBoxModule[])MyUniqueBoxes.ToArray(typeof(IBoxModule)); return(resultArray); }
/// <summary> /// Creates ModulesForCreationSubmenu for a selected box /// </summary> /// <param name="box">Boxes asking ofr creation of this box should be /// created /// </param> /// <param name="menuItem">The menu Item, where all the subitems should be added /// </param> protected void CreateModulesForCreationMenu(ToolStripMenuItem menuItem, IBoxModule box) { ToolStripMenuItem it; List<ToolStripMenuItem> modules = new List<ToolStripMenuItem>(); foreach (ModulesAskingForCreation info in box.ModulesAskingForCreation) { it = new ToolStripMenuItem(info.label); it.Click += new EventHandler(Creation_Click); modules.Add(it); } foreach (ToolStripMenuItem item in modules) { menuItem.DropDownItems.Add(item); } }
/// <summary> /// Constructor of the class when we want to get a property /// </summary> /// <param name="box">Box</param> /// <param name="res">Default resource manager</param> /// <param name="name">name of the property</param> /// <param name="views">Views to be refreshed</param> /// <param name="prop">To reset the propertygrid afterwards</param> /// <param name="arch">archive of the application</param> public OtherProperty(IBoxModule box, string name, Archive.IArchiveDisplayer arch, List<Desktop.IViewDisplayer> views, IPropertiesDisplayer prop, ResourceManager res) { this.box = box; this.propertyName = name; this.result = String.Empty; archiveDisplayer = arch; viewDisplayers = views; propertiesDisplayer = prop; resManager = res; }
/// <summary> /// Creates a context menu when a box is selected /// </summary> /// <param name="box">box which context menu should be created</param> protected ContextMenuStrip CreateBoxContextMenu(IBoxModule box) { bool canPack = false; bool canUnpack = false; bool containsDynamic = false; ContextMenuStrip cMenu = new ContextMenuStrip(); //creating dynamic parts of the menu if (box.MadeInCreator.Actions.Length != 0) { containsDynamic = true; ToolStripMenuItem actions = new ToolStripMenuItem(ResManager.GetString("MenuActions")); CreateActionsMenu(actions, box); cMenu.Items.Add(actions); } if (box.ModuleForInteractionInfos.Length != 0) { containsDynamic = true; ToolStripMenuItem modulesForInteraction = new ToolStripMenuItem(ResManager.GetString("MenuModulesForInteraction")); CreateModulesForInteractionMenu(modulesForInteraction, box); cMenu.Items.Add(modulesForInteraction); } if (box.ModulesAskingForCreation.Length != 0) { containsDynamic = true; ToolStripMenuItem modulesForCreation = new ToolStripMenuItem(ResManager.GetString("MenuModulesAskingCreation")); CreateModulesForCreationMenu(modulesForCreation, box); cMenu.Items.Add(modulesForCreation); } if (containsDynamic) { ToolStripSeparator sep0 = new ToolStripSeparator(); cMenu.Items.Add(sep0); } //normal part of the menu ToolStripMenuItem rename = new ToolStripMenuItem(ResManager.GetString("MenuEditRename")); ToolStripMenuItem copy = new ToolStripMenuItem(ResManager.GetString("MenuEditCopy")); ToolStripMenuItem clone = new ToolStripMenuItem(ResManager.GetString("MenuEditClone")); ToolStripSeparator sep = new ToolStripSeparator(); ToolStripMenuItem deleteFromDesktop = new ToolStripMenuItem(ResManager.GetString("MenuEditDeleteFromDesktop")); ToolStripMenuItem deleteFromArchive = new ToolStripMenuItem(ResManager.GetString("MenuEditDeleteFromArchive")); ToolStripSeparator sep2 = new ToolStripSeparator(); ToolStripMenuItem localizeInArchive = new ToolStripMenuItem(ResManager.GetString("MenuEditLocalizeInArchive")); ToolStripMenuItem packAllSockets = new ToolStripMenuItem(ResManager.GetString("MenuEditPackAllSockets")); ToolStripMenuItem unpackOneLayerAllSockets = new ToolStripMenuItem(ResManager.GetString("MenuEditUnpackOneLayerAllSockets")); ToolStripMenuItem unpackAllLayersAllSockets = new ToolStripMenuItem(ResManager.GetString("MenuEditUnpackAllLayersAllSockets")); //determines if there is anything to pack unpack BoxNode node = null; foreach (BoxNode bc in Nodes) { if (bc.Box == box) { node = bc; break; } } if (node == null) { throw new ApplicationException("Node with selected box not found"); } foreach (FerdaConnector fc in node.InputConnectors) { if (fc.HasPacked) { canUnpack = true; } else { canPack = true; } } //click handlers rename.Click += new EventHandler(rename_Click); copy.Click += new EventHandler(copy_Click); clone.Click += new EventHandler(clone_Click); deleteFromDesktop.Click += new EventHandler(deleteFromDesktop_Click); deleteFromArchive.Click += new EventHandler(deleteFromArchive_Click); packAllSockets.Click += new EventHandler(packAllSockets_Click); unpackOneLayerAllSockets.Click += new EventHandler(unpackOneLayerAllSockets_Click); unpackAllLayersAllSockets.Click += new EventHandler(unpackAllLayersAllSockets_Click); localizeInArchive.Click += new EventHandler(localizeInArchive_Click); //shortcuts rename.ShortcutKeys = Keys.F2; copy.ShortcutKeys = (Keys)Shortcut.CtrlC; clone.ShortcutKeys = (Keys)Shortcut.CtrlE; deleteFromDesktop.ShortcutKeys = (Keys)Shortcut.CtrlD; deleteFromArchive.ShortcutKeys = (Keys)Shortcut.ShiftDel; packAllSockets.ShortcutKeys = (Keys)Shortcut.CtrlP; unpackAllLayersAllSockets.ShortcutKeys = (Keys)Shortcut.CtrlU; unpackOneLayerAllSockets.ShortcutKeys = (Keys)Shortcut.CtrlS; localizeInArchive.ShortcutKeys = (Keys)Shortcut.CtrlL; //icons rename.Image = provider.GetIcon("Rename").ToBitmap(); copy.Image = provider.GetIcon("Copy").ToBitmap(); clone.Image = provider.GetIcon("Clone").ToBitmap(); deleteFromDesktop.Image = provider.GetIcon("DeleteFromDesktop").ToBitmap(); deleteFromArchive.Image = provider.GetIcon("DeleteFromArchive").ToBitmap(); packAllSockets.Image = provider.GetIcon("PackAllSockets").ToBitmap(); unpackAllLayersAllSockets.Image = provider.GetIcon("UnpackAllLayersAllSockets").ToBitmap(); unpackOneLayerAllSockets.Image = provider.GetIcon("UnpackAllLayersOneSocketAllSockets").ToBitmap(); localizeInArchive.Image = provider.GetIcon("LocalizeInArchive").ToBitmap(); ToolStripMenuItem layout = new ToolStripMenuItem(ResManager.GetString("DesktopLayout")); layout.Click += new EventHandler(layout_Click); layout.Image = provider.GetIcon("Layout").ToBitmap(); //addding the makegroup item (if there are more boxes selected) if (SelectedBoxes.Count > 1) { ToolStripMenuItem makeGroup = new ToolStripMenuItem(ResManager.GetString("MakeGroup")); makeGroup.Image = provider.GetIcon("MakeGroup").ToBitmap(); makeGroup.ShortcutKeys = Keys.F3; makeGroup.Click += new EventHandler(makeGroup_Click); //adding cMenu.Items.AddRange(new ToolStripItem[] { layout, rename, copy, clone, sep, makeGroup, deleteFromDesktop, deleteFromArchive, sep2, localizeInArchive }); } else { cMenu.Items.AddRange(new ToolStripItem[] { layout, rename, copy, clone, sep, deleteFromDesktop, deleteFromArchive, sep2, localizeInArchive }); } if (canUnpack) { cMenu.Items.Add(unpackOneLayerAllSockets); cMenu.Items.Add(unpackAllLayersAllSockets); } if (canPack) { cMenu.Items.Add(packAllSockets); } return cMenu; }
/// <summary> /// Gets boxes to which is connected box <paramref name="box"/>. /// </summary> /// <returns>An IBoxModule array of boxes to which is connected box /// <paramref name="box"/>.</returns> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> /// <seealso cref="M:Ferda.ProjectManager.Archive.ConnectedTo(Ferda.ModulesManager.IBoxModule)"/> public IBoxModule[] ConnectionsFrom(IBoxModule box) { List<IBoxModule> result = new List<IBoxModule>(); foreach (SocketInfo socket in box.Sockets) { foreach (IBoxModule otherBox in box.GetConnections(socket.name)) { if (!result.Contains(otherBox)) result.Add(otherBox); } } IBoxModule[] resultArray = result.ToArray(); Array.Sort<IBoxModule>(resultArray); return resultArray; }
/// <summary> /// Clones box, adds that clon to archive and returns it /// </summary> /// <returns>An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representating clone of box <paramref name="box"/></returns> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> public IBoxModule Clone(IBoxModule box) { IBoxModule result = box.Clone(); Add(result); return result; }
/// <summary> /// Adds box module with specified project identifier /// </summary> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> /// <param name="projectIdentifier">An integer representing unicate /// identifier in project</param> protected internal void AddWithIdentifier(IBoxModule box, int projectIdentifier) { if(!boxes.Contains(box)) { boxes.Add(box); box.ProjectIdentifier = projectIdentifier; lastBoxModuleProjectIdentifier = lastBoxModuleProjectIdentifier <= projectIdentifier ? projectIdentifier+1 : lastBoxModuleProjectIdentifier; addBoxCategories(box); boxesByProjectIdentifier.Add(projectIdentifier, box); } }
/// <summary> /// Adds box to archive /// </summary> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> /// <seealso cref="M:Ferda.ProjectManager.Archive.Remove(Ferda.ModulesManager.IBoxModule)"/> /// <seealso cref="P:Ferda.ProjectManager.Archive.Boxes"/> public void Add(IBoxModule box) { if(!boxes.Contains(box)) { boxes.Add(box); box.ProjectIdentifier = lastBoxModuleProjectIdentifier++; addBoxCategories(box); boxesByProjectIdentifier.Add(box.ProjectIdentifier,box); } }
/// <summary> /// Adds box <paramref name="box"/> to collection of boxes to which is this box connected. /// </summary> /// <param name="box">An IBoxModule representing box to which is this box connected.</param> /// <seealso cref="BoxModuleForManager.RemoveConnectionTo">Remove connection to</seealso> /// <seealso cref="IBoxModule.ConnectedTo">Get connections to</seealso> public void AddConnectionTo(IBoxModule box) { connectionsTo.Add(box); }
/// <summary> /// generates one cedent to XML string /// </summary> /// <param name="box">cedent box</param> /// <param name="rKLCedent">cedent record</param> /// <param name="CedentType">cedent type</param> /// <returns>XML string</returns> private static string getOneItemXML(IBoxModule box, Rec_KL_cedent rKLCedent, string CedentType) { string resultStr = ""; IBoxModule[] SubCedents = box.GetConnections(CedentType); rKLCedent.sub_cedent_cnt = SubCedents.Length; // adding KL cedent to XML if (rKLCedent.sub_cedent_cnt > 0) resultStr = rKLCedent.ToXML(getOneCedentXML(SubCedents)); return resultStr; }
/// <summary> /// generates one cedent to XML string /// </summary> /// <param name="subcedents">boxes with subcedents</param> /// <returns>XML string</returns> private static string getOneCedentXML(IBoxModule[] subcedents) { string XML = ""; #region Loop - processing of each partial cedent foreach (IBoxModule box in subcedents) // must be boxes with ID = "DataMiningCommon.CategorialPartialCedentSetting" { Rec_sub_KL_cedent rSKLC = new Rec_sub_KL_cedent(); // setting attribute "name" rSKLC.name = box.UserName; // setting attribute "length" rSKLC.length = box.GetPropertyLong("MinLen").ToString() + " - " + box.GetPropertyLong("MaxLen").ToString(); // searching each KL literal (= attributes!) string[] AttrIDs = { "DataMiningCommon.Attributes.Attribute", "DataMiningCommon.Attributes.EquifrequencyIntervalsAttribute", "DataMiningCommon.Attributes.EquidistantIntervalsAttribute", "DataMiningCommon.Attributes.EachValueOneCategoryAttribute" }; IBoxModule[] attributes = BoxesHelper.ListDirectAncestBoxesWithID(box, AttrIDs); // setting attribute "literal_cnt" (literals count) rSKLC.literal_cnt = attributes.Length; List<Rec_KL_literal> rLiterals = new List<Rec_KL_literal>(); #region Loop - processing of each KL-literal (attribute) foreach (IBoxModule attrBox in attributes) { Rec_KL_literal rLiteral = new Rec_KL_literal(); // setting "underlying_attribute" rLiteral.underlying_attribute = attrBox.GetPropertyString("NameInLiterals"); // setting "category_cnt" rLiteral.category_cnt = attrBox.GetPropertyLong("CountOfCategories"); rLiterals.Add(rLiteral); } #endregion // adding cedent to XML string XML += rSKLC.ToXML(rLiterals); } #endregion return XML; }
/// <summary> /// Returns XML string with all occurences of Active element "Boolean cedent". /// </summary> /// <param name="index">index of data source in FEplugin data sources table</param> /// <returns>XML string</returns> public static string getList(int index) { string resultString = ""; // result XML string string ErrStr = ""; // error reports int counterID = 0; // loading DTD to resultString try { resultString = XMLHelper.loadDTD(); } catch (Exception e) { #if (LADENI) MessageBox.Show("error while loading DTD: " + e.Message); #endif return(resultString); } // root element resultString += "<active_list>"; List <TaskTypeStruct> TypyTask = new List <TaskTypeStruct>(); CedentTypeStruct[] Typycedent4FT = { new CedentTypeStruct("Antecedent", "AntecedentSetting"), new CedentTypeStruct("Succedent", "SuccedentSetting"), new CedentTypeStruct("Condition", "ConditionSetting") }; CedentTypeStruct[] TypycedentSD4FT = { new CedentTypeStruct("Antecedent", "AntecedentSetting"), new CedentTypeStruct("Succedent", "SuccedentSetting"), new CedentTypeStruct("Condition", "ConditionSetting"), new CedentTypeStruct("FirstSet", "Cedent1"), new CedentTypeStruct("SecondSet", "Cedent2") }; CedentTypeStruct[] TypycedentKL = { new CedentTypeStruct("Condition", "ConditionSetting") }; CedentTypeStruct[] TypycedentSDKL = { new CedentTypeStruct("Condition", "ConditionSetting"), new CedentTypeStruct("FirstSet", "Cedent1"), new CedentTypeStruct("SecondSet", "Cedent2") }; CedentTypeStruct[] TypycedentCF = { new CedentTypeStruct("Condition", "ConditionSetting") }; CedentTypeStruct[] TypycedentSDCF = { new CedentTypeStruct("Condition", "ConditionSetting"), new CedentTypeStruct("FirstSet", "Cedent1"), new CedentTypeStruct("SecondSet", "Cedent2") }; TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.FFTTask", "4FT Task", Typycedent4FT)); TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.SDFFTTask", "SD-4FT Task", TypycedentSD4FT)); TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.KLTask", "KL Task", TypycedentKL)); TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.SDKLTask", "SD-KL Task", TypycedentSDKL)); TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.CFTask", "CF Task", TypycedentCF)); TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.SDCFTask", "SD-CF Task", TypycedentSDCF)); #region Loop - processing of each type of Task foreach (TaskTypeStruct TT in TypyTask) { // searching all boxes of tasks IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, TT.TaskTypeID); #region Loop - processing of each found Task foreach (IBoxModule box in TaskBoxes) { #region Loop - processing of each type of cedent of given Task counterID = 0; foreach (CedentTypeStruct Typcedent in TT.Cedents) { Rec_bool_cedent rBoolCedent = new Rec_bool_cedent(); // setting ID string id = "cdnt" + box.ProjectIdentifier.ToString() + "_"; try { // searching data source name (database) IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database"); if (db_names.GetLength(0) != 1) // searched more than one data source or neither one { throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases"); } rBoolCedent.db_name = db_names[0].GetPropertyString("DatabaseName"); // searching data matrix name IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix"); if (matrix_names.GetLength(0) != 1) // searched more than one data source or neither one { throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes"); } rBoolCedent.matrix_name = matrix_names[0].GetPropertyString("Name"); // searching task name rBoolCedent.task_name = box.UserName; // filling the "task_type" rBoolCedent.task_type = TT.TaskTypeLabel; // filling the "cedent_type" rBoolCedent.cedent_type = Typcedent.CedentTypeLabel; // searching all parcial cedent IBoxModule[] Subcedents = box.GetConnections(Typcedent.CedentTypeID); foreach (IBoxModule Subcedent in Subcedents) { Rec_bool_cedent rBoolCedent1 = rBoolCedent; // filling the ID rBoolCedent1.id = id + counterID.ToString(); counterID++; // setting "name" rBoolCedent1.name = Subcedent.UserName; // setting "length" rBoolCedent1.length = Subcedent.GetPropertyLong("MinLen").ToString() + " - " + Subcedent.GetPropertyLong("MaxLen").ToString(); // searching all literals IBoxModule[] literals = BoxesHelper.ListDirectAncestBoxesWithID(Subcedent, "DataMiningCommon.LiteralSetting"); // setting attribute "literal_cnt" (count of literals of parcial cedent) rBoolCedent1.literal_cnt = literals.Length; List <Rec_literal> rLiterals = new List <Rec_literal>(); #region Loop - processing of each literal of parcial cedent foreach (IBoxModule litBox in literals) { Rec_literal rLiteral = new Rec_literal(); // setting attribute "literal_type" {Basic/Remaining} rLiteral.literal_type = litBox.GetPropertyString("LiteralType"); // setting attribute "gace" {Positive/Negative/Both} rLiteral.gace = litBox.GetPropertyString("GaceType"); // searching atom IBoxModule[] atoms = BoxesHelper.ListDirectAncestBoxesWithID(litBox, "DataMiningCommon.AtomSetting"); if (atoms.Length != 1) // just one atom should be found { ErrStr += "Literal ID=" + litBox.ProjectIdentifier.ToString() + " : nalezeno " + atoms.Length.ToString() + " atom\n"; continue; // processing of next literal } IBoxModule atomBox = atoms[0].Clone(); // setting attribute "coefficient_type" {Interval/Subset/Cut/....} rLiteral.coefficient_type = atomBox.GetPropertyString("CoefficientType"); // setting attribute "length" rLiteral.length = atomBox.GetPropertyLong("MinLen").ToString() + " - " + atomBox.GetPropertyLong("MaxLen").ToString(); // searching attribute string[] AttrIDs = { "DataMiningCommon.Attributes.Attribute", "DataMiningCommon.Attributes.EquifrequencyIntervalsAttribute", "DataMiningCommon.Attributes.EquidistantIntervalsAttribute", "DataMiningCommon.Attributes.EachValueOneCategoryAttribute" }; IBoxModule[] attributes = BoxesHelper.ListDirectAncestBoxesWithID(atomBox, AttrIDs); if (attributes.Length != 1) //just one attribute should be found { ErrStr += "Literal ID=" + litBox.ProjectIdentifier.ToString() + " : nalezeno " + attributes.Length.ToString() + " attribute\n"; continue; // processing of next literal } IBoxModule attrBox = attributes[0].Clone(); // setting attribute "underlying_attribute" rLiteral.underlying_attribute = attrBox.GetPropertyString("NameInLiterals"); // setting attribute "category_cnt" rLiteral.category_cnt = attrBox.GetPropertyLong("CountOfCategories"); // setting attribute "missing_type" rLiteral.missing_type = attrBox.GetPropertyString("IncludeNullCategory"); // adding literal to list rLiterals.Add(rLiteral); } #endregion // generating boolean cedent to XML resultString += rBoolCedent1.ToXML(rLiterals); } } catch (System.Exception e) { ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n"; } } #endregion } #endregion } #endregion // root element resultString += "</active_list>"; #if (LADENI) // Kody - storing output to file "XMLBool_cedentExample.xml" in directory XMLHelper.saveXMLexample(resultString, "../XML/XMLBool_cedentExample.xml"); if (ErrStr != "") // LADICI { MessageBox.Show("Chyby pri generating seznamu Boolskych cedent:\n" + ErrStr); } #endif return(resultString); }
/// <summary> /// Shows a messagebox saying that user cannot write to the box /// </summary> /// <param name="box">Box where we cannot write</param> /// <param name="resManager">Resource Manager of the application</param> public static void CannotWriteToBox(IBoxModule box, ResourceManager resManager) { MessageBox.Show( resManager.GetString("DesktopCannotWriteText"), box.UserName + ": " + resManager.GetString("DesktopCannotWriteCaption")); }
///<summary> /// Constructs new connection /// </summary> /// <param name="fromBox">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> from which connection is</param> /// <param name="toBox">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> to which connection goes</param> /// <param name="toSocket">A string representing name of socket of <paramref name="toBox"/> to which connection goes</param> public Connection(IBoxModule fromBox, IBoxModule toBox, string toSocket) { this.fromBox = fromBox; this.toBox = toBox; this.toSocket = toSocket; }
/// <summary> /// When a box is selected in the archive, it should also be selected on the /// view. This function selects the box in the desktop /// </summary> /// <param name="box">Box to be selected</param> public void SelectBox(IBoxModule box) { }
/// <summary> /// Default constructor for the class /// </summary> public FerdaUserNote() { this.LostFocus += new EventHandler(FerdaUserNote_LostFocus); selectedBox = null; }
/// <summary> /// Method CompareTo /// </summary> /// <returns>An int</returns> /// <param name="other">A T</param> public int CompareTo(IBoxModule other) { BoxModuleForManager otherForManager = other as BoxModuleForManager; return CompareString.CompareTo(otherForManager.CompareString); }
/// <summary> /// Removes categorie and labels of box <paramref name="box"/> from class structures /// if there are no other box which have the same category or label /// </summary> /// <param name="box">A box</param> private void removeBoxCategories(IBoxModule box) { IBoxModuleFactoryCreator creator = box.MadeInCreator; foreach(string category in creator.BoxCategories) { boxesInCategory[category].Remove(box); if(boxesInCategory[category].Count == 0) { boxCategories.Remove(category); labelsInCategory[category].Clear(); } } string label = creator.Label; boxesWithLabel[label].Remove(box); if(boxesWithLabel[label].Count == 0) { boxLabels.Remove(label); foreach (StringCollection labels in labelsInCategory.Values) { if (labels.Contains(label)) labels.Remove(label); } } }
public abstract void SetUnvisibleConnection(string socketName, IBoxModule otherModule);
/// <summary> /// Removes box from archive. /// </summary> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> /// <seealso cref="M:Ferda.ProjectManager.Archive.Add(Ferda.ModulesManager.IBoxModule)"/> /// <seealso cref="P:Ferda.ProjectManager.Archive.Boxes"/> public void Remove(IBoxModule box) { foreach(IBoxModule otherBox in box.ConnectedTo()) { foreach(SocketInfo info in otherBox.Sockets) { foreach(IBoxModule thirdBox in otherBox.GetConnections(info.name)) { if(thirdBox == box) { otherBox.RemoveConnection(info.name,box); break; } } } } foreach(SocketInfo info in box.Sockets) { foreach(IBoxModule otherBox in box.GetConnections(info.name)) { box.RemoveConnection(info.name, otherBox); } } foreach(View view in views) { if(view.ContainsBox(box)) view.Remove(box); } if(boxes.Remove(box)) { removeBoxCategories(box); } boxesByProjectIdentifier.Remove(box.ProjectIdentifier); box.destroy(); }
/// <summary> /// Method RemoveUnvisibleConnection /// </summary> /// <param name="socketName">A string</param> /// <param name="otherModule">An IBoxModuleForManager</param> public override void RemoveUnvisibleConnection(String socketName, IBoxModule otherModule) { BoxModule module = otherModule as BoxModule; if(module!=null) { this.iceBoxModulePrx.removeConnection(socketName, module.IceIdentity); } else { GroupBox groupBox = otherModule as GroupBox; if(groupBox!=null) { foreach(IBoxModule box in groupBox.ConnectionsFrom()) { this.RemoveUnvisibleConnection(socketName, box); } } } }
/// <summary> /// Gets boxes connected to some socket of box <paramref name="box"/>. /// </summary> /// <returns>An IBoxModule array of boxes connected to box /// <paramref name="box"/>.</returns> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> /// <seealso cref="M:Ferda.ProjectManager.Archive.ConnectionsFrom(Ferda.ModulesManager.IBoxModule)"/> public IBoxModule[] ConnectedTo(IBoxModule box) { IBoxModule[] resultArray = box.ConnectedTo(); Array.Sort<IBoxModule>(resultArray); return resultArray; }
private void lockUnlockRecursive(IBoxModule box, BoxModule lockBox, Stack<IBoxModule> stack, bool locking) { BoxModule boxModule = box as BoxModule; if(boxModule!=null) { if(locking) boxModule.LockByBox(lockBox); else boxModule.UnlockByBox(lockBox); } else { foreach(IBoxModule newBox in box.ConnectionsFrom()) { if(!stack.Contains(newBox)) { stack.Push(newBox); lockUnlockRecursive(newBox, lockBox, stack, locking); stack.Pop(); } } } }
/// <summary> /// Looks if archive contains box <paramref name="box"/> /// </summary> /// <returns>true if archive contains box <paramref name="box"/>, /// otherwise false</returns> /// <param name="box">An <see cref="T:Ferda.ModulesManager.IBoxModule"/> /// representation of box</param> public bool ContainsBox(IBoxModule box) { return boxes.Contains(box); }
/// <summary> /// Finding all direct ancestors (all boxes box) with given box type in Ferda Archive tree structure /// </summary> /// <param name="Box">Box in archive, for which function searches the ancestors</param> /// <param name="ID">list with types of searched boxes (string identifiers)</param> /// <returns></returns> public static IBoxModule[] ListDirectAncestBoxesWithID(IBoxModule Box, string[] IDs) { ArrayList MyBoxes = new ArrayList(); IBoxModule[] Ancestors = Box.ConnectionsFrom().ToArray(); foreach (IBoxModule b in Ancestors) { foreach (string ID in IDs) { if (b.MadeInCreator.Identifier == ID) MyBoxes.Add(b); } } return (MyBoxes.ToArray(typeof(IBoxModule)) as IBoxModule[]); }
/// <summary> /// Removes box <paramref name="box"/> from collection of boxes to which is this box connected. /// </summary> /// <param name="box">An IBoxModule representing box to which was this box connected.</param> /// <seealso cref="BoxModuleForManager.AddConnectionTo">Add connection to</seealso> /// <seealso cref="IBoxModule.ConnectedTo">Get connections to</seealso> public void RemoveConnectionTo(IBoxModule box) { connectionsTo.Remove(box); }
/// <summary> /// Constructor of the class when we want to set the property /// </summary> /// <param name="result">Result string</param> public OtherProperty(string result) { this.box = null; this.propertyName = String.Empty; this.result = result; }