コード例 #1
0
        static public TreeNode BuildUnitNodes(WorkspaceUnit unit)
        {
            var node = (TreeNode)null;

            ReflectorHostEnvironment host = new ReflectorHostEnvironment();

            var iunit = host.LoadUnitFrom(unit.Location);

            if (iunit == null || iunit == Dummy.Assembly || iunit == Dummy.Module)
            {
                node = BuildErrorNodes(unit.Location, unit);
            }
            else if (iunit is IAssembly)
            {
                node = BuildAssemblyNodes(iunit as IAssembly, unit);
            }
            else if (iunit is IModule)
            {
                node = BuildModuleNodes(iunit as IModule, unit);
            }
            else  // should never goes here
            {
                throw new NotSupportedException();
            }

            if (unit.IsAdded)
            {
                node.Text = "[+] " + node.Text;
            }

            host.CloseReader();

            return(node);
        }
コード例 #2
0
ファイル: WorkspaceViewModel.cs プロジェクト: thbin/TraceLab
 private void InsertUnit(WorkspaceUnit unit, int index)
 {
     if (unit.RealUnitName.StartsWith(m_experimentId))
     {
         m_experimentWorkspaceUnits.Insert(index, unit);
     }
 }
コード例 #3
0
        /// <summary>
        /// Removes the corresponding TreeIters from the view model store of the table
        /// </summary>
        /// <param name="unitsToRemove">Units to remove.</param>
        private void RemoveUnits(System.Collections.IList unitsToRemove)
        {
            //assure that value is set using GTK+ main loop thread to avoid any threading problems
            Gtk.Application.Invoke(delegate
            {
                TreeIter iter;
                if (m_workspaceStore.GetIterFirst(out iter))
                {
                    int removedCount = 0;
                    do
                    {
                        WorkspaceUnit aUnit = (WorkspaceUnit)m_workspaceStore.GetValue(iter, 0);

                        bool foundMatching = false;

                        //check if any unit to remove matches this unit
                        foreach (object unit in unitsToRemove)
                        {
                            if ((WorkspaceUnit)unit == aUnit)
                            {
                                foundMatching = true;
                            }
                        }

                        if (foundMatching)
                        {
                            m_workspaceStore.Remove(ref iter);
                            removedCount++;
                        }
                    } while(m_workspaceStore.IterNext(ref iter) && removedCount < unitsToRemove.Count);
                }
            });
        }
コード例 #4
0
ファイル: WorkspaceViewModel.cs プロジェクト: thbin/TraceLab
 private void RemoveUnit(WorkspaceUnit unit)
 {
     if (unit.RealUnitName.StartsWith(m_experimentId))
     {
         m_experimentWorkspaceUnits.Remove(unit);
     }
 }
コード例 #5
0
ファイル: WorkspaceWindowPad.cs プロジェクト: thbin/TraceLab
 private void AddUnit(WorkspaceUnit unit)
 {
     if (unit.RealUnitName.StartsWith(m_experimentId))
     {
         m_workspaceStore.AppendValues(unit.FriendlyUnitName);
     }
 }
コード例 #6
0
        private void RenderViewerIcon(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            WorkspaceUnit workspaceUnit = (WorkspaceUnit)model.GetValue(iter, 2);

            if (!workspaceUnit.Type.IsPrimitive && workspaceUnit.Type != String.Empty.GetType())
            {
                bool success = false;
                CellRendererPixbuf renderer = (CellRendererPixbuf)cell;
                renderer.Visible = true;

                try
                {
                    success = WorkspaceViewerLoader.CheckIfEditorExists(workspaceUnit.Type);
                }
                catch (Exception) {}

                if (success)
                {
                    renderer.Pixbuf = s_workspaceViewerIcon;
                }
                else
                {
                    renderer.Pixbuf = s_noViewerIcon;
                }
            }
            else
            {
                cell.Visible = false;
            }
        }
コード例 #7
0
        private void RenderType(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            WorkspaceUnit workspaceUnit = (WorkspaceUnit)model.GetValue(iter, 1);
            string        type          = TraceLab.Core.Utilities.TypesHelper.GetFriendlyName(workspaceUnit.Type.ToString());

            (cell as CellRendererText).Text = type;
        }
