Skip to content

Commit

Permalink
update docs, fix some dinging, remove imports
Browse files Browse the repository at this point in the history
Major update to docs to bring up to date with current project.
FIXED
1. Annoying dinging sounds when pressing `Enter`, `Tab`, or `Escape` with the forms.
    Dinging sounds seem impossible to remove from the `TreeView` control
    (see #11), but I will keep trying.
2. Removed some unnecessary imports to simplify code.
  • Loading branch information
molsonkiko committed Sep 26, 2022
1 parent 3863998 commit 64fe222
Show file tree
Hide file tree
Showing 41 changed files with 92 additions and 58 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ This project has many features that were implemented in a [standalone app](https
- Sometimes recursive queries may cause an infinite loop, or something else that leads to Notepad++ crashing. Recursive queries are almost always fine, and I only saw this bug once. Not sure why yet.
- The tree view doesn't automatically reset when the user does an undo or redo action. You have to close and reopen the treeview for the changes to be reflected. This is annoying, but I can't seem to get my [Main.OnNotification](/JsonToolsNppPlugin/Main.cs) method to respond to undo and redo actions.
- Improve how well the caret tracks the node selected in the query tree, after a query that selects a subset of nodes. The iterables have their line number set to 0.
- Get rid of __ALL__ dinging sounds from the forms, including the `TreeView` control in the TreeViewer.

## [3.6.1] (unreleased) - 2022-MM-DD

### Fixed

1. Annoying dinging sounds when pressing `Enter`, `Tab`, or `Escape` with the forms. Dinging sounds seem impossible to remove from the `TreeView` control (see #11), but I will keep trying.

## [3.6.0] - 2022-09-25

Expand Down
5 changes: 0 additions & 5 deletions JsonToolsNppPlugin/Forms/GrepperForm.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using JSON_Tools.JSON_Tools;
using JSON_Tools.Utils;
Expand Down
17 changes: 17 additions & 0 deletions JsonToolsNppPlugin/Forms/JsonToCsvForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 30 additions & 1 deletion JsonToolsNppPlugin/Forms/TreeViewer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 25 additions & 9 deletions JsonToolsNppPlugin/Forms/TreeViewer.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using JSON_Tools.JSON_Tools;
using JSON_Tools.Utils;
using Kbg.NppPluginNET.PluginInfrastructure;
using Kbg.NppPluginNET;

namespace JSON_Tools.Forms
Expand Down Expand Up @@ -77,12 +70,34 @@ public TreeViewer(JNode json)
// activate the query box so user can start typing immediately
}

/// <summary>
/// this is a method that will hopefully stop the dinging from the TreeView.<br></br>
/// See https://stackoverflow.com/questions/10328103/c-sharp-winforms-how-to-stop-ding-sound-in-treeview<br></br>
/// e.SuppressKeyPress works for most controls but the TreeView is special
/// </summary>
/// <param name="msg"></param>
/// <param name="keyData"></param>
/// <returns></returns>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter || keyData == Keys.Escape || keyData == Keys.Tab)
return true;
return base.ProcessCmdKey(ref msg, keyData);
}

//private void TreeViewer_KeyUp(object sender, KeyEventArgs e)
//{
// try some weirdness to avoid bell sound from TreeViewer<br></br>
// see https://stackoverflow.com/questions/10328103/c-sharp-winforms-how-to-stop-ding-sound-in-treeview
// BeginInvoke(new Action(() => TreeViewer_KeyUp_Handler(sender, e)));
//}

// largely copied from NppManagedPluginDemo.cs in the original plugin pack
private void TreeViewer_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.Handled = true;
e.SuppressKeyPress = true;
// Ctrl+Enter in query box -> submit query
if (e.Control && QueryBox.Focused)
SubmitQueryButton.PerformClick();
Expand All @@ -106,14 +121,15 @@ private void TreeViewer_KeyUp(object sender, KeyEventArgs e)
else if (e.KeyData == Keys.Escape)
{
Npp.editor.GrabFocus();
e.SuppressKeyPress = true;
}
// Tab -> go through controls, Shift+Tab -> go through controls backward
else if (e.KeyCode == Keys.Tab)
{
Control next = GetNextControl((Control)sender, !e.Shift);
while ((next == null) || (!next.TabStop)) next = GetNextControl(next, !e.Shift);
next.Focus();
e.Handled = true;
e.SuppressKeyPress = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion JsonToolsNppPlugin/Forms/TreeViewer.resx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADC
CgAAAk1TRnQBSQFMAgEBCAEAAfgBAAH4AQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CgAAAk1TRnQBSQFMAgEBCAEAAQgBAQEIAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Expand Down
4 changes: 0 additions & 4 deletions JsonToolsNppPlugin/JSONTools/JsonGrepper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Net;
using System.Text;
using System.Windows.Forms;
using JSON_Tools.Utils;
/*
using System;
using System.Net;
Expand Down
4 changes: 0 additions & 4 deletions JsonToolsNppPlugin/Main.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
// NPP plugin platform for .Net v0.91.57 by Kasper B. Graversen etc.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using Kbg.Demo.Namespace.Properties;
using Kbg.NppPluginNET.PluginInfrastructure;
using JSON_Tools.JSON_Tools;
using JSON_Tools.Utils;
using JSON_Tools.Forms;
using JSON_Tools.Tests;
using static Kbg.NppPluginNET.PluginInfrastructure.Win32;

namespace Kbg.NppPluginNET
{
Expand Down
4 changes: 2 additions & 2 deletions JsonToolsNppPlugin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.6.0")]
[assembly: AssemblyFileVersion("3.6.0")]
[assembly: AssemblyVersion("3.6.1")]
[assembly: AssemblyFileVersion("3.6.1")]
1 change: 0 additions & 1 deletion JsonToolsNppPlugin/Tests/JsonGrepperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO;
using JSON_Tools.JSON_Tools;
using JSON_Tools.Utils;
using Kbg.NppPluginNET.PluginInfrastructure;

namespace JSON_Tools.Tests
{
Expand Down
2 changes: 0 additions & 2 deletions JsonToolsNppPlugin/Tests/JsonParserTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JSON_Tools.JSON_Tools;
using JSON_Tools.Utils;
using Kbg.NppPluginNET.PluginInfrastructure;

namespace JSON_Tools.Tests
{
Expand Down
1 change: 0 additions & 1 deletion JsonToolsNppPlugin/Tests/RemesPathTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using JSON_Tools.JSON_Tools;
Expand Down
1 change: 0 additions & 1 deletion JsonToolsNppPlugin/Tests/SliceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Text;
using JSON_Tools.Utils;
using Kbg.NppPluginNET.PluginInfrastructure;

namespace JSON_Tools.Tests
{
Expand Down
6 changes: 0 additions & 6 deletions JsonToolsNppPlugin/Tests/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ There is also a CLI utility that accepts a letter ('j' or 'y') and a filename as
resultant pretty-printed JSON (if first arg j) or YAML (if first arg y) document (UTF-8 encoded).
Redirecting this output to a text file allows the creation of a new YAML file.
*/
using System;
using System.IO;
using System.Linq;
using System.Text;
using JSON_Tools.Utils;
using JSON_Tools.JSON_Tools;
using Kbg.NppPluginNET.PluginInfrastructure;

namespace JSON_Tools.Tests
{
Expand Down
4 changes: 1 addition & 3 deletions JsonToolsNppPlugin/Tests/YamlDumperTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using JSON_Tools.JSON_Tools;
using JSON_Tools.JSON_Tools;
using JSON_Tools.Utils;
using Kbg.NppPluginNET.PluginInfrastructure;

namespace JSON_Tools.Tests
{
Expand Down
2 changes: 0 additions & 2 deletions JsonToolsNppPlugin/Utils/Misc.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Kbg.NppPluginNET.PluginInfrastructure;
Expand Down
4 changes: 1 addition & 3 deletions JsonToolsNppPlugin/Utils/NanInf.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace JSON_Tools.Utils
namespace JSON_Tools.Utils
{
public class NanInf
{
Expand Down
7 changes: 1 addition & 6 deletions JsonToolsNppPlugin/Utils/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.ComponentModel;
using JSON_Tools.JSON_Tools;
using CsvQuery.PluginInfrastructure; // for SettingsBase

Expand Down
14 changes: 7 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,25 +303,25 @@ __NOTES:__

Sometimes it is useful to work with many JSON files at a time. For this purpose, we created a tool for *grepping* (searching for certain kinds of files in a directory, possibly recursively) for JSON files in a local directory, and also for sending [REST API](https://www.redhat.com/en/topics/api/what-is-a-rest-api) requests to multiple URLs.

We can open this tool with a button in the bottom center.

![Open the JSON grepper/API requester with this button](/docs/json%20viewer%20json_from_files_and_apis%20button.PNG)
We can open this tool with the `Plugins->JsonTools->Get JSON from files and APIs` menu command or `Ctrl+Alt+Shift+G`.

The tool looks like this:

![JSON grepper/API requester appearance](/docs/json_from_files_and_apis%20initial.PNG)

## Sending REST API requests ##

Perhaps the most useful attribute of this tool is its ability to connect to APIs and extract useful data without the user needing to write a script.
Perhaps the most useful attribute of this tool is its ability to connect to APIs and extract useful data without the user needing to write a script. Just enter one URL per line in the box on the left.

**WARNING!!!** Before sending API requests, make sure you understand the correct way to format the URL, what type of JSON you expect to be getting, etc. *This tool has not been tested on private APIs*, so you should expect it to fail unless you can incorporate your API key and other authentication information into the URL.

Here's an example of what you get with successful request(s):

![JSON grepper/API requester successful API requests](/docs/json_from_files_and_apis%20api%20good%20url%20result.PNG)

Of course, sometimes an API request will fail. You can click the `View errors` button to see any errors that happened.
The URLs of successful requests show up in the box on the right. I used the `View results in buffer` button at the bottom of the form to open the buffer and tree view shown here.

Of course, sometimes an API request will fail. You can click the [View errors button](#viewing-errors) to see any errors that happened.

## Getting JSON from local directories ##

Expand All @@ -343,15 +343,15 @@ If you like most of the JSON documents you've found but you don't want to keep *

![JSON grepper/API requester remove selected files button BEFORE removal](/docs/json_from_files_and_apis%20remove%20selected%20files%20BEFORE.PNG)

After you click the button, those JSON documents will be removed.
After you click the button, those JSON documents will be removed, and the buffer and tree view will update to reflect this.

![JSON grepper/API requester remove selected files button AFTER removal](/docs/json_from_files_and_apis%20remove%20selected%20files%20AFTER.PNG)

## Viewing errors ##

Click the `View errors` button to see if any errors happened. If any did, a new buffer will happen with an object mapping from filenames and urls to the associated exception.

ADD IMAGE
![JSON grepper/API requester error report](/docs/json_from_files_and_apis%20error%20report.PNG)

# OTHER FEATURES NOT YET ADDED (COME BACK SOON!) #

Expand Down
Binary file modified docs/json parser settings allow singlequotes and comments.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/json viewer csv generator.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/json viewer query save.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/json viewer with remespath query.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/json_from_files_and_apis api bad url error.PNG
Binary file not shown.
Binary file modified docs/json_from_files_and_apis api good url result.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed docs/json_from_files_and_apis clear all files.PNG
Binary file not shown.
Binary file added docs/json_from_files_and_apis error report.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/json_from_files_and_apis get json in directory.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/json_from_files_and_apis initial.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/json_from_files_and_apis remove selected files AFTER.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed docs/lint form example.PNG
Binary file not shown.
Binary file modified docs/partial tree load example.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/path to current tree node button.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/tree first view.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/tree partially expanded.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified error json after parsing.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified jsontools before after.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified jsontools before after.pptx
Binary file not shown.

0 comments on commit 64fe222

Please sign in to comment.