Esempio n. 1
0
 public bool OpenLinkRequest(Database.LinkRequestTable link, Database.TableReference tableLink, Database.Table table)
 {
     using (ScopeDebugContext.String("OpenLinkRequest"))
     {
         if (link.LinkToOpen.RowWhere != null && link.LinkToOpen.RowWhere.Count > 0)
         {
             Database.Table filteredTable = table;
             if (table.GetMetaData().defaultFilter != null)
             {
                 filteredTable = table.GetMetaData().defaultFilter.CreateFilter(table);
             }
             var  whereUnion  = new Database.View.WhereUnion(link.LinkToOpen.RowWhere, null, null, null, null, m_UIState.CurrentMode.GetSchema(), filteredTable, link.SourceView == null ? null : link.SourceView.ExpressionParsingContext);
             long rowToSelect = whereUnion.GetIndexFirstMatch(link.SourceRow);
             if (rowToSelect < 0)
             {
                 DebugUtility.LogWarning("Could not find entry in target table '" + link.LinkToOpen.TableName + "'");
                 return(false);
             }
             DebugUtility.DebugLog("Opening table '" + link.LinkToOpen.TableName + "' at row " + rowToSelect);
             OpenTable(tableLink, table, new Database.CellPosition(rowToSelect, 0));
         }
         else
         {
             OpenTable(tableLink, table, new Database.CellPosition(0, 0));
         }
         return(true);
     }
 }
        public GroupedTable(Database.Table table, ArrayRange range, int colToGroupFirst, int colToGroupLast, int[] colGroupOrder, SortOrder[] sortOrder)
            : base(table.Schema)
        {
            m_table = table;
            if (m_table is ExpandTable)
            {
                m_expandTable = (ExpandTable)m_table;
            }
            m_Meta = m_table.GetMetaData();
            m_GroupedColumnFirst = colToGroupFirst;
            m_GroupedColumnLast  = colToGroupLast;
            m_ColumnOrder        = colGroupOrder;
            m_SortOrder          = sortOrder;

            int sourceGroupedColumnIndex = m_ColumnOrder[colToGroupFirst];

            var col     = m_table.GetColumnByIndex(sourceGroupedColumnIndex);
            var metaCol = m_Meta.GetColumnByIndex(sourceGroupedColumnIndex);

            if (metaCol.DefaultGroupAlgorithm != null)
            {
                m_GroupCollection = metaCol.DefaultGroupAlgorithm.Group(col, range, m_SortOrder[colToGroupFirst]);
            }
            else
            {
                throw new Exception("Trying to group a column without grouping algorithm. Column '" + metaCol.Name + "' from table '" + m_table.GetName() + "'");
            }
            InitializeFromGroupCollection(col, sourceGroupedColumnIndex);
        }
        // colToGroup is an index from aNewColumnOrder.
        public GroupedTable(Database.Table table, ArrayRange range, int colToGroup, SortOrder sortOrder, FnCreateGroupTable subTable)
            : base(table.Schema)
        {
            m_table = table;
            if (m_table is ExpandTable)
            {
                m_expandTable = (ExpandTable)m_table;
            }
            m_Meta = m_table.GetMetaData();
            m_GroupedColumnFirst = 0;
            m_GroupedColumnLast  = 0;
            m_ColumnOrder        = new int[] { colToGroup };// colGroupOrder;
            m_SortOrder          = new SortOrder[1] {
                sortOrder
            };
            m_createGroupTable = subTable;

            var col     = m_table.GetColumnByIndex(colToGroup);
            var metaCol = m_Meta.GetColumnByIndex(colToGroup);

            if (metaCol.DefaultGroupAlgorithm != null)
            {
                m_GroupCollection = metaCol.DefaultGroupAlgorithm.Group(col, range, sortOrder);
            }
            else
            {
                throw new Exception("Trying to group a column without grouping algorithm. Column '" + metaCol.Name + "' from table '" + m_table.GetName() + "'");
            }
            InitializeFromGroupCollection(col, colToGroup);
        }
        private void InitSplitter()
        {
            var meta     = m_TableSource.GetMetaData();
            int colCount = meta.GetColumnCount();

            m_ColumnState = new Filter.ColumnState[colCount];
            int[] colSizes = new int[colCount];

            string basePrefKey = k_DisplayWidthPrefKeyBase /*+ DisplayTable.GetName()*/;

            m_DisplayWidthPrefKeysPerColumn = new string[colCount];
            for (int i = 0; i != colCount; ++i)
            {
                var column = meta.GetColumnByIndex(i);
                m_DisplayWidthPrefKeysPerColumn[i] = basePrefKey + column.Name;
                colSizes[i]      = GetDisplayWidth(i, column.DefaultDisplayWidth);
                m_ColumnState[i] = new Filter.ColumnState();
            }
            m_Splitter = new SplitterStateEx(colSizes);
            m_Splitter.RealSizeChanged += SetDisplayWidth;
        }
