Esempio n. 1
0
        /*
         * Constructor
         */
        /// <summary>
        /// Constructor that initializes BinarySpace
        /// </summary>
        public ListSelectionSpace(ListGroupNode list, Dependency df)
        {
            _list     = list;
            _listName = list.FullPath;
            _resolved = true;

            if (df != null)
            {
                _formula = df.Simplify();
                _window  = new IndexedDataWindow(_list.DataWindow);
                changeIndexWindow(_formula);
            }
        }
Esempio n. 2
0
        public bool ResolveObject(VariableTable varTable)
        {
            _list     = varTable.GetListGroup(_listName);
            _resolved = (_list != null);

            if (_resolved)
            {
                _window = new IndexedDataWindow(_list.DataWindow);
                changeIndexWindow(_formula);
            }

            return(_resolved);
        }
Esempio n. 3
0
        protected void changeIndexWindow(IDataWindow dwin)
        {
            if (dwin.Parent is IndexedDataWindow)
            {
                IndexedDataWindow iwin = (IndexedDataWindow)dwin.Parent;

                if (iwin.ListGroup == _list)
                {
                    dwin.Parent.RemoveChildWindow(dwin);
                    _window.AddChildWindow(dwin);
                }
            }
            else
            {
                changeIndexWindow(dwin.Parent);
            }
        }
Esempio n. 4
0
        /*
         * Constructors
         */

        public ListIndexState(Appliance appliance, ListGroupNode lg)
            : base(appliance, "", false)
        {
            _listGroup  = lg;
            _dataWindow = lg.DataWindow;

            IntegerSpace intSpace =
                new IntegerSpace(new IntNumber(1),
                                 new NumberConstraint(this, lg.LengthState));

            this.Type = new PUCType(intSpace);

            this.Labels = new LabelDictionary();
            this.Labels.AddLabel(new StringValue("List Index"));
            this.Labels.AddLabel(new StringValue("Index"));

            this.ValueChangeRequested += new ValueChangeRequestedHandler(this.changeWindowIndex);
            _dataWindow.IndexChanged  += new EventHandler(WindowIndexChanged);
        }
Esempio n. 5
0
        protected void refreshListData(ListGroupNode listGroup, DataTable table, ListEventArgs a, int start, int length)
        {
            IndexedDataWindow win = listGroup.DataWindow;

            int[]          parentIndices = a.ParentIndices;
            System.Int32[] keys;

            if (parentIndices == null)
            {
                keys = new int[1];
            }
            else
            {
                keys = new int[parentIndices.Length + 1];

                for (int i = 0; i < parentIndices.Length; i++)
                {
                    keys[i] = parentIndices[i];
                }
            }

            System.Diagnostics.Debug.Assert(keys.Length == table.PrimaryKey.Length);

            for (int i = 1; i <= length; i++)
            // we start with 1 to work with 1-indexed PUC lists
            {
                keys[keys.Length - 1] = win.Index = start + i;

                DataRow row = null;

                try                 // have had some trouble with Rows.Find in an empty table (not sure if that is the only time though)
                {
                    row = table.Rows.Find(keys);
                }
                catch (Exception) { }

                if (row == null)
                {
                    // row does not exist...build a new one
                    row = table.NewRow();

                    // fill in the primary keys
                    for (int j = 0; j < table.PrimaryKey.Length; j++)
                    {
                        row[table.PrimaryKey[j]] = keys[j];
                    }

                    // add the row
                    table.Rows.Add(row);
                }

                // update data in the row
                IEnumerator cols = table.Columns.GetEnumerator();
                while (cols.MoveNext())
                {
                    ApplianceObject ao = (ApplianceObject)_columnToStateMap[cols.Current];

                    if (ao != null && ao.State)
                    {
                        ApplianceState state = (ApplianceState)ao;

                        if (state.Type.ValueSpace.Space == PUC.Types.ValueSpace.BOOLEAN_SPACE)
                        {
                            row[(DataColumn)cols.Current] = (bool)state.Value;
                        }
                        else
                        {
                            row[(DataColumn)cols.Current] = state.Value.ToString();
                        }
                    }
                }

                row.AcceptChanges();
            }

            table.AcceptChanges();
        }