mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-09 17:36:25 +00:00
Fix array editor disabled
This commit is contained in:
parent
e1096e29ca
commit
3e6240d895
6 changed files with 110 additions and 9 deletions
|
@ -3,7 +3,7 @@
|
||||||
<Product Id="*"
|
<Product Id="*"
|
||||||
Name="NBTExplorer"
|
Name="NBTExplorer"
|
||||||
Language="1033"
|
Language="1033"
|
||||||
Version="2.7.1.0"
|
Version="2.7.2.0"
|
||||||
Manufacturer="Justin Aquadro"
|
Manufacturer="Justin Aquadro"
|
||||||
UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25">
|
UpgradeCode="0bfb1026-21f2-4552-ad71-ca90aae10a25">
|
||||||
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
|
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
|
||||||
|
|
|
@ -88,9 +88,8 @@
|
||||||
<StartupObject />
|
<StartupObject />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Substrate, Version=1.3.8.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Substrate">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\References\Substrate.dll</HintPath>
|
||||||
<HintPath>References\Substrate.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.7.1.0")]
|
[assembly: AssemblyVersion("2.7.2.0")]
|
||||||
[assembly: AssemblyFileVersion("2.7.1.0")]
|
[assembly: AssemblyFileVersion("2.7.2.0")]
|
||||||
|
|
101
NBTModel/FilterExpressionParser.cs
Normal file
101
NBTModel/FilterExpressionParser.cs
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NBTExplorer.Model
|
||||||
|
{
|
||||||
|
class FilterExpressionParser
|
||||||
|
{
|
||||||
|
private Stack<string> argStack = new Stack<string>();
|
||||||
|
|
||||||
|
/*public bool Parse (DataNode targetNode, List<string> tokens)
|
||||||
|
{
|
||||||
|
Queue<string> tokenQueue = new Queue<string>(FilterExpressionConverter.Convert(tokens));
|
||||||
|
|
||||||
|
while (tokenQueue.Count > 0) {
|
||||||
|
string token = tokenQueue.Dequeue();
|
||||||
|
|
||||||
|
switch (token) {
|
||||||
|
case "equal":
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
static class FilterExpressionConverter
|
||||||
|
{
|
||||||
|
private static List<List<string>> OperatorGroups = new List<List<string>> {
|
||||||
|
new List<string> { "equal", "greater", "less", "contains", "begins", "ends" },
|
||||||
|
new List<string> { "not" },
|
||||||
|
new List<string> { "and", "or" },
|
||||||
|
};
|
||||||
|
|
||||||
|
public static List<string> Convert (List<string> tokens)
|
||||||
|
{
|
||||||
|
Queue<string> tokenQueue = new Queue<string>(tokens);
|
||||||
|
List<string> output = new List<string>();
|
||||||
|
Stack<string> opStack = new Stack<string>();
|
||||||
|
|
||||||
|
while (tokenQueue.Count > 0) {
|
||||||
|
string token = tokenQueue.Dequeue();
|
||||||
|
|
||||||
|
if (IsGroupStart(token)) {
|
||||||
|
opStack.Push(token);
|
||||||
|
}
|
||||||
|
else if (IsGroupEnd(token)) {
|
||||||
|
while (opStack.Count > 0 && !IsGroupStart(opStack.Peek()))
|
||||||
|
output.Add(opStack.Pop());
|
||||||
|
if (opStack.Count == 0)
|
||||||
|
throw new Exception("Mismatched grouping");
|
||||||
|
opStack.Pop();
|
||||||
|
}
|
||||||
|
else if (IsOperator(token)) {
|
||||||
|
while (opStack.Count > 0 && IsOperator(opStack.Peek())) {
|
||||||
|
if (Precedence(token) > Precedence(opStack.Peek()))
|
||||||
|
output.Add(opStack.Pop());
|
||||||
|
}
|
||||||
|
opStack.Push(token);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
output.Add(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (opStack.Count > 0) {
|
||||||
|
if (IsGroupStart(opStack.Peek()))
|
||||||
|
throw new Exception("Mismatched grouping");
|
||||||
|
output.Add(opStack.Pop());
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsGroupStart (string token)
|
||||||
|
{
|
||||||
|
return token == "(";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsGroupEnd (string token)
|
||||||
|
{
|
||||||
|
return token == ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsOperator (string token)
|
||||||
|
{
|
||||||
|
foreach (var group in OperatorGroups) {
|
||||||
|
if (group.Contains(token))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Precedence (string op) {
|
||||||
|
for (int i = 0; i < OperatorGroups.Count; i++) {
|
||||||
|
if (OperatorGroups[i].Contains(op))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return int.MaxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>TRACE;DEBUG;WINDOWS</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE;WINDOWS</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -46,6 +46,7 @@
|
||||||
<Compile Include="Data\DataNodeCollection.cs" />
|
<Compile Include="Data\DataNodeCollection.cs" />
|
||||||
<Compile Include="Data\Nodes\DirectoryDataNode.cs" />
|
<Compile Include="Data\Nodes\DirectoryDataNode.cs" />
|
||||||
<Compile Include="Data\FileTypeRegistry.cs" />
|
<Compile Include="Data\FileTypeRegistry.cs" />
|
||||||
|
<Compile Include="FilterExpressionParser.cs" />
|
||||||
<Compile Include="Interop\FormRegistry.cs" />
|
<Compile Include="Interop\FormRegistry.cs" />
|
||||||
<Compile Include="Interop\NbtClipboardController.cs" />
|
<Compile Include="Interop\NbtClipboardController.cs" />
|
||||||
<Compile Include="Interop\NbtClipboardData.cs" />
|
<Compile Include="Interop\NbtClipboardData.cs" />
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace NBTExplorer.Model
|
||||||
|
|
||||||
string part = nextLevels[0];
|
string part = nextLevels[0];
|
||||||
List<string> remainingLevels = nextLevels.GetRange(1, nextLevels.Count - 1);
|
List<string> remainingLevels = nextLevels.GetRange(1, nextLevels.Count - 1);
|
||||||
|
|
||||||
if (part == "*") {
|
if (part == "*") {
|
||||||
foreach (DataNode childNode in containerNode.Nodes) {
|
foreach (DataNode childNode in containerNode.Nodes) {
|
||||||
foreach (DataNode grandChildNode in EnumerateNodes(childNode, remainingLevels))
|
foreach (DataNode grandChildNode in EnumerateNodes(childNode, remainingLevels))
|
||||||
|
|
Loading…
Reference in a new issue