+
+#include "ctkXnatSession.h"
+#include "ctkXnatLoginProfile.h"
+#include "ctkXnatException.h"
+
+using namespace berry;
+
+QmitkXnatConnectionPreferencePage::QmitkXnatConnectionPreferencePage()
+: m_MainControl(0)
+{
+
+}
+
+void QmitkXnatConnectionPreferencePage::Init(berry::IWorkbench::Pointer )
+{
+
+}
+
+void QmitkXnatConnectionPreferencePage::CreateQtControl(QWidget* parent)
+{
+ IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID);
+ berry::IPreferences::Pointer _XnatConnectionPreferencesNode = prefService->GetSystemPreferences()->Node("/XnatConnection");
+ m_XnatConnectionPreferencesNode = _XnatConnectionPreferencesNode;
+
+ m_LineEditors[1] = qMakePair(QString("Server Address"), new QLineEdit(""));
+ m_LineEditors[1].second->setObjectName("inHostAddress");
+ m_LineEditors[1].second->setToolTip("Examples:
"http://localhost:8080/xnat"
"http://central.xnat.org:80"
"https://xnat.myserver.de:443"
");
+
+ m_LineEditors[2] = qMakePair(QString("Username"), new QLineEdit(""));
+ m_LineEditors[2].second->setObjectName("inUser");
+
+ m_LineEditors[3] = qMakePair(QString("Password"), new QLineEdit(""));
+ m_LineEditors[3].second->setObjectName("inPassword");
+ m_LineEditors[3].second->setEchoMode(QLineEdit::Password);
+
+ m_LineEditors[4] = qMakePair(QString("Download Path"), new QLineEdit(""));
+ m_LineEditors[4].second->setObjectName("inDownloadPath");
+
+ m_MainControl = new QWidget(parent);
+
+ QGridLayout* layout = new QGridLayout;
+ int i = 0;
+ for (QMap >::iterator it = m_LineEditors.begin();
+ it != m_LineEditors.end(); ++it)
+ {
+ layout->addWidget(new QLabel(it.value().first), i,0);
+ layout->addWidget(it.value().second, i,1);
+ layout->setRowStretch(i,0);
+ ++i;
+ }
+ layout->setRowStretch(i+1,10);
+
+ m_MainControl->setLayout(layout);
+ this->Update();
+}
+
+QWidget* QmitkXnatConnectionPreferencePage::GetQtControl() const
+{
+ return m_MainControl;
+}
+
+bool QmitkXnatConnectionPreferencePage::PerformOk()
+{
+ IPreferences::Pointer _XnatConnectionPreferencesNode = m_XnatConnectionPreferencesNode.Lock();
+ if(_XnatConnectionPreferencesNode.IsNotNull())
+ {
+ // Regular Expression for uri and download path
+ QRegExp uriregex("^(https?)://([a-zA-Z0-9\\.]+):?([0-9]+)?(/[^ /]+)*$");
+ QRegExp downloadPathRegex("([/|\\]?[^/|^\\])+[/|\\]?");
+
+ QString keyString;
+ QString errString;
+ for (QMap >::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it)
+ {
+ keyString = it.value().second->text();
+
+ if(keyString.isEmpty())
+ {
+ if(it.value().first != QString("Download Path"))
+ {
+ errString += QString("No input for \"%1\"\n").arg(it.value().first);
+ }
+ }
+ else
+ {
+ if(it.value().first == QString("Server Address") && !uriregex.exactMatch(m_MainControl->findChild("inHostAddress")->text()))
+ {
+ errString += QString("No valid input for \"Server Address\"\n");
+ }
+ else if(it.value().first == QString("Download Path"))
+ {
+ if(!downloadPathRegex.exactMatch(m_MainControl->findChild("inDownloadPath")->text()))
+ {
+ errString += QString("No valid input for \"Download Path\"\n");
+ }
+ else
+ {
+ QString downloadPath = m_MainControl->findChild("inDownloadPath")->text();
+ if(downloadPath.contains('\\'))
+ {
+ if(!downloadPath.endsWith('\\'))
+ {
+ downloadPath += '\\';
+ }
+ }
+ else if(downloadPath.contains('/'))
+ {
+ if(!downloadPath.endsWith('/'))
+ {
+ downloadPath += '/';
+ }
+ }
+ m_MainControl->findChild("inDownloadPath")->setText(downloadPath);
+ }
+ }
+ }
+ }
+
+ if(!errString.isEmpty())
+ {
+ QMessageBox::critical(QApplication::activeWindow(), "Error", errString);
+ return false;
+ }
+ else
+ {
+ // Set up the session for the connection test
+ ctkXnatLoginProfile profile;
+ profile.setName("Default");
+ profile.setServerUrl(m_LineEditors[1].second->text());
+ profile.setUserName(m_LineEditors[2].second->text());
+ profile.setPassword(m_LineEditors[3].second->text());
+ profile.setDefault(true);
+ ctkXnatSession* session = new ctkXnatSession(profile);
+
+ // Testing the inputs by trying to create a session
+ try
+ {
+ session->open();
+ }
+ catch(const ctkXnatAuthenticationException& auth)
+ {
+ errString += QString("Test connection failed.\nAuthentication error: Wrong name or password.\nCode:\"%1\"").arg(auth.message());
+ delete session;
+ QMessageBox::critical(QApplication::activeWindow(), "Error", errString);
+ return false;
+ }
+ catch(const ctkException& e)
+ {
+ errString += QString("Test connection failed with error code:\n\"%1\"").arg(e.message());
+ delete session;
+ QMessageBox::critical(QApplication::activeWindow(), "Error", errString);
+ return false;
+ }
+ delete session;
+ }
+
+ // no error in the input
+ for (QMap >::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it)
+ _XnatConnectionPreferencesNode->Put(it.value().first.toStdString(), it.value().second->text().toStdString());
+
+ _XnatConnectionPreferencesNode->Flush();
+
+ return true;
+ }
+ return false;
+}
+
+void QmitkXnatConnectionPreferencePage::PerformCancel()
+{
+
+}
+
+void QmitkXnatConnectionPreferencePage::Update()
+{
+ IPreferences::Pointer _XnatConnectionPreferencesNode = m_XnatConnectionPreferencesNode.Lock();
+ if(_XnatConnectionPreferencesNode.IsNotNull())
+ {
+ for (QMap >::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it)
+ {
+ it.value().second->setText(QString::fromStdString(_XnatConnectionPreferencesNode->Get(it.value().first.toStdString(),
+ it.value().second->text().toStdString())));
+ }
+ }
+}
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.h
new file mode 100644
index 0000000000..54e3559226
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatConnectionPreferencePage.h
@@ -0,0 +1,67 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 QMITKXNATCONNECTIONPREFERENCEPAGE_H_
+#define QMITKXNATCONNECTIONPREFERENCEPAGE_H_
+
+#include "berryIQtPreferencePage.h"
+#include
+
+class QWidget;
+class QLineEdit;
+
+struct QmitkXnatConnectionPreferencePage : public QObject, public berry::IQtPreferencePage
+{
+ Q_OBJECT
+ Q_INTERFACES(berry::IPreferencePage)
+
+public:
+ QmitkXnatConnectionPreferencePage();
+
+ void Init(berry::IWorkbench::Pointer workbench);
+
+ void CreateQtControl(QWidget* widget);
+
+ QWidget* GetQtControl() const;
+
+ ///
+ /// \see IPreferencePage::PerformOk()
+ ///
+ virtual bool PerformOk();
+
+ ///
+ /// \see IPreferencePage::PerformCancel()
+ ///
+ virtual void PerformCancel();
+
+ ///
+ /// \see IPreferencePage::Update()
+ ///
+ virtual void Update();
+
+protected:
+ QWidget* m_MainControl;
+
+ berry::IPreferences::WeakPtr m_XnatConnectionPreferencesNode;
+
+ ///
+ /// Maps a label to lineedit (sorted)
+ ///
+ QMap > m_LineEditors;
+};
+
+#endif /* QMITKXNATCONNECTIONPREFERENCEPAGE_H_ */
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.cpp
new file mode 100644
index 0000000000..9ffd861221
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.cpp
@@ -0,0 +1,451 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 "QmitkXnatEditor.h"
+
+// Qmitk
+#include "QmitkXnatObjectEditorInput.h"
+#include "org_mitk_gui_qt_xnatinterface_Activator.h"
+
+// CTK XNAT Core
+#include "ctkXnatObject.h"
+#include "ctkXnatDataModel.h"
+#include "ctkXnatScanResource.h"
+#include "ctkXnatFile.h"
+
+// CTK XNAT Widgets
+#include "ctkXnatListModel.h"
+
+// Blueberry
+#include
+#include
+
+// Qt
+#include
+#include
+#include
+#include
+
+// MITK
+#include
+#include
+
+const std::string QmitkXnatEditor::EDITOR_ID = "org.mitk.editors.xnat.browser";
+
+QmitkXnatEditor::QmitkXnatEditor() :
+ m_DataStorageServiceTracker(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetContext()),
+ m_Session(0),
+ m_ListModel(new ctkXnatListModel()),
+ m_SelectionListener(new berry::SelectionChangedAdapter(this, &QmitkXnatEditor::SelectionChanged)),
+ m_DownloadPath(berry::Platform::GetServiceRegistry().
+ GetServiceById(berry::IPreferencesService::ID)->
+ GetSystemPreferences()->Node("/XnatConnection")->Get("Download Path", "").c_str())
+{
+ m_DataStorageServiceTracker.open();
+ if(m_DownloadPath.isEmpty())
+ {
+ QString xnatFolder = "XNAT_DOWNLOADS";
+ QDir dir(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetContext()->getDataFile("").absoluteFilePath());
+ dir.mkdir(xnatFolder);
+ dir.setPath(dir.path() + "/" + xnatFolder);
+ m_DownloadPath = dir.path() + "/";
+ }
+}
+
+QmitkXnatEditor::~QmitkXnatEditor()
+{
+ delete m_ListModel;
+ berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService();
+ s->RemoveSelectionListener(m_SelectionListener);
+ m_DataStorageServiceTracker.close();
+}
+
+bool QmitkXnatEditor::IsDirty() const
+{
+ return false;
+}
+
+bool QmitkXnatEditor::IsSaveAsAllowed() const
+{
+ return false;
+}
+
+void QmitkXnatEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input)
+{
+ this->SetInput(input);
+ this->SetSite(site);
+}
+
+void QmitkXnatEditor::DoSave()
+{
+}
+
+void QmitkXnatEditor::DoSaveAs()
+{
+}
+
+void QmitkXnatEditor::SetInput(berry::IEditorInput::Pointer input)
+{
+ // If the input is not a QmitkXnatObjectEditorInput the semi global xnat session will be loaded.
+ QmitkXnatObjectEditorInput::Pointer oPtr = input.Cast();
+ if(oPtr.IsNotNull())
+ {
+ SetInputWithNotify(oPtr);
+ this->GetEditorInput().Cast()->GetXnatObject()->fetch();
+ }
+ else
+ {
+ m_Session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatConnectionManager()->GetXnatConnection();
+
+ if(m_Session == 0)
+ {
+ MITK_INFO << "Please check your XNAT Connection Preferences!";
+ return;
+ }
+
+ QmitkXnatObjectEditorInput::Pointer xoPtr = QmitkXnatObjectEditorInput::New( m_Session->dataModel() );
+ berry::IEditorInput::Pointer editorInput( xoPtr );
+ SetInputWithNotify(editorInput);
+ this->GetEditorInput().Cast()->GetXnatObject()->fetch();
+ }
+}
+
+//const char* QmitkXnatEditor::GetClassNameA() const
+//{
+// return QtEditorPart::GetClassNameA();
+//}
+
+void QmitkXnatEditor::SetFocus()
+{
+}
+
+void QmitkXnatEditor::CreateQtPartControl( QWidget *parent )
+{
+ // create GUI widgets from the Qt Designer's .ui file
+ m_Controls.setupUi( parent );
+ m_Controls.treeView->setModel(m_ListModel);
+
+ GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener(m_SelectionListener);
+
+ connect( m_Controls.treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(OnObjectActivated(const QModelIndex&)) );
+
+ connect( m_Controls.buttonDownloadResource, SIGNAL(clicked()), this, SLOT(DownloadResource()) );
+ connect( m_Controls.buttonDownloadFile, SIGNAL(clicked()), this, SLOT(DownloadFile()) );
+ connect( m_Controls.buttonDataModel, SIGNAL(clicked()), this, SLOT(OnDataModelButtonClicked()) );
+ connect( m_Controls.buttonProject, SIGNAL(clicked()), this, SLOT(OnProjectButtonClicked()) );
+ connect( m_Controls.buttonSubject, SIGNAL(clicked()), this, SLOT(OnSubjectButtonClicked()) );
+ connect( m_Controls.buttonExperiment, SIGNAL(clicked()), this, SLOT(OnExperimentButtonClicked()) );
+ connect( m_Controls.buttonKindOfData, SIGNAL(clicked()), this, SLOT(OnKindOfDataButtonClicked()) );
+ connect( m_Controls.buttonSession, SIGNAL(clicked()), this, SLOT(OnSessionButtonClicked()) );
+ connect( m_Controls.buttonResource, SIGNAL(clicked()), this, SLOT(OnResourceButtonClicked()) );
+
+ // Makes the breadcrumb feature invisible
+ for(int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count()-1; i++)
+ {
+ QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i);
+ child->widget()->setVisible(false);
+ }
+ for(int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count()-1; i++)
+ {
+ QLayoutItem* child = m_Controls.breadcrumbDescriptionLayout->itemAt(i);
+ child->widget()->setVisible(false);
+ }
+ UpdateList();
+}
+
+void QmitkXnatEditor::UpdateList()
+{
+ QmitkXnatObjectEditorInput::Pointer xoPtr(GetEditorInput().Cast());
+ if( xoPtr.IsNull() )
+ return;
+ ctkXnatObject* inputObject = xoPtr->GetXnatObject();
+ if( inputObject == NULL )
+ return;
+ m_ListModel->setRootObject( inputObject );
+ m_Controls.treeView->reset();
+
+ // recursive method to check parents of the inputObject
+ m_ParentCount = ParentChecker(inputObject);
+
+ // breadcrumb labels
+ for(int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count()-1; i++)
+ {
+ QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i);
+ child->widget()->setVisible(false);
+ }
+ for(int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count()-1; i++)
+ {
+ QLayoutItem* child = m_Controls.breadcrumbDescriptionLayout->itemAt(i);
+ child->widget()->setVisible(false);
+ }
+
+ ctkXnatObject* parent = NULL;
+ for(int i = m_ParentCount*2; i >= 0; i--)
+ {
+ if(i > 12)
+ break;
+ m_Controls.breadcrumbDescriptionLayout->itemAt(i)->widget()->setVisible(true);
+ QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i);
+ child->widget()->setVisible(true);
+ if(i>0)
+ {
+ m_Controls.breadcrumbHorizontalLayout->itemAt(i-1)->widget()->setVisible(true);
+ m_Controls.breadcrumbDescriptionLayout->itemAt(i-1)->widget()->setVisible(true);
+ }
+ if(parent == NULL)
+ {
+ parent = inputObject;
+ }
+ // make breadcrumb button
+ QPushButton* breadcrumbButton = dynamic_cast(child->widget());
+ breadcrumbButton->setText(parent->id());
+ parent = parent->parent();
+ i--;
+ }
+}
+
+void QmitkXnatEditor::SelectionChanged(berry::IWorkbenchPart::Pointer sourcepart,
+ berry::ISelection::ConstPointer selection)
+{
+ // check for null selection
+ if (selection.IsNull())
+ {
+ return;
+ }
+ // exclude own selection events and check whether this kind of selection can be handled
+ if (sourcepart != this &&
+ selection.Cast())
+ {
+ berry::IStructuredSelection::ConstPointer currentSelection = selection.Cast();
+ // iterates over the selection
+ for (berry::IStructuredSelection::iterator itr = currentSelection->Begin();
+ itr != currentSelection->End(); ++itr)
+ {
+ if (berry::SmartPointer objectPointer = itr->Cast())
+ {
+ // get object of selected ListWidgetElement
+ ctkXnatObject* object = objectPointer->GetQModelIndex().data(Qt::UserRole).value();
+
+ // if a file is selected, don't change the input and list view
+ if ( dynamic_cast(object) == NULL ){
+ QmitkXnatObjectEditorInput::Pointer oPtr = QmitkXnatObjectEditorInput::New( object );
+ berry::IEditorInput::Pointer editorInput( oPtr );
+ if ( !(editorInput == this->GetEditorInput()) )
+ this->SetInput(editorInput);
+
+ UpdateList();
+ }
+ }
+ }
+ }
+}
+
+void QmitkXnatEditor::DownloadResource()
+{
+ if (!m_Controls.treeView->selectionModel()->hasSelection())
+ return;
+
+ const QModelIndex index = m_Controls.treeView->selectionModel()->currentIndex();
+ QVariant variant = m_ListModel->data(index, Qt::UserRole);
+ if ( variant.isValid() )
+ {
+ ctkXnatScanResource* resource = dynamic_cast(variant.value());
+ if (resource != NULL)
+ {
+ MITK_INFO << "Download started ...";
+ MITK_INFO << "...";
+ QString resourcePath = m_DownloadPath + resource->id() + ".zip";
+ resource->download(resourcePath);
+
+ // Testing if the path exists
+ QDir downDir(m_DownloadPath);
+ if( downDir.exists(resource->id() + ".zip") )
+ {
+ MITK_INFO << "Download of " << resource->id().toStdString() << ".zip was completed!";
+ }
+ else
+ {
+ MITK_INFO << "Download of " << resource->id().toStdString() << ".zip failed!";
+ }
+ }
+ else
+ {
+ MITK_INFO << "Selection was not a resource folder!";
+ }
+ }
+}
+
+void QmitkXnatEditor::DownloadFile()
+{
+ if (!m_Controls.treeView->selectionModel()->hasSelection())
+ return;
+ const QModelIndex index = m_Controls.treeView->selectionModel()->currentIndex();
+ InternalFileDownload(index);
+}
+
+void QmitkXnatEditor::ToHigherLevel()
+{
+ ctkXnatObject* parent = GetEditorInput().Cast()->GetXnatObject()->parent();
+ if( parent == NULL)
+ {
+ return;
+ }
+ QmitkXnatObjectEditorInput::Pointer oPtr = QmitkXnatObjectEditorInput::New( parent );
+ berry::IEditorInput::Pointer editorInput( oPtr );
+ SetInput(editorInput);
+ UpdateList();
+}
+
+void QmitkXnatEditor::OnObjectActivated(const QModelIndex &index)
+{
+ if (!index.isValid()) return;
+
+ ctkXnatObject* child = GetEditorInput().Cast()->GetXnatObject()->children().at(index.row());
+ if( child != NULL )
+ {
+ ctkXnatFile* file = dynamic_cast(child);
+ if( file != NULL )
+ {
+ // Download file and put into datamanager
+ InternalFileDownload(index);
+ mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService();
+ if(dsService != NULL)
+ {
+ mitk::DataNode::Pointer node = mitk::IOUtil::LoadDataNode((m_DownloadPath + file->id()).toStdString());
+ if ( ( node.IsNotNull() ) && ( node->GetData() != NULL ) )
+ {
+ dsService->GetDataStorage()->GetDataStorage()->Add(node);
+ mitk::BaseData::Pointer basedata = node->GetData();
+ mitk::RenderingManager::GetInstance()->InitializeViews(
+ basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true );
+ }
+ }
+ }
+ else
+ {
+ // Updates the root item
+ QmitkXnatObjectEditorInput::Pointer oPtr = QmitkXnatObjectEditorInput::New( child );
+ berry::IEditorInput::Pointer editorInput( oPtr );
+ SetInput(editorInput);
+
+ this->GetEditorInput().Cast()->GetXnatObject()->fetch();
+
+ UpdateList();
+ }
+ }
+
+}
+
+void QmitkXnatEditor::InternalFileDownload(const QModelIndex& index)
+{
+ QVariant variant = m_ListModel->data(index, Qt::UserRole);
+ if ( variant.isValid() )
+ {
+ ctkXnatFile* file = dynamic_cast(variant.value());
+ if (file != NULL)
+ {
+ MITK_INFO << "Download started ...";
+ MITK_INFO << "...";
+ QString filePath = m_DownloadPath + file->id();
+ file->download(filePath);
+
+ // Testing if the file exists
+ QDir downDir(m_DownloadPath);
+ if( downDir.exists(file->id()) )
+ {
+ MITK_INFO << "Download of " << file->id().toStdString() << " was completed!";
+ }
+ else
+ {
+ MITK_INFO << "Download of " << file->id().toStdString() << " failed!";
+ }
+ }
+ else
+ {
+ MITK_INFO << "Selection was not a file!";
+ }
+ }
+}
+
+int QmitkXnatEditor::ParentChecker(ctkXnatObject* child)
+{
+ int sum;
+ if( child->parent() == NULL )
+ {
+ return 0;
+ }
+ else
+ {
+ sum = 1 + ParentChecker(child->parent());
+ }
+ return sum;
+}
+
+void QmitkXnatEditor::OnDataModelButtonClicked()
+{
+ for(int i = m_ParentCount; i > 0; i--)
+ {
+ ToHigherLevel();
+ }
+}
+
+void QmitkXnatEditor::OnProjectButtonClicked()
+{
+ for(int i = m_ParentCount-1; i > 0; i--)
+ {
+ ToHigherLevel();
+ }
+}
+
+void QmitkXnatEditor::OnSubjectButtonClicked()
+{
+ for(int i = m_ParentCount-2; i > 0; i--)
+ {
+ ToHigherLevel();
+ }
+}
+
+void QmitkXnatEditor::OnExperimentButtonClicked()
+{
+ for(int i = m_ParentCount-3; i > 0; i--)
+ {
+ ToHigherLevel();
+ }
+}
+
+void QmitkXnatEditor::OnKindOfDataButtonClicked()
+{
+ for(int i = m_ParentCount-4; i > 0; i--)
+ {
+ ToHigherLevel();
+ }
+}
+
+void QmitkXnatEditor::OnSessionButtonClicked()
+{
+ for(int i = m_ParentCount-5; i > 0; i--)
+ {
+ ToHigherLevel();
+ }
+}
+
+void QmitkXnatEditor::OnResourceButtonClicked()
+{
+ for(int i = m_ParentCount-6; i > 0; i--)
+ {
+ ToHigherLevel();
+ }
+}
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.h
new file mode 100644
index 0000000000..a46b22fd11
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.h
@@ -0,0 +1,124 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 QMITKXNATEDITOR_h
+#define QMITKXNATEDITOR_h
+
+#include
+#include
+#include
+
+#include
+
+#include
+
+#include "ui_QmitkXnatEditorControls.h"
+
+#include "ctkXnatListModel.h"
+#include "ctkXnatSession.h"
+
+#include
+
+/*!
+\brief QmitkXnatEditor
+
+\warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation.
+
+\sa QmitkFunctionality
+\ingroup ${plugin_target}_internal
+*/
+class QmitkXnatEditor : public berry::QtEditorPart, public berry::IReusableEditor
+{
+ // 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:
+
+ berryObjectMacro(QmitkXnatEditor)
+
+ QmitkXnatEditor();
+ ~QmitkXnatEditor();
+
+ static const std::string EDITOR_ID;
+
+ void CreateQtPartControl(QWidget *parent);
+
+ void DoSave(/*IProgressMonitor monitor*/);
+ void DoSaveAs();
+ void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input);
+ bool IsDirty() const;
+ bool IsSaveAsAllowed() const;
+ void SetInput(berry::IEditorInput::Pointer input);
+ const char* GetClassNameA() const;
+
+ /**
+ \brief Here the root object will be set and the view reset. Additionally the breadcrumbs will set visible.
+ */
+ void UpdateList();
+
+ protected slots:
+
+ /**
+ \brief A resource folder will be downloaded to the chosen download path.
+ */
+ void DownloadResource();
+
+ /**
+ \brief A file will be downloaded to the chosen download path.
+ */
+ void DownloadFile();
+
+ /**
+ \brief Every time you activate a node in the list, the root item will be updated to a child of the previous parent.\
+ In exception of the node is a file. The file will be downloaded and loaded to the DataManager.
+ */
+ void OnObjectActivated(const QModelIndex& index);
+
+ // Breadcrumb button slots
+ void OnDataModelButtonClicked();
+ void OnProjectButtonClicked();
+ void OnSubjectButtonClicked();
+ void OnExperimentButtonClicked();
+ void OnKindOfDataButtonClicked();
+ void OnSessionButtonClicked();
+ void OnResourceButtonClicked();
+
+protected:
+
+ virtual void SetFocus();
+
+ Ui::QmitkXnatEditorControls m_Controls;
+
+private:
+
+ int m_ParentCount;
+ QString m_DownloadPath;
+ ctkServiceTracker m_DataStorageServiceTracker;
+
+ void InternalFileDownload(const QModelIndex& index);
+ int ParentChecker(ctkXnatObject* child);
+ void ToHigherLevel();
+
+ ctkXnatListModel* m_ListModel;
+ ctkXnatSession* m_Session;
+
+ berry::ISelectionListener::Pointer m_SelectionListener;
+ void SelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection);
+};
+
+#endif // QMITKXNATEDITOR_h
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditorControls.ui b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditorControls.ui
new file mode 100644
index 0000000000..5f13d15459
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditorControls.ui
@@ -0,0 +1,460 @@
+
+
+ QmitkXnatEditorControls
+
+
+
+ 0
+ 0
+ 823
+ 706
+
+
+
+
+ 0
+ 0
+
+
+
+ QmitkTemplate
+
+
+
+ xnat_icon.icoxnat_icon.ico
+
+
+ -
+
+
-
+
+
+ Current Position:
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Server
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Project
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Subject
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Experiment
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Kind of Data
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Image Session
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Resource Folder
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+
+ -
+
+
+ 6
+
+
+ QLayout::SetDefaultConstraint
+
+
+ 0
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Data Model
+
+
+
+ -
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::LeftToRight
+
+
+ Project
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Subject
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Experiment
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Kind of Data
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Session
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ >>
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Resource
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ -
+
+
-
+
+
+ (no function)
+
+
+
+ -
+
+
+ Download Folder
+
+
+
+ -
+
+
+ Download File
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.cpp
new file mode 100644
index 0000000000..88fd6cd358
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.cpp
@@ -0,0 +1,63 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 "QmitkXnatObjectEditorInput.h"
+
+QmitkXnatObjectEditorInput::QmitkXnatObjectEditorInput(ctkXnatObject* object)
+ : m_Object(object)
+{
+}
+
+QmitkXnatObjectEditorInput::~QmitkXnatObjectEditorInput()
+{
+}
+
+ctkXnatObject* QmitkXnatObjectEditorInput::GetXnatObject() const
+{
+ return m_Object;
+}
+
+bool QmitkXnatObjectEditorInput::Exists() const
+{
+ return m_Object->exists();
+}
+
+std::string QmitkXnatObjectEditorInput::GetName() const
+{
+ return m_Object->id().toStdString();
+}
+
+std::string QmitkXnatObjectEditorInput::GetToolTipText() const
+{
+ return m_Object->description().toStdString();
+}
+
+bool QmitkXnatObjectEditorInput::operator==(const berry::Object* o) const
+{
+ if ( const QmitkXnatObjectEditorInput* other = dynamic_cast(o) )
+ {
+ if ( other->GetXnatObject()->parent() )
+ {
+ return ( !other->GetName().compare(this->GetName()) ) &&
+ ( !other->GetXnatObject()->parent()->id().toStdString().compare(this->GetXnatObject()->parent()->id().toStdString()) );
+ }
+ else
+ {
+ return ( !other->GetName().compare(this->GetName()) );
+ }
+ }
+ return false;
+}
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.h
new file mode 100644
index 0000000000..ab5699f470
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatObjectEditorInput.h
@@ -0,0 +1,45 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 QMITKXNATOBJECTEDITORINPUT_H_
+#define QMITKXNATOBJECTEDITORINPUT_H_
+
+#include "berryIEditorInput.h"
+#include "ctkXnatObject.h"
+
+class QmitkXnatObjectEditorInput : public berry::IEditorInput {
+
+public:
+ berryObjectMacro(QmitkXnatObjectEditorInput);
+ berryNewMacro1Param(QmitkXnatObjectEditorInput, ctkXnatObject*);
+
+ ~QmitkXnatObjectEditorInput();
+
+ /// \brief Returns the kept ctkXnatObject.
+ ctkXnatObject* GetXnatObject() const;
+
+ virtual bool Exists() const;
+ virtual std::string GetName() const;
+ virtual std::string GetToolTipText() const;
+ virtual bool operator==(const berry::Object* o) const;
+
+private:
+ QmitkXnatObjectEditorInput(ctkXnatObject* object);
+
+ ctkXnatObject* m_Object;
+};
+
+#endif /*QMITKXNATOBJECTEDITORINPUT_H_*/
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchView.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchView.cpp
new file mode 100644
index 0000000000..bc21d41ce1
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchView.cpp
@@ -0,0 +1,104 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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.
+
+===================================================================*/
+
+// Qmitk
+#include "QmitkXnatSimpleSearchView.h"
+
+// Standard
+#include
+#include
+
+// Blueberry
+#include
+#include
+
+// Qt
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// ctkXnatCore
+#include "ctkXnatProject.h"
+
+const std::string QmitkXnatSimpleSearchView::VIEW_ID = "org.mitk.views.qmitkxnatsimplesearchview";
+
+QmitkXnatSimpleSearchView::QmitkXnatSimpleSearchView() :
+ m_Session(0),
+ m_TreeModel(new ctkXnatTreeModel())
+{
+}
+
+QmitkXnatSimpleSearchView::~QmitkXnatSimpleSearchView()
+{
+ delete m_TreeModel;
+}
+
+void QmitkXnatSimpleSearchView::SetFocus()
+{
+ m_Controls.buttonStartSearch->setFocus();
+}
+
+void QmitkXnatSimpleSearchView::CreateQtPartControl( QWidget *parent )
+{
+ // create GUI widgets from the Qt Designer's .ui file
+ m_Controls.setupUi( parent );
+ m_Controls.treeView->setModel(m_TreeModel);
+
+ connect( m_Controls.buttonStartSearch, SIGNAL(clicked()), this, SLOT(StartSearch()) );
+}
+
+void QmitkXnatSimpleSearchView::StartSearch()
+{
+ int type;
+
+ switch(m_Controls.objectComboBox->currentIndex())
+ {
+ case QmitkXnatSimpleSearchView::PROJECT:
+ type = QmitkXnatSimpleSearchView::PROJECT;
+ break;
+ case QmitkXnatSimpleSearchView::SUBJECT:
+ type = QmitkXnatSimpleSearchView::SUBJECT;
+ break;
+ case QmitkXnatSimpleSearchView::EXPERIMENT:
+ type = QmitkXnatSimpleSearchView::EXPERIMENT;
+ break;
+ default:
+ type = QmitkXnatSimpleSearchView::EMPTY;
+ MITK_INFO << "You did something weird or chose nothing!";
+ break;
+ }
+
+ //m_TreeModel->setMatchingObject( type );
+ //m_TreeModel->setSearchTerm( m_Controls.termLineEdit->text() );
+ //m_TreeModel->setIsStartOfSearch( true );
+
+ // create ctkXnatConnection
+ //m_Connection = m_ConnectionFactory->makeConnection(m_Controls.inHostAddress->text(), m_Controls.inUser->text(), m_Controls.inPassword->text());
+ //ctkXnatServer* server = m_Connection->server();
+
+ //m_TreeModel->addServer(server);
+ //m_Controls.treeView->reset();
+}
+
+void QmitkXnatSimpleSearchView::SetSelectionProvider()
+{
+ GetSite()->SetSelectionProvider(m_SelectionProvider);
+}
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchView.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchView.h
new file mode 100644
index 0000000000..ae73e28a44
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchView.h
@@ -0,0 +1,85 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 QMITKXNATSIMPLESEARCHVIEW_H
+#define QMITKXNATSIMPLESEARCHVIEW_H
+
+#include
+
+#include
+#include "QmitkXnatTreeBrowserView.h"
+
+#include "ui_QmitkXnatSimpleSearchViewControls.h"
+
+// ctkXnatCore
+#include "ctkXnatSession.h"
+
+// ctkXnatWidget
+#include "ctkXnatTreeModel.h"
+
+/*!
+\brief QmitkXnatSimpleSearchView
+
+\warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation.
+
+\sa QmitkFunctionality
+\ingroup ${plugin_target}_internal
+*/
+class QmitkXnatSimpleSearchView : public QmitkXnatTreeBrowserView
+{
+ // 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:
+
+ enum MatchingObject
+ {
+ EMPTY,
+ PROJECT,
+ SUBJECT,
+ EXPERIMENT
+ };
+
+ QmitkXnatSimpleSearchView();
+ ~QmitkXnatSimpleSearchView();
+ static const std::string VIEW_ID;
+
+ virtual void CreateQtPartControl(QWidget *parent);
+
+ berry::QtSelectionProvider::Pointer m_SelectionProvider;
+
+ protected slots:
+
+ /// \brief Called when the user clicks the GUI button
+ void StartSearch();
+
+protected:
+
+ virtual void SetFocus();
+
+ Ui::QmitkXnatSimpleSearchViewControls m_Controls;
+
+private:
+
+ void SetSelectionProvider();
+
+ ctkXnatSession* m_Session;
+ ctkXnatTreeModel* m_TreeModel;
+
+};
+
+#endif // QMITKXNATSIMPLESEARCHVIEW_H
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchViewControls.ui b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchViewControls.ui
new file mode 100644
index 0000000000..1432f36d13
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatSimpleSearchViewControls.ui
@@ -0,0 +1,190 @@
+
+
+ QmitkXnatSimpleSearchViewControls
+
+
+
+ 0
+ 0
+ 306
+ 975
+
+
+
+
+ 0
+ 0
+
+
+
+ QmitkTemplate
+
+
+
+ xnat_icon.icoxnat_icon.ico
+
+
+ -
+
+
-
+
+
+ QLabel { color: rgb(255, 0, 0) }
+
+
+ Please insert your XNAT host address:
+
+
+
+ -
+
+
+
+ 230
+ 0
+
+
+
+ <html><head/><body><p>Examples:</p><p>"http://localhost:8080/xnat"</p><p>"http://central.xnat.org:80"</p><p>"https://xnat.myserver.de:443"</p></body></html>
+
+
+ http://localhost:12345/xnat
+
+
+ http(s)://host:port/pathToXnatServerInstance
+
+
+
+ -
+
+
-
+
+
+ admin
+
+
+ User
+
+
+
+ -
+
+
+
+ 53
+ 0
+
+
+
+ admin
+
+
+ QLineEdit::Password
+
+
+ Password
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Minimum
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
-
+
+
+
+
+ -
+
+ Project
+
+
+ -
+
+ Subject
+
+
+ -
+
+ Experiment
+
+
+
+
+ -
+
+
+ Matching Object
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Search Term
+
+
+
+
+
+ -
+
+
+ true
+
+
+ Get all projects
+
+
+ Start Search
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserView.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserView.cpp
new file mode 100644
index 0000000000..587c74f360
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserView.cpp
@@ -0,0 +1,119 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 "QmitkXnatTreeBrowserView.h"
+
+// Qmitk
+#include "QmitkXnatObjectEditorInput.h"
+#include "QmitkXnatEditor.h"
+#include "org_mitk_gui_qt_xnatinterface_Activator.h"
+
+// Blueberry
+#include
+
+// CTK XNAT Core
+#include "ctkXnatFile.h"
+
+const std::string QmitkXnatTreeBrowserView::VIEW_ID = "org.mitk.views.xnat.treebrowser";
+
+QmitkXnatTreeBrowserView::QmitkXnatTreeBrowserView():
+ m_Session(0),
+ m_TreeModel(new ctkXnatTreeModel())
+{
+}
+
+QmitkXnatTreeBrowserView::~QmitkXnatTreeBrowserView()
+{
+ delete m_TreeModel;
+}
+
+void QmitkXnatTreeBrowserView::SetFocus()
+{
+}
+
+void QmitkXnatTreeBrowserView::CreateQtPartControl( QWidget *parent )
+{
+ // Create GUI widgets from the Qt Designer's .ui file
+ m_Controls.setupUi( parent );
+ m_Controls.treeView->setModel(m_TreeModel);
+ m_Controls.treeView->header()->hide();
+
+ m_SelectionProvider = new berry::QtSelectionProvider();
+ m_SelectionProvider->SetItemSelectionModel(m_Controls.treeView->selectionModel());
+ this->SetSelectionProvider();
+ m_Controls.treeView->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ connect( m_Controls.treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(OnActivatedNode(const QModelIndex&)) );
+
+ // Get the XNAT Session from Activator
+ m_Session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatConnectionManager()->GetXnatConnection();
+
+ if(m_Session == 0) return;
+
+ // Fill model and show in the GUI
+ m_TreeModel->addDataModel(m_Session->dataModel());
+ m_Controls.treeView->reset();
+}
+
+void QmitkXnatTreeBrowserView::OnActivatedNode(const QModelIndex& index)
+{
+ if (!index.isValid()) return;
+
+ berry::IWorkbenchPage::Pointer page = GetSite()->GetPage();
+ QmitkXnatObjectEditorInput::Pointer oPtr = QmitkXnatObjectEditorInput::New( index.data(Qt::UserRole).value() );
+ berry::IEditorInput::Pointer editorInput( oPtr );
+ berry::IEditorPart::Pointer reuseEditor = page->FindEditor(editorInput);
+
+ if(reuseEditor)
+ {
+ // Just set it activ
+ page->Activate(reuseEditor);
+ }
+ else
+ {
+ std::vector editors =
+ page->FindEditors(berry::IEditorInput::Pointer(0), QmitkXnatEditor::EDITOR_ID, berry::IWorkbenchPage::MATCH_ID);
+
+ if (editors.empty())
+ {
+ // No XnatEditor is currently open, create a new one
+ ctkXnatFile* file = dynamic_cast(oPtr->GetXnatObject());
+ if(file != NULL)
+ {
+ // If a file is activated take the parent and open a new editor
+ QmitkXnatObjectEditorInput::Pointer oPtr2 = QmitkXnatObjectEditorInput::New( file->parent() );
+ berry::IEditorInput::Pointer editorInput2( oPtr2 );
+ page->OpenEditor(editorInput2, QmitkXnatEditor::EDITOR_ID);
+ }
+ else
+ {
+ page->OpenEditor(editorInput, QmitkXnatEditor::EDITOR_ID);
+ }
+ }
+ else
+ {
+ // Reuse an existing editor
+ reuseEditor = editors.front()->GetEditor(true);
+ page->ReuseEditor(reuseEditor.Cast(), editorInput);
+ page->Activate(reuseEditor);
+ }
+ }
+}
+
+void QmitkXnatTreeBrowserView::SetSelectionProvider()
+{
+ GetSite()->SetSelectionProvider(m_SelectionProvider);
+}
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserView.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserView.h
new file mode 100644
index 0000000000..8c6de2b22c
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserView.h
@@ -0,0 +1,76 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 QMITKXNATTREEBROWSERVIEW_H
+#define QMITKXNATTREEBROWSERVIEW_H
+
+#include
+
+#include
+
+#include "ui_QmitkXnatTreeBrowserViewControls.h"
+
+// ctkXnatCore
+#include "ctkXnatSession.h"
+
+// ctkXnatWidget
+#include "ctkXnatTreeModel.h"
+
+/*!
+\brief QmitkXnatTreeBrowserView
+
+\warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation.
+
+\sa QmitkFunctionality
+\ingroup ${plugin_target}_internal
+*/
+class QmitkXnatTreeBrowserView : 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:
+
+ QmitkXnatTreeBrowserView();
+ ~QmitkXnatTreeBrowserView();
+
+ static const std::string VIEW_ID;
+
+ virtual void CreateQtPartControl(QWidget *parent);
+
+ berry::QtSelectionProvider::Pointer m_SelectionProvider;
+
+ protected slots:
+
+ /// \brief Opens or reuses the xnat editor with the activated node as root item.
+ void OnActivatedNode(const QModelIndex& index);
+
+protected:
+
+ virtual void SetFocus();
+
+ Ui::QmitkXnatTreeBrowserViewControls m_Controls;
+
+private:
+
+ void SetSelectionProvider();
+
+ ctkXnatSession* m_Session;
+ ctkXnatTreeModel* m_TreeModel;
+};
+
+#endif // QMITKXNATTREEBROWSERVIEW_H
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserViewControls.ui b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserViewControls.ui
new file mode 100644
index 0000000000..5199283997
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatTreeBrowserViewControls.ui
@@ -0,0 +1,37 @@
+
+
+ QmitkXnatTreeBrowserViewControls
+
+
+
+ 0
+ 0
+ 455
+ 975
+
+
+
+
+ 0
+ 0
+
+
+
+ QmitkTemplate
+
+
+ -
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/org_mitk_gui_qt_xnatinterface_Activator.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/org_mitk_gui_qt_xnatinterface_Activator.cpp
new file mode 100644
index 0000000000..74119845af
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/org_mitk_gui_qt_xnatinterface_Activator.cpp
@@ -0,0 +1,56 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 "org_mitk_gui_qt_xnatinterface_Activator.h"
+
+#include
+
+#include "QmitkXnatEditor.h"
+#include "QmitkXnatTreeBrowserView.h"
+#include "QmitkXnatConnectionPreferencePage.h"
+
+namespace mitk {
+
+ctkPluginContext* org_mitk_gui_qt_xnatinterface_Activator::m_Context = 0;
+
+QmitkXnatConnectionManager* org_mitk_gui_qt_xnatinterface_Activator::GetXnatConnectionManager()
+{
+ static QmitkXnatConnectionManager manager;
+ return &manager;
+}
+
+ctkPluginContext* org_mitk_gui_qt_xnatinterface_Activator::GetContext()
+{
+ return m_Context;
+}
+
+void org_mitk_gui_qt_xnatinterface_Activator::start(ctkPluginContext* context)
+{
+ this->m_Context = context;
+
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkXnatEditor, context)
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkXnatTreeBrowserView, context)
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkXnatConnectionPreferencePage, context)
+}
+
+void org_mitk_gui_qt_xnatinterface_Activator::stop(ctkPluginContext* context)
+{
+ Q_UNUSED(context)
+}
+
+}
+
+Q_EXPORT_PLUGIN2(org_mitk_gui_qt_xnatinterface, mitk::org_mitk_gui_qt_xnatinterface_Activator)
diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/org_mitk_gui_qt_xnatinterface_Activator.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/org_mitk_gui_qt_xnatinterface_Activator.h
new file mode 100644
index 0000000000..9b39558730
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/org_mitk_gui_qt_xnatinterface_Activator.h
@@ -0,0 +1,48 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+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 org_mitk_gui_qt_xnatinterface_Activator_h
+#define org_mitk_gui_qt_xnatinterface_Activator_h
+
+#include
+#include "QmitkXnatConnectionManager.h"
+
+namespace mitk {
+
+class org_mitk_gui_qt_xnatinterface_Activator :
+ public QObject, public ctkPluginActivator
+{
+ Q_OBJECT
+ Q_INTERFACES(ctkPluginActivator)
+
+public:
+
+ static QmitkXnatConnectionManager* GetXnatConnectionManager();
+ static ctkPluginContext* GetContext();
+
+ void start(ctkPluginContext* context);
+ void stop(ctkPluginContext* context);
+
+private:
+
+ static ctkPluginContext* m_Context;
+
+}; // org_mitk_gui_qt_xnatinterface_Activator
+
+}
+
+#endif // org_mitk_gui_qt_xnatinterface_Activator_h
diff --git a/Plugins/org.mitk.gui.qt.xnat/target_libraries.cmake b/Plugins/org.mitk.gui.qt.xnat/target_libraries.cmake
new file mode 100644
index 0000000000..e18fde9a3e
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.xnat/target_libraries.cmake
@@ -0,0 +1,9 @@
+# See CMake/ctkFunctionGetTargetLibraries.cmake
+#
+# This file should list the libraries required to build the current CTK plugin.
+# For specifying required plugins, see the manifest_headers.cmake file.
+#
+
+set(target_libraries
+ CTKXNATCore
+)