Skip to content

Commit 3bd06eb

Browse files
authored
Switch to 2.0 (#138)
* Preparing for v2.0 * Show context menu using handling right click * Removed commented code * 1. Disable few controls which are not yet implemented 2. Added callback for compress * Make json viewer working as before * Rename class `JsonTreeViewDlg` to `JsonViewDlg` * Make compress function working * Fix x64 compilation error * Added context menu functionality * Implement node path * Minor code reformatting * Handle tree view item changed event * Implement validate functionality * Implement format functionality * Fix x64 compilation * Capture pdbs too * Check artifacts * Remove unused files * Correct version as 2.0 * Minor correction * Disable "option" temporarily * Minor error message correction * Capture symbols * Fix codacy issue
1 parent 6552601 commit 3bd06eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3620
-1621
lines changed

NppJSONViewer/NPPJSONViewer.sln

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.3.32804.467
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NPPJSONViewer", "NppJsonViewer\NPPJSONViewer.vcxproj", "{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}"
77
EndProject
8+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UtilityLib", "UtilityLib\UtilityLib.vcxproj", "{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|ARM64 = Debug|ARM64
@@ -27,8 +29,23 @@ Global
2729
{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|Win32.Build.0 = Release|Win32
2830
{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.ActiveCfg = Release|x64
2931
{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.Build.0 = Release|x64
32+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|ARM64.ActiveCfg = Debug|ARM64
33+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|ARM64.Build.0 = Debug|ARM64
34+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|Win32.ActiveCfg = Debug|Win32
35+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|Win32.Build.0 = Debug|Win32
36+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|x64.ActiveCfg = Debug|x64
37+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|x64.Build.0 = Debug|x64
38+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|ARM64.ActiveCfg = Release|ARM64
39+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|ARM64.Build.0 = Release|ARM64
40+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|Win32.ActiveCfg = Release|Win32
41+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|Win32.Build.0 = Release|Win32
42+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|x64.ActiveCfg = Release|x64
43+
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|x64.Build.0 = Release|x64
3044
EndGlobalSection
3145
GlobalSection(SolutionProperties) = preSolution
3246
HideSolutionNode = FALSE
3347
EndGlobalSection
48+
GlobalSection(ExtensibilityGlobals) = postSolution
49+
SolutionGuid = {66FFEF3A-7122-49C7-8CE4-4704DFB30594}
50+
EndGlobalSection
3451
EndGlobal
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#include "AboutDlg.h"
2+
#include "resource.h"
3+
#include "Utility.h"
4+
#include "StringHelper.h"
5+
#include "Define.h"
6+
#include <string>
7+
#include <commctrl.h>
8+
9+
10+
AboutDlg::AboutDlg(HINSTANCE hIntance, HWND hParent, int nCmdId) : m_nCmdId(nCmdId), StaticDialog()
11+
{
12+
init(hIntance, hParent);
13+
}
14+
15+
16+
bool AboutDlg::ShowDlg(bool bShow)
17+
{
18+
bool bShouldShow = bShow && !isVisible();
19+
if (bShouldShow)
20+
{
21+
if (!isCreated())
22+
create(IDD_ABOUTDLG);
23+
24+
// Adjust the position of AboutBox
25+
goToCenter();
26+
}
27+
else
28+
{
29+
SendMessage(_hSelf, WM_COMMAND, IDCANCEL, NULL);
30+
}
31+
return bShouldShow;
32+
}
33+
34+
35+
INT_PTR AboutDlg::run_dlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
36+
{
37+
AboutDlg* pSelf = nullptr;
38+
switch (uMsg)
39+
{
40+
case WM_INITDIALOG:
41+
{
42+
::SetWindowLongPtr(_hSelf, DWLP_USER, lParam);
43+
44+
pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR> (::GetWindowLongPtr(_hSelf, DWLP_USER)));
45+
if (pSelf)
46+
{
47+
pSelf->SetVersion(_hSelf);
48+
}
49+
SetFocus(GetDlgItem(_hSelf, IDOK));
50+
51+
// Set links
52+
std::wstring urlIssue(TEXT("<a href=\"__URL__\">__URL__</a>"));
53+
std::wstring urlRepo = urlIssue;
54+
55+
urlIssue = StringHelper::ReplaceAll(urlIssue, TEXT("__URL__"), URL_REPORT_ISSUE);
56+
urlRepo = StringHelper::ReplaceAll(urlRepo, TEXT("__URL__"), URL_SOURCE_CODE);
57+
58+
SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_ISSUE), urlIssue.c_str());
59+
SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_SOURCE), urlRepo.c_str());
60+
61+
return TRUE;
62+
}
63+
64+
case WM_NOTIFY:
65+
{
66+
switch (reinterpret_cast<LPNMHDR>(lParam)->code)
67+
{
68+
case NM_CLICK:
69+
case NM_RETURN:
70+
{
71+
auto nmLink = reinterpret_cast<PNMLINK>(lParam);
72+
LITEM item = nmLink->item;
73+
74+
ShellExecute(nullptr, L"open", item.szUrl, nullptr, nullptr, SW_SHOW);
75+
return TRUE;
76+
}
77+
}
78+
return FALSE;
79+
}
80+
81+
case WM_COMMAND:
82+
{
83+
pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR> (::GetWindowLongPtr(_hSelf, DWLP_USER)));
84+
switch (LOWORD(wParam))
85+
{
86+
case IDCANCEL: // Close this dialog when clicking to close button
87+
case IDOK:
88+
if (pSelf)
89+
::SendMessage(pSelf->_hParent, NPPM_SETMENUITEMCHECK, static_cast<WPARAM>(pSelf->m_nCmdId), false);
90+
EndDialog(_hSelf, wParam);
91+
_hSelf = nullptr;
92+
return TRUE;
93+
}
94+
}
95+
}
96+
return FALSE;
97+
}
98+
99+
void AboutDlg::SetVersion(HWND hWnd)
100+
{
101+
std::wstring version;
102+
103+
// Get module path
104+
wchar_t moduleFileName[MAX_PATH + 1] = {};
105+
::GetModuleFileName(static_cast<HMODULE>(getHinst()), moduleFileName, _MAX_PATH);
106+
107+
version = CUtility::GetVersion(moduleFileName);
108+
if (!version.empty())
109+
{
110+
std::wstring text(PLUGIN_NAME);
111+
text += TEXT(" (");
112+
text += STR_VERSION;
113+
text += version;
114+
text += TEXT(") ");
115+
::SetWindowText(::GetDlgItem(hWnd, IDC_GB_TITLE), text.c_str());
116+
}
117+
}
118+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
#include "StaticDialog.h"
3+
4+
class AboutDlg :public StaticDialog
5+
{
6+
public:
7+
AboutDlg(HINSTANCE hIntance, HWND hParent, int nCmdId);
8+
~AboutDlg() = default;
9+
10+
bool ShowDlg(bool bShow);
11+
12+
protected:
13+
virtual INT_PTR CALLBACK run_dlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
14+
15+
void SetVersion(HWND hWnd);
16+
17+
private:
18+
int m_nCmdId = -1;
19+
};
20+

