]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
#3213 bbGEditor Feature New Normal - vtk8itk4wx3-mingw64 MACOS
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------  
24 */
25
26 /*=========================================================================
27  Program:   bbtk
28  Module:    $RCSfile$
29  Language:  C++
30  Date:      $Date$
31  Version:   $Revision$
32  =========================================================================*/
33
34 /* ---------------------------------------------------------------------
35
36  * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37  * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
38  *
39  *  This software is governed by the CeCILL-B license under French law and
40  *  abiding by the rules of distribution of free software. You can  use,
41  *  modify and/ or redistribute the software under the terms of the CeCILL-B
42  *  license as circulated by CEA, CNRS and INRIA at the following URL
43  *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44  *  or in the file LICENSE.txt.
45  *
46  *  As a counterpart to the access to the source code and  rights to copy,
47  *  modify and redistribute granted by the license, users are provided only
48  *  with a limited warranty  and the software's author,  the holder of the
49  *  economic rights,  and the successive licensors  have only  limited
50  *  liability.
51  *
52  *  The fact that you are presently reading this means that you have had
53  *  knowledge of the CeCILL-B license and that you accept its terms.
54  * ------------------------------------------------------------------------ */
55
56 /**
57  *  \file
58  *  \brief Class bbtk::WxInterfaceEditorGraphicBBS .
59  */
60
61 #include "bbtkwxGUIEditorGraphicBBS.h"
62 #include "creaWx.h"
63 #include "creaSystem.h"
64 //must go #include "bbtkUtilities.h"
65 //must go #include "bbtkConfigurationFile.h"
66 #include <wx/defs.h>
67
68 #include <InterpreterBBS.h>
69
70 namespace bbtk {
71
72 //=========================================================================
73 wxGUIEditorGraphicBBS::wxGUIEditorGraphicBBS(wxFrame *parent) 
74         : wxFrame( parent, -1, _T("bbtkGEditor"), wxDefaultPosition, wxSize(1200,800) ) 
75 {
76         _pkgBrowser = NULL;
77         _frameAUIMgr = new wxAuiManager(this);
78
79         /*std::string datadir( crea::System::GetExecutablePath() );
80          std::string datadir (".");
81          cout<<"RaC //------------------"<<endl;
82          cout<<"RaC //TODO wxGUIEditorGraphicBBS constructor.Initialize datadir with  crea::System::GetExecutablePath() ."<<endl;
83          cout<<"RaC //------------------"<<endl;
84
85          #ifdef LINUX // assume this is OSX
86          datadir=datadir+"/../share/creaContours";
87          #endif // MACOSX
88
89          #ifdef MACOSX // assume this is OSX
90          datadir=datadir+"/../../../../share/creaContours";
91          #endif // MACOSX
92
93          _dataDir = datadir;*/
94
95         initMenu();
96         initToolbar();
97         initPackageBrowser();
98         initTabPanelsManager();
99         // JGGR & CM  initHelpHTMLBrowser();
100         _helpHtmlBrowser = NULL;
101         CreateStatusBar();
102         _frameAUIMgr->Update();
103         _actualPkgBrowserBoxName = "";
104         _actualPkgBrowserPkgName = "";
105         refreshGUIControls();
106
107         /////////////////////////////////
108         /// IMPORTANT!! FOR SAVE&LOAD PROCESSES THE VERSION IS VERY IMPORTANT.
109         /// RaC 2012 2nd Hackfest
110         _currentBBGversion="1.4";
111 }
112
113 //=========================================================================
114 wxGUIEditorGraphicBBS::~wxGUIEditorGraphicBBS() 
115 {
116         //EED02JUIN2010         delete _tabsMgr;
117         _frameAUIMgr->UnInit();
118         // FCY memory leaks
119         delete _frameAUIMgr;
120         delete _notebook;
121         delete _tabsMgr;
122 }
123
124 //=========================================================================
125 void wxGUIEditorGraphicBBS::initToolbar() 
126 {
127         wxBitmap bmp_new(new_xpm);
128         wxBitmap bmp_open(open_xpm);
129         wxBitmap bmp_save(save_xpm);
130         wxBitmap bmp_run(run_xpm);
131         wxBitmap bmp_delete(delete_xpm);
132         wxBitmap bmp_centerview(centerview_xpm);
133         wxBitmap bmp_box(box_xpm);
134         wxBitmap bmp_executablebox(executablebox_xpm);
135         wxBitmap bmp_complexbox(complexbox_xpm);
136         wxBitmap bmp_complexinputport(complexinputport_xpm);
137         wxBitmap bmp_complexoutputport(complexoutputport_xpm);
138         wxBitmap bmp_undo(undo_xpm);
139         wxBitmap bmp_redo(redo_xpm);
140         wxBitmap bmp_editProperties(editProperties_xpm);
141         wxBitmap bmp_showTree(showTree_xpm);
142         
143 //      wxToolBar *toolbar = new wxToolBar(this, wxID_ANY);
144         wxToolBar *toolbar =    CreateToolBar();
145
146         //Adds a tool btn to the toolbar
147         toolbar->AddTool(ID_NEW, _T("New"), bmp_new, wxNullBitmap, wxITEM_NORMAL,
148                         _T("New tab"), _T("Create a new panel tab"));
149
150         toolbar->AddTool(ID_OPEN, _T("Open diagram"), bmp_open, wxNullBitmap,
151                         wxITEM_NORMAL, _T("Open a diagram"), _T("Open a diagram"));
152
153         toolbar->AddTool(ID_SAVE_DIAGRAM, _T("Save Diagram"), bmp_save,
154                         wxNullBitmap, wxITEM_NORMAL, _T("Saves the current diagram"),
155                         _T("Saves the current diagram")); //DFCH
156         //toolbar->AddTool(ID_SAVE_AS_DIAGRAM,_T("Save Diagram As"),bmp_save, wxNullBitmap, wxITEM_NORMAL,_T("Saves the current diagram"), _T("Saves the current diagram")); //DFCH
157         toolbar->AddTool(ID_RUN, _T("Run"), bmp_run, wxNullBitmap, wxITEM_NORMAL,
158                         _T("Execute actual diagram"), _T("Execute actual diagram"));
159         toolbar->AddTool(ID_DELETEALL, _T("Delete all"), bmp_delete, wxNullBitmap,
160                         wxITEM_NORMAL, _T("Delete all boxes"), _T("Delete all boxes"));
161         toolbar->AddTool(ID_CENTERVIEW, _T("Center view"), bmp_centerview,
162                         wxNullBitmap, wxITEM_NORMAL, _T("Center view"), _T("Center view"));
163         toolbar->AddSeparator();
164         toolbar->AddTool(ID_BTNBOX, _T("New Box"), bmp_box, wxNullBitmap,
165                         wxITEM_NORMAL, _T("New Box"), _T("Nex Box"));
166         toolbar->AddSeparator();
167         toolbar->AddTool(ID_BTEXECUTABLEBOX, _T("Select as executable Box"),
168                         bmp_executablebox, wxNullBitmap, wxITEM_NORMAL,
169                         _T("Select as executable Box"), _T("Select as executable Box"));
170         toolbar->AddSeparator();
171         toolbar->AddTool(ID_BTNCOMPLEXBOX, _T("Complex box"), complexbox_xpm,
172                         wxNullBitmap, wxITEM_NORMAL, _T("Complex box"), _T("Complex box"));
173
174 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
175 #if wxMAJOR_VERSION <= 2
176         toolbar->SetToggle(ID_BTNCOMPLEXBOX, true);
177 #else
178         printf ("EED Warnning. wxGUIEditorGraphicBBS::initToolbar       >>>   toolbar->SetToggle  \n ");
179         // ..
180 #endif
181
182         // RaC 2012 2nd HackFest - Now Complex inputs are any external input
183         //              toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add input to Complex box"),
184         //              bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL,
185         //              _T("Add input to Complex box"), _T("Add input to Complex box"));
186         toolbar->AddTool(ID_ADDCOMPLEXBOXINPUT, _T("Add external input (Complex box or console app)"),
187                         bmp_complexinputport, wxNullBitmap, wxITEM_NORMAL,
188                         _T("Add external input (Complex box or console app)"), _T("Add external input (Complex box or console app)"));
189
190         toolbar->AddTool(ID_ADDCOMPLEXBOXOUTPUT, _T("Add output to Complex box"),
191                         bmp_complexoutputport, wxNullBitmap, wxITEM_NORMAL,
192                         _T("Add output Complex box"), _T("Add output Complex box"));
193
194         // toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); RaC2012 2nd HackFest
195         toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true);
196
197         toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false);
198         toolbar->AddSeparator();
199         toolbar->AddTool(ID_UNDO, _T("Undo"),bmp_undo, wxNullBitmap, wxITEM_NORMAL,     _T("Undo"), _T("Undo"));
200         toolbar->AddTool(ID_REDO, _T("Redo"),bmp_redo, wxNullBitmap, wxITEM_NORMAL,     _T("Redo"), _T("Redo"));
201         toolbar->AddSeparator();
202         toolbar->AddTool(ID_EDITPROPERTIES, _T("Edit diagram properties"),bmp_editProperties, wxNullBitmap, wxITEM_NORMAL,      _T("Edit diagram properties"), _T("Edit diagram properties"));
203         toolbar->EnableTool(ID_EDITPROPERTIES, false);
204
205         toolbar->AddTool(ID_SHOWTREE, _T("Show tree"),bmp_showTree, wxNullBitmap, wxITEM_NORMAL,        _T("Show tree"), _T("Show tree"));
206
207         
208         toolbar->EnableTool(ID_UNDO, false);
209         toolbar->EnableTool(ID_REDO, false);
210         toolbar->SetMargins(2, 2);
211         toolbar->Realize();
212         SetToolBar(toolbar);
213
214
215         
216         // connect command event handlers
217
218         Connect(ID_NEW, wxEVT_COMMAND_TOOL_CLICKED,
219                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
220         Connect(ID_OPEN, wxEVT_COMMAND_TOOL_CLICKED,
221                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenDiagram));
222         Connect(ID_SAVE_DIAGRAM, wxEVT_COMMAND_TOOL_CLICKED,
223                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
224         Connect(ID_SAVE_AS_DIAGRAM, wxEVT_COMMAND_TOOL_CLICKED,
225                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram)); //DFCH
226         Connect(
227                         ID_RUN,
228                         wxEVT_COMMAND_TOOL_CLICKED,
229                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExecuteActualDiagram));
230         Connect(
231                         ID_DELETEALL,
232                         wxEVT_COMMAND_TOOL_CLICKED,
233                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram));
234         Connect(
235                         ID_CENTERVIEW,
236                         wxEVT_COMMAND_TOOL_CLICKED,
237                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCenterViewActualDiagram));
238         Connect(ID_BTNBOX, wxEVT_COMMAND_TOOL_CLICKED,
239                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnBox));
240         Connect(
241                         ID_BTEXECUTABLEBOX,
242                         wxEVT_COMMAND_TOOL_CLICKED,
243                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnExecutableBox));
244         Connect(ID_BTNCOMPLEXBOX, wxEVT_COMMAND_TOOL_CLICKED,
245                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnClickBtnComplexBox));
246         Connect(ID_ADDCOMPLEXBOXINPUT, wxEVT_COMMAND_TOOL_CLICKED,
247                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxInput));
248         Connect(ID_ADDCOMPLEXBOXOUTPUT, wxEVT_COMMAND_TOOL_CLICKED,
249                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnAddComplexBoxOutput));
250         Connect(ID_UNDO,wxEVT_COMMAND_TOOL_CLICKED,     wxCommandEventHandler(wxGUIEditorGraphicBBS::OnUndo));
251         Connect(ID_REDO,wxEVT_COMMAND_TOOL_CLICKED,     wxCommandEventHandler(wxGUIEditorGraphicBBS::OnRedo));
252         Connect(ID_CHANGENAME, wxEVT_COMMAND_RIGHT_CLICK, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnChangeName));
253         Connect(ID_EDITPROPERTIES,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditDiagramProperties));
254         Connect(ID_SHOWTREE,wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(wxGUIEditorGraphicBBS::OnShowTree));
255
256
257 }
258 //=========================================================================
259 void wxGUIEditorGraphicBBS::initHelpHTMLBrowser() {
260         // JGRR & CM 
261         _helpHtmlBrowser = new WxGUIHtmlBrowser(this, wxSize(200, 0));
262    
263         // EO JGRR & CM 
264         
265 }
266
267 //=========================================================================
268 void wxGUIEditorGraphicBBS::initMenu() {
269         // Create File menu and its items
270         wxMenu *fileMenu = new wxMenu();
271         fileMenu->Append(ID_NEW, _T("New diagram"), _T("New"));
272         fileMenu->Append(ID_SAVE_DIAGRAM, _T("Save Diagram"), _T("Save Diagram")); //DFCH
273         fileMenu->Append(ID_SAVE_AS_DIAGRAM, _T("Save Diagram As"),
274                         _T("Save Diagram As")); //DFCH
275         fileMenu->Append(ID_OPEN_BBS, _T("Open BBS"), _T("Open BBS"));
276         // CM
277         fileMenu->Append(ID_OPEN, _T("Open a diagram"), _T("Open a diagram"));
278         fileMenu->Append(ID_SAVE_AS_BBS, _T("Save BBS"), _T("Save BBS"));
279         fileMenu->Append(ID_SAVE_AS_COMPLEXBOX, _T("Save complex box"),
280                         _T("Save complex box"));
281         fileMenu->Append(ID_EXPORT_CONSOLEAPP, _T("Export console commands"),
282                                 _T("Export console execution commands"));
283         fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
284
285         Connect(ID_NEW, wxEVT_COMMAND_MENU_SELECTED,
286                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateNewTab));
287         Connect(ID_SAVE_DIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
288                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualDiagram)); //DFCH
289         Connect(ID_SAVE_AS_DIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
290                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveAsActualDiagram));
291         Connect(ID_OPEN_BBS, wxEVT_COMMAND_MENU_SELECTED,
292                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnOpenBBS));
293         Connect(ID_SAVE_AS_BBS, wxEVT_COMMAND_MENU_SELECTED,
294                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualBBS));
295         Connect( ID_SAVE_AS_COMPLEXBOX, wxEVT_COMMAND_MENU_SELECTED,
296                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnSaveActualComplexBox));
297         Connect( ID_EXPORT_CONSOLEAPP, wxEVT_COMMAND_MENU_SELECTED,
298                                 wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExportConsoleExecCommand));
299         Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
300                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
301
302         // Create Edit menu and its items
303         wxMenu *editMenu = new wxMenu;
304         editMenu->Append(ID_COPY_TO_COMPLEXDIAGRAM, _T("Copy selected to complex box"), _T("Creates a new complex box diagram with selected boxes"));
305         editMenu->Append(ID_EDIT_COMPLEXBOX_SCRIPT, _T("Edit Complex Box"), _T("Edit Complex Box"));
306         Connect( ID_COPY_TO_COMPLEXDIAGRAM, wxEVT_COMMAND_MENU_SELECTED,
307                          wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram));
308         Connect( ID_EDIT_COMPLEXBOX_SCRIPT, wxEVT_COMMAND_MENU_SELECTED,
309                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditComplexBoxScript));
310
311         // Create Help menu and its items
312         wxMenu *helpMenu = new wxMenu;
313         helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
314         helpMenu->Append(ID_HELP_BBEDITOR, _T("&Help..."), _T("Help"));
315         Connect(ID_HELP_BBEDITOR, wxEVT_COMMAND_MENU_SELECTED,
316                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnHelpBBeditor));
317
318         // Create Tool menu
319         wxMenu *menuTools = new wxMenu;
320         menuTools->Append(ID_bbEditor_Tool_Menu_CreatePackage,
321                         _T("Create &package") );
322         menuTools->Append(ID_bbEditor_Tool_Menu_CreateBlackBox,
323                         _T("Create &blackbox") );
324         menuTools->Append(ID_bbEditor_Tool_Menu_PlugPackage, _T("Plug package") );
325         menuTools->Append(ID_bbEditor_Tool_Menu_EditConfig, _T("&Edit bbtk config") );
326         menuTools->Append(ID_bbEditor_Tool_Menu_ShowHTMLDoc,
327                         _T("Show &HTML documentation") );
328         menuTools->Append(ID_bbEditor_Tool_Menu_CreateIndex, _T("&Generate index") );
329
330         Connect(ID_bbEditor_Tool_Menu_CreatePackage, wxEVT_COMMAND_MENU_SELECTED,
331                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreatePackage));
332         Connect(ID_bbEditor_Tool_Menu_CreateBlackBox, wxEVT_COMMAND_MENU_SELECTED,
333                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateBlackBox));
334         Connect(ID_bbEditor_Tool_Menu_PlugPackage, wxEVT_COMMAND_MENU_SELECTED,
335                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnPlugPackage));
336         Connect(ID_bbEditor_Tool_Menu_EditConfig, wxEVT_COMMAND_MENU_SELECTED,
337                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnEditConfig));
338         Connect(ID_bbEditor_Tool_Menu_ShowHTMLDoc, wxEVT_COMMAND_MENU_SELECTED,
339                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnShowHTMLDoc));
340         Connect(ID_bbEditor_Tool_Menu_CreateIndex, wxEVT_COMMAND_MENU_SELECTED,
341                         wxCommandEventHandler(wxGUIEditorGraphicBBS::OnCreateIndex));
342
343         // Append the created menu to the menu bar
344         wxMenuBar *menuBar = new wxMenuBar();
345         menuBar->Append(fileMenu, _T("&File") );
346         menuBar->Append(editMenu, _T("&Edit") );
347         menuBar->Append(menuTools, _T("&Tool") );
348         menuBar->Append(helpMenu, _T("&Help") );
349
350         // Attach this menu bar to the frame
351         SetMenuBar(menuBar);
352 }
353
354 //=========================================================================
355 void wxGUIEditorGraphicBBS::initTabPanelsManager() 
356 {
357         _notebook = new wxAuiNotebook(this, wxID_NOTEBOOK, wxDefaultPosition,
358                         wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_MOVE
359                                         | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | wxAUI_NB_TAB_FIXED_WIDTH
360                                         | wxAUI_NB_WINDOWLIST_BUTTON);
361         _tabsMgr = new wxTabPanelsManager(this);
362         _frameAUIMgr->AddPane(_notebook, wxAuiPaneInfo().CenterPane());
363 }
364
365 //=========================================================================
366 void wxGUIEditorGraphicBBS::initPackageBrowser() 
367 {
368         _pkgBrowser = new WxGUIPackageBrowser2(this);
369         _pkgBrowser->IncludeAll();
370         _frameAUIMgr->AddPane(_pkgBrowser, wxAuiPaneInfo().Left().MinSize(30, 500).BestSize(750,500).CloseButton(false));
371 }
372
373 //================================================================
374
375 void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc(const std::string& pack) 
376 {
377         std::string mess("Regenerating doc for package '");
378         if (pack != "-a") {
379                 mess += pack + "'";
380         } else {
381                 mess = "Regenerating doc for all packages";
382         }
383
384         mess += " ... please wait";
385
386         SetStatusText(std2wx(mess));
387
388         //BBTK_BUSY_CURSOR;
389
390         std::string command;
391 #if defined(WIN32)
392         command = "\"";
393 #endif
394         command += ConfigurationFile::GetInstance().Get_bin_path();
395         command += ConfigurationFile::GetInstance().Get_file_separator();
396         command += "bbRegeneratePackageDoc";
397 #if defined(WIN32)
398         command += "\"";
399 #endif
400
401         command += " " + pack + " -q";
402         bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
403
404         if (!system(command.c_str())) {
405                 SetStatusText(_T("Done !"));
406                 /*
407                  wxMessageBox(_T("Done !"),_T("Regenerate package '")
408                  +std2wx(pack)+_T("' doc"),
409                  wxOK | wxICON_INFORMATION);
410                  */
411         } else {
412                 SetStatusText(_T("Done !"));
413                 wxString err(_T("An error occured while running '"));
414                 err += bbtk::std2wx(command) + _T("'");
415                 wxMessageBox(err, _T("Regenerate package doc"), wxOK | wxICON_ERROR);
416         }
417 }
418
419 //================================================================
420 void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists() {
421         SetStatusText(_T("Regenerating boxes lists ... please wait"));
422         //BBTK_BUSY_CURSOR ;
423
424         std::string command;
425 #if defined(WIN32)
426         command = "\"";
427 #endif
428         command += ConfigurationFile::GetInstance().Get_bin_path();
429         command += ConfigurationFile::GetInstance().Get_file_separator();
430         command += "bbRegenerateBoxesLists";
431
432 #if defined(WIN32)
433         command += "\"";
434 #endif
435         command += " -q";
436
437         bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
438
439         if (!system(command.c_str())) {
440                 SetStatusText(_T("Done !"));
441                 /*
442                  wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
443                  wxOK | wxICON_INFORMATION);
444                  */
445         } else {
446                 SetStatusText(_T("Done !"));
447                 wxString err(_T("An error occured while running '"));
448                 err += bbtk::std2wx(command) + _T("'");
449                 wxMessageBox(err, _T("Regenerate boxes lists"), wxOK | wxICON_ERROR);
450         }
451 }
452
453 //================================================================
454 void wxGUIEditorGraphicBBS::RegenerateAll() {
455         DoRegeneratePackageDoc("-a");
456         DoRegenerateBoxesLists();
457 }
458
459 //================================================================
460
461 wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook() {
462         return _notebook;
463 }
464
465 //================================================================
466
467 void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName) 
468 {
469         if (_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName) 
470         {
471
472                 _actualPkgBrowserPkgName = packageName;
473                 _actualPkgBrowserBoxName = boxName;
474
475 //EED 15 oct 2012               BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
476                 
477                 Package::Pointer k;
478 //EED           ComplexBlackBoxDescriptor::Pointer descriptor;
479                 BlackBoxDescriptor::Pointer descriptor;
480
481                 std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
482                 k                       = _pkgBrowser->GetFactory()->GetPackage(_actualPkgBrowserPkgName);
483                 mapDesc         = k->GetDescriptorMap();                
484                 descriptor      = mapDesc[_actualPkgBrowserBoxName];
485 /*
486                 tree.treeTour(0);               
487
488                 tree.deleteTree();
489
490                 descriptor->GetBoxesInside(tree, 0);
491
492                 //tree.treeTour(0);
493                 //std::vector<std::string> boxesDiagram = _sceneM->boxesDiagram;
494                 //for(int i=0;i<boxesDiagram.size();i++){
495                 //      std::cout<<"caja: "<<boxesDiagram[i]<<std::endl;
496                 //}             
497                 
498                 _actualPkgBrowserPkgName = "";
499                 _actualPkgBrowserBoxName = "";
500 */
501                 /*
502                 Package::Pointer k;
503                 BlackBoxDescriptor::Pointer descriptor;
504                 std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
505                 k                       = _pkgBrowser->GetFactory()->GetPackage(packageName);
506                 std::vector<std::string> temp;
507                 _pkgBrowser->GetFactory()->GetPackagesList(temp);
508                 for(int ii = 0 ; ii < temp.size() ; ii++)
509                 {
510                                 std::cout << " packs "<< temp[ii]<< std::endl;
511                 }
512                 mapDesc         = k->GetDescriptorMap();                
513                 descriptor      = mapDesc[boxName];
514                 */
515                 _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
516         }
517 }
518
519 //=========================================================================
520
521 void wxGUIEditorGraphicBBS::editBlackBox(GBlackBoxModel *bbmodel) {
522         wxBlackBoxEditionDialog* dialog =
523                         new wxBlackBoxEditionDialog(this, bbmodel);
524         dialog->Show();
525 }
526
527 //=========================================================================
528
529 bool wxGUIEditorGraphicBBS::boxNameExists(std::string boxname) {
530  
531         return this->_tabsMgr->getActualTabPanel()->getSceneManager()->boxExist(boxname);
532 }
533
534 //=========================================================================
535
536 void wxGUIEditorGraphicBBS::updateStatusBar(std::string textStatus) {
537         SetStatusText(crea::std2wx(textStatus));
538 }
539
540 //=========================================================================
541
542 void wxGUIEditorGraphicBBS::executeScript(std::string script) {
543         std::string separator =
544                         ConfigurationFile::GetInstance().Get_file_separator();
545         std::string dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
546         std::string filename = dir + separator + "tmp_bbtk.bbs";
547
548         ofstream tempFile;
549         tempFile.open(filename.c_str());
550         tempFile << script;
551         tempFile.close();
552
553         std::string command = "";
554
555 #ifdef WIN32
556         command += "start /b ";
557 #endif
558
559         //              command += "\""+ crea::System::GetExecutablePath();
560         //#ifdef MACOSX
561         //              command += separator + "../../../bbi.app/Contents/MacOS";
562         //#endif
563
564         command += "bbi ";
565         command += "\"" + filename + "\"";
566
567 #ifndef WIN32
568         command += " & ";
569 #endif
570
571         printf("RaC wxGUIEditorGraphicBBS::executeScript %s \n", command.c_str());
572         system(command.c_str());
573 }
574
575 //=========================================================================
576 std::string wxGUIEditorGraphicBBS::CheckExtension(std::string filename, std::string extension) {
577         if(filename.size() > extension.size() ){
578                 if( (filename.compare(filename.size()-extension.size(), extension.size(),extension)) !=0 ){
579                         filename.append(extension);
580                 }
581         }else{
582                 filename.append(extension);
583         }
584         return filename;
585 }
586 //=========================================================================
587 // EVENT HANDLERS
588 //=========================================================================
589
590 void wxGUIEditorGraphicBBS::OnCreateNewTab(wxCommandEvent& event) {
591         _tabsMgr->addNewTab();
592         refreshGUIControls();
593 }
594
595 void wxGUIEditorGraphicBBS::OnUndo(wxCommandEvent& event) {
596         unsigned short disable;
597         std::string stundo;
598         std::string stredo;
599
600         _tabsMgr->loadTempDiagram(0);
601         disable = _tabsMgr->getUndoState(stundo);
602         if(disable == 0)
603         {
604                 std::string name = _tabsMgr->GetNameTabPanel();
605                 if(name[name.length() - 1] == '*')
606                 {
607                         name =name.substr(0,name.length()-1);
608                 }
609                 _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
610         }
611
612         GetToolBar()->EnableTool(ID_UNDO,disable);
613         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
614         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
615         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
616         refreshGUIControls();
617 }
618
619 //=========================================================================
620
621 void wxGUIEditorGraphicBBS::OnRedo(wxCommandEvent& event) {
622         unsigned short disable;
623         std::string stundo;
624         std::string stredo;
625
626         _tabsMgr->loadTempDiagram(1);
627         std::string name = _tabsMgr->GetNameTabPanel();
628         if(name[name.length() - 1] != '*')
629                 name +="*";
630         _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
631         GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
632         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
633         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
634         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
635         refreshGUIControls();
636 }
637
638 void wxGUIEditorGraphicBBS::OnChangeName(wxCommandEvent& event){
639 }
640 //=========================================================================
641
642 void wxGUIEditorGraphicBBS::OnShowTree(wxCommandEvent& event){
643                 std::cout <<  "wxGUIEditorGraphicBBS::OnShowTree"<<std::endl;
644 if (_actualPkgBrowserPkgName !="" || _actualPkgBrowserBoxName != "") 
645         {
646                 Package::Pointer k;
647 //EED           ComplexBlackBoxDescriptor::Pointer descriptor;
648                 BlackBoxDescriptor::Pointer descriptor;
649
650                 std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
651                 k                       = _pkgBrowser->GetFactory()->GetPackage(_actualPkgBrowserPkgName);
652                 mapDesc         = k->GetDescriptorMap();                
653                 descriptor      = mapDesc[_actualPkgBrowserBoxName];
654
655                 tree.treeTour(0);               
656
657                 tree.deleteTree();
658
659                 descriptor->GetBoxesInside(tree, 0);
660                 
661                 _actualPkgBrowserPkgName = "";
662                 _actualPkgBrowserBoxName = "";
663         }
664 else
665         {
666                 std::cout<<"Select a Box"<<std::endl;
667         }
668 }
669
670 //=========================================================================
671
672 void wxGUIEditorGraphicBBS::OnEditDiagramProperties(wxCommandEvent& event)
673 {
674         wxDiagramPropertiesEditionDialog* dialog =
675                                 new wxDiagramPropertiesEditionDialog(this, tree);
676         dialog->Show();
677 }
678
679 //=========================================================================
680
681 void wxGUIEditorGraphicBBS::OnExecuteActualDiagram(wxCommandEvent& event) {
682         std::string script1 = _tabsMgr->getActualDiagramBBS(true);
683         cout << endl << "RaC wxGUIEditorGraphicBBS::executeActualDiagram SCRIPT"
684                         << endl << endl;
685         cout << script1 << endl;
686
687         std::string script2 = _tabsMgr->getActualDiagramBBS(false);
688         executeScript(script2);
689 }
690
691         
692 //=========================================================================
693 void wxGUIEditorGraphicBBS::OpenBBS(std::string filePathName, std::string fileName) 
694 {
695         _tabsMgr->addNewTab( crea::std2wx(fileName) );
696         bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager(), _pkgBrowser->GetFactory());
697         // We tell the interpreter to throw exceptions on error
698         I->SetThrow(true);
699         // Interpret the file supposed to define a box called 'Processing'
700         I->InterpretFile( filePathName );
701         refreshGUIControls();
702 }
703         
704 //=========================================================================
705 // HANDLERS
706 //=========================================================================
707 void wxGUIEditorGraphicBBS::OnOpenBBS(wxCommandEvent& event) 
708 {
709 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
710 #if wxMAJOR_VERSION <= 2
711         wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxOPEN);
712 #else
713         wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open BBS"), wxEmptyString, wxT("NewBBS"), wxT("*.bbs"), wxFD_OPEN);
714 #endif
715
716         if (openFileDialog->ShowModal() == wxID_OK) 
717         {
718                 OpenBBS( crea::wx2std(openFileDialog->GetPath()) , crea::wx2std(openFileDialog->GetFilename())  );
719         }
720         
721 /*EED Borrame   
722         if (openFileDialog->ShowModal() == wxID_OK) 
723         {
724                 wxString fileName = openFileDialog->GetPath();
725                 _tabsMgr->addNewTab(openFileDialog->GetFilename());
726                 bbtk::InterpreterBBS::Pointer I = bbtk::InterpreterBBS::New( this->_tabsMgr->getActualTabPanel()->getSceneManager(), _pkgBrowser->GetFactory());
727                 // We tell the interpreter to throw exceptions on error
728                 I->SetThrow(true);
729                 // Interpret the file supposed to define a box called 'Processing'
730                 I->InterpretFile((const char*) (fileName.mb_str()));
731         }
732         refreshGUIControls();
733 */ 
734 }
735
736 //=========================================================================
737 void wxGUIEditorGraphicBBS::SaveActualBBS(std::string filename) {
738         ofstream file;
739
740         //EED           file.open(fileName.c_str());
741         file.open(filename.c_str());
742         std::string content = "";
743         // writing file header
744         content += "# ----------------------------------\n";
745         content += "# - BBTKGEditor v ";
746         content += _currentBBGversion; //VERSION
747         content += " BBS BlackBox Script\n";
748         content += "# - ";
749         content += filename;
750         content += "\n";
751         content += "# ----------------------------------\n";
752         content += "\n";
753         content += _tabsMgr->getActualDiagramBBS();
754         file << content;
755         file.close();
756 }
757
758 void wxGUIEditorGraphicBBS::OnSaveActualBBS(wxCommandEvent& event) {
759
760 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
761 #if wxMAJOR_VERSION <= 2
762         wxFileDialog * saveFileDialog = new wxFileDialog(this,
763                         wxT("Save  actual BBS"), wxEmptyString, wxT("NewBBS"),
764                         wxT("*.bbs"), wxSAVE | wxOVERWRITE_PROMPT);
765 #else
766         wxFileDialog * saveFileDialog = new wxFileDialog(this,
767                         wxT("Save  actual BBS"), wxEmptyString, wxT("NewBBS"),
768                         wxT("*.bbs"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
769 #endif
770
771         if (saveFileDialog->ShowModal() == wxID_OK) {
772                 wxString fileName = saveFileDialog->GetPath();
773                 std::string filename = (const char*) (fileName.mb_str());
774                 filename=CheckExtension (filename, ".bbs");
775                 SaveActualBBS(filename);
776         }
777
778 }
779
780 void wxGUIEditorGraphicBBS::AskComplexBoxConfiguration() {
781         std::string cbName = _tabsMgr->GetCbName();
782         std::string paName = _tabsMgr->GetCbPackageName();
783
784         wxTextEntryDialog *cbNameDialog = new wxTextEntryDialog(this,
785                         wxT("Complex Box name"));
786         wxTextEntryDialog *paNameDialog = new wxTextEntryDialog(this,
787                         wxT("Package name"));
788
789         cbNameDialog->SetValue(wxString(cbName.c_str(), wxConvUTF8));
790         paNameDialog->SetValue(wxString(paName.c_str(), wxConvUTF8));
791
792         if (cbNameDialog->ShowModal() == wxID_OK) {
793                 wxString complexboxname = cbNameDialog->GetValue();
794                 cbName = (const char*) (complexboxname.mb_str());
795         }
796
797         if (paNameDialog->ShowModal() == wxID_OK) {
798                 wxString packagename = paNameDialog->GetValue();
799                 paName = (const char*) (packagename.mb_str());
800         }
801
802         _tabsMgr->SetCbName(cbName);
803         _tabsMgr->SetCbPackageName(paName);
804 }
805
806 //=========================================================================
807
808 void wxGUIEditorGraphicBBS::SaveActualComplexBox(std::string filename) {
809         ofstream file;
810         file.open(filename.c_str());
811
812         std::string content = "";
813
814         // writing file header
815         content += "# ----------------------------------\n";
816         content += "# - BBTKGEditor v ";
817         content += _currentBBGversion;//VERSION
818         content += " BBS BlackBox Script (Complex Box)\n";
819         content += "# - ";
820         content += filename;
821         content += "\n";
822         content += "# ----------------------------------\n";
823         content += "\n";
824         content += _tabsMgr->getActualComplexBoxBBS();
825         file << content;
826         file.close();
827 }
828
829 //=========================================================================
830
831 void wxGUIEditorGraphicBBS::OnSaveActualComplexBox(wxCommandEvent& event) 
832 {
833 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
834 #if wxMAJOR_VERSION <= 2
835         wxFileDialog * saveFileDialog = new wxFileDialog(this,
836                         wxT("Save Complex Box BBS"), wxEmptyString,
837                         _T("ComplexBoxName"), wxT("*.bbs"), wxSAVE
838                                         | wxOVERWRITE_PROMPT);
839 #else
840         wxFileDialog * saveFileDialog = new wxFileDialog(this,
841                         wxT("Save Complex Box BBS"), wxEmptyString,
842                         _T("ComplexBoxName"), wxT("*.bbs"), wxFD_SAVE
843                                         | wxFD_OVERWRITE_PROMPT);
844 #endif
845
846         if (saveFileDialog->ShowModal() == wxID_OK) {
847                 wxString fileName = saveFileDialog->GetPath();
848                 std::string filename = (const char*) (fileName.mb_str());
849                 filename=CheckExtension (filename, ".bbs");
850                 SaveActualComplexBox(filename);
851         }
852 }
853
854 //=========================================================================
855 void wxGUIEditorGraphicBBS::SaveActualDiagram(std::string filename) {
856         ofstream file;
857         file.open(filename.c_str());
858
859         std::string content = "";
860
861         // writing file header
862         content += "# ----------------------------------\n";
863         content += "# - BBTKGEditor v ";
864         content += _currentBBGversion; //VERSION
865         content += " BBG BlackBox Diagram file\n";
866         content += "# - ";
867
868         content += filename;
869
870         content += "\n";
871         content += "# ----------------------------------\n";
872         content += "\n";
873         content += "APP_START\n";
874         _tabsMgr->saveActualDiagram(content, filename); //DFCH
875         content += "APP_END\n";
876         file << content;
877         file.close();
878 }
879
880 //=========================================================================
881 void wxGUIEditorGraphicBBS::SaveTempActualDiagram(const std::string &action) 
882 {
883         std::string stundo;
884         std::string stredo;
885         std::string name = _tabsMgr->GetNameTabPanel();
886         if(name[name.length() - 1] != '*')
887                 name +="*";
888         _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
889         _tabsMgr->saveTempActualDiagram(action);
890         GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
891         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
892         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
893         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
894 }
895
896 //=========================================================================
897
898 //The following method allows to save the current diagram asking the filename
899 //DFCH
900 void wxGUIEditorGraphicBBS::SaveCurrentDiagramAs() 
901 {
902
903 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
904 #if wxMAJOR_VERSION <= 2
905         wxFileDialog * saveFileDialog = new wxFileDialog(this,
906                         wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"),
907                         wxT("*.bbg"), wxSAVE | wxOVERWRITE_PROMPT);
908 #else
909         wxFileDialog * saveFileDialog = new wxFileDialog(this,
910                         wxT("Save current diagram"), wxEmptyString, wxT("NewDiagram"),
911                         wxT("*.bbg"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
912 #endif
913
914         if (saveFileDialog->ShowModal() == wxID_OK) {
915                 //_tabsMgr->SetNameTabPanel(saveFileDialog->GetFilename());
916                 wxString pathfileName = saveFileDialog->GetPath();
917                 std::string pathfilename = (const char*) (pathfileName.mb_str());
918                 pathfilename=CheckExtension (pathfilename, ".bbg");
919
920                 //modify the tab name accordingly
921                 wxString fileName = saveFileDialog->GetFilename();
922                 std::string filename = (const char*) (fileName.mb_str());
923                 filename=CheckExtension (filename, ".bbg");
924                 _tabsMgr->SetNameTabPanel( wxString (filename.c_str(), wxConvUTF8) );
925
926                 std::string pathfilenamebbs = pathfilename;
927                 pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
928                 if (_tabsMgr->isActualDiagramComplexBox() == false) {
929                         SaveActualDiagram(pathfilename);
930                         SaveActualBBS(pathfilenamebbs);
931                 } else {
932                         AskComplexBoxConfiguration();
933                         SaveActualDiagram(pathfilename);
934                         SaveActualComplexBox(pathfilenamebbs);
935                 } //if isActualDiagramComplexBox
936         } // if saveFileDialog
937 }
938 //=========================================================================
939 //DFCH
940 void wxGUIEditorGraphicBBS::OnSaveActualDiagram(wxCommandEvent& event) {
941         std::string pathfilename = _tabsMgr->GetCurrentTabPanelPath();
942         if (pathfilename.empty()) {
943                 SaveCurrentDiagramAs();
944         } else {
945                 std::string pathfilenamebbs = pathfilename;
946                 pathfilenamebbs[pathfilenamebbs.length() - 1] = 's';
947                 
948                 if (_tabsMgr->isActualDiagramComplexBox() == false) {
949                         std::string name = _tabsMgr->GetNameTabPanel();
950                         if(name[name.length() - 1] == '*')
951                         {
952                                 name =name.substr(0,name.length()-1);
953                         }
954                         _tabsMgr->SetNameTabPanel(wxString (name.c_str(), wxConvUTF8));
955                         SaveActualDiagram(pathfilename);
956                         SaveActualBBS(pathfilenamebbs);
957                 } else {
958                         AskComplexBoxConfiguration();
959                         SaveActualDiagram(pathfilename);
960                         SaveActualComplexBox(pathfilenamebbs);
961                 } //if isActualDiagramComplexBox
962         }
963 }
964 //=========================================================================
965 //DFCH
966 void wxGUIEditorGraphicBBS::OnSaveAsActualDiagram(wxCommandEvent& event) {
967         SaveCurrentDiagramAs();
968 }
969
970 //=========================================================================
971 void wxGUIEditorGraphicBBS::OnExportConsoleExecCommand(wxCommandEvent& event)
972 {
973 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
974 #if wxMAJOR_VERSION <= 2
975         wxFileDialog * saveFileDialog = new wxFileDialog(this,
976                         wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"),
977                         wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxSAVE | wxOVERWRITE_PROMPT);
978 #else
979         wxFileDialog * saveFileDialog = new wxFileDialog(this,
980                         wxT("Export console command"), wxEmptyString, wxT("ConsoleApp.txt"),
981                         wxT("*.txt;*.bbs;*.bbg;*.sh;*.bat"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
982 #endif
983
984
985         if (saveFileDialog->ShowModal() == wxID_OK)
986         {
987                 wxString fileName = saveFileDialog->GetPath();
988                 std::string filename = (const char*) (fileName.mb_str());
989                 filename=CheckExtension (filename, ".txt");
990
991                 ofstream file;
992                 file.open(filename.c_str());
993
994                 std::vector<std::string> extInputs = _tabsMgr->getActualTabPanel()->getSceneManager()->GetExternalInputsNames();
995
996                 //TODO PUT IN A METHOD OF A FILES AND TEXT MANAGER CLASS !!!
997                 //std::string inputsInCommentsWin="";
998                 //std::string inputsInCommentsUnix="";
999                 //std::string inputsInOneLineWin="";
1000                 std::string inputsInOneLineUnix="";
1001                 for (unsigned int i = 0; i < extInputs.size(); ++i)
1002                 {
1003                         /* No gusto la idea al jefe pero por si acaso ...
1004                         * RaC 2012 2nd HackFest
1005                         *
1006                         inputsInCommentsWin+="REM ";
1007                         inputsInCommentsWin+=extInputs[i];
1008                         inputsInCommentsWin+="=\"value\"\n";
1009                         inputsInCommentsUnix+="# ";
1010                         inputsInCommentsUnix+=extInputs[i];
1011                         inputsInCommentsUnix+="=\"value\"\n";
1012
1013                         char buffer [50];
1014                         sprintf (buffer, "%d", (i+1));
1015                         inputsInOneLineWin+=extInputs[i];
1016                         inputsInOneLineWin+="=\"%";
1017                         inputsInOneLineWin+=buffer;
1018                         inputsInOneLineWin+="\" ";
1019                         */
1020                         inputsInOneLineUnix+=extInputs[i];
1021                         inputsInOneLineUnix+="=\"<value>\" ";
1022
1023                 }
1024
1025
1026                 std::string content = "";
1027                 // writing file header
1028                 content += "# ----------------------------------\n";
1029                 content += "# - BBTKGEditor v ";
1030                 content += _currentBBGversion; //VERSION
1031                 content += " Console Commands to execute BBS application\n";
1032                 content += "# - ";
1033                 content += filename;
1034                 content += "\n";
1035                 content += "# ----------------------------------\n";
1036                 content += "\n";
1037                 content += "\n";
1038                 content += "# Command to execute bbi\n";
1039                 content += "bbi <bbs_path> ";
1040                 content += inputsInOneLineUnix;
1041
1042                 /* No gusto la idea al jefe pero por si acaso ...
1043                  * RaC 2012 2nd HackFest
1044                  content += "# For Windows (copy the following lines to a .bat file)\n";
1045                  content += "REM BBS application\n";
1046                  content += "REM Inputs:\n";
1047                  content += inputsInCommentsWin;
1048                  content += "REM To use previous inputs, put %$inputName% in the corresponding input of the execution bbi line\n";
1049                  content += "bbi applicationBBS.bbs ";
1050                  content += inputsInOneLineWin;
1051                  content += "\n";
1052                  content += "\n";
1053                  content += "# For Linux or Mac (copy the following lines to a .sh file)\n";
1054                  content += "#!/bin/bash\n";
1055                  content += "# BBS application\n";
1056                  content += "# Inputs:\n";
1057                  content += inputsInCommentsUnix;
1058                  content += "# To use previous inputs, put $inputName in the corresponding input of the execution bbi line\n";
1059                  content += "bbi applicationBBS.bbs ";
1060                  content += inputsInOneLineUnix;
1061                  content += "\n";
1062                 */
1063
1064                 file << content;
1065                 file.close();
1066         }
1067
1068
1069 }
1070
1071 //=========================================================================
1072
1073 void wxGUIEditorGraphicBBS::refreshGUIControls() 
1074 {
1075         std::string stundo;
1076         std::string stredo;
1077         //RaC2012 2ndHackFest Next line seems weird ... To keep in mind for other devels
1078         wxToolBar* toolbar = GetToolBar();
1079         if (_tabsMgr->isActualDiagramComplexBox()) 
1080         {
1081                 toolbar->ToggleTool(ID_BTNCOMPLEXBOX, true);
1082                 //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, true); RaC2012 2nd HackFest
1083                 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, true);
1084
1085                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, true);
1086                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, false);
1087                 GetMenuBar()->GetMenu(0)->Enable(ID_EXPORT_CONSOLEAPP, false);
1088         } else {
1089                 toolbar->ToggleTool(ID_BTNCOMPLEXBOX, false);
1090                 //toolbar->EnableTool(ID_ADDCOMPLEXBOXINPUT, false); RaC2012 2nd HackFest
1091                 toolbar->EnableTool(ID_ADDCOMPLEXBOXOUTPUT, false);
1092
1093                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_COMPLEXBOX, false);
1094                 GetMenuBar()->GetMenu(0)->Enable(ID_SAVE_AS_BBS, true);
1095                 GetMenuBar()->GetMenu(0)->Enable(ID_EXPORT_CONSOLEAPP, true);
1096         }
1097
1098         //RaC2012 2ndHackFest
1099         GetToolBar()->EnableTool(ID_EDITPROPERTIES,true);
1100
1101         GetToolBar()->EnableTool(ID_UNDO,_tabsMgr->getUndoState(stundo));
1102         GetToolBar()->SetToolShortHelp(ID_UNDO,crea::std2wx(stundo));
1103         GetToolBar()->EnableTool(ID_REDO,_tabsMgr->getRedoState(stredo));
1104         GetToolBar()->SetToolShortHelp(ID_REDO,crea::std2wx(stredo));
1105
1106         if (_tabsMgr->getNumActualSelectedObjects() > 0) {
1107                 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true);
1108         } else {
1109                 ///TODO Fix the possibility to say from the SceneManager to the GUI to refresh the options
1110                 GetMenuBar()->GetMenu(1)->Enable(ID_COPY_TO_COMPLEXDIAGRAM, true);
1111         }
1112
1113 }
1114
1115 //=========================================================================
1116
1117 void wxGUIEditorGraphicBBS::OnDeleteAllBoxesActualDiagram(wxCommandEvent& event) 
1118 {
1119         wxMessageDialog *dial = new wxMessageDialog(NULL,wxT("Are you sure to delete all boxes of the diagram?"),wxT("Delete all boxes"), wxYES_NO | wxNO_DEFAULT| wxICON_QUESTION);
1120         if (dial->ShowModal() == wxID_YES)
1121         {
1122                 _tabsMgr->deleteAllBoxesActualDiagram();
1123         }
1124 }
1125
1126 //=========================================================================
1127
1128 void wxGUIEditorGraphicBBS::OnCenterViewActualDiagram(wxCommandEvent& event) 
1129 {
1130         _tabsMgr->centerViewActualDiagram();
1131 }
1132
1133 //=========================================================================
1134 void wxGUIEditorGraphicBBS::OpenDiagram(std::string filePathName, std::string fileName) 
1135 {
1136         ifstream inputStream;   
1137         inputStream.open(filePathName.c_str());
1138         assert(inputStream.good()); // fails
1139         
1140         if(_tabsMgr->FindTab(filePathName)!=-1) //RaC2012 avoid opening same diagram twice
1141         {
1142                 inputStream.close();
1143                 printf("RaC: Diagram already opened\n");
1144                 return;
1145         }
1146         _tabsMgr->addNewTab( crea::std2wx(fileName) );
1147         _tabsMgr->loadDiagram(inputStream, filePathName);
1148
1149         _tabsMgr->saveTempActualDiagram("load diagram");
1150         GetToolBar()->EnableTool(ID_UNDO, false);
1151         GetToolBar()->EnableTool(ID_UNDO, false);
1152         inputStream.close();
1153         refreshGUIControls();
1154 }
1155         
1156 //=========================================================================
1157
1158 void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) 
1159 {
1160
1161 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1162 #if wxMAJOR_VERSION <= 2
1163         wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"), wxEmptyString, wxT(""), wxT("*.bbg"), wxOPEN | wxFILE_MUST_EXIST);
1164 #else
1165         wxFileDialog * openFileDialog = new wxFileDialog(this, wxT("Open diagram"), wxEmptyString, wxT(""), wxT("*.bbg"), wxFD_OPEN | wxFD_FILE_MUST_EXIST);
1166 #endif
1167
1168         if (openFileDialog->ShowModal() == wxID_OK) 
1169         {
1170                 wxString filePath = openFileDialog->GetPath();
1171                 wxString fileName = openFileDialog->GetFilename();
1172                 OpenDiagram( crea::wx2std(filePath) , crea::wx2std(fileName) );                                 
1173         }
1174 }
1175
1176 //=========================================================================
1177 void wxGUIEditorGraphicBBS::OnClickBtnBox(wxCommandEvent& event) 
1178 {
1179         std::cout<<"wxGUIEditorGraphicBBS::OnClickBtnBox"<<std::endl;
1180         BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
1181         if (bbDes != NULL) {
1182                 std::string typeName = bbDes->GetTypeName();
1183                 std::string packageName = bbDes->GetPackage()->GetName();
1184                 wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
1185                 if (pnl != NULL) {
1186                         wxVtkSceneManager *scn = pnl->getSceneManager();
1187                         scn->createGBlackBox(50, 50, packageName, typeName);
1188                         scn->refresh();
1189                 }
1190                 SaveTempActualDiagram("New Box");
1191                 // if pnl
1192         }// if bbDes
1193 }
1194
1195 //=========================================================================
1196
1197 void wxGUIEditorGraphicBBS::OnClickBtnExecutableBox(wxCommandEvent& event) 
1198 {
1199         //DFCH
1200         wxGEditorTabPanel *pnl = this->_tabsMgr->getActualTabPanel();
1201
1202         if (pnl != NULL) {
1203                 wxVtkSceneManager *scn = pnl->getSceneManager();
1204                 if( scn->MakeBoxExecutable() )
1205                         std::cout<<"DFCH: wxGUIEditorGraphicBBS::OnClickBtnExecutableBox...successful"<<std::endl;
1206                 else
1207                         std::cout<<"DFCH: wxGUIEditorGraphicBBS::OnClickBtnExecutableBox...Error!!"<<std::endl;
1208         }
1209         //DFCH
1210
1211 }
1212
1213 //=========================================================================
1214 void wxGUIEditorGraphicBBS::OnClickBtnComplexBox(wxCommandEvent& event) 
1215 {
1216         std::cout<<"wxGUIEditorGraphicBBS::OnClickBtnComplexBox"<<std::endl;
1217         wxToolBar* toolbar = GetToolBar();
1218         bool temp = toolbar->GetToolState(ID_BTNCOMPLEXBOX);
1219         if (temp) {
1220                 enableComplexBox();
1221         } else {
1222                 disableComplexBox();
1223         }
1224 }
1225
1226 //=========================================================================
1227 //EED01
1228 void wxGUIEditorGraphicBBS::OnAddComplexBoxInput(wxCommandEvent& event) 
1229 {
1230         wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,
1231                         wxT("Name of input port"));
1232         if (nameDialog->ShowModal() == wxID_OK) 
1233         {
1234                 wxString fileName = nameDialog->GetValue();
1235                 if (!fileName.IsEmpty()) 
1236                 {
1237                         std::string portName = (const char*) (fileName.mb_str());
1238                         if ( !boxNameExists(portName) )
1239                         {
1240                            _tabsMgr->addActualDiagramComplexInputPort(portName);
1241                         } else {
1242                            wxMessageDialog *dial = new wxMessageDialog(NULL,
1243                                        wxT("Impossible to create Box. The name already exists. Please provide another name"),
1244                                        wxT("Change name: name already exists"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP);
1245                            dial->ShowModal();
1246                         }
1247                 } // if !fileName
1248         } // if namaDialog
1249 }
1250
1251 //=========================================================================
1252 void wxGUIEditorGraphicBBS::OnAddComplexBoxOutput(wxCommandEvent& event) 
1253 {
1254         wxTextEntryDialog *nameDialog = new wxTextEntryDialog(this,
1255                         wxT("Name of output port"));
1256         if (nameDialog->ShowModal() == wxID_OK) 
1257         {
1258                 wxString fileName = nameDialog->GetValue();
1259                 if (!fileName.IsEmpty()) 
1260                 {
1261                         std::string portName = (const char*) (fileName.mb_str());
1262                         if ( !boxNameExists(portName) )
1263                         {
1264                         _tabsMgr->addActualDiagramComplexOutputPort(portName);
1265                         } else {
1266                            wxMessageDialog *dial = new wxMessageDialog(NULL,
1267                                        wxT("Impossible to create Box. The name already exists. Please provide another name"),
1268                                        wxT("Change name: name already exists"), wxOK | wxICON_EXCLAMATION | wxSTAY_ON_TOP);
1269                            dial->ShowModal();
1270                         }
1271
1272                 } // if !filename
1273         } // namaDialog
1274 }
1275
1276 //=========================================================================
1277 void wxGUIEditorGraphicBBS::OnCopySelectedToComplexDiagram(
1278                 wxCommandEvent& event) 
1279 {
1280         _tabsMgr->copySelectedBBoxesToComplexDiagram();
1281 }
1282
1283 //=========================================================================
1284 void wxGUIEditorGraphicBBS::OnHelpBBeditor(wxCommandEvent& event) 
1285 {
1286         printf("wxGUIEditorGraphicBBS::OnHelpBBeditor ....not implemented..\n");
1287 }
1288
1289 //=========================================================================
1290 void wxGUIEditorGraphicBBS::OnCreatePackage(wxCommandEvent& event) 
1291 {
1292         bbtkSystemTools::CreatePackage();
1293 }
1294
1295 //=========================================================================
1296 void wxGUIEditorGraphicBBS::OnCreateBlackBox(wxCommandEvent& event) 
1297 {
1298         bbtkSystemTools::CreateBlackBox();
1299 }
1300         
1301 //=========================================================================
1302 void wxGUIEditorGraphicBBS::OnPlugPackage(wxCommandEvent& event) 
1303 {
1304         //DFGO2012 Plug Package functionnalities
1305         long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
1306         wxDirDialog* FD =
1307           new wxDirDialog( 0,
1308                            _T("Select package directory"),
1309                            _T(""),
1310                            style);
1311         long userResponse;
1312         do
1313         {
1314                 userResponse = FD->ShowModal();
1315                 if(userResponse==wxID_OK)
1316                 {
1317                         std::string path = wx2std (FD->GetPath()) ;
1318                         #ifdef WIN32
1319                         std::string fname = path + "\\bbtkPackage";
1320                         #else
1321                         std::string fname = path + "/bbtkPackage";
1322                         #endif
1323                         
1324                         std::cout << "Path chosen = \"" << FD->GetPath() << "\"" << std::endl;
1325                         if ( Utilities::FileExists( fname ) )
1326                         {
1327                                 std::ifstream f;
1328                                 f.open(fname.c_str());
1329                                 std::string pname;
1330                                 f >> pname;
1331                                 while(pname[0] == '#')
1332                                 {
1333                                         getline(f, pname, '\n');
1334                                         f >> pname;
1335                                 }
1336                                 f.close();
1337
1338                                 bbtk::ConfigurationFile::GetInstance().AddPackagePathsAndWrite( path );
1339
1340                                 DoRegeneratePackageDoc(pname);
1341                                 DoRegenerateBoxesLists();
1342
1343                                 _pkgBrowser->RebuildList();
1344
1345                                 wxMessageBox(_T("Package successfully plugged. Please restart bbEditor to see the new package in the package browser."),_T("Plug package"),wxOK | wxICON_INFORMATION);
1346                                 userResponse = wxID_CANCEL;
1347                         }
1348                         else
1349                         {
1350                                 std::string err = "The directory \"" + path + "\" does not contain a 'bbtkPackage' file.";
1351                                 #ifndef WIN32
1352                                         #ifndef MACOSX
1353                                                 err += "\nNote: If you are on Linux please select the folder and click \"Open\", don't enter in it.";
1354                                         #endif
1355                                 #endif
1356
1357                                 wxMessageBox(crea::std2wx(err), _T("Plug package"),wxOK | wxICON_ERROR);
1358                                 // THE FOLLOWING LINE GIVES ERRORS BECAUSE IT IS NECESSARY TO USE std2wx
1359                                 //wxMessageBox( _T( err) , _T("Plug package"),wxOK | wxICON_ERROR);
1360                         }
1361                 }
1362         }while(userResponse != wxID_CANCEL);
1363
1364 }
1365         
1366 //=========================================================================
1367 void wxGUIEditorGraphicBBS::OnEditConfig(wxCommandEvent& event) 
1368 {
1369         std::string commandStr;
1370             std::string configFile = ConfigurationFile::GetInstance().Get_config_xml_full_path();
1371         #ifdef WIN32
1372                 commandStr = "notepad.exe ";
1373         #else
1374                 commandStr = "gedit ";
1375         #endif
1376                 commandStr = commandStr + configFile;
1377                 std::cout << "system: " << commandStr << std::endl;
1378                 system ( commandStr.c_str() );
1379 }
1380         
1381 //=========================================================================
1382 void wxGUIEditorGraphicBBS::OnShowHTMLDoc(wxCommandEvent& event) 
1383 {
1384         // JGRR & CM WH
1385         if (_helpHtmlBrowser != NULL){
1386              _frameAUIMgr->DetachPane(_helpHtmlBrowser);
1387             _helpHtmlBrowser->Destroy();   
1388         }
1389         initHelpHTMLBrowser();
1390         _frameAUIMgr->AddPane(_helpHtmlBrowser, wxAuiPaneInfo().Right().MinSize(200, 200));
1391         _frameAUIMgr->Update();
1392         refreshGUIControls();
1393         
1394         // EO JGRR    & CM WH       
1395 }
1396         
1397 //=========================================================================
1398 void wxGUIEditorGraphicBBS::OnCreateIndex(wxCommandEvent& event) 
1399 {
1400         printf("EED wxGUIEditorGraphicBBS::OnCreateIndex ... not implemented ..\n");
1401 }
1402
1403         
1404 //=========================================================================
1405 void wxGUIEditorGraphicBBS::OnEditComplexBoxScript(wxCommandEvent& event)
1406 {
1407         BlackBoxDescriptor *bbDes = _pkgBrowser->GetActualSelected();
1408         if (bbDes != NULL) 
1409         {
1410                 std::string packageName = bbDes->GetPackage()->GetName();
1411                 std::string typeName = bbDes->GetTypeName();
1412                 if (!TryToOpenScriptComplexBox(packageName ,typeName))
1413                 {
1414                         wxMessageDialog windowMessage1(NULL,_T("This is not a ComplexBox script."), _T("Alert !"), wxOK);
1415                         windowMessage1.ShowModal();
1416                 }
1417         }// if bbDes
1418 }
1419
1420 //=========================================================================
1421 void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event) 
1422 {
1423         Close(true);
1424 }
1425
1426 Factory::Pointer wxGUIEditorGraphicBBS::GetBBTKFactory()
1427 {
1428         if (_pkgBrowser==NULL) 
1429         {
1430                 printf ("EED ERROR! wxGUIEditorGraphicBBS::GetBBTKFactory _pkgBrowser = NULL\n");
1431         }
1432         return _pkgBrowser->GetFactory();
1433 }
1434
1435 //=========================================================================
1436 void wxGUIEditorGraphicBBS::enableComplexBox() 
1437 {
1438         _tabsMgr->setActualDiagramComplexBox(true);
1439         refreshGUIControls();
1440 }
1441
1442 //=========================================================================
1443
1444 void wxGUIEditorGraphicBBS::disableComplexBox() 
1445 {
1446         _tabsMgr->setActualDiagramComplexBox(false);
1447         refreshGUIControls();
1448 }
1449
1450 //=========================================================================
1451 void wxGUIEditorGraphicBBS::setCurrentDiagramDescription(std::string description)
1452 {
1453         _tabsMgr->SetDescription(description);
1454 }
1455
1456 //=========================================================================
1457 void wxGUIEditorGraphicBBS::setCurrentDiagramAuthor(std::string author)
1458 {
1459         _tabsMgr->SetAuthor(author);
1460 }
1461
1462 //=========================================================================
1463 void wxGUIEditorGraphicBBS::setCurrentDiagramCategory(std::string category)
1464 {
1465         _tabsMgr->SetCategory(category);
1466 }
1467
1468 //=========================================================================
1469 void wxGUIEditorGraphicBBS::setCurrentDiagramMessageKind(std::string kind){
1470         _tabsMgr->SetMessageKind(kind); 
1471 }
1472
1473 //=========================================================================
1474 void wxGUIEditorGraphicBBS::setCurrentDiagramMessageLevel(std::string level){
1475         _tabsMgr->SetMessageLevel(level);       
1476 }
1477
1478 //=========================================================================
1479 std::string wxGUIEditorGraphicBBS::getCurrentDiagramDescription()
1480 {
1481         return _tabsMgr->GetDescription();
1482 }
1483
1484 //=========================================================================
1485 std::string wxGUIEditorGraphicBBS::getCurrentDiagramAuthor()
1486 {
1487         return _tabsMgr->GetAuthor();
1488 }
1489
1490 //=========================================================================
1491 std::string wxGUIEditorGraphicBBS::getCurrentDiagramCategory()
1492 {
1493         return _tabsMgr->GetCategory();
1494 }
1495
1496 //=========================================================================
1497 std::string wxGUIEditorGraphicBBS::getCurrentDiagramMessageKind(){
1498         return _tabsMgr->GetMessageKind();
1499 }
1500
1501 //=========================================================================
1502 std::string wxGUIEditorGraphicBBS::getCurrentDiagramMessageLevel(){
1503         return _tabsMgr->GetMessageLevel();
1504 }
1505
1506 //=========================================================================
1507 bool wxGUIEditorGraphicBBS::isCurrentDiagramComplexBox()
1508 {
1509         return _tabsMgr->isActualDiagramComplexBox();
1510 }
1511
1512
1513 //=========================================================================
1514 void wxGUIEditorGraphicBBS::OpenScript(std::string filePathNameBBS ,std::string boxType)
1515 {       
1516         std::string fileName                                                    = boxType+".bbg";
1517         std::string filePathNameBBG                                             = filePathNameBBS;
1518         filePathNameBBG[ filePathNameBBG.length()-1 ]   = 'g';
1519         
1520         wxMessageDialog windowMessage1(NULL,_T("The system is going to open a bbg or bbs for you. Be careful if you save this file."), _T("Alert !"), wxOK);
1521         windowMessage1.ShowModal();
1522         
1523         if ( Utilities::FileExists( filePathNameBBG ) )
1524         {
1525                 OpenDiagram( filePathNameBBG , fileName );     
1526         } else {
1527                 if ( Utilities::FileExists( filePathNameBBS ) )
1528                 {
1529                         OpenBBS( filePathNameBBS , fileName );     
1530                 } else {
1531                         wxMessageDialog windowMessage1(NULL,_T("..ERROR.. loading script bbg/bbs."), _T("Alert !"), wxOK);
1532                         windowMessage1.ShowModal();
1533                 } // FileExists BBS
1534         } // FieExists BBG
1535 } //OpenScript
1536         
1537         
1538         
1539 //=========================================================================
1540 bool wxGUIEditorGraphicBBS::TryToOpenScriptApplication(std::string packageName ,std::string boxType)
1541 {       
1542         return TryToOpenScript(packageName ,boxType, true, false);
1543 }               
1544
1545 //=========================================================================
1546 bool wxGUIEditorGraphicBBS::TryToOpenScriptComplexBox(std::string packageName ,std::string boxType)
1547 {       
1548         return TryToOpenScript(packageName ,boxType, false, true);
1549 }               
1550         
1551         
1552 //=========================================================================
1553 bool wxGUIEditorGraphicBBS::TryToOpenScript(std::string packageName ,std::string boxType,bool scriptApplication, bool scriptComplexBox)
1554 {       
1555         printf("EED wxGUIEditorGraphicBBS::TryToOpenScript Start\n ");
1556         Package::Pointer k;
1557         std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
1558         BlackBoxDescriptor::Pointer descriptor;
1559         printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 1\n ");
1560         k                       = GetBBTKFactory()->GetPackage(packageName);
1561         printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 2\n ");
1562         mapDesc         = k->GetDescriptorMap();
1563         printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 3\n ");
1564         descriptor      = mapDesc[boxType];
1565         printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 3.1  packageName:%s  boxType:%s \n",packageName.c_str(), boxType.c_str() );
1566
1567         if (descriptor==NULL) printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 3.2\n  AUUCHH ");
1568         printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 3.2\n  ");
1569
1570         bool result=false;
1571 descriptor->IsTypeOfScript_Application();       
1572         if (descriptor!=NULL)
1573         {
1574                 if ( 
1575                         ((descriptor->IsTypeOfScript_Application()==true) && (scriptApplication==true))
1576                         ||
1577                         ((descriptor->IsTypeOfScript_ComplexBox()==true) && (scriptComplexBox==true))           
1578                         )
1579                 {
1580                         result=true;
1581                 printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 4\n ");
1582                         OpenScript(descriptor->GetScriptFileName(),boxType);
1583                 printf("EED wxGUIEditorGraphicBBS::TryToOpenScript 5\n ");
1584                 } // if descriptor Type
1585         } else {
1586                 printf("EED ERROR wxGUIEditorGraphicBBS::TryToOpenScript >> The descriptor of this box not exists (packageName:%s  boxType:%s) this is not normal\n",packageName.c_str(), boxType.c_str() );
1587         }  // if descriptor NULL
1588         
1589         printf("EED wxGUIEditorGraphicBBS::TryToOpenScript END\n ");
1590         
1591         return result;
1592 }       
1593         
1594 } // EO namespace bbtk
1595
1596 // EOF
1597