Skip to content

Commit

Permalink
When creating new project of type 'wxCrafter' prompt the user if the …
Browse files Browse the repository at this point in the history
…plugin is not installed

Added patch to wxPG editors.cpp file
Make sure that plugins menu is sorted by the plugin name

git-svn-id: https://codelite.svn.sourceforge.net/svnroot/codelite/trunk@5985 9da81c78-c036-0410-9e1f-a2b0375e4b5a
  • Loading branch information
eranif committed Dec 6, 2012
1 parent 0d8a9cb commit 72b6f99
Show file tree
Hide file tree
Showing 12 changed files with 3,461 additions and 776 deletions.
4 changes: 2 additions & 2 deletions LiteEditor.workspace
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<Project Name="CallGraph" Path="CallGraph/CallGraph.project" Active="No"/>
<Project Name="Outline" Path="Outline/Outline.project" Active="No"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Win Release Unicode" Selected="yes">
<WorkspaceConfiguration Name="Win Release Unicode" Selected="no">
<Project Name="abbreviation" ConfigName="WinReleaseUnicode"/>
<Project Name="CallGraph" ConfigName="WinReleaseUnicode"/>
<Project Name="CodeFormatter" ConfigName="WinReleaseUnicode"/>
Expand Down Expand Up @@ -99,7 +99,7 @@
<Project Name="wxsqlite3" ConfigName="WinDebugUnicode"/>
<Project Name="Outline" ConfigName="WinDebugUnicode"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Unix_Custom_Makefile" Selected="no">
<WorkspaceConfiguration Name="Unix_Custom_Makefile" Selected="yes">
<Project Name="wxsqlite3" ConfigName="WinDebugUnicode"/>
<Project Name="wxshapeframework" ConfigName="DebugUnicode"/>
<Project Name="wxFormBuilder" ConfigName="WinDebugUnicode"/>
Expand Down
10 changes: 6 additions & 4 deletions LiteEditor/LiteEditor.project
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@
<File Name="workspacesettingsdlg.cpp"/>
<File Name="code_completion_page.h"/>
<File Name="code_completion_page.cpp"/>
<File Name="wxcDownloadDlg.h"/>
<File Name="wxcDownloadDlg.cpp"/>
</VirtualDirectory>
<VirtualDirectory Name="Plugins">
<File Name="pluginmgrdlg.h"/>
Expand Down Expand Up @@ -973,7 +975,7 @@ $(WorkspacePath)/sdk/clang/include</SearchPaths>
<Library Value="libsqlite3.a"/>
</Linker>
<ResourceCompiler Options="$(shell wx-config --rcflags)" Required="no"/>
<General OutputFile="../Runtime/codelite" IntermediateDirectory="./ReleaseUnicode" Command="/home/eran/root/bin/codelite" CommandArguments="" UseSeparateDebugArgs="yes" DebugArguments="" WorkingDirectory="" PauseExecWhenProcTerminates="no"/>
<General OutputFile="../Runtime/codelite" IntermediateDirectory="./ReleaseUnicode" Command="/home/eran/root/bin/codelite" CommandArguments="" UseSeparateDebugArgs="yes" DebugArguments="--no-plugins" WorkingDirectory="" PauseExecWhenProcTerminates="no"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="wxWidgets-29">
<![CDATA[SUDO_ASKPASS=/usr/bin/ssh-askpass
LD_LIBRARY_PATH=/home/eran/root/lib/codelite/]]>
Expand Down Expand Up @@ -1004,7 +1006,8 @@ LD_LIBRARY_PATH=/home/eran/root/lib/codelite/]]>
<CustomPostBuild/>
<CustomPreBuild>resources.cpp
resources.cpp: resources.xrc
wxrc -c -v -o resources.cpp resources.xrc</CustomPreBuild>
wxrc -c -v -o resources.cpp resources.xrc
</CustomPreBuild>
</AdditionalRules>
<Completion EnableCpp11="no">
<ClangCmpFlagsC/>
Expand Down Expand Up @@ -1120,8 +1123,7 @@ resources.cpp: resources.xrc
wxrc /c /v /o resources.cpp resources.xrc

