Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions NppJSONViewer/JSONDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Delete all items from the tree and creates the root node
HTREEITEM JSONDialog::initTree(HWND hWndDlg)
{

int TreeCount=TreeView_GetCount(GetDlgItem(this->getHSelf(),IDC_TREE1));
int TreeCount=TreeView_GetCount(GetDlgItem(this->getHSelf(),IDC_TREE));
if(TreeCount>0)
TreeView_DeleteAllItems(GetDlgItem(this->getHSelf(),IDC_TREE1));
TreeView_DeleteAllItems(GetDlgItem(this->getHSelf(),IDC_TREE));

TV_INSERTSTRUCT tvinsert;

Expand All @@ -45,7 +45,7 @@ HTREEITEM JSONDialog::initTree(HWND hWndDlg)
tvinsert.item.mask=TVIF_TEXT;

tvinsert.item.pszText=L"JSON";
HTREEITEM item=(HTREEITEM)SendDlgItemMessage(hWndDlg,IDC_TREE1,TVM_INSERTITEM,0,(LPARAM)&tvinsert);
HTREEITEM item=(HTREEITEM)SendDlgItemMessage(hWndDlg,IDC_TREE,TVM_INSERTITEM,0,(LPARAM)&tvinsert);

return item;
}
Expand All @@ -69,7 +69,7 @@ HTREEITEM JSONDialog::insertToTree(HWND hWndDlg,HTREEITEM parent, const char *te
MultiByteToWideChar(CP_UTF8, NULL, text, -1, w_msg, static_cast<int>(len));

tvinsert.item.pszText = w_msg;
item = (HTREEITEM)SendDlgItemMessage(hWndDlg, IDC_TREE1, TVM_INSERTITEM, 0, (LPARAM)&tvinsert);
item = (HTREEITEM)SendDlgItemMessage(hWndDlg, IDC_TREE, TVM_INSERTITEM, 0, (LPARAM)&tvinsert);
delete[] w_msg; // fix memory leak
}

Expand Down Expand Up @@ -346,12 +346,12 @@ void JSONDialog::drawTreeSaxParse()
if (strlen(curJSON) == 0)
{
insertToTree(this->getHSelf(), tree_root, "Error:Please select a JSON String.");
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE1), tree_root, TVE_EXPAND);
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE), tree_root, TVE_EXPAND);
return;
}

populateTreeUsingSax(this->getHSelf(), tree_root, curJSON);
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE1), tree_root, TVE_EXPAND);
TreeView_Expand(GetDlgItem(this->getHSelf(), IDC_TREE), tree_root, TVE_EXPAND);
}


