void OpenLinkRequest(Database.LinkRequestTable link, bool focus) { //TODO this code is the same as the one inSpreadsheetPane, should be put together UIElementsHelper.SetVisibility(VisualElements[2], m_ActiveMode.snapshot.nativeAllocationSites.Count > 0 && m_CurrentTableView == TableDisplayMode.Allocations); var tableRef = new Database.TableReference(link.LinkToOpen.TableName, link.Parameters); var table = m_ActiveMode.SchemaToDisplay.GetTableByReference(tableRef); if (table == null) { UnityEngine.Debug.LogError("No table named '" + link.LinkToOpen.TableName + "' found."); return; } 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); } Database.Operation.ExpressionParsingContext expressionParsingContext = null; if (link.SourceView != null) { expressionParsingContext = link.SourceView.ExpressionParsingContext; } var whereUnion = new Database.View.WhereUnion(link.LinkToOpen.RowWhere, null, null, null, null, m_ActiveMode.SchemaToDisplay, filteredTable, expressionParsingContext); var indices = whereUnion.GetMatchingIndices(link.SourceRow); var newTab = new Database.Operation.IndexedTable(table, new ArrayRange(indices)); OpenTable(tableRef, newTab, focus); } else { OpenTable(tableRef, table, new Database.CellPosition(0, 0), focus); } }
void OpenLinkRequest(Database.LinkRequestTable link, bool focus, string tableTypeFilter = null, bool select = true) { List <Where.Builder> tableFilterWhere = null; m_CurrentTableTypeFilter = tableTypeFilter; if (tableTypeFilter != null) { tableFilterWhere = new List <Where.Builder>(); tableFilterWhere.Add(new Where.Builder("Type", Database.Operation.Operator.Equal, new Database.Operation.Expression.MetaExpression(tableTypeFilter, true))); } //TODO this code is the same as the one inSpreadsheetPane, should be put together using (ScopeDebugContext.String("OpenLinkRequest")) { var tableRef = new Database.TableReference(link.LinkToOpen.TableName, link.Parameters); var table = m_UIState.snapshotMode.SchemaToDisplay.GetTableByReference(tableRef); if (table == null) { UnityEngine.Debug.LogError("No table named '" + link.LinkToOpen.TableName + "' found."); return; } if (link.LinkToOpen.RowWhere != null && link.LinkToOpen.RowWhere.Count > 0) { if (table.GetMetaData().defaultFilter != null) { table = table.GetMetaData().defaultFilter.CreateFilter(table); } Database.Operation.ExpressionParsingContext expressionParsingContext = null; if (link.SourceView != null) { expressionParsingContext = link.SourceView.ExpressionParsingContext; } if (tableFilterWhere != null && tableFilterWhere.Count > 0) { table = FilterTable(table, link.SourceRow, tableFilterWhere); } var whereUnion = new WhereUnion(link.LinkToOpen.RowWhere, null, null, null, null, m_UIState.snapshotMode.SchemaToDisplay, table, expressionParsingContext); long rowToSelect = whereUnion.GetIndexFirstMatch(link.SourceRow); if (rowToSelect < 0) { UnityEngine.Debug.LogError("Could not find entry in target table '" + link.LinkToOpen.TableName + "'"); return; } OpenTable(tableRef, table, new Database.CellPosition(rowToSelect, 0), focus, select); } else if (tableFilterWhere != null && tableFilterWhere.Count > 0) { table = FilterTable(table, link.SourceRow, tableFilterWhere); OpenTable(tableRef, table, new Database.CellPosition(0, 0), focus, select); } else { OpenTable(tableRef, table, new Database.CellPosition(0, 0), focus, select); } } }
public static LinkRequestTable MakeLinkRequest(TableLink metaLink, Table sourceTable, Column sourceColumn, long sourceRow, Database.Operation.ExpressionParsingContext expressionParsingContext) { if (metaLink == null) { return(null); } using (ScopeDebugContext.Func(() => { return("MakeLinkRequest from table '" + sourceTable.GetName() + "' row " + sourceRow); })) { var lr = new LinkRequestTable(); lr.LinkToOpen = metaLink; lr.SourceTable = sourceTable; lr.SourceView = sourceTable as View.ViewTable; lr.SourceColumn = sourceColumn; lr.SourceRow = sourceRow; if (lr.LinkToOpen.Parameters != null) { foreach (var p in lr.LinkToOpen.Parameters) { var opt = new Operation.Expression.ParseIdentifierOption(sourceTable.Schema as View.ViewSchema, sourceTable, true, true, typeof(string), expressionParsingContext); var metaExpression = new Operation.Expression.MetaExpression(p.Value, true); var exp = Operation.Expression.ParseIdentifier(metaExpression, opt); var exp2 = Operation.ColumnCreator.CreateTypedExpressionFixedRow(exp, sourceRow); lr.Parameters.Add(p.Key, exp2); } } return(lr); } }