Esempio n. 5
0
        public int m_ColumnIndexFirst; //index into m_SortColumn
        public SortedTable(Database.Table table, int[] sortColumn, SortOrder[] sortOrder, int columnIndexFirst, ArrayRange indices)
            : base(table.Schema)
        {
            m_SourceTable      = table;
            m_Meta             = m_SourceTable.GetMetaData();
            m_SortColumn       = sortColumn;
            m_SortOrder        = sortOrder;
            m_ColumnIndexFirst = columnIndexFirst;

            this.indices = SortRange(indices, sortColumn, sortOrder, m_ColumnIndexFirst);

            //create columns
            CreateColumn();
        }
Esempio n. 6
0
        public int m_ColumnIndexFirst; //index into m_SortColumn
        public SortedTable(Database.Table table, int[] sortColumn, SortOrder[] sortOrder, int columnIndexFirst, ArrayRange indices)
            : base(table.Schema)
        {
            m_SourceTable      = table;
            m_Meta             = m_SourceTable.GetMetaData();
            m_SortColumn       = sortColumn;
            m_SortOrder        = sortOrder;
            m_ColumnIndexFirst = columnIndexFirst;

            using (Profiling.GetMarker(Profiling.MarkerId.SortedTable).Auto())
            {
                this.indices = SortRange(indices, sortColumn, sortOrder, m_ColumnIndexFirst);
            }


            //create columns
            CreateColumn();
        }
Esempio n. 7
0
 public override int GetColumnIndex(Database.Table tableIn)
 {
     return(tableIn.GetMetaData().GetColumnByName(ColumnName).Index);
 }
Esempio n. 8
0
 public override string GetColumnName(Database.Table tableIn)
 {
     return(tableIn.GetMetaData().GetColumnByIndex(ColumnIndex).Name);
 }
        protected override void DrawHeader(long col, Rect r, ref GUIPipelineState pipe)
        {
            var colState = m_ColumnState[col];

            string str = m_FormattingOptions.ObjectDataFormatter.ShowPrettyNames
                ? m_TableDisplay.GetMetaData().GetColumnByIndex((int)col).DisplayName
                : m_TableDisplay.GetMetaData().GetColumnByIndex((int)col).Name;

            if (colState.Grouped)
            {
                str = "[" + str + "]";
            }
            var sorted   = colState.Sorted != SortOrder.None ? colState.Sorted : colState.DefaultSorted;
            var sortName = Filter.Sort.GetSortName(sorted);

            str = sortName + str;

            if (!GUI.Button(r, str, Styles.Header))
            {
                return;
            }

            var  meta     = m_TableSource.GetMetaData();
            var  metaCol  = meta.GetColumnByIndex((int)col);
            bool canGroup = false;

            if (metaCol != null)
            {
                if (metaCol.DefaultGroupAlgorithm != null)
                {
                    canGroup = true;
                }
            }

            var          menu       = new GenericMenu();
            const string strGroup   = "Group";
            const string strSortAsc = "Sort Ascending";
            const string strSortDsc = "Sort Descending";
            const string strMatch   = "Match...";

            if (canGroup)
            {
                menu.AddItem(new GUIContent(strGroup), colState.Grouped, () =>
                {
                    if (colState.Grouped)
                    {
                        RemoveSubGroupFilter((int)col);
                    }
                    else
                    {
                        AddSubGroupFilter((int)col);
                    }
                });
            }

            menu.AddItem(new GUIContent(strSortAsc), sorted == SortOrder.Ascending, () =>
            {
                if (sorted == SortOrder.Ascending)
                {
                    RemoveDefaultSortFilter();
                }
                else
                {
                    SetDefaultSortFilter((int)col, SortOrder.Ascending);
                }
            });

            menu.AddItem(new GUIContent(strSortDsc), sorted == SortOrder.Descending, () =>
            {
                if (sorted == SortOrder.Descending)
                {
                    RemoveDefaultSortFilter();
                }
                else
                {
                    SetDefaultSortFilter((int)col, SortOrder.Descending);
                }
            });

            menu.AddItem(new GUIContent(strMatch), false, () =>
            {
                AddMatchFilter((int)col);
            });
            menu.DropDown(r);
        }
