]> Creatis software - crea.git/commitdiff
Feature #1711 CreaDevManager application implementation
authorDaniel Gonzalez <daniel@daniel.laptop>
Thu, 27 Jun 2013 09:50:46 +0000 (11:50 +0200)
committerDaniel Gonzalez <daniel@daniel.laptop>
Thu, 27 Jun 2013 09:50:46 +0000 (11:50 +0200)
Feature: Now detecting BBS files in folders. They can be executed with bbs or edited in code editor.

13 files changed:
lib/creaDevManagerLib/CDMUtilities.cpp
lib/creaDevManagerLib/CDMUtilities.h
lib/creaDevManagerLib/images/BBSIcon20.xpm
lib/creaDevManagerLib/images/BBSIcon64.xpm
lib/creaDevManagerLib/modelCDMBBSFile.cpp [new file with mode: 0644]
lib/creaDevManagerLib/modelCDMBBSFile.h [new file with mode: 0644]
lib/creaDevManagerLib/modelCDMFolder.cpp
lib/creaDevManagerLib/modelCDMFolder.h
lib/creaDevManagerLib/wxCDMBBSFileDescriptionPanel.cpp [new file with mode: 0644]
lib/creaDevManagerLib/wxCDMBBSFileDescriptionPanel.h [new file with mode: 0644]
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.cxx
lib/creaDevManagerLib/wxCDMProjectsTreeCtrl.h

index 37f4deb9370e09b7bf2fc7b1130d5ce5ab8f6d1c..e683862c24ec7f022dfb48b72b3c1d7289342cbb 100644 (file)
@@ -117,16 +117,16 @@ namespace CDMUtilities
     return system(command.c_str());
   }
 