svninfo.cpp:
autorev .
</CustomPreBuild>
autorev .</CustomPreBuild>
</AdditionalRules>
<Completion EnableCpp11="no">
<ClangCmpFlagsC/>
Expand Down
19 changes: 17 additions & 2 deletions LiteEditor/newprojectdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "dirtraverser.h"
#include <wx/imaglist.h>
#include <set>
#include "pluginmanager.h"
#include "wxcDownloadDlg.h"

class NewProjectClientData : public wxClientData
{
Expand Down Expand Up @@ -182,7 +184,7 @@ void NewProjectDlg::OnCreate(wxCommandEvent &event)
// dont check the return
Mkdir(fn.GetPath());
}

wxString projectName = m_txtProjName->GetValue();
projectName.Trim().Trim(false);
if(projectName.find_first_not_of(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")) != wxString::npos) {
Expand Down Expand Up @@ -226,7 +228,20 @@ void NewProjectDlg::OnCreate(wxCommandEvent &event)
m_projectData.m_name = m_txtProjName->GetValue();
m_projectData.m_path = fn.GetPath();
m_projectData.m_cmpType = m_chCompiler->GetStringSelection();


if ( m_projectData.m_srcProject ) {
if ( m_projectData.m_srcProject->GetName().Contains("wxCrafter") ) {
// Check that wxCrafter plugin is installed
if ( !PluginManager::Get()->GetPlugin("wxCrafter") ) {
// wxCrafter plugin is not installed, prompt the user
wxcDownloadDlg dlg(wxTheApp->GetTopWindow());
dlg.ShowModal();

// We always continue to project creation
}
}
}

EndModal(wxID_OK);
}

Expand Down
5 changes: 4 additions & 1 deletion LiteEditor/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ void PluginManager::Load()
//get list of dlls
wxArrayString files;
wxDir::GetAllFiles( pluginsDir, &files, fileSpec, wxDIR_FILES );


// Sort the plugins by A-Z
std::sort(files.begin(), files.end());

for ( size_t i=0; i<files.GetCount(); i++ ) {
clDynamicLibrary *dl = new clDynamicLibrary();
wxString fileName( files.Item( i ) );
Expand Down
22 changes: 22 additions & 0 deletions LiteEditor/wxcDownloadDlg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "wxcDownloadDlg.h"
#include <wx/utils.h>

wxcDownloadDlg::wxcDownloadDlg(wxWindow* parent)
: wxcDownloadDlgBaseClass(parent)
{
m_cmdLnkBtnDownload->SetDefault();
}

wxcDownloadDlg::~wxcDownloadDlg()
{
}
void wxcDownloadDlg::OnDownloadWxCrafterPlugin(wxCommandEvent& event)
{
::wxLaunchDefaultBrowser("http://wxcrafter.codelite.org");
this->EndModal(wxID_OK);
}

void wxcDownloadDlg::OnIgnoreTheError(wxCommandEvent& event)
{
this->EndModal(wxID_OK);
}
14 changes: 14 additions & 0 deletions LiteEditor/wxcDownloadDlg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef WXCDOWNLOADDLG_H
#define WXCDOWNLOADDLG_H
#include "wxcrafter.h"

class wxcDownloadDlg : public wxcDownloadDlgBaseClass
{
public:
wxcDownloadDlg(wxWindow* parent);
virtual ~wxcDownloadDlg();
protected:
virtual void OnDownloadWxCrafterPlugin(wxCommandEvent& event);
virtual void OnIgnoreTheError(wxCommandEvent& event);
};
#endif // WXCDOWNLOADDLG_H
55 changes: 55 additions & 0 deletions LiteEditor/wxcrafter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,58 @@ NewProjImgList::NewProjImgList()
NewProjImgList::~NewProjImgList()
{
}

wxcDownloadDlgBaseClass::wxcDownloadDlgBaseClass(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxDialog(parent, id, title, pos, size, style)
{
if ( !bBitmapLoaded ) {
// We need to initialise the default bitmap handler
wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler);
wxC3F25InitBitmapResources();
bBitmapLoaded = true;
}

wxBoxSizer* boxSizer71 = new wxBoxSizer(wxVERTICAL);
this->SetSizer(boxSizer71);

m_banner76 = new wxBannerWindow(this, wxID_ANY, wxTOP, wxDefaultPosition, wxSize(-1,-1), wxBORDER_SIMPLE);
m_banner76->SetBitmap(wxNullBitmap);
m_banner76->SetText(_("Plugin is not installed"), _("It seems that the wxCrafter plugin is not installed\nWhat would you like to do?"));
m_banner76->SetGradient(wxColour(wxT("rgb(80,80,80)")), wxColour(wxT("rgb(80,80,80)")));
m_banner76->SetForegroundColour(wxColour(wxT("rgb(255,255,255)")));

boxSizer71->Add(m_banner76, 0, wxALL|wxEXPAND, 5);

m_panel75 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL);

boxSizer71->Add(m_panel75, 1, wxALL|wxEXPAND, 5);

wxBoxSizer* boxSizer79 = new wxBoxSizer(wxVERTICAL);
m_panel75->SetSizer(boxSizer79);

m_cmdLnkBtnDownload = new wxCommandLinkButton(m_panel75, wxID_ANY, _("Download wxCrafter"), _("Download wxCrafter plugin from codelite's website"), wxDefaultPosition, wxSize(-1,-1), 0);

boxSizer79->Add(m_cmdLnkBtnDownload, 0, wxALL|wxEXPAND, 5);

m_cmdLnkBtnContinue = new wxCommandLinkButton(m_panel75, wxID_ANY, _("Create the project"), _("Ignore the missing plugin and create the project anyway"), wxDefaultPosition, wxSize(-1,-1), 0);

boxSizer79->Add(m_cmdLnkBtnContinue, 0, wxALL|wxEXPAND, 5);


SetSizeHints(-1,-1);
if ( GetSizer() ) {
GetSizer()->Fit(this);
}
Centre(wxBOTH);
// Connect events
m_cmdLnkBtnDownload->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxcDownloadDlgBaseClass::OnDownloadWxCrafterPlugin), NULL, this);
m_cmdLnkBtnContinue->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxcDownloadDlgBaseClass::OnIgnoreTheError), NULL, this);

}