コード例 #8
0
        public void LoadTestFromXML()
        {
            //set workspace so that it writes units to disc, otherwise files would not be written to disc,
            //so the persistence the units would not be persistent after resetting the workspace
            TestWorkspace.WriteUnitsToDisc = true;

            TestObject obj = new TestObject();

            obj.Value = "value";

            string tmp_unitname = "testobject";

            //string tmpDataPath = Path.Combine(TmpDataDir, TestWorkspace.CurrentGroupId.ToString() + "." + tmp_unitname + ".xml");
            string tmpDataPath = Path.Combine(TmpDataDir, tmp_unitname + ".xml");

            WorkspaceUnit tmpUnit = TestWorkspace.CreateWorkspaceUnit(tmp_unitname);

            tmpUnit.Data = obj;

            // Reset the workspace - this will cause it to realize that
            // the workspace unit exists, even though it's not loaded yet.
            ResetWorkspace();

            TestObject obj2 = (TestObject)TestWorkspace.Load(tmp_unitname);

            Assert.AreEqual(obj, obj2);
        }
コード例 #9
0
        /// <summary>
        /// Build a unit node.
        /// </summary>
        /// <param name="unit"></param>
        /// <returns></returns>
        public TreeNode BuildUnitNode(WorkspaceUnit unit)
        {
            var node  = (TreeNode)null;
            var iunit = _host.LoadUnitFrom(unit.Location);

            if (iunit == null || iunit == Dummy.Assembly || iunit == Dummy.Module)
            {
                node = BuildErrorNode(unit.Location, unit);
            }
            else if (iunit is IAssembly)
            {
                node = BuildAssemblyNode(iunit as IAssembly, unit);
            }
            else if (iunit is IModule)
            {
                node = BuildModuleNode(iunit as IModule, unit);
            }
            else  // should never goes here
            {
                throw new NotSupportedException();
            }

            if (unit.IsAdded)
            {
                node.Text = "[+] " + node.Text;
            }

            return(node);
        }
コード例 #10
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         m_unit = null;
         m_data = null;
     }
 }
コード例 #11
0
        static public TreeNode BuildErrorNodes(string location, WorkspaceUnit unit)
        {
            var node = new TreeNode();

            // CreateTreeNodes(new ErrorNodeTag<TreeNode>(node, location, unit));

            return(node);
        }
コード例 #12
0
        static public TreeNode BuildAssemblyInfo(IAssembly assembly, WorkspaceUnit unit)
        {
            var node = new TreeNode();

            CreateTreeNodes(new AssemblyNodeTag <TreeNode>(node, assembly, unit));

            node.Nodes.Add(BuildModuleNodes(assembly, null));
            foreach (var module in assembly.MemberModules)
            {
                node.Nodes.Add(BuildModuleNodes(module, null));
            }

            return(node);
        }
コード例 #13
0
        private void HandleRowActivated(object source, RowActivatedArgs args)
        {
            TreeIter item;

            if (m_treeView.Selection.GetSelected(out item))
            {
                WorkspaceUnit unit = (WorkspaceUnit)m_treeView.Model.GetValue(item, 0);

                String error;
                if (!WorkspaceViewerLoader.LoadViewer(unit.Data, unit.FriendlyUnitName, out error))
                {
                    NLog.LogManager.GetCurrentClassLogger().Warn(error);
                }
            }
        }
コード例 #14
0
        public WpfWorkspaceUnitWrapper(Dispatcher dispatch, WorkspaceUnit unit)
        {
            if (unit == null)
            {
                throw new ArgumentNullException("unit");
            }
            if (dispatch == null)
            {
                throw new ArgumentNullException("dispatch");
            }

            m_unit = unit;
            m_unit.PropertyChanged += UnitPropertyChanged;
            Dispatch = dispatch;
        }
コード例 #15
0
        private void RenderValue(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            WorkspaceUnit    workspaceUnit = (WorkspaceUnit)model.GetValue(iter, 2);
            CellRendererText renderer      = (CellRendererText)cell;

            if (workspaceUnit.Type.IsPrimitive || workspaceUnit.Type == String.Empty.GetType())
            {
                renderer.Visible = true;
                renderer.Text    = workspaceUnit.Data.ToString();
            }
            else
            {
                renderer.Visible = false;
            }
        }
コード例 #16
0
        public ModuleNodeTag(TUITreeNode treeNode, IModule module, WorkspaceUnit unit)
        {
            if (module == null)
            {
                throw new ArgumentNullException("module");
            }

            if (treeNode == null)
            {
                throw new ArgumentNullException("treeNode");
            }

            this.UITreeNode    = treeNode;
            this.Module        = module;
            this.WorkspaceUnit = unit;
        }
コード例 #17
0
 /// <summary>
 /// Adds the units to the store view
 /// </summary>
 /// <param name="items">Items.</param>
 private void AddUnits(System.Collections.IList items)
 {
     //assure that value is set using GTK+ main loop thread to avoid any threading problems
     Gtk.Application.Invoke(delegate
     {
         foreach (object item in items)
         {
             WorkspaceUnit unit = (WorkspaceUnit)item;
             if (unit.RealUnitName.StartsWith(m_experimentId))
             {
                 //each column has it's own rendering of same unit
                 m_workspaceStore.AppendValues(unit, unit, unit);
             }
         }
     });
 }
