private SearchExpressionNode LoadNodeData(SearchExpressionNode node, IDictionary info) { if (SJSON.TryGetValue(info, ExpressionField.name, out var name)) { node.name = Convert.ToString(name); } if (SJSON.TryGetValue(info, ExpressionField.value, out var value)) { node.value = value; } if (node.type == ExpressionType.Expression) { var nestedExpression = new SearchExpression(m_SearchOptions); if (node.value is string expressionPath && File.Exists(expressionPath)) { nestedExpression.Load(expressionPath); } else if (SJSON.TryGetValue(info, ExpressionField.source, out var source) && source is IDictionary sourceData) { nestedExpression.Load(sourceData); } if (nestedExpression.m_EvalNode != null && nestedExpression.m_EvalNode.source != null) { node.source = nestedExpression.m_EvalNode.source; } }
/// <summary> /// Parse a simple json document string as a SearchExpression. /// </summary> /// <param name="sjson">Simple Json string defining a SearchExpression</param> /// <param name="options">Options defining how the query will be performed</param> /// <returns>Returns a SearchExpression ready to be evaluated.</returns> public static ISearchExpression ParseExpression(string sjson, SearchFlags options = SearchFlags.Default) { var se = new SearchExpression(options); se.Parse(sjson); return(se); }
public ExpressionResultView(SearchExpression expression) { style.overflow = Overflow.Hidden; onGUIHandler = OnGUI; this.expression = expression; m_View = new ListView(this); }
/// <summary> /// Load a search expression asset. /// </summary> /// <param name="expressionPath">Asset path of the search expression</param> /// <param name="options">Options defining how the query will be performed</param> /// <returns>Returns a SearchExpression ready to be evaluated.</returns> public static ISearchExpression LoadExpression(string expressionPath, SearchFlags options = SearchFlags.Default) { if (!File.Exists(expressionPath)) { throw new ArgumentException($"Cannot find expression {expressionPath}", nameof(expressionPath)); } var se = new SearchExpression(options); se.Load(expressionPath); return(se); }
private void InitializeExpression() { if (m_Expression != null) { return; } m_ExpressionPath = AssetDatabase.GetAssetPath(target); m_ExpressionName = Path.GetFileNameWithoutExtension(m_ExpressionPath); m_ExpressionTitle = new GUIContent(m_ExpressionName, Icons.quicksearch, m_ExpressionPath); m_Expression = new SearchExpression(SearchSettings.GetContextOptions()); m_Expression.Load(m_ExpressionPath); m_Expression.Evaluate(); }
internal static void CreateIndexProject() { var folderPath = AssetDatabase.GetAssetPath(Selection.activeObject); if (File.Exists(folderPath)) { folderPath = Path.GetDirectoryName(folderPath); } var expressionPath = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(folderPath, "expression.qse")); var newExpression = new SearchExpression(SearchFlags.Default); newExpression.Save(expressionPath); AssetDatabase.ImportAsset(expressionPath); Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(expressionPath); }
public ExpressionGraph(SearchExpression expression) { focusable = true; m_Expression = expression; SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); Insert(0, new GridBackground()); this.AddManipulator(new ContentDragger()); this.AddManipulator(new SelectionDragger()); this.AddManipulator(new RectangleSelector()); this.AddManipulator(new FreehandSelector()); ReloadExpression(); graphViewChanged += OnGraphViewChanged; }
public void OnDisable() { SaveSplitterPosition(); m_ExpressionGraph.nodeChanged -= OnNodePropertiesChanged; m_ExpressionGraph.graphChanged -= OnGraphChanged; m_ExpressionGraph.selectionChanged -= OnSelectionChanged; m_ExpressionGraph.Dispose(); m_ExpressionGraph = null; m_NodeEditor.propertiesChanged -= OnNodePropertiesChanged; m_NodeEditor.variableAdded -= OnNodeVariableAdded; m_NodeEditor.variableRemoved -= OnNodeVariableRemoved; m_NodeEditor.variableRenamed -= OnNodeVariableRenamed; m_NodeEditor.Dispose(); m_NodeEditor = null; m_Expression.Dispose(); m_Expression = null; }
public void OnEnable() { m_Expression = new SearchExpression(SearchSettings.GetContextOptions()); m_ExpressionGraph = new ExpressionGraph(m_Expression); titleContent = new GUIContent("Expression Builder", Icons.quicksearch); #if UNITY_2020_2_OR_NEWER wantsLessLayoutEvents = true; #endif BuildUI(); Reload(); m_ExpressionGraph.nodeChanged += OnNodePropertiesChanged; m_ExpressionGraph.graphChanged += OnGraphChanged; m_ExpressionGraph.selectionChanged += OnSelectionChanged; m_NodeEditor.propertiesChanged += OnNodePropertiesChanged; m_NodeEditor.variableAdded += OnNodeVariableAdded; m_NodeEditor.variableRemoved += OnNodeVariableRemoved; m_NodeEditor.variableRenamed += OnNodeVariableRenamed; }
public static SearchVariable[] UpdateVariables(SearchExpression se, in SearchVariable[] variables)