wxcDownloadDlgBaseClass::~wxcDownloadDlgBaseClass()
{
m_cmdLnkBtnDownload->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxcDownloadDlgBaseClass::OnDownloadWxCrafterPlugin), NULL, this);
m_cmdLnkBtnContinue->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxcDownloadDlgBaseClass::OnIgnoreTheError), NULL, this);

}
22 changes: 21 additions & 1 deletion LiteEditor/wxcrafter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <wx/imaglist.h>
#include <wx/bitmap.h>
#include <map>
#include <wx/bannerwindow.h>
#include <wx/commandlinkbutton.h>

class NewProjectDlgBaseClass : public wxDialog
{
Expand Down Expand Up @@ -80,7 +82,7 @@ class NavBarControlBaseClass : public wxPanel
virtual void OnFuncListMouseDown(wxMouseEvent& event) { event.Skip(); }

public:
NavBarControlBaseClass(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1,-1), long style = wxTAB_TRAVERSAL);
NavBarControlBaseClass(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1,-1), long style = wxWANTS_CHARS|wxTAB_TRAVERSAL|wxTRANSPARENT_WINDOW);
virtual ~NavBarControlBaseClass();
};

Expand Down Expand Up @@ -126,4 +128,22 @@ class NewProjImgList : public wxImageList
virtual ~NewProjImgList();
};


class wxcDownloadDlgBaseClass : public wxDialog
{
protected:
wxBannerWindow* m_banner76;
wxPanel* m_panel75;
wxCommandLinkButton* m_cmdLnkBtnDownload;
wxCommandLinkButton* m_cmdLnkBtnContinue;

protected:
virtual void OnDownloadWxCrafterPlugin(wxCommandEvent& event) { event.Skip(); }
virtual void OnIgnoreTheError(wxCommandEvent& event) { event.Skip(); }

public:
wxcDownloadDlgBaseClass(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plugin is missing"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(-1,-1), long style = wxDEFAULT_DIALOG_STYLE);
virtual ~wxcDownloadDlgBaseClass();
};

#endif
Loading

0 comments on commit 72b6f99

Please sign in to comment.