public ObjectChangingEventArgs(ITabularObject tabularObject, string propertyName, object newValue)
 {
     TabularObject = tabularObject;
     PropertyName  = propertyName;
     NewValue      = newValue;
     Cancel        = false;
 }
 public ObjectChangedEventArgs(ITabularObject tabularObject, string propertyName, object oldValue, object newValue)
 {
     TabularObject = tabularObject;
     PropertyName  = propertyName;
     OldValue      = oldValue;
     NewValue      = newValue;
 }
        internal void DoObjectDeleting(ITabularObject obj, ref bool cancel)
        {
            var e = new ObjectDeletingEventArgs(obj);

            ObjectDeleting?.Invoke(this, e);
            cancel = e.Cancel;
        }
Example #4
0
        public static int GetIconIndex(ITabularObject obj, bool isExpanded = false)
        {
            int iconIndex = -1;

            switch (obj.ObjectType)
            {
            case ObjectType.Table:
                var t = obj as Table;
                if (t.DataCategory == "Time" && t.Columns.Any(c => c.IsKey))
                {
                    return(obj is CalculatedTable ? TabularIcons.ICON_CALCTIMETABLE : TabularIcons.ICON_TIMETABLE);
                }
                return(obj is CalculatedTable ? TabularIcons.ICON_CALCTABLE : TabularIcons.ICON_TABLE);

            case ObjectType.Column:
                return(obj is CalculatedColumn ? TabularIcons.ICON_CALCCOLUMN : TabularIcons.ICON_COLUMN);

            case ObjectType.Level:
                iconIndex = TabularIcons.ICON_LEVEL1 + (obj as Level).Ordinal;
                return(iconIndex > TabularIcons.ICON_LEVEL12 ? TabularIcons.ICON_LEVEL12 : iconIndex);

            case ObjectType.Folder:
            case ObjectType.Group:
                return(isExpanded ? TabularIcons.ICON_FOLDEROPEN : TabularIcons.ICON_FOLDER);

            case ObjectType.RLSFilterExpression:
                return(TabularIcons.ICON_ROLE);

            default:
                IconMap.TryGetValue(obj.ObjectType, out iconIndex);
                return(iconIndex);
            }
        }
Example #5
0
 public static string GetTypeName(this ITabularObject obj, bool plural = false)
 {
     if (obj is DataColumn)
     {
         return("Column" + (plural ? "s" : ""));
     }
     if (obj is StructuredDataSource)
     {
         return("Data Source (Power Query)");
     }
     if (obj is ProviderDataSource)
     {
         return("Data Source (Legacy)");
     }
     if (obj is MPartition p1)
     {
         return($"Partition (M - {p1.GetMode()})");
     }
     if (obj is Partition p2)
     {
         return($"Partition (Legacy - {p2.GetMode()})");
     }
     if (obj is Table t)
     {
         return($"Table ({t.GetMode()})");
     }
     else
     {
         return(obj.ObjectType.GetTypeName(plural));
     }
 }
        public static string GetName(this ITabularObject obj)
        {
            if ((obj is ITabularNamedObject)) return (obj as ITabularNamedObject)?.Name;

            if(obj is TablePermission tp) return tp.Role.Name;

            return obj.GetTypeName();
        }
 public UndoPropertyChangedNonMetadataObjectAction(ITabularObject wrapperObject, string propertyName, object oldValue, object newValue, string index = null)
 {
     this.wrapperObject = wrapperObject;
     this.oldValue      = oldValue;
     this.newValue      = newValue;
     this.objectType    = wrapperObject.GetType();
     this.prop          = objectType.GetProperty(propertyName);
     this.index         = index;
     this.ActionName    = GetActionNameFromProperty(propertyName);
 }
        internal void DoObjectChanged(ITabularObject obj, string propertyName, object oldValue, object newValue)
        {
            if (_disableUpdates)
            {
                return;
            }

            var e = new ObjectChangedEventArgs(obj, propertyName, oldValue, newValue);

            ObjectChanged?.Invoke(this, e);
        }
        internal void DoObjectDeleted(ITabularObject obj, ITabularNamedObject parentBeforeDeletion)
        {
            if (obj is IFolderObject)
            {
                Tree.RebuildFolderCacheForTable(parentBeforeDeletion as Table);
            }

            var e = new ObjectDeletedEventArgs(obj);

            ObjectDeleted?.Invoke(this, e);
        }