-  int openFileWithCommand(const std::string& file, const std::string& command)
+  int openFileWithCommand(const std::string& file, const std::string& command, const std::string& parameters)
   {
 #ifdef _WIN32
     std::string comm = "start " + command;
     if(file != "")
-      comm += " \"" + file + "\"";
+      comm += " \"" + file + "\" " + parameters;
 #else
     std::string comm = command;
     if(file != "")
-      comm += " \"" + file + "\"";
+      comm += " \"" + file + "\" " + parameters;
     comm += " &";
 #endif
     return system(comm.c_str());
index 935ce941635e63e787d60b23f8491c8b25bba9ab..50e2cd410a9160db3b022d8d4bd0b1e6f4d63856 100644 (file)
@@ -173,9 +173,10 @@ namespace CDMUtilities
    * Opens a file with a given command.
    * @param file Full path of the file to open.
    * @param command Command to execute the file with.
+   * @param parameters Parameters to open file.
    * @return True if there was an error on the execution of the operation.
    */
-  int openFileWithCommand(const std::string& file, const std::string& command);
+  int openFileWithCommand(const std::string& file, const std::string& command, const std::string& parameters = "");
   /**
    * Opens the BBTK Graphical Editor
    * @return True if there was an error on the execution of the operation.
index b3a4b0609b47185cda47abf0bea7e3b5f15a5630..aae2b8d52f665b50a2c5db57d0cf211625a69620 100644 (file)
@@ -1,5 +1,5 @@
 /* XPM */
-static char * BBSIcon20_xpm[] = {
+const static char * BBSIcon20[] = {
 "20 20 131 2",
 "      c None",
 ".     c #171E27",
index df59a109a00bedf14c8042102f9d3145d0c6d000..96404141c5b30549a6cb1678170f4d5a34d5fffb 100644 (file)
@@ -1,5 +1,5 @@
 /* XPM */
-static char * BBSIcon_xpm[] = {
+const static char * BBSIcon64[] = {
 "64 64 217 2",
 "      c None",
 ".     c #1D242D",
diff --git a/lib/creaDevManagerLib/modelCDMBBSFile.cpp b/lib/creaDevManagerLib/modelCDMBBSFile.cpp
new file mode 100644 (file)
index 0000000..19d39a9
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+/*
+ * modelCDMBBSFile.cpp
+ *
+ *  Created on: Jun 27, 2013
+ *      Author: Daniel Felipe Gonzalez Obando
+ */
+
+#include "modelCDMBBSFile.h"
+
+#include <fstream>
+
+#include<creaWx.h>
+#include<wx/dir.h>
+
+#include "CDMUtilities.h"
+
+modelCDMBBSFile::modelCDMBBSFile()
+{
+}
+
+modelCDMBBSFile::modelCDMBBSFile(modelCDMIProjectTreeNode* parent, const std::string& path, const std::string& name, const int& level)
+{
+  std::cout << "creating bbs file: " + path + "\n";
+  this->parent = parent;
+  this->children.clear();
+  this->level = level;
+  this->type = wxDIR_FILES;
+  this->name = name;
+  this->path = path;
+
+  std::ifstream in(path.c_str(), std::ifstream::in | std::ifstream::binary);
+  in.seekg(0, std::ifstream::end);
+  this->length = in.tellg();
+  in.close();
+}
+
+modelCDMBBSFile::~modelCDMBBSFile()
+{
+}
+
+bool modelCDMBBSFile::OpenFile(std::string*& result)
+{
+
+  if (!CDMUtilities::openTextEditor(this->path))
+    return true;
+  else
+    {
+      result = new std::string("Couldn't open bbs file in text editor.");
+      return false;
+    }
+}
+
+bool modelCDMBBSFile::ExecuteFile(
+    std::string*& result,
+    const std::string& parameters)
+{
+  if (!CDMUtilities::openFileWithCommand(this->path, "bbi", parameters))
+    return true;
+  else
+    {
+      result = new std::string("Couldn't open bbs file with bbi.");
+      return false;
+    }
+}
+
+const bool modelCDMBBSFile::Refresh(std::string*& result)
+{
+  //std::cout << "refreshing bbs file" << std::endl;
+  std::ifstream in((this->path).c_str());
+  if(!in.is_open())
+    {
+      in.close();
+      return false;
+    }
+  std::ifstream in2(path.c_str(), std::ifstream::in | std::ifstream::binary);
+  in2.seekg(0, std::ifstream::end);
+  this->length = in2.tellg();
+  in2.close();
+  return true;
+}
diff --git a/lib/creaDevManagerLib/modelCDMBBSFile.h b/lib/creaDevManagerLib/modelCDMBBSFile.h
new file mode 100644 (file)
index 0000000..68e1497
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+/*
+ * modelCDMBBSFile.h
+ *
+ *  Created on: Jun 27, 2013
+ *      Author: Daniel Felipe Gonzalez Obando
+ */
+
+#ifndef MODELCDMBBSFILE_H_
+#define MODELCDMBBSFILE_H_
+
+#include "modelCDMFile.h"
+
+/**
+ * Class representing a bbs file in a folder of a Crea project.
+ */
+class modelCDMBBSFile : public modelCDMFile
+{
+public:
+  /**
+   * Default Constructor.
+   */
+  modelCDMBBSFile();
+  /**
+   * BBS file Constructor.
+   * @param parent Parent node of the BBS file node.
+   * @param path Full path to the BBS file node.
+   * @param name File name of the BBS file node.
+   * @param level Project hierarchy level of the BBS file node.
+   */
+  modelCDMBBSFile(modelCDMIProjectTreeNode* parent, const std::string& path, const std::string& name = "CMakeLists.txt", const int& level = 1);
+  /**
+   * Destructor
+   */
+  ~modelCDMBBSFile();
+
+  /**
+   * Opens the file in the system default code editor.
+   * @param result Result message.
+   * @return True if the operation was successful.
+   */
+  bool OpenFile(std::string*& result);
+
+  /**
+   * Opens the file using bbi.
+   * @param parameters Execution parameters.
+   * @param result Result message.
+   * @return True if the operation was successful.
+   */
+  bool ExecuteFile(std::string*& result, const std::string& parameters = "");
+
+  /**
+   * Refreshes the state of the BBS file.
+   * @param result Result message.
+   * @return True if the operation was successful.
+   */
+  virtual const bool Refresh(std::string*& result);
+};
+
+#endif /* MODELCDMBBSFILE_H_ */
index 01379ac7ccd49d8845a47581e72e43bd481452b9..cdd10068eacfdcaf1ad9357cd8dc3d268a804a59 100644 (file)
@@ -109,6 +109,11 @@ modelCDMFolder::modelCDMFolder(modelCDMIProjectTreeNode* parent, const std::stri
               modelCDMCodeFile* file = new modelCDMCodeFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
               this->children.push_back(file);
             }
+          else if(fileType == ".bbs")
+            {
+              modelCDMBBSFile* file = new modelCDMBBSFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
+              this->children.push_back(file);
+            }
           //if is an unknown file, create file
           else
             {
@@ -283,6 +288,10 @@ const bool modelCDMFolder::Refresh(std::string*& result)
                     {
                       this->children.push_back(new modelCDMCodeFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
                     }
+                  else if(fileType == ".bbs")
+                    {
+                      this->children.push_back(new modelCDMBBSFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
+                    }
                   else
                     {
                       modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
index e9cae7c5b632390daee55052e85866256c22bae3..d11c6761c36aa1d3e0726852da826e0d43555368 100644 (file)
@@ -41,6 +41,7 @@
 #include "modelCDMIProjectTreeNode.h"
 #include "modelCDMCMakeListsFile.h"
 #include "modelCDMCodeFile.h"
+#include "modelCDMBBSFile.h"
 
 /**
  * Class representing a folder in the project hierarchy.
diff --git a/lib/creaDevManagerLib/wxCDMBBSFileDescriptionPanel.cpp b/lib/creaDevManagerLib/wxCDMBBSFileDescriptionPanel.cpp
new file mode 100644 (file)
index 0000000..75cb0ad
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+/*
+ * wxCDMBBSFileDescriptionPanel.cpp
+ *
+ *  Created on: Jun 27, 2012
+ *      Author: Daniel Felipe Gonzalez Obando
+ */
+
+#include "wxCDMBBSFileDescriptionPanel.h"
+
+#include "wxCDMMainFrame.h"
+
+#include "creaDevManagerIds.h"
+#include "images/BBSIcon64.xpm"
+
+BEGIN_EVENT_TABLE(wxCDMBBSFileDescriptionPanel, wxPanel)
+EVT_HYPERLINK(ID_BUTTON_PREV, wxCDMBBSFileDescriptionPanel::OnBtnReturn)
+EVT_BUTTON(ID_BUTTON_OPEN_FILE, wxCDMBBSFileDescriptionPanel::OnBtnOpenInEditor)
+EVT_BUTTON(ID_BUTTON_OPEN_COMMAND, wxCDMBBSFileDescriptionPanel::OnBtnOpenInBBI)
+EVT_BUTTON(ID_BUTTON_OPEN_FOLDER, wxCDMBBSFileDescriptionPanel::OnBtnOpenFolder)
+END_EVENT_TABLE()
+
+wxCDMBBSFileDescriptionPanel::wxCDMBBSFileDescriptionPanel(
+    wxWindow* parent,
+    modelCDMBBSFile* bbsfile,
+    wxWindowID id,
+    const wxString& caption,
+    const wxPoint& pos,
+    const wxSize& size,
+    long style
+)
+{
+  wxCDMBBSFileDescriptionPanel::Create(parent, bbsfile, id, caption, pos, size, style);
+}
+
+wxCDMBBSFileDescriptionPanel::~wxCDMBBSFileDescriptionPanel()
+{
+}
+
+bool wxCDMBBSFileDescriptionPanel::Create(
+    wxWindow* parent,
+    modelCDMBBSFile* bbsfile,
+    wxWindowID id,
+    const wxString& caption,
+    const wxPoint& pos,
+    const wxSize& size,
+    long style
+)
+{
+  wxPanel::Create(parent, id, pos, size, style);
+  this->bbsFile = bbsfile;
+  CreateControls();
+  // this part makes the scrollbars show up
+  this->FitInside(); // ask the sizer about the needed size
+  this->SetScrollRate(5, 5);
+  return TRUE;
+}
+
+void wxCDMBBSFileDescriptionPanel::CreateControls()
+{
+  wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+  //Links to return
+  wxBoxSizer *linksSizer = new wxBoxSizer(wxHORIZONTAL);
+  std::vector<modelCDMIProjectTreeNode*> parents = this->bbsFile->GetParents();
+  for (int i = 0; i < (int)(parents.size()); i++)
+    {
+      wxHyperlinkCtrl* returnLnk = new wxHyperlinkCtrl(this, ID_BUTTON_PREV, crea::std2wx(parents[parents.size()-1-i]->GetName()), crea::std2wx(parents[parents.size()-1-i]->GetPath()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
+      returnLnk->SetWindowStyle(wxNO_BORDER);
+      returnLnk->SetToolTip(crea::std2wx("Return to " + parents[parents.size()-1-i]->GetName() + "."));
+      linksSizer->Add(returnLnk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
+      linksSizer->Add(new wxStaticText(this,wxID_ANY, wxT("/")), 0, wxALIGN_CENTER, 0);
+    }
+
+  linksSizer->Add(new wxStaticText(this, wxID_ANY, crea::std2wx(this->bbsFile->GetName())), 0, wxALIGN_CENTER, 0);
+
+  sizer->Add(linksSizer, 0, wxALIGN_CENTER | wxALL, 5);
+
+  //Header
+  wxBoxSizer* headerSizer = new wxBoxSizer(wxHORIZONTAL);
+  {
+    //Image
+    headerSizer->Add(new wxStaticBitmap(this, -1, wxBitmap(BBSIcon64)),0, wxALIGN_CENTER, 0);
+    wxBoxSizer* textSizer = new wxBoxSizer(wxVERTICAL);
+    //Title
+    textSizer->Add(new wxStaticText(this, -1, _("BBS Script File")),0, wxALIGN_LEFT, 0);
+    //File Name
+    textSizer->Add(new wxStaticText(this, -1, crea::std2wx(this->bbsFile->GetName())),0, wxALIGN_LEFT, 0);
+    headerSizer->Add(textSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  }
+  sizer->Add(headerSizer, 0, wxALIGN_CENTER);
+
+  //Actions
+  wxStaticBoxSizer* actionsBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("&Actions"));
+  wxPanel* actionsPanel = new wxPanel(this);
+  wxBoxSizer* actionsPanelSizer = new wxBoxSizer(wxHORIZONTAL);
+  //actionsGrid Sizer
+  wxFlexGridSizer* actionsGridSizer = new wxFlexGridSizer(2, 2, 9, 15);
+
+  wxButton* executeScriptbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_COMMAND, _T("Execute Script"));
+  executeScriptbt->SetToolTip(wxT("Execute the BBS file using bbi."));
+  actionsGridSizer->Add(executeScriptbt, 1, wxALL | wxEXPAND, 5);
+  wxButton* editScriptbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FILE, _T("Edit File"));
+  editScriptbt->SetToolTip(wxT("Edit the BBS file in the default text editor."));
+    actionsGridSizer->Add(editScriptbt, 1, wxALL | wxEXPAND, 5);
+  wxButton* openFolderbt = new wxButton(actionsPanel, ID_BUTTON_OPEN_FOLDER, _T("Open Containing Folder"));
+  openFolderbt->SetToolTip(wxT("Open the folder where the BBS file is located in the file explorer."));
+  actionsGridSizer->Add(openFolderbt, 1, wxALL | wxEXPAND, 5);
+
+  actionsGridSizer->AddGrowableCol(0,1);
+  actionsGridSizer->AddGrowableCol(1,1);
+
+  actionsPanelSizer->Add(actionsGridSizer, 1, wxEXPAND, 0);
+  actionsPanel->SetSizer(actionsPanelSizer);
+  actionsPanelSizer->Fit(actionsPanel);
+  actionsBox->Add(actionsPanel, 1, wxEXPAND);
+  sizer -> Add(actionsBox, 0, wxEXPAND | wxALL, 10);
+
+  //Assign sizer
+  SetSizer(sizer);
+  sizer->SetSizeHints(this);
+}
+
+void wxCDMBBSFileDescriptionPanel::OnBtnReturn(wxHyperlinkEvent& event)
+{
+  std::vector<modelCDMIProjectTreeNode*> parents = this->bbsFile->GetParents();
+  std::string parentURL = crea::wx2std(((wxHyperlinkCtrl*)event.GetEventObject())->GetURL());
+  //std::cout << parentURL << std::endl;
+  for (int i = 0; i < (int)(parents.size()); i++)
+    {
+      if (parents[i]->GetPath() == parentURL)
+        {
+          wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_DISPLAY_CHANGED);
+          newEvent->SetClientData(parents[i]);
+          newEvent->SetId(0);
+          wxPostEvent(this->GetParent(), *newEvent);
+        }
+    }
+}
+
+void wxCDMBBSFileDescriptionPanel::OnBtnOpenInEditor(wxCommandEvent& event)
+{
+  std::string* result;
+  if(!this->bbsFile->OpenFile(result))
+    wxMessageBox(crea::std2wx(*result),_T("Open BBS File - Error!"),wxOK | wxICON_ERROR);
+}
+
+void
+wxCDMBBSFileDescriptionPanel::OnBtnOpenInBBI(wxCommandEvent& event)
+{
+  std::string* result;
+  std::string params = "-g";
+  if(!this->bbsFile->ExecuteFile(result, params))
+    {
+      wxMessageBox(crea::std2wx(*result),_T("Execute BBS File - Error!"),wxOK | wxICON_ERROR);
+    }
+}
+
+void wxCDMBBSFileDescriptionPanel::OnBtnOpenFolder(wxCommandEvent& event)
+{
+  std::string* result;
+  if(!this->bbsFile->OpenInFileExplorer(result))
+    wxMessageBox(crea::std2wx(*result),_T("Open Folder - Error!"),wxOK | wxICON_ERROR);
+}
diff --git a/lib/creaDevManagerLib/wxCDMBBSFileDescriptionPanel.h b/lib/creaDevManagerLib/wxCDMBBSFileDescriptionPanel.h
new file mode 100644 (file)
index 0000000..9319407
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+/*
+ * wxCDMBBSFileDescriptionPanel.h
+ *
+ *  Created on: Jun 27, 2012
+ *      Author: Daniel Felipe Gonzalez Obando
+ */
+
+#ifndef WXCDMBBSFILEDESCRIPTIONPANEL_H_
+#define WXCDMBBSFILEDESCRIPTIONPANEL_H_
+
+#include <creaWx.h>
+#include <wx/hyperlink.h>
+
+#include "modelCDMBBSFile.h"
+
+/**
+ * BBS File description panel. Shows the file properties and the available actions for it.
+ */
+class wxCDMBBSFileDescriptionPanel : public wxScrolledWindow
+{
+  DECLARE_EVENT_TABLE()
+public:
+  /**
+   * BBS File description panel Constructor.
+   * @param parent Parent window reference.
+   * @param bbsfile BBSFile class reference.
+   * @param id Panel ID. By default -1.
+   * @param caption Panel label. By default "Description Frame".
+   * @param pos Panel position. By default wxDefaultPosition.
+   * @param size Panel size. By default wxDefaultSize.
+   * @param style Panel style. By default wxDEFAULT_FRAME_STYLE.
+   */
+  wxCDMBBSFileDescriptionPanel(
+      wxWindow* parent,
+      modelCDMBBSFile* bbsfile,
+      wxWindowID id = -1,
+      const wxString& caption = _("Description Frame"),
+      const wxPoint& pos = wxDefaultPosition,
+      const wxSize& size = wxDefaultSize,
+      long style = wxDEFAULT_FRAME_STYLE
+  );
+
+  /**
+   * Destructor.
+   */
+  ~wxCDMBBSFileDescriptionPanel();
+
+  /**
+   * BBS File description panel Constructor.
+   * @param parent Parent window reference.
+   * @param bbsfile BBSFile class reference.
+   * @param id Panel ID. By default -1.
+   * @param caption Panel label. By default "Description Frame".
+   * @param pos Panel position. By default wxDefaultPosition.
+   * @param size Panel size. By default wxDefaultSize.
+   * @param style Panel style. By default wxDEFAULT_FRAME_STYLE.
+   * @return True if the creation was successful.
+   */
+  bool Create(
+      wxWindow* parent,
+      modelCDMBBSFile* bbsfile,
+      wxWindowID id = -1,
+      const wxString& caption = _("Description Frame"),
+      const wxPoint& pos = wxDefaultPosition,
+      const wxSize& size = wxDefaultSize,
+      long style = wxDEFAULT_FRAME_STYLE
+  );
+
+  /**
+   * Creates all the controls in the panel (property and action controls).
+   */
+  void CreateControls();
+
+private:
+  /**
+   * BBS file described.
+   */
+  modelCDMBBSFile* bbsFile;
+
+  //handlers
+protected:
+  /**
+   * Handles when a return link is pressed.
+   * @param event Has the link reference to know where to return
+   */
+  void OnBtnReturn(wxHyperlinkEvent& event);
+  /**
+   * Handles when the open file in text editor button is pressed.
+   */
+  void OnBtnOpenInEditor(wxCommandEvent& event);
+  /**
+   * Handles when the open file in bbi button is pressed.
+   */
+  void OnBtnOpenInBBI(wxCommandEvent& event);
+  /**
+   * Handles when the open containing folder button is pressed.
+   */
+  void OnBtnOpenFolder(wxCommandEvent& event);
+};
+
+#endif /* WXCDMBBSFILEDESCRIPTIONPANEL_H_ */
index 6ef4155e2243cd2615bb1ceac5385b89985559e7..e8d28c522ca75ef4c83c79f96b1cfca297dc5da6 100755 (executable)
@@ -51,6 +51,7 @@
 #include "wxCDMLibraryDescriptionPanel.h"
 #include "wxCDMPackageDescriptionPanel.h"
 #include "wxCDMBlackBoxDescriptionPanel.h"
+#include "wxCDMBBSFileDescriptionPanel.h"
 #include "wxCDMCodeFileDescriptionPanel.h"
 #include "wxCDMCMakeListsDescriptionPanel.h"
 #include "wxCDMFolderDescriptionPanel.h"
@@ -1022,14 +1023,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                                         }
                                       else
                                         {
-                                          //folder
-                                          modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
-                                          if(elementFolder != NULL)
+                                          //BBSFile
+                                          modelCDMBBSFile* elementBBSFile = dynamic_cast<modelCDMBBSFile*>(element);
+                                          if(elementBBSFile != NULL)
                                             {
                                               //create element description
-                                              description = new wxCDMFolderDescriptionPanel(
+                                              description = new wxCDMBBSFileDescriptionPanel(
                                                   this,
-                                                  elementFolder,
+                                                  elementBBSFile,
                                                   ID_WINDOW_PROPERTIES,
                                                   wxT("Description Panel"),
                                                   wxDefaultPosition,
@@ -1039,14 +1040,14 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                                             }
                                           else
                                             {
-                                              //file
-                                              modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
-                                              if(elementFile != NULL)
+                                              //folder
+                                              modelCDMFolder* elementFolder = dynamic_cast<modelCDMFolder*>(element);
+                                              if(elementFolder != NULL)
                                                 {
                                                   //create element description
-                                                  description = new wxCDMFileDescriptionPanel(
+                                                  description = new wxCDMFolderDescriptionPanel(
                                                       this,
-                                                      elementFile,
+                                                      elementFolder,
                                                       ID_WINDOW_PROPERTIES,
                                                       wxT("Description Panel"),
                                                       wxDefaultPosition,
@@ -1056,17 +1057,35 @@ void wxCDMMainFrame::OnTreeSelectionChanged(wxTreeEvent& event)
                                                 }
                                               else
                                                 {
-
-                                                  //main if not any
-                                                  //create element description
-                                                  description = new wxCDMMainDescriptionPanel(
-                                                      this,
-                                                      ID_WINDOW_PROPERTIES,
-                                                      wxT("Description Panel"),
-                                                      wxDefaultPosition,
-                                                      wxSize(600, 400),
-                                                      0
-                                                  );
+                                                  //file
+                                                  modelCDMFile* elementFile = dynamic_cast<modelCDMFile*>(element);
+                                                  if(elementFile != NULL)
+                                                    {
+                                                      //create element description
+                                                      description = new wxCDMFileDescriptionPanel(
+                                                          this,
+                                                          elementFile,
+                                                          ID_WINDOW_PROPERTIES,
+                                                          wxT("Description Panel"),
+                                                          wxDefaultPosition,
+                                                          wxSize(600, 400),
+                                                          0
+                                                      );
+                                                    }
+                                                  else
+                                                    {
+
+                                                      //main if not any
+                                                      //create element description
+                                                      description = new wxCDMMainDescriptionPanel(
+                                                          this,
+                                                          ID_WINDOW_PROPERTIES,
+                                                          wxT("Description Panel"),
+                                                          wxDefaultPosition,
+                                                          wxSize(600, 400),
+                                                          0
+                                                      );
+                                                    }
                                                 }
                                             }
                                         }
index 653397d83945c412c45a3eb8e3ed9fca755768b0..6007d9434e23ecb5fdaed1a530c366e0338bdabd 100755 (executable)
@@ -44,6 +44,7 @@
 #include "images/AIcon20.xpm"
 #include "images/ApIcon20.xpm"
 #include "images/BBIcon20.xpm"
+#include "images/BBSIcon20.xpm"
 #include "images/CIcon20.xpm"
 #include "images/CFIcon20.xpm"
 #include "images/CMIcon20.xpm"
@@ -89,6 +90,7 @@ bool wxCDMProjectsTreeCtrl::Create(
   this->ID_AIcon = images->Add(wxIcon(AIcon20));
   this->ID_ApIcon = images->Add(wxIcon(ApIcon20));
   this->ID_BBIcon = images->Add(wxIcon(BBIcon20));
+  this->ID_BBSIcon = images->Add(wxIcon(BBSIcon20));
   this->ID_Cicon = images->Add(wxIcon(CIcon20));
   this->ID_CMIcon = images->Add(wxIcon(CMIcon20));
   this->ID_FdIcon = images->Add(wxIcon(FdIcon20));
@@ -219,21 +221,29 @@ int wxCDMProjectsTreeCtrl::GetIconId(modelCDMIProjectTreeNode* node)
                                     }
                                   else
                                     {
-                                      element = dynamic_cast<modelCDMFolder*>(node);
+                                      element = dynamic_cast<modelCDMBBSFile*>(node);
                                       if(element != NULL)
                                         {
-                                          return this->ID_FdIcon;
+                                          return this->ID_BBSIcon;
                                         }
                                       else
                                         {
-                                          element = dynamic_cast<modelCDMFile*>(node);
+                                          element = dynamic_cast<modelCDMFolder*>(node);
                                           if(element != NULL)
                                             {
-                                              return this->ID_FlIcon;
+                                              return this->ID_FdIcon;
                                             }
                                           else
                                             {
-                                              return this->ID_Cicon;
+                                              element = dynamic_cast<modelCDMFile*>(node);
+                                              if(element != NULL)
+                                                {
+                                                  return this->ID_FlIcon;
+                                                }
+                                              else
+                                                {
+                                                  return this->ID_Cicon;
+                                                }
                                             }
                                         }
                                     }
index 8d63e58dd58187eb58e98610874dfafe2e744ca4..a29745b93bbf1c59630d3dd52074a4b0319e857a 100755 (executable)
@@ -113,6 +113,10 @@ private:
    * BB Icon ID.
    */
   int ID_BBIcon;
+  /**
+   * BBS Icon ID.
+   */
+  int ID_BBSIcon;
   /**
    * C Icon ID.
    */