[doc_tool] Moved executing of external programms from Model to FSHelper
[hsd_doku_tool.git] / src / View.cxx
index aa6862d..3dde325 100644 (file)
@@ -24,6 +24,13 @@ View::View(ControllerIF::SPtr contr, ModelIF::SPtr model)
 
 View::~View()
 {
+    win_doctool->hide();
+    win_chapt_add->hide();
+    win_settings->hide();
+    win_auth_coord->hide();
+    win_depart_coord->hide();
+    win_log_view->hide();
+
     // Ressourcen freigeben
     Fl::delete_widget(win_doctool);
     Fl::delete_widget(win_chapt_add);
@@ -310,7 +317,7 @@ void View::btn_next_cb(Fl_Button* btn, void* view)
         View* thisView = static_cast<View*>(view);
         thisView->saveBuffer();
         int selectedNum=1;
-        for (selectedNum =1 ; selectedNum<=thisView->br_chapters->size(); selectedNum++ )
+        for (selectedNum=1 ; selectedNum<=thisView->br_chapters->size(); selectedNum++ )
             if (thisView->br_chapters->selected(selectedNum)) break;
 
 
@@ -337,23 +344,36 @@ void View::btn_generate_cb(Fl_Button* btn, void* view)
     {
         View* thisView = static_cast<View*>(view);
         thisView->saveBuffer();
+        thisView->win_doctool->deactivate();
+        thisView->win_doctool->cursor(FL_CURSOR_WAIT);
+
+
+        Fl::check();
         thisView->mController->generateDocument();
 
-        if(thisView->mLogBuf->loadfile(std::string(thisView->mModel->getOutPath() + "Log.txt").c_str()) != 0)
+        if(thisView->mLogBuf->loadfile(std::string(thisView->mModel->getOutPath() + thisView->mModel->getLogFile()).c_str()) != 0)
             throw std::string("Error opening Logfile!");
 
         thisView->win_log_view->show();
+        thisView->win_doctool->activate();
+        thisView->win_doctool->cursor(FL_CURSOR_DEFAULT);
     }
     // ----------- Exception Handling ------------
     catch(std::string& e)
     {
         std::cerr << e << std::endl;
         fl_alert(e.c_str()); //Textbox mit fehlermeldung
+        View* thisView = static_cast<View*>(view);
+        thisView->win_doctool->activate();
+        thisView->win_doctool->cursor(FL_CURSOR_DEFAULT);
     }
     catch(...)
     {
         fl_alert("Unknown error occured!");
         std::cerr << "Unknown error occured!" << std::endl;
+        View* thisView = static_cast<View*>(view);
+        thisView->win_doctool->activate();
+        thisView->win_doctool->cursor(FL_CURSOR_DEFAULT);
     }
 }
 
@@ -402,11 +422,13 @@ void View::menu_open_template_cb(Fl_Menu_* menu, void* view)
         while(chooser.shown())
             Fl::wait();
 
-        // Abbruch gedr├╝ckt
         if ( chooser.value() != nullptr )
         {
             thisView->mController->setTemplate(chooser.value());
-            thisView->menu_out_dir->do_callback(nullptr);
+
+            while(thisView->mModel->getOutPath().empty())
+                thisView->menu_out_dir->do_callback(nullptr);
+
             thisView->activate();
         }
     }
@@ -908,6 +930,9 @@ void View::menu_new_templ_cb(Fl_Menu_* menu, void* view)
         View* thisView = static_cast<View*>(view);
         thisView->menu_out_dir->do_callback(nullptr);
 
+        if(thisView->mModel->getOutPath().empty())
+            throw std::string("An output directory has to be set!");
+
         menu_settings->do_callback(nullptr);
 
         // Warte bis benutzer einstellungen eingegeben hat