diff --git a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.cpp b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.cpp index 04eb0c1fcf..6cf667f971 100644 --- a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.cpp +++ b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.cpp @@ -1,164 +1,186 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "CommandLineModulesPreferencesPage.h" #include "CommandLineModulesViewConstants.h" #include #include #include #include +#include +#include #include +#include #include #include #include "QmitkDirectoryListWidget.h" #include "QmitkFileListWidget.h" //----------------------------------------------------------------------------- CommandLineModulesPreferencesPage::CommandLineModulesPreferencesPage() : m_MainControl(0) , m_TemporaryDirectory(0) , m_ModulesDirectories(0) , m_ModulesFiles(0) , m_LoadFromHomeDir(0) , m_LoadFromCurrentDir(0) , m_LoadFromApplicationDir(0) , m_LoadFromAutoLoadPathDir(0) +, m_ValidationMode(0) , m_CLIPreferencesNode(0) { } //----------------------------------------------------------------------------- CommandLineModulesPreferencesPage::~CommandLineModulesPreferencesPage() { } //----------------------------------------------------------------------------- void CommandLineModulesPreferencesPage::Init(berry::IWorkbench::Pointer ) { } //----------------------------------------------------------------------------- void CommandLineModulesPreferencesPage::CreateQtControl(QWidget* parent) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); std::string id = "/" + CommandLineModulesViewConstants::VIEW_ID; m_CLIPreferencesNode = prefService->GetSystemPreferences()->Node(id); m_MainControl = new QWidget(parent); m_TemporaryDirectory = new ctkDirectoryButton(m_MainControl); m_TemporaryDirectory->setCaption("Select a directory for temporary files ... "); m_ModulesDirectories = new QmitkDirectoryListWidget(m_MainControl); m_ModulesDirectories->m_Label->setText("Select directories to scan:"); m_ModulesFiles = new QmitkFileListWidget(m_MainControl); m_ModulesFiles->m_Label->setText("Select additional executables:"); m_DebugOutput = new QCheckBox(m_MainControl); m_LoadFromApplicationDir = new QCheckBox(m_MainControl); m_LoadFromAutoLoadPathDir = new QCheckBox(m_MainControl); m_LoadFromHomeDir = new QCheckBox(m_MainControl); m_LoadFromCurrentDir = new QCheckBox(m_MainControl); + m_ValidationMode = new QComboBox(m_MainControl); + m_ValidationMode->addItem("strict", ctkCmdLineModuleManager::STRICT_VALIDATION); + m_ValidationMode->addItem("none", ctkCmdLineModuleManager::SKIP_VALIDATION); + m_ValidationMode->addItem("weak", ctkCmdLineModuleManager::WEAK_VALIDATION); + m_ValidationMode->setCurrentIndex(0); QFormLayout *formLayout = new QFormLayout; formLayout->addRow("scan home directory:", m_LoadFromHomeDir); formLayout->addRow("scan current directory:", m_LoadFromCurrentDir); formLayout->addRow("scan installation directory:", m_LoadFromApplicationDir); formLayout->addRow("scan CTK_MODULE_LOAD_PATH:", m_LoadFromAutoLoadPathDir); formLayout->addRow("additional module directories:", m_ModulesDirectories); formLayout->addRow("additional modules:", m_ModulesFiles); formLayout->addRow("temporary directory:", m_TemporaryDirectory); formLayout->addRow("debug output:", m_DebugOutput); + formLayout->addRow("XML validation mode:", m_ValidationMode); + m_MainControl->setLayout(formLayout); this->Update(); } //----------------------------------------------------------------------------- QWidget* CommandLineModulesPreferencesPage::GetQtControl() const { return m_MainControl; } //----------------------------------------------------------------------------- std::string CommandLineModulesPreferencesPage::ConvertToStdString(const QStringList& list) { std::string output; for (int i = 0; i < list.count(); i++) { QString path = list[i] + ";"; output += path.toStdString(); } return output; } //----------------------------------------------------------------------------- bool CommandLineModulesPreferencesPage::PerformOk() { m_CLIPreferencesNode->Put(CommandLineModulesViewConstants::TEMPORARY_DIRECTORY_NODE_NAME, m_TemporaryDirectory->directory().toStdString()); m_CLIPreferencesNode->PutBool(CommandLineModulesViewConstants::DEBUG_OUTPUT_NODE_NAME, m_DebugOutput->isChecked()); m_CLIPreferencesNode->PutBool(CommandLineModulesViewConstants::LOAD_FROM_APPLICATION_DIR, m_LoadFromApplicationDir->isChecked()); m_CLIPreferencesNode->PutBool(CommandLineModulesViewConstants::LOAD_FROM_HOME_DIR, m_LoadFromHomeDir->isChecked()); m_CLIPreferencesNode->PutBool(CommandLineModulesViewConstants::LOAD_FROM_CURRENT_DIR, m_LoadFromCurrentDir->isChecked()); m_CLIPreferencesNode->PutBool(CommandLineModulesViewConstants::LOAD_FROM_AUTO_LOAD_DIR, m_LoadFromAutoLoadPathDir->isChecked()); std::string paths = this->ConvertToStdString(m_ModulesDirectories->directories()); m_CLIPreferencesNode->Put(CommandLineModulesViewConstants::MODULE_DIRECTORIES_NODE_NAME, paths); std::string modules = this->ConvertToStdString(m_ModulesFiles->files()); m_CLIPreferencesNode->Put(CommandLineModulesViewConstants::MODULE_FILES_NODE_NAME, modules); + int currentValidationMode = m_CLIPreferencesNode->GetInt(CommandLineModulesViewConstants::XML_VALIDATION_MODE, 0); + if (currentValidationMode != m_ValidationMode->currentIndex()) + { + QMessageBox msgBox; + msgBox.setText("Changing the XML validation mode will require a restart of the application."); + msgBox.exec(); + } + + m_CLIPreferencesNode->PutInt(CommandLineModulesViewConstants::XML_VALIDATION_MODE, m_ValidationMode->currentIndex()); return true; } //----------------------------------------------------------------------------- void CommandLineModulesPreferencesPage::PerformCancel() { } //----------------------------------------------------------------------------- void CommandLineModulesPreferencesPage::Update() { QString fallbackTmpDir = QDir::tempPath(); m_TemporaryDirectory->setDirectory(QString::fromStdString(m_CLIPreferencesNode->Get(CommandLineModulesViewConstants::TEMPORARY_DIRECTORY_NODE_NAME, fallbackTmpDir.toStdString()))); m_DebugOutput->setChecked(m_CLIPreferencesNode->GetBool(CommandLineModulesViewConstants::DEBUG_OUTPUT_NODE_NAME, false)); m_LoadFromApplicationDir->setChecked(m_CLIPreferencesNode->GetBool(CommandLineModulesViewConstants::LOAD_FROM_APPLICATION_DIR, false)); m_LoadFromHomeDir->setChecked(m_CLIPreferencesNode->GetBool(CommandLineModulesViewConstants::LOAD_FROM_HOME_DIR, false)); m_LoadFromCurrentDir->setChecked(m_CLIPreferencesNode->GetBool(CommandLineModulesViewConstants::LOAD_FROM_CURRENT_DIR, false)); m_LoadFromAutoLoadPathDir->setChecked(m_CLIPreferencesNode->GetBool(CommandLineModulesViewConstants::LOAD_FROM_AUTO_LOAD_DIR, false)); QString paths = QString::fromStdString(m_CLIPreferencesNode->Get(CommandLineModulesViewConstants::MODULE_DIRECTORIES_NODE_NAME, "")); QStringList directoryList = paths.split(";", QString::SkipEmptyParts); m_ModulesDirectories->setDirectories(directoryList); QString files = QString::fromStdString(m_CLIPreferencesNode->Get(CommandLineModulesViewConstants::MODULE_FILES_NODE_NAME, "")); QStringList fileList = files.split(";", QString::SkipEmptyParts); m_ModulesFiles->setFiles(fileList); + + m_ValidationMode->setCurrentIndex(m_CLIPreferencesNode->GetInt(CommandLineModulesViewConstants::XML_VALIDATION_MODE, 0)); } diff --git a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.h b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.h index 9aa26fc97f..8543e08c30 100644 --- a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.h +++ b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesPreferencesPage.h @@ -1,98 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef COMMANDLINEMODULESPREFERENCESPAGE_H #define COMMANDLINEMODULESPREFERENCESPAGE_H #include "berryIQtPreferencePage.h" #include "berryIPreferences.h" #include class QWidget; class QCheckBox; +class QComboBox; class QmitkDirectoryListWidget; class QmitkFileListWidget; class ctkDirectoryButton; /** * \class CommandLineModulesPreferencesPage * \brief Preference page for CommandLineModulesView * \author Matt Clarkson (m.clarkson@ucl.ac.uk) * \ingroup org_mitk_gui_qt_cli_internal */ class CommandLineModulesPreferencesPage : public QObject, public berry::IQtPreferencePage { Q_OBJECT Q_INTERFACES(berry::IPreferencePage) public: CommandLineModulesPreferencesPage(); ~CommandLineModulesPreferencesPage(); /** * \brief Called by framework to initialise this preference page, but currently does nothing. * \param workbench The workbench. */ void Init(berry::IWorkbench::Pointer workbench); /** * \brief Called by framework to create the GUI, and connect signals and slots. * \param widget The Qt widget that acts as parent to all GUI components, as this class itself is not derived from QWidget. */ void CreateQtControl(QWidget* widget); /** * \brief Required by framework to get hold of the GUI. * \return QWidget* the top most QWidget for the GUI. */ QWidget* GetQtControl() const; /** * \see IPreferencePage::PerformOk */ virtual bool PerformOk(); /** * \see IPreferencePage::PerformCancel */ virtual void PerformCancel(); /** * \see IPreferencePage::Update */ virtual void Update(); public slots: protected: QWidget *m_MainControl; QCheckBox *m_DebugOutput; ctkDirectoryButton *m_TemporaryDirectory; QmitkDirectoryListWidget *m_ModulesDirectories; QmitkFileListWidget *m_ModulesFiles; QCheckBox *m_LoadFromHomeDir; QCheckBox *m_LoadFromCurrentDir; QCheckBox *m_LoadFromApplicationDir; QCheckBox *m_LoadFromAutoLoadPathDir; + QComboBox *m_ValidationMode; berry::IPreferences::Pointer m_CLIPreferencesNode; private: std::string ConvertToStdString(const QStringList& list); }; #endif // COMMANDLINEMODULESPREFERENCESPAGE_H diff --git a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.cpp b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.cpp index 3f496cffdb..8e6667d096 100644 --- a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.cpp +++ b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.cpp @@ -1,318 +1,345 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include #include // Qmitk #include "CommandLineModulesView.h" #include "CommandLineModulesViewConstants.h" #include "CommandLineModulesViewControls.h" #include "CommandLineModulesPreferencesPage.h" #include "QmitkCmdLineModuleFactoryGui.h" #include "QmitkCmdLineModuleProgressWidget.h" // Qt #include #include #include #include #include #include // CTK #include #include #include #include #include #include #include //----------------------------------------------------------------------------- CommandLineModulesView::CommandLineModulesView() : m_Controls(NULL) , m_Parent(NULL) , m_Layout(NULL) , m_ModuleManager(NULL) , m_ModuleBackend(NULL) , m_DirectoryWatcher(NULL) , m_TemporaryDirectoryName("") , m_DebugOutput(false) { } //----------------------------------------------------------------------------- CommandLineModulesView::~CommandLineModulesView() { if (m_ModuleManager != NULL) { delete m_ModuleManager; } if (m_ModuleBackend != NULL) { delete m_ModuleBackend; } if (m_DirectoryWatcher != NULL) { delete m_DirectoryWatcher; } if (m_Layout != NULL) { delete m_Layout; } } //----------------------------------------------------------------------------- void CommandLineModulesView::SetFocus() { this->m_Controls->m_ComboBox->setFocus(); } //----------------------------------------------------------------------------- void CommandLineModulesView::CreateQtPartControl( QWidget *parent ) { + m_Parent = parent; + if (!m_Controls) { // We create CommandLineModulesViewControls, which derives from the Qt generated class. m_Controls = new CommandLineModulesViewControls(parent); // Create a layout to contain a display of QmitkCmdLineModuleProgressWidget. m_Layout = new QVBoxLayout(m_Controls->m_GeneratedGuiWidget); m_Layout->setContentsMargins(0,0,0,0); m_Layout->setSpacing(0); // This must be done independent of other preferences, as we need it before // we create the ctkCmdLineModuleManager to initialise the Cache. this->RetrieveAndStoreTemporaryDirectoryPreferenceValues(); + this->RetrieveAndStoreValidationMode(); + + qDebug() << "CommandLineModulesView: Creating ctkCmdLineModuleManager with mode=" << m_ValidationMode << ", temp directory=" << m_TemporaryDirectoryName; // Start to create the command line module infrastructure. m_ModuleBackend = new ctkCmdLineModuleBackendLocalProcess(); - m_ModuleManager = new ctkCmdLineModuleManager(ctkCmdLineModuleManager::STRICT_VALIDATION, m_TemporaryDirectoryName); + m_ModuleManager = new ctkCmdLineModuleManager(m_ValidationMode, m_TemporaryDirectoryName); // Set the main object, the ctkCmdLineModuleManager onto all the objects that need it. m_Controls->m_ComboBox->SetManager(m_ModuleManager); m_DirectoryWatcher = new ctkCmdLineModuleDirectoryWatcher(m_ModuleManager); m_ModuleManager->registerBackend(m_ModuleBackend); // Setup the remaining preferences. this->RetrieveAndStorePreferenceValues(); // Connect signals to slots after we have set up GUI. connect(this->m_Controls->m_RunButton, SIGNAL(pressed()), this, SLOT(OnRunButtonPressed())); connect(this->m_Controls->m_RestoreDefaults, SIGNAL(pressed()), this, SLOT(OnRestoreButtonPressed())); connect(this->m_Controls->m_ComboBox, SIGNAL(actionChanged(QAction*)), this, SLOT(OnActionChanged(QAction*))); } } //----------------------------------------------------------------------------- berry::IBerryPreferences::Pointer CommandLineModulesView::RetrievePreferences() { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); assert( prefService ); std::string id = "/" + CommandLineModulesViewConstants::VIEW_ID; berry::IBerryPreferences::Pointer prefs = (prefService->GetSystemPreferences()->Node(id)) .Cast(); assert( prefs ); return prefs; } //----------------------------------------------------------------------------- void CommandLineModulesView::RetrieveAndStoreTemporaryDirectoryPreferenceValues() { berry::IBerryPreferences::Pointer prefs = this->RetrievePreferences(); QString fallbackTmpDir = QDir::tempPath(); m_TemporaryDirectoryName = QString::fromStdString( prefs->Get(CommandLineModulesViewConstants::TEMPORARY_DIRECTORY_NODE_NAME, fallbackTmpDir.toStdString())); } +//----------------------------------------------------------------------------- +void CommandLineModulesView::RetrieveAndStoreValidationMode() +{ + berry::IBerryPreferences::Pointer prefs = this->RetrievePreferences(); + + int value = prefs->GetInt(CommandLineModulesViewConstants::XML_VALIDATION_MODE, 0); + if (value == 0) + { + m_ValidationMode = ctkCmdLineModuleManager::STRICT_VALIDATION; + } + else if (value == 1) + { + m_ValidationMode = ctkCmdLineModuleManager::SKIP_VALIDATION; + } + else + { + m_ValidationMode = ctkCmdLineModuleManager::WEAK_VALIDATION; + } +} + + //----------------------------------------------------------------------------- void CommandLineModulesView::RetrieveAndStorePreferenceValues() { berry::IBerryPreferences::Pointer prefs = this->RetrievePreferences(); // Get the flag for debug output, useful when parsing all the XML. m_DebugOutput = prefs->GetBool(CommandLineModulesViewConstants::DEBUG_OUTPUT_NODE_NAME, false); m_DirectoryWatcher->setDebug(m_DebugOutput); bool loadApplicationDir = prefs->GetBool(CommandLineModulesViewConstants::LOAD_FROM_APPLICATION_DIR, false); bool loadHomeDir = prefs->GetBool(CommandLineModulesViewConstants::LOAD_FROM_HOME_DIR, false); bool loadCurrentDir = prefs->GetBool(CommandLineModulesViewConstants::LOAD_FROM_CURRENT_DIR, false); bool loadAutoLoadDir = prefs->GetBool(CommandLineModulesViewConstants::LOAD_FROM_AUTO_LOAD_DIR, false); // Get some default application paths. // Here we can use the preferences to set up the builder, ctkCmdLineModuleDefaultPathBuilder builder; builder.setLoadFromApplicationDir(loadApplicationDir); builder.setLoadFromHomeDir(loadHomeDir); builder.setLoadFromCurrentDir(loadCurrentDir); builder.setLoadFromCtkModuleLoadPath(loadAutoLoadDir); // and then we ask the builder to set up the paths. QStringList defaultPaths = builder.build(); // We get additional directory paths from preferences. QString pathString = QString::fromStdString(prefs->Get(CommandLineModulesViewConstants::MODULE_DIRECTORIES_NODE_NAME, "")); QStringList additionalPaths = pathString.split(";", QString::SkipEmptyParts); // Combine the sets of directory paths. QStringList totalPaths; totalPaths << defaultPaths; totalPaths << additionalPaths; QString additionalModulesString = QString::fromStdString(prefs->Get(CommandLineModulesViewConstants::MODULE_FILES_NODE_NAME, "")); QStringList additionalModules = additionalModulesString.split(";", QString::SkipEmptyParts); // OnPreferencesChanged can be called for each preference in a dialog box, so // when you hit "OK", it is called repeatedly, whereas we want to only call these only once. if (this->m_DirectoryWatcher->directories() != totalPaths) { m_DirectoryWatcher->setDirectories(totalPaths); } if (this->m_DirectoryWatcher->additionalModules() != additionalModules) { m_DirectoryWatcher->setAdditionalModules(additionalModules); } } //----------------------------------------------------------------------------- void CommandLineModulesView::OnPreferencesChanged(const berry::IBerryPreferences* /*prefs*/) { this->RetrieveAndStoreTemporaryDirectoryPreferenceValues(); + this->RetrieveAndStoreValidationMode(); this->RetrieveAndStorePreferenceValues(); } //----------------------------------------------------------------------------- ctkCmdLineModuleReference CommandLineModulesView::GetReferenceByFullName(QString fullName) { ctkCmdLineModuleReference result; QList references = this->m_ModuleManager->moduleReferences(); ctkCmdLineModuleReference ref; foreach(ref, references) { QString name = ref.description().category() + "." + ref.description().title(); if (name == fullName) { result = ref; } } return result; } //----------------------------------------------------------------------------- QmitkCmdLineModuleProgressWidget* CommandLineModulesView::GetWidget(const int& indexNumber) { QmitkCmdLineModuleProgressWidget *result = NULL; QLayoutItem *layoutItem = m_Layout->itemAt(indexNumber); if (layoutItem != NULL) { QWidgetItem *widgetItem = dynamic_cast(layoutItem); if (widgetItem != NULL) { result = dynamic_cast(widgetItem->widget()); } } return result; } //----------------------------------------------------------------------------- void CommandLineModulesView::OnActionChanged(QAction* action) { QString fullName = action->objectName(); ctkCmdLineModuleReference ref = this->GetReferenceByFullName(fullName); if (ref) { QmitkCmdLineModuleProgressWidget *widget = this->GetWidget(0); if (widget == NULL || widget->IsStarted()) { // Create new widget. QmitkCmdLineModuleProgressWidget* newWidget = new QmitkCmdLineModuleProgressWidget(m_Controls->m_GeneratedGuiWidget); // Configure new widget. newWidget->SetTemporaryDirectory(this->m_TemporaryDirectoryName); newWidget->SetDataStorage(this->GetDataStorage()); newWidget->SetManager(this->m_ModuleManager); newWidget->SetModule(ref); // Add new widget to the top (nearest top of screen) of layout. m_Layout->insertWidget(0, newWidget); } else { // If the first widget has not even started, we can simply replace the GUI, // with the correct GUI for the newly selected command line module. // Note: At the moment, I'm getting 3 signals instead of 1 ??? if (widget->GetFullName() != fullName) { widget->SetModule(ref); } } } } //----------------------------------------------------------------------------- void CommandLineModulesView::OnRestoreButtonPressed() { QmitkCmdLineModuleProgressWidget *widget = this->GetWidget(0); if (widget != NULL && !widget->IsStarted()) { widget->Reset(); } } //----------------------------------------------------------------------------- void CommandLineModulesView::OnRunButtonPressed() { QmitkCmdLineModuleProgressWidget *widget = this->GetWidget(0); if (widget != NULL && !widget->IsStarted()) { widget->Run(); } } diff --git a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.h b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.h index c92d134d65..bdb38caa2c 100644 --- a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.h +++ b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesView.h @@ -1,176 +1,185 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef CommandLineModulesView_h #define CommandLineModulesView_h #include #include #include #include #include #include +#include -class ctkCmdLineModuleManager; class ctkCmdLineModuleBackendLocalProcess; class ctkCmdLineModuleDirectoryWatcher; class CommandLineModulesViewControls; class QmitkCmdLineModuleProgressWidget; class QAction; class QVBoxLayout; namespace berry { class IBerryPreferences; } /*! * \class CommandLineModulesView * \brief Provides basic GUI interface to the CTK command line modules. * \author Matt Clarkson (m.clarkson@ucl.ac.uk) * \ingroup org_mitk_gui_qt_cli_internal * \sa QmitkAbstractView */ class CommandLineModulesView : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: CommandLineModulesView(); virtual ~CommandLineModulesView(); /** * \brief Main method, called by framework to create the GUI at the right time. * \param parent The parent QWidget, as this class itself is not a QWidget subclass. */ virtual void CreateQtPartControl(QWidget *parent); /** * \brief Called by the framework to indicate that the preferences have changed. * \param prefs not used, as we call RetrievePreferenceValues(). */ void OnPreferencesChanged(const berry::IBerryPreferences* prefs); protected Q_SLOTS: /** * \brief Called when the ctkMenuComboBox has the menu selection changed, * and causes the corresponding GUI to be displayed. */ void OnActionChanged(QAction*); /** * \brief Slot that is called when the restore defaults button is pressed, * to reset the current GUI form to the default values, if the XML specifies them. */ void OnRestoreButtonPressed(); /** * \brief Slot that is called when the Run button (green arrow) is pressed, * to run the current module. */ void OnRunButtonPressed(); protected: /** * \brief Called by framework to set the focus on the right widget * when this view has focus, so currently, thats the combo box. */ virtual void SetFocus(); private: /** * \brief Called on startup and by OnPreferencesChanged to load all * preferences except the temporary folder into member variables. */ void RetrieveAndStorePreferenceValues(); /** * \brief Called on startup and by OnPreferencesChanged to load the temporary folder * preference into member variable m_TemporaryDirectoryName. */ void RetrieveAndStoreTemporaryDirectoryPreferenceValues(); + /** + * \brief Called on startup and by OnPreferencesChanged to set the validation mode, but will require a restart. + */ + void RetrieveAndStoreValidationMode(); /** * \brief Called to get hold of the actual preferences node. */ berry::IBerryPreferences::Pointer RetrievePreferences(); /** * \brief Search all modules for the one matching the given identifier. * \param fullName The "fullName" is the . from the XML. * \return ctkCmdLineModuleReference the reference corresponding to the fullName, or an invalid reference if non found. */ ctkCmdLineModuleReference GetReferenceByFullName(QString fullName); /** * \brief Returns the QmitkCmdLineModuleProgressWidget from the layout. * \param indexNumber the number of the widget in the layout, starting at zero. */ QmitkCmdLineModuleProgressWidget* GetWidget(const int& indexNumber); /** * \brief The GUI controls contain a reset and run button, and a QWidget container, and the GUI component * for each command line module is added to the QWidget dynamically at run time. */ CommandLineModulesViewControls *m_Controls; /** * \brief We store the parent, passed in via CommandLineModulesView::CreateQtPartControl, * as this class itself is not a QWidget. */ QWidget *m_Parent; /** * \brief We keep a local layout, and arrange a display of QmitkCmdLineModuleProgressWidget, * where each QmitkCmdLineModuleProgressWidget represents a single running job. */ QVBoxLayout *m_Layout; /** * \brief The manager is responsible for loading and instantiating command line modules. */ ctkCmdLineModuleManager *m_ModuleManager; /** * \brief We are using a back-end that runs locally installed command line programs. */ ctkCmdLineModuleBackendLocalProcess *m_ModuleBackend; /** * \brief The ctkCmdLineModuleDirectoryWatcher maintains the list of directories * we are using to load modules, to provide automatic updates. */ ctkCmdLineModuleDirectoryWatcher *m_DirectoryWatcher; /** * \brief We store a temporary folder name, accessible via user preferences. */ QString m_TemporaryDirectoryName; + /** + * \brief We store the validation mode, accessisble via user preferences. + */ + ctkCmdLineModuleManager::ValidationMode m_ValidationMode; + /** * \brief Member variable, taken from preference page. */ bool m_DebugOutput; }; #endif // CommandLineModulesView_h diff --git a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.cpp b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.cpp index a6d09eb06f..25cf46be16 100644 --- a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.cpp +++ b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.cpp @@ -1,27 +1,27 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "CommandLineModulesViewConstants.h" const std::string CommandLineModulesViewConstants::VIEW_ID = "org.mitk.gui.qt.cli"; const std::string CommandLineModulesViewConstants::TEMPORARY_DIRECTORY_NODE_NAME = "temporary directory"; const std::string CommandLineModulesViewConstants::MODULE_DIRECTORIES_NODE_NAME = "module directories"; const std::string CommandLineModulesViewConstants::MODULE_FILES_NODE_NAME = "module files"; const std::string CommandLineModulesViewConstants::DEBUG_OUTPUT_NODE_NAME = "debug output"; const std::string CommandLineModulesViewConstants::LOAD_FROM_APPLICATION_DIR = "load from application dir"; const std::string CommandLineModulesViewConstants::LOAD_FROM_HOME_DIR = "load from home dir"; const std::string CommandLineModulesViewConstants::LOAD_FROM_CURRENT_DIR = "load from current dir"; const std::string CommandLineModulesViewConstants::LOAD_FROM_AUTO_LOAD_DIR = "load from auto-load dir"; - +const std::string CommandLineModulesViewConstants::XML_VALIDATION_MODE = "xml validation mode"; diff --git a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.h b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.h index b57e164ffc..02e4515385 100644 --- a/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.h +++ b/Plugins/org.mitk.gui.qt.cli/src/internal/CommandLineModulesViewConstants.h @@ -1,81 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) University College London (UCL). All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef CommandLineModulesViewConstants_h #define CommandLineModulesViewConstants_h #include <QString> #include <string> /** * \class CommandLineModulesViewConstants * \brief Structure to define a namespace for constants used privately within this view. * \author Matt Clarkson (m.clarkson@ucl.ac.uk) * \ingroup org_mitk_gui_qt_cli_internal */ struct CommandLineModulesViewConstants { /** * \brief The name of the preferences node containing the temporary directory. */ static const std::string TEMPORARY_DIRECTORY_NODE_NAME; /** * \brief The name of the preferences node containing the list of directories to scan. */ static const std::string MODULE_DIRECTORIES_NODE_NAME; /** * \brief The name of the preferences node containing the additional files to add to the module list. */ static const std::string MODULE_FILES_NODE_NAME; /** * \brief The name of the preferences node containing whether we are producing debug output. */ static const std::string DEBUG_OUTPUT_NODE_NAME; /** * \brief The name of the preferences node containing a boolean describing whether * we are loading modules from the application directory. */ static const std::string LOAD_FROM_APPLICATION_DIR; /** * \brief The name of the preferences node containing a boolean describing whether * we are loading modules from the users home directory. */ static const std::string LOAD_FROM_HOME_DIR; /** * \brief The name of the preferences node containing a boolean describing whether * we are loading modules from the applications current working directory. */ static const std::string LOAD_FROM_CURRENT_DIR; /** * \brief The name of the preferences node containing a boolean describing whether * we are loading modules from the directory specified in CTK_MODULE_LOAD_PATH. */ static const std::string LOAD_FROM_AUTO_LOAD_DIR; + /** + * \brief The name of the preferences node containing the validation mode. + */ + static const std::string XML_VALIDATION_MODE; + /** * \brief The View ID = org.mitk.gui.qt.cli, and should match that in plugin.xml. */ static const std::string VIEW_ID; }; #endif // CommandLineModulesViewConstants_h