Expand Down Expand Up @@ -431,14 +431,14 @@ INT_PTR CALLBACK JSONDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
switch (message)
{
case WM_INITDIALOG:
hTree=GetDlgItem(this->getHSelf(),IDC_TREE1);// tree control
hTree=GetDlgItem(this->getHSelf(),IDC_TREE);// tree control
drawTreeSaxParse();
return TRUE;

case WM_SIZE:
width=LOWORD(lParam);
height=HIWORD(lParam);
SetWindowPos(GetDlgItem(this->getHSelf(),IDC_TREE1),HWND_TOP,0,0,width,height,SWP_SHOWWINDOW);
SetWindowPos(GetDlgItem(this->getHSelf(),IDC_TREE),HWND_TOP,0,0,width,height,SWP_SHOWWINDOW);
return TRUE;

default :
Expand Down
114 changes: 57 additions & 57 deletions NppJSONViewer/JSONDialog.h
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
/*
This file is part of JSONViewer Plugin for Notepad++
Copyright (C)2011 Kapil Ratnani <kapil.ratnani@iiitb.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include "DockingDlgInterface.h"
#include "PluginInterface.h"
#include <commctrl.h>
#include "resource.h"
#include "json.h"
class JSONDialog : public DockingDlgInterface
{
char *curJSON = nullptr;
HANDLE hTree = nullptr;
//void drawTree();
void drawTreeSaxParse();
HTREEITEM initTree(HWND hWndDlg);
HTREEITEM insertToTree(HWND hWndDlg, HTREEITEM parent, const char *text);
//void populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_root, int level);
void populateTreeUsingSax(HWND hWndDlg, HTREEITEM tree_root, char * json);
public:
JSONDialog() : DockingDlgInterface(IDD_TREE) {};
HTREEITEM insertToTree(HTREEITEM parent, const char *text);
virtual void display(bool toShow = true) const
{
DockingDlgInterface::display(toShow);
}
void setParent(HWND parent2set)
{
_hParent = parent2set;
}
void setJSON(char *json);
protected:
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};
/*
This file is part of JSONViewer Plugin for Notepad++
Copyright (C)2011 Kapil Ratnani <kapil.ratnani@iiitb.net>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#pragma once

#include "DockingDlgInterface.h"
#include "PluginInterface.h"
#include <commctrl.h>
#include "resource.h"
#include "json.h"

class JSONDialog : public DockingDlgInterface
{
char *curJSON = nullptr;
HANDLE hTree = nullptr;
//void drawTree();
void drawTreeSaxParse();
HTREEITEM initTree(HWND hWndDlg);
HTREEITEM insertToTree(HWND hWndDlg, HTREEITEM parent, const char *text);
//void populateTree (HWND hWndDlg, HTREEITEM tree_root, json_t * json_root, int level);
void populateTreeUsingSax(HWND hWndDlg, HTREEITEM tree_root, char * json);
public :
JSONDialog() : DockingDlgInterface(IDD_TREEDLG){};

HTREEITEM insertToTree(HTREEITEM parent, const char *text);

virtual void display(bool toShow = true) const
{
DockingDlgInterface::display(toShow);
}

void setParent(HWND parent2set)
{
_hParent = parent2set;
}

void setJSON(char *json);

protected:
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};
9 changes: 5 additions & 4 deletions NppJSONViewer/NPPJSONViewer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<ImportLibrary>$(TargetName).lib</ImportLibrary>
Expand All @@ -120,7 +120,7 @@
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
Expand All @@ -141,7 +141,7 @@
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
Expand All @@ -165,7 +165,7 @@
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<ImportLibrary>$(TargetName).lib</ImportLibrary>
Expand All @@ -180,6 +180,7 @@
<ClCompile Include="PluginDefinition.cpp" />
<ClCompile Include="TreeBuilder.cpp" />
<ClCompile Include="StaticDialog.cpp" />
<ClCompile Include="utils.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Docking.h" />
Expand Down
3 changes: 3 additions & 0 deletions NppJSONViewer/NPPJSONViewer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<ClCompile Include="TreeBuilder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Docking.h">
Expand Down
14 changes: 14 additions & 0 deletions NppJSONViewer/PluginDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "menuCmdID.h"
#include "JSONDialog.h"
#include "Hyperlinks.h"
#include "utils.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/reader.h"
Expand Down Expand Up @@ -81,11 +82,24 @@ void commandMenuInit()
setCommand(2, TEXT("&About"), openAboutDlg, NULL, false);
}

void setVersion(HWND hwndDlg)
{
std::wstring version;

// Get module path
wchar_t moduleFileName[MAX_PATH + 1] = {};
::GetModuleFileName((HINSTANCE)&__ImageBase, moduleFileName, _MAX_PATH);

version = getVersion(moduleFileName);
::SetWindowText(::GetDlgItem(hwndDlg, IDC_VERSION), version.c_str());
}

INT_PTR CALLBACK abtDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/)
{
switch (uMsg)
{
case WM_INITDIALOG:
setVersion(hwndDlg);
ConvertStaticToHyperlink(hwndDlg, IDC_WEB);
return TRUE;
case WM_COMMAND:
Expand Down
26 changes: 19 additions & 7 deletions NppJSONViewer/resource.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by resource.rc
//
#define IDD_TREEDLG 101
#define IDD_ABOUTDLG 102
#define IDC_TREE 1001
#define IDC_WEB 1002
#define IDC_VERSION 1003

#define IDD_TREE 101
#define IDD_ABOUTDLG 103
#define IDC_TREE1 1002
#define IDC_WEB 1002
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Loading