Esempio n. 10
0
        public override bool OnGui(Database.Table sourceTable, ref bool dirty)
        {
            EditorGUILayout.BeginHorizontal();
            bool   bRemove = OnGui_RemoveButton();
            var    metaCol = sourceTable.GetMetaData().GetColumnByIndex(m_ColumnIndex);
            string label;

            var t = metaCol.Type;

            if (t == typeof(string))
            {
                label = "'" + metaCol.DisplayName + "' contains:";
            }
            else
            {
                label = "'" + metaCol.DisplayName + "' is:";
            }
            GUILayout.Label(label);
            if (t.IsEnum)
            {
                string[] popupSelection;
                if (m_CacheSourceTable == sourceTable)
                {
                    popupSelection = m_CachePopupSelection;
                }
                else
                {
                    var names = System.Enum.GetNames(t);
                    popupSelection    = new string[names.Length + 1];
                    popupSelection[0] = "<All>";
                    System.Array.Copy(names, 0, popupSelection, 1, names.Length);

                    if (m_CacheSourceTable == null)
                    {
                        m_CacheSourceTable    = sourceTable;
                        m_CachePopupSelection = popupSelection;
                    }
                }

                GUI.SetNextControlName(k_MatchStringField);
                int newSelectedPopup = EditorGUILayout.Popup(m_SelectedPopup, popupSelection);
                if (m_ForceFocus)
                {
                    m_ForceFocus = false;
                    GUI.FocusControl(k_MatchStringField);
                }

                if (m_SelectedPopup != newSelectedPopup)
                {
                    m_SelectedPopup = newSelectedPopup;
                    if (m_SelectedPopup == 0)
                    {
                        m_MatchString = "";
                    }
                    else
                    {
                        m_MatchString = popupSelection[m_SelectedPopup];
                    }
                    dirty = true;
                }
            }
            else
            {
                GUI.SetNextControlName(k_MatchStringField);
                var newMatchString = GUILayout.TextField(m_MatchString, GUILayout.MinWidth(250));
                if (m_ForceFocus)
                {
                    m_ForceFocus = false;
                    GUI.FocusControl(k_MatchStringField);
                }
                if (m_MatchString != newMatchString)
                {
                    m_MatchString = newMatchString;
                    dirty         = true;
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            return(bRemove);
        }
Esempio n. 11
0
 public string GetColumnName(Database.Table sourceTable)
 {
     return(sourceTable.GetMetaData().GetColumnByIndex(m_ColumnIndex).Name);
 }
Esempio n. 12
0
        public override bool OnGui(Database.Table sourceTable, ref bool dirty)
        {
            EditorGUILayout.BeginHorizontal();
            bool bRemove = OnGui_RemoveButton();
            var  metaCol = sourceTable.GetMetaData().GetColumnByIndex(m_ColumnIndex);
            var  t       = metaCol.Type;

            GUILayout.Label(string.Format(t.comparisonMethod == DataMatchMethod.AsString ? "'{0}' contains:" : "'{0}' is:", metaCol.DisplayName));
            if (t.scriptingType.IsEnum)
            {
                string[] popupSelection;
                if (m_CacheSourceTable == sourceTable)
                {
                    popupSelection = m_CachePopupSelection;
                }
                else
                {
                    var names = System.Enum.GetNames(t.scriptingType);
                    popupSelection    = new string[names.Length];
                    popupSelection[0] = "All";
                    System.Array.Copy(names, 1, popupSelection, 1, names.Length - 1);

                    if (m_CacheSourceTable == null)
                    {
                        m_CacheSourceTable    = sourceTable;
                        m_CachePopupSelection = popupSelection;
                    }
                }

                GUI.SetNextControlName(k_MatchStringField);
                int newSelectedPopup = EditorGUILayout.Popup(m_SelectedPopup, popupSelection, GUILayout.Width(75));
                if (m_ForceFocus)
                {
                    m_ForceFocus = false;
                    GUI.FocusControl(k_MatchStringField);
                }

                if (m_SelectedPopup != newSelectedPopup)
                {
                    m_SelectedPopup = newSelectedPopup;
                    if (m_SelectedPopup == 0)
                    {
                        m_MatchString = "";
                    }
                    else
                    {
                        m_MatchString = popupSelection[m_SelectedPopup];
                    }
                    dirty = true;
                }
            }
            else
            {
                GUI.SetNextControlName(k_MatchStringField);
                var newMatchString = GUILayout.TextField(m_MatchString, GUILayout.MinWidth(250));
                if (m_ForceFocus)
                {
                    m_ForceFocus = false;
                    GUI.FocusControl(k_MatchStringField);
                }
                if (m_MatchString != newMatchString)
                {
                    m_MatchString = newMatchString;
                    dirty         = true;
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            return(bRemove);
        }