20#include "../compositions/grouppanel.hpp"
21#include "../globals.hpp"
22#include "../../kernel/core/ui/language.hpp"
23#include "../../kernel/core/ui/winlayout.hpp"
24#include "../../kernel/core/utils/tools.hpp"
25#include "../../kernel/core/utils/tinyxml2.h"
26#include "../../kernel/core/procedure/dependency.hpp"
27#include "../../kernel/core/procedure/includer.hpp"
28#include "../../kernel/core/io/styledtextfile.hpp"
29#include "../../common/vcsmanager.hpp"
30#include "../../common/filerevisions.hpp"
31#include "../../common/datastructures.h"
36#define INCLUDEDOCS "_doctemplate"
37#define DOCFILE "_docfile"
65 m_packageProperties =
nullptr;
67 m_terminal = terminal;
69 m_isAutoIncrement =
false;
71 wxBoxSizer* vsizer =
new wxBoxSizer(wxVERTICAL);
74 GroupPanel* panel =
new GroupPanel(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxBORDER_STATIC);
81 m_packageProperties =
new wxPropertyGrid(group->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize(-1, 260*
g_pixelScale), wxPG_THEME_BORDER | wxPG_TOOLTIPS | wxPG_SPLITTER_AUTO_CENTER);
82 m_packageProperties->Append(
new wxPropertyCategory(
_guilang.
get(
"GUI_PKGDLG_GENERAL_CATEGORY")));
83 m_packageProperties->Append(
new wxStringProperty(
_guilang.
get(
"GUI_PKGDLG_PACKAGENAME"),
"-name"));
84 m_packageProperties->Append(
new wxStringProperty(
_guilang.
get(
"GUI_PKGDLG_AUTHOR"),
"-author"));
85 m_packageProperties->Append(
new wxStringProperty(
_guilang.
get(
"GUI_PKGDLG_VERSION"),
"-version",
"<AUTO>"));
88 flags.Add(
"ENABLE_DEFAULTS");
89 flags.Add(
"ENABLE_FULL_LOGGING");
90 flags.Add(
"DISABLE_SCREEN_OUTPUT");
91 m_packageProperties->Append(
new wxEnumProperty(
_guilang.
get(
"GUI_PKGDLG_FLAGS"),
"-flags", flags));
94 type.Add(
"TYPE_PACKAGE");
95 type.Add(
"TYPE_PLUGIN");
96 type.Add(
"TYPE_PLUGIN_WITH_RETURN_VALUE");
97 type.Add(
"TYPE_GUI_PLUGIN");
98 m_packageProperties->Append(
new wxEnumProperty(
_guilang.
get(
"GUI_PKGDLG_TYPE"),
"-type", type));
101 wxArrayString license;
102 license.Add(
"Apache-2.0");
103 license.Add(
"BSD-2-Clause");
104 license.Add(
"BSD-3-Clause");
105 license.Add(
"CC-BY-4.0");
106 license.Add(
"CC-BY-ND-4.0");
107 license.Add(
"CC-BY-SA-4.0");
108 license.Add(
"CC-BY-SA-ND-4.0");
109 license.Add(
"EPL-2.0");
110 license.Add(
"GPL-2.0-only");
111 license.Add(
"GPL-2.0-or-later");
112 license.Add(
"GPL-3.0-only");
113 license.Add(
"GPL-3.0-or-later");
114 license.Add(
"LGPL-2.0-only");
115 license.Add(
"LGPL-2.0-or-later");
116 license.Add(
"LGPL-3.0-only");
117 license.Add(
"LGPL-3.0-or-later");
119 license.Add(
"MPL-2.0");
120 m_packageProperties->Append(
new wxEditEnumProperty(
_guilang.
get(
"GUI_PKGDLG_LICENSE"),
"-license", license, wxArrayInt(), license[0]));
121 m_packageProperties->Append(
new wxLongStringProperty(
_guilang.
get(
"GUI_PKGDLG_PLUGINDESC"),
"-desc"));
122 m_packageProperties->Append(
new wxLongStringProperty(
_guilang.
get(
"GUI_PKGDLG_KEYWORDS"),
"-keywords"));
123 m_packageProperties->Append(
new wxLongStringProperty(
_guilang.
get(
"GUI_PKGDLG_CHANGESLOG"),
"-changelog"));
124 m_packageProperties->Append(
new wxStringProperty(
_guilang.
get(
"GUI_PKGDLG_DEPENDENCIES"),
"-requirepackages"));
128 wxPGProperty* pluginsCategory = m_packageProperties->Append(
new wxPropertyCategory(
_guilang.
get(
"GUI_PKGDLG_PLUGIN_CATEGORY")));
129 m_packageProperties->Append(
new wxStringProperty(
_guilang.
get(
"GUI_PKGDLG_PLUGINCOMMAND"),
"-plugincommand"));
130 m_packageProperties->SetPropertyValidator(
"-plugincommand", wxTextValidator(wxFILTER_ALPHANUMERIC));
131 m_packageProperties->Append(
new wxStringProperty(
_guilang.
get(
"GUI_PKGDLG_PLUGINMENUENTRY"),
"-pluginmenuentry"));
132 m_packageProperties->SetPropertyValidator(
"-pluginmenuentry", wxTextValidator(wxFILTER_ASCII));
134 m_packageProperties->Append(
new wxStringProperty(
_guilang.
get(
"GUI_PKGDLG_PLUGINMAIN"),
"-pluginmain"));
136 wxPGProperty* docsCategory = m_packageProperties->Append(
new wxPropertyCategory(
_guilang.
get(
"GUI_PKGDLG_DOCS_CATEGORY")));
137 m_packageProperties->Append(
new wxBoolProperty(
_guilang.
get(
"GUI_PKGDLG_INCLUDEDOCUMENTATION"),
INCLUDEDOCS));
138 wxFileProperty* docfile =
new wxFileProperty(
_guilang.
get(
"GUI_PKGDLG_DOCUMENTATION"),
DOCFILE);
139 docfile->SetAttribute(wxPG_FILE_DIALOG_STYLE, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
140 docfile->SetAttribute(wxPG_FILE_WILDCARD,
"Doc files (*.xml,*.nhlp)|*.xml;*.nhlp|Text files (*.txt)|*.txt|All files (*.*)|*.*");
141 docfile->SetAttribute(wxPG_FILE_DIALOG_TITLE,
_guilang.
get(
"GUI_DLG_OPEN"));
142 m_packageProperties->Append(docfile);
145 m_packageProperties->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX,
true);
146 m_packageProperties->SetValidationFailureBehavior(wxPG_VFB_MARK_CELL | wxPG_VFB_STAY_IN_PROPERTY);
149 m_packageProperties->Collapse(wxPGPropArg(pluginsCategory));
150 m_packageProperties->Collapse(wxPGPropArg(docsCategory));
152 group->Add(m_packageProperties, 1, wxEXPAND | wxALL, 5);
158 wxBoxSizer* buttonSizer = panel->
createGroup(wxHORIZONTAL, group);
168 m_fileList->SetImageList(icons->GetImageList(), wxIMAGE_LIST_SMALL);
171 wxBoxSizer* projectButtonSizer = panel->
createGroup(wxHORIZONTAL);
180 panel->SetScrollbars(0, 20, 0, 200);
183 vsizer->Add(panel, 1, wxEXPAND, 0);
205 EndModal(wxID_CANCEL);
224 _guilang.
get(
"GUI_FILTER_INSTALLABLES") +
" (*.nprc, *.nlyt)|*.nprc;*.nlyt|"
225 +
_guilang.
get(
"COMMON_FILETYPE_NPRC") +
" (*.nprc)|*.nprc|"
226 +
_guilang.
get(
"COMMON_FILETYPE_NLYT") +
" (*.nlyt)|*.nlyt|"
227 +
_guilang.
get(
"COMMON_FILETYPE_NSCR") +
" (*.nscr)|*.nscr",
230 if (dlg.ShowModal() == wxID_OK)
237 for (
size_t i = 0; i < files.size(); i++)
241 wxString sExt = files[i].substr(files[i].rfind(
'.'));
261 long selected =
m_fileList->GetFirstSelected();
286 int res = wxMessageBox(
_guilang.
get(
"GUI_UNSAVEDFILE_CLOSE"),
_guilang.
get(
"GUI_SAVE_QUESTION"), wxYES_NO);
292 if (dialog.ShowModal() == wxID_OK)
299 if (dialog.ShowModal() == wxID_OK)
316 if (dialog.ShowModal() == wxID_OK)
348 EndModal(wxID_CANCEL);
363 SetTitle(GetTitle().insert(GetTitle().find(
"[")+1,
"*"));
365 event.GetProperty()->SetTextColour(*wxRED);
396 int res = wxMessageBox(
_guilang.
get(
"GUI_UNSAVEDFILE_CLOSE"),
_guilang.
get(
"GUI_SAVE_QUESTION"), wxYES_NO);
402 if (dialog.ShowModal() == wxID_OK)
420 std::vector<std::string> vIncludes;
422 for (
auto iter = fileSet.begin(); iter != fileSet.end(); ++iter)
426 sSearchPath.erase(sSearchPath.find_last_of(
"/\\"));
438 for (
const auto& incl : vIncludes)
439 fileSet.insert(incl);
456 std::set<std::string> fileSet;
460 for (
size_t i = 0; i < mainfiles.size(); i++)
462 if (mainfiles[i].substr(0, 4) ==
"(!) ")
465 if (mainfiles[i].rfind(
".nlyt") == std::string::npos)
474 for (
auto iter = fileSet.begin(); iter != fileSet.end(); ++iter)
476 if (
m_fileList->FindItem(-1, *iter,
false) == -1)
478 std::string sExt = (*iter).substr((*iter).rfind(
'.'));
500 fileSet.insert(sFile);
512 for (
auto listiter = iter->second.begin(); listiter != iter->second.end(); ++listiter)
514 if (fileSet.find(listiter->getFileName()) == fileSet.end())
538 for (
size_t i = 0; i < vProcs.size(); i++)
540 if (fileSet.find(vProcs[i]) == fileSet.end())
559 bool allFilesFound =
true;
563 if (!root || !root->
Attribute(
"version.npkp",
"1"))
578 wxPGProperty* prop = *iter;
579 prop->SetTextColour(*wxBLACK);
582 if (!infoitem || !infoitem->
GetText())
585 if (prop->GetName() ==
"-version")
590 prop->SetTextColour(*wxRED);
597 allFilesFound =
false;
601 prop->SetValueFromString(infoitem->
GetText());
613 allFilesFound =
false;
619 std::string sExt = file->
GetText();
620 sExt = sExt.substr(sExt.rfind(
'.'));
630 wxFileName fname(filename);
631 SetTitle(
_guilang.
get(
"GUI_PKGDLG_HEAD") +
" [" + fname.GetFullName() +
"]");
637 wxMessageBox(
_guilang.
get(
"GUI_PKGDLG_NOTALLFILESFOUND"),
_guilang.
get(
"GUI_PKGDLG_NOTALLFILESFOUND_HEAD"), wxOK,
this);
652 std::unique_ptr<FileRevisions> revisions(manager.
getRevisions(filename));
657 if (!revisions->getRevisionCount() && wxFileExists(filename))
659 wxFile tempfile(filename);
661 tempfile.ReadAll(&contents);
662 revisions->addRevision(contents);
682 wxPGProperty* prop = *iter;
683 prop->SetTextColour(*wxBLACK);
686 if (prop->GetName() ==
"-version" && (prop->GetValueAsString() ==
"<AUTO>" ||
m_isAutoIncrement))
688 if (prop->GetValueAsString() ==
"<AUTO>")
691 infoitem->
SetText(prop->GetValueAsString().ToStdString().c_str());
696 infoitem->
SetText(prop->GetValueAsString().ToStdString().c_str());
704 for (
int i = 0; i <
m_fileList->GetItemCount(); i++)
707 std::string sFile =
m_fileList->GetItemText(i).ToStdString();
709 if (sFile.substr(0, 4) ==
"(!) ")
722 if (wxFileExists(filename))
724 wxFile tempfile(filename);
726 tempfile.ReadAll(&contents);
727 revisions->addRevision(contents);
731 wxFileName fname(filename);
734 SetTitle(
_guilang.
get(
"GUI_PKGDLG_HEAD") +
" [" + fname.GetFullName() +
"]");
747 SetTitle(GetTitle().insert(GetTitle().find(
"[")+1,
"*"));
760 return GetTitle().find(
"[*") == std::string::npos;
776 if (mainfile.rfind(
".nlyt") == std::string::npos)
796 wxArrayString stringArray;
798 for (
int i = 0; i <
m_fileList->GetItemCount(); i++)
817 wxString installInfo =
"\t<info>\r\n";
826 wxPGProperty* prop = *iter;
829 if (prop->GetName() ==
"-type" || prop->GetName() ==
"-flags")
831 installInfo +=
"\t\t" + prop->GetName() +
"=" + prop->GetValueAsString() +
"\r\n";
834 else if ((prop->GetName().substr(0, 7) ==
"-plugin" && (!isplugin || !prop->GetValueAsString().length())) || prop->GetName()[0] !=
'-')
836 else if (prop->GetName() ==
"-name")
841 else if (prop->GetName() ==
"-version" && prop->GetValueAsString() ==
"<AUTO>")
843 installInfo +=
"\t\t-version=\"0.0.1\"\r\n";
846 else if (prop->GetName() ==
"-requirepackages" && !prop->GetValueAsString().length())
850 wxString value = prop->GetValueAsString();
851 value.Replace(
"\"",
"\\\"");
852 installInfo +=
"\t\t" + prop->GetName() +
"=\"" + value +
"\"\r\n";
857 installInfo +=
"\t\t-requireversion=\"" +
sVersion.substr(0,
sVersion.find(
' ')) +
"\"\r\n";
858 installInfo +=
"\t<endinfo>\r\n";
899 for (
size_t i = 0; i < identifier.length(); i++)
901 if (!isalnum(identifier[i]) && identifier[i] !=
'_')
906 return "plgn_" + identifier;
908 return "pkg_" + identifier;
963 return m_packageProperties->GetPropertyByName(
"-type")->GetValueAsString().find(
"PLUGIN") != std::string::npos;
const std::string sVersion
std::string toLowerCase(const std::string &)
Converts uppercase to lowercase letters.
This class handles the dependencies of the current procedure file (passed as pointer to a ProcedureEl...
std::map< std::string, DependencyList > & getDependencyMap()
This class simplifies the creation of simple windows and creates a common layout among all windows.
wxListView * CreateListView(wxWindow *parent, wxSizer *sizer, int nStyle=wxLC_REPORT, wxSize size=wxDefaultSize, int id=wxID_ANY)
This member function creates the layout for a listview control.
wxStaticBoxSizer * createGroup(const wxString &sGroupName, int orient=wxVERTICAL, wxWindow *parent=nullptr, wxSizer *sizer=nullptr, int expand=0)
Member function to create a group (a static box with a label) in the panel.
wxButton * CreateButton(wxWindow *parent, wxSizer *sizer, const wxString &description, int id=wxID_ANY, int alignment=wxALIGN_CENTER_VERTICAL)
This member function creates the layout for a button.
int GetIconIndex(wxString iconInfo)
This class represents a file, which can be included into other files using the @ syntax.
std::string getIncludedFileName() const
Returns the embedded file name.
static bool is_including_syntax(const std::string &sLine)
Static member function which determines, whether the passed line is actually a including syntax.
This class handles the internal language system and returns the language strings of the selected lang...
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
ProcedureLibrary & getProcedureLibrary()
The terminal class for the GUI. It's a specialisation of the GenericTerminal.
NumeReKernel & getKernel()
std::vector< std::string > getPathSettings()
Returns the standard paths as a STL vector.
This class is the actual NumeRe main frame. The application's logic is implemented here.
This class represents a dialog for creating a package from a set of procedures.
wxArrayString getProcedures()
This member function will create a string array containing the procedure files, which are currently p...
void loadProjectFile(const wxString &filename)
Loads a NumeRe package project file to memory and updates the UI correspondingly.
void OnRemoveItems(wxCommandEvent &event)
This is the event handler for the remove files button.
void OnClose(wxCloseEvent &event)
Event handler, which is called, when the user closes the dialog.
void OnAutoDetect(wxCommandEvent &event)
This is the event handler for the autodetect button.
void saveProjectFile(const wxString &filename)
Saves a prepared package configuration as a NumeRe package project file to the HDD.
wxPropertyGrid * m_packageProperties
wxString getPackageIdentifier()
This member function returns the package identifier, which is constructed from the name and only cont...
void setMainFile(const wxString &mainfile)
This function can be used to insert the current mainfile to the dialog. Used by the main window,...
wxString getInstallInfo()
This member function will create the install information section of the package based upon the setted...
bool includeDocs()
This member function returns whether the user selected the "include docs" property.
void autoDetect(const wxArrayString &mainfiles)
This function autodetects the dependencies of the passed files by calling the PackageDialog::followBr...
void OnLoadProjectFile(wxCommandEvent &event)
Button event handler to load an existing project file.
void findLayoutDependencies(const std::string &sFile, std::set< std::string > &fileSet)
This member function uses the event procedures of a window layout file to create a dependency tree fo...
void OnCreatePackage(wxCommandEvent &event)
Called upon clicking on "Create package" button. Will ask for saving the project.
void OnAddItems(wxCommandEvent &event)
This is the event handler for the add files button.
void OnAbort(wxCommandEvent &event)
Called upon clicking on "Cancel" button. Will ask for saving the project.
NumeReTerminal * m_terminal
void followBranch(const std::string &sFile, std::set< std::string > &fileSet)
This function will recursively call itself to detect a whole branch of file dependencies.
void markUnsaved()
Marks the current project as modified.
wxString getPackageName()
This member function returns the name of the package, as been set by the user.
void OnPropGridChange(wxPropertyGridEvent &event)
Event handler for all property grid changes.
bool isSaved()
Returns true, if the current project is in a saved state.
void SaveOnClose()
Evaluates, whether the current project has been saved and prompt the user a saving dialog,...
void OnSaveProjectFile(wxCommandEvent &event)
Button event handler to save a prepared package setting to a project file.
wxString getPackageVersion()
Returns the version of the defined package as a simple string.
bool isPlugin()
This member function returns, whether the user selected a plugin type as install type.
wxString getDocFile()
Returns the user-chosen documentation file.
Dependencies * getDependencies()
This member function returns the first-level dependencies of the current procedure file....
This class manages all already read and possibly pre-parsed procedure files for easier and faster acc...
ProcedureElement * getProcedureContents(const std::string &sProcedureFileName)
Returns the ProcedureElement pointer to the desired procedure file. It also creates the element,...
This class represents a text file in memory (e.g. a code file). This class will try to lex the loaded...
std::string getStrippedLine(size_t line) const
Returns the selected line (without the line termination characters and without any comments).
int getLinesCount() const
Returns the number of lines in the current loaded file.
std::string getFileName() const
Returns the filename of the respresented file in memory.
FileRevisions * getRevisions(const wxString ¤tFile)
This method returns the file revisions as pointer.
XMLError LoadFile(const char *filename)
XMLElement * NewElement(const char *name)
XMLError SaveFile(const char *filename, bool compact=false)
const char * GetText() const
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
void SetText(const char *inText)
const char * Attribute(const char *name, const char *value=0) const
bool BoolAttribute(const char *name, bool defaultValue=false) const
See IntAttribute()
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
const XMLElement * FirstChildElement(const char *name=0) const
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLNode * InsertEndChild(XMLNode *addThis)
@ ID_PKGDLG_CREATEPACKAGE
std::string replacePathSeparator(const std::string &)
This function replaces the Windows style path sparators to UNIX style.
bool fileExists(const string &)
This function checks, whether the file with the passed file name exists.
std::string get(const std::string &sUrl, const std::string &sUserName, const std::string &sPassWord)
Get the contents of a URL.
static void resolveIncludes(std::set< std::string > &fileSet)
Static function to resolve the includes in the passed set and add them to the set afterwards.
std::vector< std::string > getEventProcedures(const std::string &sLayoutFile)
Examines a window layout file and searches for all event handler procedures. Returns their correspond...