Skip to content

Commit

Permalink
Switch to 2.0 (#138)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SinghRajenM authored Sep 24, 2022
1 parent 6552601 commit 3bd06eb
Show file tree
Hide file tree
Showing 51 changed files with 3,620 additions and 1,621 deletions.
17 changes: 17 additions & 0 deletions NppJSONViewer/NPPJSONViewer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.3.32804.467
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NPPJSONViewer", "NppJsonViewer\NPPJSONViewer.vcxproj", "{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UtilityLib", "UtilityLib\UtilityLib.vcxproj", "{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Expand All @@ -27,8 +29,23 @@ Global
{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|Win32.Build.0 = Release|Win32
{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.ActiveCfg = Release|x64
{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.Build.0 = Release|x64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|ARM64.ActiveCfg = Debug|ARM64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|ARM64.Build.0 = Debug|ARM64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|Win32.ActiveCfg = Debug|Win32
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|Win32.Build.0 = Debug|Win32
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|x64.ActiveCfg = Debug|x64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Debug|x64.Build.0 = Debug|x64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|ARM64.ActiveCfg = Release|ARM64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|ARM64.Build.0 = Release|ARM64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|Win32.ActiveCfg = Release|Win32
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|Win32.Build.0 = Release|Win32
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|x64.ActiveCfg = Release|x64
{171CAFC6-E679-4B81-BF5B-049AC0FAB4F8}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {66FFEF3A-7122-49C7-8CE4-4704DFB30594}
EndGlobalSection
EndGlobal
118 changes: 118 additions & 0 deletions NppJSONViewer/NppJsonViewer/AboutDlg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include "AboutDlg.h"
#include "resource.h"
#include "Utility.h"
#include "StringHelper.h"
#include "Define.h"
#include <string>
#include <commctrl.h>


AboutDlg::AboutDlg(HINSTANCE hIntance, HWND hParent, int nCmdId) : m_nCmdId(nCmdId), StaticDialog()
{
init(hIntance, hParent);
}


bool AboutDlg::ShowDlg(bool bShow)
{
bool bShouldShow = bShow && !isVisible();
if (bShouldShow)
{
if (!isCreated())
create(IDD_ABOUTDLG);

// Adjust the position of AboutBox
goToCenter();
}
else
{
SendMessage(_hSelf, WM_COMMAND, IDCANCEL, NULL);
}
return bShouldShow;
}


INT_PTR AboutDlg::run_dlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
AboutDlg* pSelf = nullptr;
switch (uMsg)
{
case WM_INITDIALOG:
{
::SetWindowLongPtr(_hSelf, DWLP_USER, lParam);

pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR> (::GetWindowLongPtr(_hSelf, DWLP_USER)));
if (pSelf)
{
pSelf->SetVersion(_hSelf);
}
SetFocus(GetDlgItem(_hSelf, IDOK));

// Set links
std::wstring urlIssue(TEXT("<a href=\"__URL__\">__URL__</a>"));
std::wstring urlRepo = urlIssue;

urlIssue = StringHelper::ReplaceAll(urlIssue, TEXT("__URL__"), URL_REPORT_ISSUE);
urlRepo = StringHelper::ReplaceAll(urlRepo, TEXT("__URL__"), URL_SOURCE_CODE);

SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_ISSUE), urlIssue.c_str());
SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_SOURCE), urlRepo.c_str());

return TRUE;
}

case WM_NOTIFY:
{
switch (reinterpret_cast<LPNMHDR>(lParam)->code)
{
case NM_CLICK:
case NM_RETURN:
{
auto nmLink = reinterpret_cast<PNMLINK>(lParam);
LITEM item = nmLink->item;

ShellExecute(nullptr, L"open", item.szUrl, nullptr, nullptr, SW_SHOW);
return TRUE;
}
}
return FALSE;
}

case WM_COMMAND:
{
pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR> (::GetWindowLongPtr(_hSelf, DWLP_USER)));
switch (LOWORD(wParam))
{
case IDCANCEL: // Close this dialog when clicking to close button
case IDOK:
if (pSelf)
::SendMessage(pSelf->_hParent, NPPM_SETMENUITEMCHECK, static_cast<WPARAM>(pSelf->m_nCmdId), false);
EndDialog(_hSelf, wParam);
_hSelf = nullptr;
return TRUE;
}
}
}
return FALSE;
}