コード例 #18
0
        /// <summary>
        /// Create a new node tag object.
        /// </summary>
        /// <param name="assembly"></param>
        public AssemblyNodeTag(TUITreeNode treeNode, IAssembly assembly, WorkspaceUnit unit)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            if (treeNode == null)
            {
                throw new ArgumentNullException("treeNode");
            }

            this.UITreeNode    = treeNode;
            this.Assembly      = assembly;
            this.WorkspaceUnit = unit;
        }
コード例 #19
0
        public override bool Equals(object obj)
        {
            WorkspaceUnit otherUnit = null;

            if (obj is WpfWorkspaceUnitWrapper)
            {
                var otherWrapper = obj as WpfWorkspaceUnitWrapper;
                otherUnit = otherWrapper.m_unit;
            }
            if (obj is WorkspaceUnit)
            {
                otherUnit = obj as WorkspaceUnit;
            }

            return(m_unit.Equals(otherUnit));
        }
コード例 #20
0
        //private void HostErrorsHandler(object sender, ErrorEventArgs e)
        //{
        //    var sb = new StringBuilder();
        //    sb.AppendFormat("Error Report: {0}", e.ErrorReporter);
        //    sb.AppendLine();
        //    sb.AppendLine("Errors:");

        //    foreach (var err in e.Errors)
        //    {
        //        sb.AppendFormat("  Location: {0}", err.Location.Document.Location);
        //        sb.AppendLine();
        //        sb.AppendFormat("  Code: {0}", err.Code);
        //        sb.AppendLine();
        //        sb.AppendFormat("  Message: {0}", err.Message);
        //        sb.AppendLine();
        //    }

        //    sb.AppendFormat("Location: {0}", e.Location.Document.Location);

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

        static public TreeNode BuildUnitNodes(string file)
        {
            string s = AppDomain.CurrentDomain.BaseDirectory;

            string g = s + "temp";

            string b = g + Path.GetFileName(file);

            if (Directory.Exists(g) == false)
            {
                Directory.CreateDirectory(g);
            }

            try
            {
                if (File.Exists(b) == true)
                {
                    File.Delete(b);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                if (File.Exists(file))
                {
                    File.Copy(file, b);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            WorkspaceUnit w = new WorkspaceUnit(b);

            TreeNode node = BuildUnitNodes(w);

            return(node);
        }
コード例 #21
0
        static public TreeNode BuildModuleNodes(IModule module, WorkspaceUnit unit)
        {
            var node = new TreeNode();

            CreateTreeNodes(new ModuleNodeTag <TreeNode>(node, module, unit));

            // Add namespace nodes.
            var types = module.GetAllTypes();

            var topTypes = new List <INamedTypeDefinition>();

            foreach (var t in types)
            {
                if (t is INamespaceTypeDefinition)
                {
                    topTypes.Add(t);
                }
            }

            var namespaceTypes = new Dictionary <string, List <INamedTypeDefinition> >();

            foreach (var t in topTypes)
            {
                var ns = TypeHelper.GetNamespaceName(
                    (t as INamespaceTypeDefinition).ContainingUnitNamespace,
                    NameFormattingOptions.None);

                if (!namespaceTypes.ContainsKey(ns))
                {
                    namespaceTypes.Add(ns, new List <INamedTypeDefinition>());
                }

                namespaceTypes[ns].Add(t);
            }

            foreach (var ns in namespaceTypes.Keys)
            {
                node.Nodes.Add(BuildNamespaceNodes(ns, namespaceTypes[ns]));
            }

            return(node);
        }
コード例 #22
0
        private void RenderName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            WorkspaceUnit workspaceUnit = (WorkspaceUnit)model.GetValue(iter, 0);

            (cell as CellRendererText).Text = workspaceUnit.FriendlyUnitName;
        }
コード例 #23
0
 private void AddUnit(WorkspaceUnit unit)
 {
     Dispatch.Invoke(new Action <WorkspaceUnit>(DoAddUnit), DispatcherPriority.Send, unit);
 }
コード例 #24
0
 private void InsertUnit(WorkspaceUnit unit, int index)
 {
     Dispatch.Invoke(new Action(() => m_units.Insert(index, new WpfWorkspaceUnitWrapper(Dispatch, unit))),
                     DispatcherPriority.Send);
 }
コード例 #25
0
 private void RemoveUnit(WorkspaceUnit unit)
 {
     Dispatch.Invoke(new Action(() => m_units.Remove(new WpfWorkspaceUnitWrapper(Dispatch, unit))),
                     DispatcherPriority.Send);
 }