Example #10
0
 public override void OnNodesInserted(ITabularObject parent, params ITabularObject[] children)
 {
     if (UpdateLocks > 0)
     {
         structureChangedItems.AddIfNotExists(parent);
         return;
     }
     else
     {
         NodesInserted?.Invoke(this, new TreeModelEventArgs(GetPath(parent), children));
     }
 }
        internal void DoObjectChanging(ITabularObject obj, string propertyName, object newValue, ref bool cancel)
        {
            if (_disableUpdates)
            {
                return;
            }

            var e = new ObjectChangingEventArgs(obj, propertyName, newValue);

            ObjectChanging?.Invoke(this, e);
            cancel = e.Cancel;
        }
Example #12
0
 public override void OnNodesChanged(ITabularObject nodeItem)
 {
     if (UpdateLocks > 0)
     {
         nodeChangedItemsCount++;
         return;
     }
     else
     {
         var path = GetPath(nodeItem);
         NodesChanged?.Invoke(this, new TreeModelEventArgs(path, new object[] { }));
     }
 }
Example #13
0
        public void OnNodesInserted(ITabularObject parent, IEnumerable <ITabularObject> children)
        {
            var table = parent as Table;

            if (table != null && Options.HasFlag(LogicalTreeOptions.DisplayFolders))
            {
                foreach (var child in children.OfType <IFolderObject>())
                {
                    Folder.CreateFolder(table, child.DisplayFolder).Children.Add(child);
                }
            }
            OnNodesInserted(parent, children.ToArray());
        }
 public static string GetTypeName(this ITabularObject obj, bool plural = false)
 {
     if (obj is DataColumn) return "Column" + (plural ? "s" : "");
     if (obj is StructuredDataSource) return "Data Source (Power Query)";
     if (obj is ProviderDataSource) return "Data Source (Legacy)";
     if (obj is PolicyRangePartition p4) return $"Partition (Policy Range)";
     if (obj is EntityPartition p3) return $"Partition (DQ over AS)";
     if (obj is MPartition p1) return $"Partition (M - {p1.GetMode()})";
     if (obj is Partition p2) return $"Partition (Legacy - {p2.GetMode()})";
     if (obj is CalculationGroupTable cgt) return $"Calculation Group Table" + (plural ? "s" : "");
     if (obj is CalculatedTable ct) return $"Calculated Table" + (plural ? "s" : "");
     if (obj is Table t) return $"Table ({t.GetMode()})";
     else return obj.ObjectType.GetTypeName(plural);
 }
Example #15
0
        public static string GetName(this ITabularObject obj)
        {
            if ((obj is ITabularNamedObject))
            {
                return((obj as ITabularNamedObject)?.Name);
            }

            var tryRlsFilterExpr = obj as RLSFilterExpression;

            if (tryRlsFilterExpr != null)
            {
                return(tryRlsFilterExpr.Role.Name);
            }

            return(obj.GetTypeName());
        }
Example #16
0
 public override void OnNodesRemoved(ITabularObject parent, params ITabularObject[] children)
 {
     if (UpdateLocks > 0)
     {
         structureChangedItems.AddIfNotExists(parent);
         return;
     }
     else
     {
         if (FilterActive && FilterMode == FilterMode.Flat)
         {
             StructureChanged?.Invoke(this, new TreePathEventArgs());
         }
         else
         {
             NodesRemoved?.Invoke(this, new TreeModelEventArgs(GetPath(parent), children));
         }
     }
 }
Example #17
0
 public static string GetTypeName(this ITabularObject obj, bool plural = false)
 {
     if (obj is CalculatedTable)
     {
         return("Calculated Table" + (plural ? "s" : ""));
     }
     if (obj is DataColumn)
     {
         return("Column" + (plural ? "s" : ""));
     }
     if (obj is CalculatedColumn)
     {
         return("Calculated Column" + (plural ? "s" : ""));
     }
     if (obj is CalculatedTableColumn)
     {
         return("Calculated Table Column" + (plural ? "s" : ""));
     }
     if (obj is StructuredDataSource)
     {
         return("Data Source (Power Query)");
     }
     if (obj is ProviderDataSource)
     {
         return("Data Source (Legacy)");
     }
     if (obj is MPartition)
     {
         return("Partition (Power Query)");
     }
     if (obj is Partition)
     {
         return("Partition (Legacy)");
     }
     else
     {
         return(obj.ObjectType.GetTypeName(plural));
     }
 }
