/// <summary>
        /// Called when an FCO or folder changes
        /// </summary>
        /// <param name="subject">the object the event(s) happened to</param>
        /// <param name="eventMask">objectevent_enum values ORed together</param>
        /// <param name="param">extra information provided for cetertain event types</param>
        public void ObjectEvent(MgaObject subject, uint eventMask, object param)
        {
            if (!componentEnabled)
            {
                return;
            }

            if (subject.HasReadOnlyAccess())
            {
                return;
            }

            if (GMEConsole == null)
            {
                GMEConsole = GMEConsole.CreateFromProject(subject.Project);
            }

            // TODO: Handle object events (OR eventMask with the members of objectevent_enum)
            // Warning: Only those events are received that you have subscribed for by setting ComponentConfig.eventMask
            uint uOBJEVENT_ATTR = 0;
            uint uOBJEVENT_CREATED = 0;
            uint uOBJEVENT_NEWCHILD = 0;
            uint uOBJEVENT_LOSTCHILD = 0;
            uint uOBJEVENT_OPENMODEL = 0;

            unchecked { uOBJEVENT_ATTR = (uint)objectevent_enum.OBJEVENT_ATTR; }
            unchecked { uOBJEVENT_CREATED = (uint)objectevent_enum.OBJEVENT_CREATED; }
            unchecked { uOBJEVENT_NEWCHILD = (uint)objectevent_enum.OBJEVENT_NEWCHILD; }
            unchecked { uOBJEVENT_LOSTCHILD = (uint)objectevent_enum.OBJEVENT_LOSTCHILD; }
            unchecked { uOBJEVENT_OPENMODEL = (uint)objectevent_enum.OBJEVENT_OPENMODEL; }

            if ((eventMask & uOBJEVENT_CREATED) != 0)
            {
                if (subject.IsLibObject || subject.IsWritable == false)
                    return;
                if (subject.MetaBase.Name == "TestBenchRef")
                {
                    // set the port label lenght 0
                    // FIXME: why not just change it in the meta?
                    (subject as MgaFCO).RegistryValue["portLabelLength"] = "0";
                    if (subject as MgaReference != null)
                    {
                        UpdateColor((subject as MgaReference).Referred);
                    }
                }
                else if (subject.MetaBase.Name == "Optimizer")
                {
                    (subject as MgaFCO).RegistryValue["portLabelLength"] = "0";
                    UpdateColor(subject as MgaFCO);
                }
                else if (subject.MetaBase.Name == "VariableSweep")
                {
                    (subject as MgaFCO).RegistryValue["dstStyle"] = "arrow";
                    (subject as MgaFCO).RegistryValue["color"] = "0xff80c0";
                }
                else if (subject.MetaBase.Name == "ObjectiveMapping")
                {
                    (subject as MgaFCO).RegistryValue["dstStyle"] = "arrow";
                    (subject as MgaFCO).RegistryValue["color"] = "0x7cadde";
                }
            }
            else if ((eventMask & uOBJEVENT_ATTR) != 0)
            {
                this.DisplayPCCIterations(subject, true);

                if (subject.MetaBase.Name == "ValueFlow")
                {
                    // set the src custom formula's name to the specified name
                    // in the ValueFlow attribute field
                    MgaConnection ValueFlow = subject as MgaConnection;
                    foreach (MgaConnPoint cp in ValueFlow.ConnPoints)
                    {
                        if (cp.ConnRole == "src")
                        {
                            if (cp.Target.Meta.Name == "CustomFormula")
                            {
                                foreach (MgaAttribute attr in ValueFlow.Attributes)
                                {
                                    if (attr.Meta.Name == "FormulaVariableName")
                                    {
                                        if (string.IsNullOrEmpty(attr.StringValue) == false)
                                        {
                                            cp.Target.Name = attr.StringValue;
                                            break;
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                else if (subject.MetaBase.Name == "TestBench")
                {
                    // Excel import helper
                    MgaModel testBench = subject as MgaModel;

                    // call color helper
                    UpdateColor(testBench as MgaFCO);
                }
            }
            else if ((eventMask & uOBJEVENT_NEWCHILD) != 0 || (eventMask & uOBJEVENT_LOSTCHILD) != 0)
            {
                this.DisplayPCCIterations(subject, false);
            }
            else if ((eventMask & uOBJEVENT_OPENMODEL) != 0)
            {
            if (subject.MetaBase.Name == "ParametricExploration")
            {
                var pet = subject as MgaModel;
                foreach (MgaModel PCCDriver in pet.GetChildrenOfKind("PCCDriver"))
                {
                    var upMethod = PCCDriver.StrAttrByName["PCC_UP_Methods"];
                    if (upMethod == "UP_MPP" || upMethod == "UP_PCE")
                    {
                        GMEConsole.Out.WriteLine("{1}The output of the selected method ({0}) is not compatible with the project analyzer Dashboard.", upMethod, WARNING_BADGE);
                        if (upMethod == "UP_PCE")
                        {
                            GMEConsole.Out.WriteLine("{0}Trying to display such data might require a refresh in order to view other data again.", WARNING_BADGE);
                        }
                    }
                }
            }
            }
            //MessageBox.Show(eventMask.ToString());

        }
Example #2
0
        /// <summary>
        /// Called when an FCO or folder changes
        /// </summary>
        /// <param name="subject">the object the event(s) happened to</param>
        /// <param name="eventMask">objectevent_enum values ORed together</param>
        /// <param name="param">extra information provided for cetertain event types</param>
        public void ObjectEvent(MgaObject subject, uint eventMask, object param)
        {
            if (!componentEnabled)
            {
                return;
            }

            if (subject.HasReadOnlyAccess())
            {
                return;
            }

            if (GMEConsole == null)
            {
                GMEConsole = GMEConsole.CreateFromProject(subject.Project);
            }

            // TODO: Handle object events (OR eventMask with the members of objectevent_enum)
            // Warning: Only those events are received that you have subscribed for by setting ComponentConfig.eventMask
            uint uOBJEVENT_ATTR      = 0;
            uint uOBJEVENT_CREATED   = 0;
            uint uOBJEVENT_NEWCHILD  = 0;
            uint uOBJEVENT_LOSTCHILD = 0;
            uint uOBJEVENT_OPENMODEL = 0;

            unchecked { uOBJEVENT_ATTR = (uint)objectevent_enum.OBJEVENT_ATTR; }
            unchecked { uOBJEVENT_CREATED = (uint)objectevent_enum.OBJEVENT_CREATED; }
            unchecked { uOBJEVENT_NEWCHILD = (uint)objectevent_enum.OBJEVENT_NEWCHILD; }
            unchecked { uOBJEVENT_LOSTCHILD = (uint)objectevent_enum.OBJEVENT_LOSTCHILD; }
            unchecked { uOBJEVENT_OPENMODEL = (uint)objectevent_enum.OBJEVENT_OPENMODEL; }

            if ((eventMask & uOBJEVENT_CREATED) != 0)
            {
                if (subject.IsLibObject || subject.IsWritable == false)
                {
                    return;
                }
                if (subject.MetaBase.Name == "TestBenchRef")
                {
                    if (subject as MgaReference != null)
                    {
                        UpdateColor((subject as MgaReference).Referred);
                    }
                }
                else if (subject.MetaBase.Name == "Optimizer")
                {
                    (subject as MgaFCO).RegistryValue["portLabelLength"] = "0";
                }
                else if (subject.MetaBase.Name == "VariableSweep")
                {
                    (subject as MgaFCO).RegistryValue["dstStyle"] = "arrow";
                    (subject as MgaFCO).RegistryValue["color"]    = "0xff80c0";
                }
                else if (subject.MetaBase.Name == "ObjectiveMapping")
                {
                    (subject as MgaFCO).RegistryValue["dstStyle"] = "arrow";
                    (subject as MgaFCO).RegistryValue["color"]    = "0x7cadde";
                }
            }
            else if ((eventMask & uOBJEVENT_ATTR) != 0)
            {
                this.DisplayPCCIterations(subject, true);

                if (subject.MetaBase.Name == "ValueFlow")
                {
                    // set the src custom formula's name to the specified name
                    // in the ValueFlow attribute field
                    MgaSimpleConnection ValueFlow = subject as MgaSimpleConnection;
                    var src = ValueFlow.Src;
                    if (src.Meta.Name == "CustomFormula")
                    {
                        foreach (MgaAttribute attr in ValueFlow.Attributes)
                        {
                            if (attr.Meta.Name == "FormulaVariableName")
                            {
                                if (string.IsNullOrEmpty(attr.StringValue) == false)
                                {
                                    src.Name = attr.StringValue;
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (subject.MetaBase.Name == "TestBench")
                {
                    // Excel import helper
                    MgaModel testBench = subject as MgaModel;

                    // call color helper
                    UpdateColor(testBench as MgaFCO);
                }
            }
            else if ((eventMask & uOBJEVENT_NEWCHILD) != 0 || (eventMask & uOBJEVENT_LOSTCHILD) != 0)
            {
                this.DisplayPCCIterations(subject, false);
            }
            else if ((eventMask & uOBJEVENT_OPENMODEL) != 0)
            {
            }
            //MessageBox.Show(eventMask.ToString());
        }
Example #3
0
		/// <summary>
		/// Called when an FCO or folder changes
		/// </summary>
		/// <param name="subject">
		///   the object the event(s) happened to
		/// </param>
		/// <param name="eventMask">
		///   objectevent_enum values ORed together
		/// </param>
		/// <param name="param">
		///   extra information provided for cetertain event types
		/// </param>
		public void ObjectEvent(
			MgaObject subject,
			uint eventMask,
			object param)
		{
			if (!componentEnabled)
			{
				return;
			}
			else if (isXMLImportInProgress)
			{
				return;
			}
			//else if (isProjectInTransation)
			//{
			//  return;
			//}

            if (subject.HasReadOnlyAccess() ||
                subject.IsLibObject)
            {
                return;
            }

			uint uOBJEVENT_CREATED = 0;
			uint uOBJEVENT_COPIED = 0;

			unchecked { uOBJEVENT_CREATED = (uint)objectevent_enum.OBJEVENT_CREATED; }
			unchecked { uOBJEVENT_COPIED = (uint)objectevent_enum.OBJEVENT_COPIED; }



			if ((eventMask & uOBJEVENT_COPIED) != 0)
			{
				isCopied = true;
			}
			else if ((eventMask & uOBJEVENT_CREATED) != 0 && subject.Status == 0)
                // check Status, since object can be created and deleted in same tx
			{
				if (isCopied)
				{
					// handle copy event
					isCopied = false;
				}
				else
				{
                    //subject.Project.RootMeta.RootFolder.DefinedFCOByName["Task", 
                    //MgaMetaBase task;
                    //if (task.MetaRef == subject.MetaBase.MetaRef)
                    {

                    }
					// handle new object event
					if (subject.MetaBase.Name == "Task" ||
						subject.MetaBase.Name == "WorkflowRef")
					{
						Type t = Type.GetTypeFromProgID(DecoratorName);
						if (t != null)
						{
							(subject as MgaFCO).RegistryValue["decorator"] = DecoratorName;
						}
					}

                    bool isBasicTask = (subject.MetaBase.Name == "Task");

					if (subject.MetaBase.Name == "Task" || subject.MetaBase.Name == "ExecutionTask")
					{
                        using (InterpreterSelectionForm form = new InterpreterSelectionForm())
                        {
                            form.addon = this;
                            form.Init();

                            IEnumerable<MgaAtom> taskChildren = subject.ExGetParent().
                                                                        ChildObjects.
                                                                        OfType<MgaAtom>().
                                                                        Where(x => x.ExDstFcos().Count() == 0).
                                                                        Where(x => x.ID != subject.ID);

                            form.lbTasks.Items.Clear();
                            foreach (var currTask in taskChildren)
                            {
                                var atomWrapper = new MgaAtomWrapper(currTask);
                                form.lbTasks.Items.Add(new MgaAtomWrapper(currTask));
                                form.lbTasks.SelectedItem = atomWrapper;
                            }

                            if (form.lbTasks.Items.Count > 0)
                            {
                                form.lbTasks.SetSelected(0, true);
                            }

                            if (!isBasicTask) // remove interpreter selection and reset positions
                            {
                                form.lbInterpreters.Items.Clear();
                                form.lbInterpreters.Visible = false;
                                form.lblSelectInterpreter.Visible = false;
                                form.chbAutoConnect.Location = form.label1.Location;
                                form.label1.Location = form.lblSelectInterpreter.Location;
                                form.lbTasks.Location = form.lbInterpreters.Location;
                            }

                            DialogResult dgr = form.ShowDialog();
                            if (dgr == DialogResult.OK)
                            {
                                if (isBasicTask)
                                {
                                    ComComponent c = form.lbInterpreters.SelectedItem as ComComponent;
                                    try
                                    {
                                        if (c != null &&
                                            c.isValid)
                                        {
                                            (subject as MgaFCO).StrAttrByName["COMName"] = c.ProgId;
                                        }
                                    }
                                    catch
                                    {
                                        MessageBox.Show("Cannot save interpreter settings. 'COMName' is not a parameter of 'Task'.");
                                    }
                                }

                                //Flow
                                if (form.chbAutoConnect.Checked && (form.lbTasks.SelectedItem != null))
                                {
                                    MgaAtomWrapper selectedTask = form.lbTasks.SelectedItem as MgaAtomWrapper;
                                    MgaAtom lastInWorkflow = null;

                                    if (selectedTask != null)
                                    {
                                        lastInWorkflow = selectedTask.Atom;
                                    }

                                    if (lastInWorkflow != null)
                                    {
                                        MgaMetaRole role = ((subject.ExGetParent() as MgaModel).
                                            Meta as MgaMetaModel).RoleByName["Flow"];

                                        (subject.ExGetParent() as MgaModel).CreateSimplerConnDisp(
                                            role,
                                            lastInWorkflow as MgaFCO,
                                            subject as MgaFCO);
                                    }
                                }
                            }
                        }
					}
				}
			}

			// TODO: Handle object events (OR eventMask with the members of objectevent_enum)
			// Warning: Only those events are received that you have subscribed for by setting ComponentConfig.eventMask

			// MessageBox.Show(eventMask.ToString());

		}
Example #4
0
        /// <summary>
        /// Called when an FCO or folder changes
        /// </summary>
        /// <param name="subject">
        ///   the object the event(s) happened to
        /// </param>
        /// <param name="eventMask">
        ///   objectevent_enum values ORed together
        /// </param>
        /// <param name="param">
        ///   extra information provided for cetertain event types
        /// </param>
        public void ObjectEvent(
            MgaObject subject,
            uint eventMask,
            object param)
        {
            if (!componentEnabled)
            {
                return;
            }
            else if (isXMLImportInProgress)
            {
                return;
            }
            //else if (isProjectInTransation)
            //{
            //  return;
            //}

            if (subject.HasReadOnlyAccess() ||
                subject.IsLibObject)
            {
                return;
            }

            uint uOBJEVENT_CREATED = 0;
            uint uOBJEVENT_COPIED  = 0;

            unchecked { uOBJEVENT_CREATED = (uint)objectevent_enum.OBJEVENT_CREATED; }
            unchecked { uOBJEVENT_COPIED = (uint)objectevent_enum.OBJEVENT_COPIED; }



            if ((eventMask & uOBJEVENT_COPIED) != 0)
            {
                isCopied = true;
            }
            else if ((eventMask & uOBJEVENT_CREATED) != 0 && subject.Status == 0)
            // check Status, since object can be created and deleted in same tx
            {
                if (isCopied)
                {
                    // handle copy event
                    isCopied = false;
                }
                else
                {
                    //subject.Project.RootMeta.RootFolder.DefinedFCOByName["Task",
                    //MgaMetaBase task;
                    //if (task.MetaRef == subject.MetaBase.MetaRef)
                    {
                    }
                    // handle new object event
                    bool isBasicTask = (subject.MetaBase.Name == "Task");

                    if (subject.MetaBase.Name == "Task" || subject.MetaBase.Name == "ExecutionTask")
                    {
                        if (subject.MetaBase.Name == "Task" && string.IsNullOrEmpty((subject as MgaFCO).StrAttrByName["COMName"]) == false)
                        {
                            return;
                        }
                        if (subject.MetaBase.Name == "ExecutionTask" && string.IsNullOrEmpty((subject as MgaFCO).StrAttrByName["Invocation"]) == false)
                        {
                            return;
                        }
                        using (InterpreterSelectionForm form = new InterpreterSelectionForm())
                        {
                            form.addon = this;
                            form.Init();

                            HashSet <string> taskKinds = new HashSet <string>()
                            {
                                "ExecutionTask",
                                "Task"
                            };

                            IEnumerable <MgaAtom> taskChildren = subject.ExGetParent().
                                                                 ChildObjects.
                                                                 OfType <MgaAtom>().
                                                                 Where(x => x.ExDstFcos().Count() == 0).
                                                                 Where(x => x.ID != subject.ID).
                                                                 Where(x => taskKinds.Contains(x.Meta.Name));

                            form.lbTasks.Items.Clear();
                            foreach (var currTask in taskChildren)
                            {
                                var atomWrapper = new MgaAtomWrapper(currTask);
                                form.lbTasks.Items.Add(new MgaAtomWrapper(currTask));
                                form.lbTasks.SelectedItem = atomWrapper;
                            }

                            if (form.lbTasks.Items.Count > 0)
                            {
                                form.lbTasks.SetSelected(0, true);
                            }

                            if (!isBasicTask) // remove interpreter selection and reset positions
                            {
                                form.lbInterpreters.Items.Clear();
                                form.lbInterpreters.Visible       = false;
                                form.lblSelectInterpreter.Visible = false;
                                form.chbAutoConnect.Location      = form.label1.Location;
                                form.label1.Location  = form.lblSelectInterpreter.Location;
                                form.lbTasks.Location = form.lbInterpreters.Location;
                            }

                            DialogResult dgr = form.ShowDialog();
                            if (dgr == DialogResult.OK)
                            {
                                if (isBasicTask)
                                {
                                    ComComponent c = form.lbInterpreters.SelectedItem as ComComponent;
                                    try
                                    {
                                        if (c != null &&
                                            c.isValid)
                                        {
                                            (subject as MgaFCO).StrAttrByName["COMName"] = c.ProgId;
                                        }
                                    }
                                    catch
                                    {
                                        MessageBox.Show("Cannot save interpreter settings. 'COMName' is not a parameter of 'Task'.");
                                    }
                                }

                                //Flow
                                if (form.chbAutoConnect.Checked && (form.lbTasks.SelectedItem != null))
                                {
                                    MgaAtomWrapper selectedTask   = form.lbTasks.SelectedItem as MgaAtomWrapper;
                                    MgaAtom        lastInWorkflow = null;

                                    if (selectedTask != null)
                                    {
                                        lastInWorkflow = selectedTask.Atom;
                                    }

                                    if (lastInWorkflow != null)
                                    {
                                        MgaMetaRole role = ((subject.ExGetParent() as MgaModel).
                                                            Meta as MgaMetaModel).RoleByName["Flow"];

                                        (subject.ExGetParent() as MgaModel).CreateSimplerConnDisp(
                                            role,
                                            lastInWorkflow as MgaFCO,
                                            subject as MgaFCO);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // TODO: Handle object events (OR eventMask with the members of objectevent_enum)
            // Warning: Only those events are received that you have subscribed for by setting ComponentConfig.eventMask

            // MessageBox.Show(eventMask.ToString());
        }