void AboutDlg::SetVersion(HWND hWnd)
{
std::wstring version;

// Get module path
wchar_t moduleFileName[MAX_PATH + 1] = {};
::GetModuleFileName(static_cast<HMODULE>(getHinst()), moduleFileName, _MAX_PATH);

version = CUtility::GetVersion(moduleFileName);
if (!version.empty())
{
std::wstring text(PLUGIN_NAME);
text += TEXT(" (");
text += STR_VERSION;
text += version;
text += TEXT(") ");
::SetWindowText(::GetDlgItem(hWnd, IDC_GB_TITLE), text.c_str());
}
}

20 changes: 20 additions & 0 deletions NppJSONViewer/NppJsonViewer/AboutDlg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "StaticDialog.h"

class AboutDlg :public StaticDialog
{
public:
AboutDlg(HINSTANCE hIntance, HWND hParent, int nCmdId);
~AboutDlg() = default;

bool ShowDlg(bool bShow);

protected:
virtual INT_PTR CALLBACK run_dlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override;

void SetVersion(HWND hWnd);

private:
int m_nCmdId = -1;
};

46 changes: 46 additions & 0 deletions NppJSONViewer/NppJsonViewer/Define.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once
#include "PluginInterface.h"

// Define the number of plugin commands here
enum class CallBackID :int { SHOW_DOC_PANEL = 0, FORMAT, COMPRESS, SEP_1, /*OPTION,*/ ABOUT };
const int nTotalCommandCount = static_cast<int>(CallBackID::ABOUT) + 1;

// Define plugin name here
const TCHAR PLUGIN_NAME[] = TEXT("JSON Viewer");

// Text which can be considered for localization
const TCHAR TITLE_JSON_PANEL[] = TEXT("JSON Viewer Panel");
const TCHAR MENU_SHOW_JSON_PANEL[] = TEXT("Show &JSON Viewer");
const TCHAR MENU_FORMAT_JSON[] = TEXT("&Format JSON");
const TCHAR MENU_COMPRESS_JSON[] = TEXT("&Compress JSON");
const TCHAR MENU_OPTION[] = TEXT("&Option");
const TCHAR MENU_ABOUT[] = TEXT("&About");
const TCHAR MENU_SEPERATOR[] = TEXT("-SEPARATOR-");

const TCHAR TOOLTIP_REFRESH[] = TEXT("Refresh JSON tree");
const TCHAR TOOLTIP_VALIDATE[] = TEXT("Validate JSON to detect any error");
const TCHAR TOOLTIP_FORMAT[] = TEXT("Format JSON to beautify it");
const TCHAR TOOLTIP_SEARCH[] = TEXT("Search in JSON");

const TCHAR URL_SOURCE_CODE[] = TEXT("https://github.com/kapilratnani/JSON-Viewer");
const TCHAR URL_REPORT_ISSUE[] = TEXT("https://github.com/kapilratnani/JSON-Viewer/issues/new");


const TCHAR JSON_ROOT[] = TEXT("JSON");

const TCHAR JSON_ERROR_TITLE[] = TEXT("JSON Viewer: Error");
const TCHAR JSON_WARNING_TITLE[] = TEXT("JSON Viewer: Warning");
const TCHAR JSON_INFO_TITLE[] = TEXT("JSON Viewer: Information");

const TCHAR JSON_ERR_PARSE[] = TEXT("Cannot parse JSON. Please select a JSON String.");
const TCHAR JSON_ERR_VALIDATE[] = TEXT("There was an error while parsing JSON. Refer the current selection for possible problematic area.");
const TCHAR JSON_ERR_VALIDATE_SUCCESS[] = TEXT("JSON looks good. No error found while validating it.");

const TCHAR STR_VERSION[] = TEXT("Version: ");
const TCHAR STR_COPY[] = TEXT("Copy");
const TCHAR STR_COPYNAME[] = TEXT("Copy name");
const TCHAR STR_COPYVALUE[] = TEXT("Copy value");
const TCHAR STR_COPYPATH[] = TEXT("Copy path");
const TCHAR STR_EXPANDALL[] = TEXT("Expand all");
const TCHAR STR_COLLAPSEALL[] = TEXT("Collapse all");

166 changes: 0 additions & 166 deletions NppJSONViewer/NppJsonViewer/Hyperlinks.cpp

This file was deleted.

10 changes: 0 additions & 10 deletions NppJSONViewer/NppJsonViewer/Hyperlinks.h

This file was deleted.

Loading

0 comments on commit 3bd06eb

Please sign in to comment.