Example #18
0
 public ComparisonObject(
     ComparisonObjectType comparisonObjectType,
     ComparisonObjectStatus status,
     ITabularObject sourceObject,
     string sourceObjectName,
     string sourceObjectId,
     string sourceObjectDefinition,
     MergeAction mergeAction,
     ITabularObject targetObject,
     string targetObjectName,
     string targetObjectId,
     string targetObjectDefinition) : base(comparisonObjectType, status, mergeAction)
 {
     _sourceObject           = sourceObject;
     _sourceObjectName       = sourceObjectName;
     _sourceObjectId         = sourceObjectId;
     _sourceObjectDefinition = sourceObjectDefinition;
     _targetObject           = targetObject;
     _targetObjectName       = targetObjectName;
     _targetObjectId         = targetObjectId;
     _targetObjectDefinition = targetObjectDefinition;
 }
Example #19
0
        public static int GetIconIndex(ITabularObject obj, bool isExpanded = false)
        {
            int iconIndex = -1;

            switch (obj.ObjectType)
            {
            case ObjectType.Table:
                var t = obj as Table;
                if (t.DataCategory == "Time" && t.Columns.Any(c => c.IsKey))
                {
                    return(obj is CalculatedTable ? TabularIcons.ICON_CALCTIMETABLE : TabularIcons.ICON_TIMETABLE);
                }
                return(obj is CalculatedTable ? TabularIcons.ICON_CALCTABLE : TabularIcons.ICON_TABLE);

            case ObjectType.Column:
                if (obj is DataColumn dc && dc.Table is CalculationGroupTable && dc.SourceColumn.EqualsI("name"))
                {
                    return(TabularIcons.ICON_FIELDCOLUMN);
                }
                else
                {
                    return(obj is CalculatedColumn ? TabularIcons.ICON_CALCCOLUMN : TabularIcons.ICON_COLUMN);
                }
 public static string GetTypeName(this ITabularObject obj, bool plural = false)
 {
     if (obj is CalculatedTable)
     {
         return("Calculated Table" + (plural ? "s" : ""));
     }
     if (obj is DataColumn)
     {
         return("Column" + (plural ? "s" : ""));
     }
     if (obj is CalculatedColumn)
     {
         return("Calculated Column" + (plural ? "s" : ""));
     }
     if (obj is CalculatedTableColumn)
     {
         return("Calculated Table Column" + (plural ? "s" : ""));
     }
     else
     {
         return(obj.ObjectType.GetTypeName(plural));
     }
 }
 public override void OnNodesRemoved(ITabularObject parent, params ITabularObject[] children)
 {
 }
Example #22
0
 public static TOM.MetadataObject GetMetadataObject(this ITabularObject obj)
 {
     return((obj as TabularObject)?.MetadataObject);
 }
 public override void OnNodesChanged(ITabularObject nodeItem)
 {
 }
Example #24
0
        public TreePath GetPath(ITabularObject item)
        {
            if (item == null)
            {
                return(TreePath.Empty);
            }

            var stack = new List <object>();

            stack.Add(Model);
            if (item is PartitionViewTable || item is Partition)
            {
                stack.Add(Model.Groups.Partitions);
                if (item is Partition)
                {
                    stack.Add((item as Partition).Table.PartitionViewTable);
                }
                stack.Add(item);
                return(new TreePath(stack.ToArray()));
            }

            if (Options.HasFlag(LogicalTreeOptions.AllObjectTypes) && item != Model)
            {
                // If "Show all object types" is enabled, we need to add the "group" of the item to the stack,
                // to get the complete path. The group can be determined from the type of object:
                switch (item.ObjectType)
                {
                case ObjectType.Culture: stack.Add(Model.Groups.Translations); break;

                case ObjectType.Role: stack.Add(Model.Groups.Roles); break;

                case ObjectType.Perspective: stack.Add(Model.Groups.Perspectives); break;

                case ObjectType.DataSource: stack.Add(Model.Groups.DataSources); break;

                case ObjectType.Relationship: stack.Add(Model.Groups.Relationships); break;

                default:
                    // All other object types should appear in the "Tables" group:
                    stack.Add(Model.Groups.Tables); break;
                }
            }
            if (item is Table)
            {
                stack.Add(item);
            }
            else if (item is ITabularTableObject)
            {
                stack.Add((item as ITabularTableObject).Table);

                var level = item as Level;
                if (level != null)
                {
                    item = level.Hierarchy;
                }

                if (item is IDetailObject && Options.HasFlag(LogicalTreeOptions.DisplayFolders))
                {
                    var dfo = item as IDetailObject;

                    var pathBits   = dfo.Table.Name.ConcatPath(dfo.GetDisplayFolder(Culture)).Split('\\');
                    var folderPath = dfo.Table.Name;
                    for (var i = 1; i < pathBits.Length; i++)
                    {
                        folderPath = folderPath.ConcatPath(pathBits[i]);
                        if (!FolderCache.ContainsKey(folderPath))
                        {
                            Folder.CreateFolder(dfo.Table, FolderHelper.PathFromFullPath(folderPath));
                        }
                        stack.Add(FolderCache[folderPath]);
                    }
                }

                stack.Add(item);
                if (level != null)
                {
                    stack.Add(level);
                }
            }
            return(new TreePath(stack.ToArray()));
        }
 public ObjectDeletedEventArgs(ITabularObject tabularObject)
 {
     TabularObject = tabularObject;
 }
Example #26
0
        public TreePath GetPath(ITabularObject item)
        {
            if (item == null)
            {
                return(TreePath.Empty);
            }

            var stack = new List <object>();

            stack.Add(Model);
            if (item is Partition)
            {
                stack.Add((item as Partition).Table.Partitions);
                stack.Add(item);
                return(new TreePath(stack.ToArray()));
            }

            if (Options.HasFlag(LogicalTreeOptions.AllObjectTypes) && item != Model)
            {
                // If "Show all object types" is enabled, we need to add the "group" of the item to the stack,
                // to get the complete path. The group can be determined from the type of object:
                switch (item.ObjectType)
                {
                case ObjectType.Culture: stack.Add(Model.Groups.Translations); stack.Add(item); break;

                case ObjectType.Role: stack.Add(Model.Groups.Roles); stack.Add(item); break;

                case ObjectType.Perspective: stack.Add(Model.Groups.Perspectives); stack.Add(item); break;

                case ObjectType.DataSource: stack.Add(Model.Groups.DataSources); stack.Add(item); break;

                case ObjectType.Relationship: stack.Add(Model.Groups.Relationships); stack.Add(item); break;

                case ObjectType.Expression: stack.Add(Model.Groups.Expressions); stack.Add(item); break;

                default:
                    // All other object types should appear in the "Tables" group:
                    stack.Add(Model.Groups.Tables); break;
                }
            }
            if (item is Table)
            {
                stack.Add(item);
            }
            else if (item is ITabularTableObject)
            {
                stack.Add((item as ITabularTableObject).Table);

                var calcItem = item as CalculationItem;
                if (calcItem != null)
                {
                    item = calcItem.Field;
                }

                var level = item as Level;
                if (level != null)
                {
                    item = level.Hierarchy;
                }

                var kpi = item as KPI;
                if (kpi != null)
                {
                    item = kpi.Measure;
                }

                if (item is IFolderObject && Options.HasFlag(LogicalTreeOptions.DisplayFolders))
                {
                    var folderStack = new Stack <Folder>();
                    var folder      = (item as IFolderObject).GetFolder(Culture);
                    while (folder != null && folder.Path != "")
                    {
                        folderStack.Push(folder);
                        folder = folder.GetFolder(Culture);
                    }
                    while (folderStack.Count > 0)
                    {
                        stack.Add(folderStack.Pop());
                    }
                }

                stack.Add(item);
                if (calcItem != null)
                {
                    stack.Add(calcItem);
                }
                if (level != null)
                {
                    stack.Add(level);
                }
                if (kpi != null)
                {
                    stack.Add(kpi);
                }
            }
            return(new TreePath(stack.ToArray()));
        }
 internal void UpdateObject(ITabularObject obj)
 {
     Tree.OnNodesChanged(obj);
 }
Example #28
0
 /// <summary>
 /// Call this method to signal to the TreeView that a node needs repaint, typically
 /// because a property was changed that affects how the node should be rendered (but not
 /// WHERE the node should be rendered).
 /// </summary>
 /// <param name="nodeItem"></param>
 public abstract void OnNodesChanged(ITabularObject nodeItem);
Example #29
0
 public void OnNodesRemoved(ITabularObject parent, IEnumerable <ITabularObject> children)
 {
     OnNodesRemoved(parent, children.ToArray());
 }
Example #30
0
 public abstract void OnNodesInserted(ITabularObject parent, params ITabularObject[] children);