public SearcherDatabase Build()
        {
            var items = new List <SearcherItem>();

            foreach (var component in m_Query.Components)
            {
                var handle        = component.Component.TypeHandle;
                var componentItem = new TypeSearcherItem(handle, handle.Name(m_Stencil));
                CreateFieldItems(componentItem, handle.Resolve(m_Stencil), k_Depth);

                // We only display components with fields
                if (componentItem.HasChildren)
                {
                    items.Add(componentItem);
                }
            }

            return(SearcherDatabase.Create(items, "", false));
        }
예제 #2
0
        internal static void ShowEnumValues(string title, Type enumType, Vector2 position, Action <Enum, int> callback)
        {
            var items = Enum.GetValues(enumType)
                        .Cast <Enum>()
                        .Select(v => new EnumValuesAdapter.EnumValueSearcherItem(v) as SearcherItem)
                        .ToList();
            var database = SearcherDatabase.Create(items, "", false);
            var searcher = new Searcher.Searcher(database, new EnumValuesAdapter(title));

            SearcherWindow.Show(EditorWindow.focusedWindow, searcher, item =>
            {
                if (item == null)
                {
                    return(false);
                }

                callback(((EnumValuesAdapter.EnumValueSearcherItem)item).value, 0);
                return(true);
            }, position, null);
        }
예제 #3
0
        internal static void FindInGraph(
            EditorWindow host,
            VSGraphModel graph,
            Action <FindInGraphAdapter.FindSearcherItem> highlightDelegate,
            Action <FindInGraphAdapter.FindSearcherItem> selectionDelegate
            )
        {
            var items = graph.GetAllNodes()
                        .Where(x => !string.IsNullOrEmpty(x.Title))
                        .Select(MakeFindItems)
                        .ToList();
            var database = SearcherDatabase.Create(items, "", false);
            var searcher = new Searcher.Searcher(database, new FindInGraphAdapter(highlightDelegate));
            var position = new Vector2(host.rootVisualElement.layout.center.x, 0);

            SearcherWindow.Show(host, searcher, item =>
            {
                selectionDelegate(item as FindInGraphAdapter.FindSearcherItem);
                return(true);
            },
                                position, null, k_FindAlignment);
        }
예제 #4
0
        public SearcherDatabase Build()
        {
            var items = new List <SearcherItem>();

            foreach (var meta in m_TypesMetadata)
            {
                foreach (var metaRegistration in m_MetaRegistrations)
                {
                    if (metaRegistration.Invoke(items, meta))
                    {
                        break;
                    }
                }
            }

            foreach (var registration in m_Registrations)
            {
                registration.Invoke(items);
            }

            return(SearcherDatabase.Create(items, "", false));
        }
예제 #5
0
        public Searcher.Searcher LoadSearchWindow()
        {
            if (regenerateEntries)
            {
                GenerateNodeEntries();
                regenerateEntries = false;
            }

            //create empty root for searcher tree
            var root       = new List <SearcherItem>();
            var dummyEntry = new NodeEntry();

            foreach (var nodeEntry in currentNodeEntries)
            {
                SearcherItem item   = null;
                SearcherItem parent = null;
                for (int i = 0; i < nodeEntry.title.Length; i++)
                {
                    var pathEntry = nodeEntry.title[i];
                    List <SearcherItem> children = parent != null ? parent.Children : root;
                    item = children.Find(x => x.Name == pathEntry);

                    if (item == null)
                    {
                        //if we have slot entries and are at a leaf, add the slot name to the entry title
                        if (nodeEntry.compatibleSlotId != -1 && i == nodeEntry.title.Length - 1)
                        {
                            item = new SearchNodeItem(pathEntry + ": " + nodeEntry.slotName, nodeEntry, nodeEntry.node.synonyms);
                        }
                        //if we don't have slot entries and are at a leaf, add userdata to the entry
                        else if (nodeEntry.compatibleSlotId == -1 && i == nodeEntry.title.Length - 1)
                        {
                            item = new SearchNodeItem(pathEntry, nodeEntry, nodeEntry.node.synonyms);
                        }
                        //if we aren't a leaf, don't add user data
                        else
                        {
                            item = new SearchNodeItem(pathEntry, dummyEntry, null);
                        }

                        if (parent != null)
                        {
                            parent.AddChild(item);
                        }
                        else
                        {
                            children.Add(item);
                        }
                    }

                    parent = item;

                    if (parent.Depth == 0 && !root.Contains(parent))
                    {
                        root.Add(parent);
                    }
                }
            }

            var nodeDatabase = SearcherDatabase.Create(root, string.Empty, false);

            return(new Searcher.Searcher(nodeDatabase, new SearchWindowAdapter("Create Node")));
        }
예제 #6
0
 protected override SearcherDatabaseBase Create(List <SearcherItem> bookItems)
 {
     return(SearcherDatabase.Create(bookItems, null, false));
 }
예제 #7
0
 public SearcherDatabase Build()
 {
     return(SearcherDatabase.Create(Items, "", false));
 }