NppJSONViewer/NppJsonViewer/Define.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
#include "PluginInterface.h"
3+
4+
// Define the number of plugin commands here
5+
enum class CallBackID :int { SHOW_DOC_PANEL = 0, FORMAT, COMPRESS, SEP_1, /*OPTION,*/ ABOUT };
6+
const int nTotalCommandCount = static_cast<int>(CallBackID::ABOUT) + 1;
7+
8+
// Define plugin name here
9+
const TCHAR PLUGIN_NAME[] = TEXT("JSON Viewer");
10+
11+
// Text which can be considered for localization
12+
const TCHAR TITLE_JSON_PANEL[] = TEXT("JSON Viewer Panel");
13+
const TCHAR MENU_SHOW_JSON_PANEL[] = TEXT("Show &JSON Viewer");
14+
const TCHAR MENU_FORMAT_JSON[] = TEXT("&Format JSON");
15+
const TCHAR MENU_COMPRESS_JSON[] = TEXT("&Compress JSON");
16+
const TCHAR MENU_OPTION[] = TEXT("&Option");
17+
const TCHAR MENU_ABOUT[] = TEXT("&About");
18+
const TCHAR MENU_SEPERATOR[] = TEXT("-SEPARATOR-");
19+
20+
const TCHAR TOOLTIP_REFRESH[] = TEXT("Refresh JSON tree");
21+
const TCHAR TOOLTIP_VALIDATE[] = TEXT("Validate JSON to detect any error");
22+
const TCHAR TOOLTIP_FORMAT[] = TEXT("Format JSON to beautify it");
23+
const TCHAR TOOLTIP_SEARCH[] = TEXT("Search in JSON");
24+
25+
const TCHAR URL_SOURCE_CODE[] = TEXT("https://github.com/kapilratnani/JSON-Viewer");
26+
const TCHAR URL_REPORT_ISSUE[] = TEXT("https://github.com/kapilratnani/JSON-Viewer/issues/new");
27+
28+
29+
const TCHAR JSON_ROOT[] = TEXT("JSON");
30+
31+
const TCHAR JSON_ERROR_TITLE[] = TEXT("JSON Viewer: Error");
32+
const TCHAR JSON_WARNING_TITLE[] = TEXT("JSON Viewer: Warning");
33+
const TCHAR JSON_INFO_TITLE[] = TEXT("JSON Viewer: Information");
34+
35+
const TCHAR JSON_ERR_PARSE[] = TEXT("Cannot parse JSON. Please select a JSON String.");
36+
const TCHAR JSON_ERR_VALIDATE[] = TEXT("There was an error while parsing JSON. Refer the current selection for possible problematic area.");
37+
const TCHAR JSON_ERR_VALIDATE_SUCCESS[] = TEXT("JSON looks good. No error found while validating it.");
38+
39+
const TCHAR STR_VERSION[] = TEXT("Version: ");
40+
const TCHAR STR_COPY[] = TEXT("Copy");
41+
const TCHAR STR_COPYNAME[] = TEXT("Copy name");
42+
const TCHAR STR_COPYVALUE[] = TEXT("Copy value");
43+
const TCHAR STR_COPYPATH[] = TEXT("Copy path");
44+
const TCHAR STR_EXPANDALL[] = TEXT("Expand all");
45+
const TCHAR STR_COLLAPSEALL[] = TEXT("Collapse all");
46+

NppJSONViewer/NppJsonViewer/Hyperlinks.cpp

Lines changed: 0 additions & 166 deletions
This file was deleted.

NppJSONViewer/NppJsonViewer/Hyperlinks.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)