diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/plugin.xml b/BlueBerry/Bundles/org.blueberry.ui.qt.help/plugin.xml index 7d7ec224db..c7bd593c26 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/plugin.xml +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/plugin.xml @@ -1,43 +1,43 @@ diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.cpp index 41522b4413..36ec40c920 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpIndexView.cpp @@ -1,325 +1,323 @@ /*=================================================================== BlueBerry Platform 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. ===================================================================*/ #ifdef __MINGW32__ // We need to inlclude winbase.h here in order to declare // atomic intrinsics like InterlockedIncrement correctly. // Otherwhise, they would be declared wrong within qatomic_windows.h . #include #endif #include "berryHelpIndexView.h" #include "berryHelpPluginActivator.h" #include "berryHelpEditor.h" #include "berryHelpEditorInput.h" #include "berryHelpWebView.h" #include "berryQHelpEngineWrapper.h" #include "berryHelpTopicChooser.h" #include #include #include #include #include #include #include namespace berry { - HelpIndexWidget::HelpIndexWidget() : QListView(0) { setEditTriggers(QAbstractItemView::NoEditTriggers); setUniformItemSizes(true); connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(showLink(QModelIndex))); } void HelpIndexWidget::showLink(const QModelIndex &index) { if (!index.isValid()) return; QHelpIndexModel *indexModel = qobject_cast(model()); if (!indexModel) return; QVariant v = indexModel->data(index, Qt::DisplayRole); QString name; if (v.isValid()) name = v.toString(); QMap links = indexModel->linksForKeyword(name); if (links.count() == 1) { emit linkActivated(links.constBegin().value(), name); } else if (links.count() > 1) { emit linksActivated(links, name); } } void HelpIndexWidget::activateCurrentItem() { showLink(currentIndex()); } void HelpIndexWidget::filterIndices(const QString &filter, const QString &wildcard) { QHelpIndexModel *indexModel = qobject_cast(model()); if (!indexModel) return; QModelIndex idx = indexModel->filter(filter, wildcard); if (idx.isValid()) setCurrentIndex(idx); } HelpIndexView::HelpIndexView() : m_IndexWidget(0) { } HelpIndexView::~HelpIndexView() { } void HelpIndexView::CreateQtPartControl(QWidget* parent) { if (m_IndexWidget == 0) { QVBoxLayout *layout = new QVBoxLayout(parent); //QLabel *l = new QLabel(tr("&Look for:")); //layout->addWidget(l); m_SearchLineEdit = new ctkSearchBox(parent); m_SearchLineEdit->setClearIcon(QIcon(":/org.blueberry.ui.qt.help/clear.png")); m_SearchLineEdit->setPlaceholderText("Filter..."); m_SearchLineEdit->setContentsMargins(2,2,2,0); //l->setBuddy(m_SearchLineEdit); connect(m_SearchLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterIndices(QString))); m_SearchLineEdit->installEventFilter(this); layout->setMargin(0); layout->setSpacing(2); layout->addWidget(m_SearchLineEdit); QHelpEngineWrapper& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine(); m_IndexWidget = new HelpIndexWidget(); m_IndexWidget->setModel(helpEngine.indexModel()); connect(helpEngine.indexModel(), SIGNAL(indexCreationStarted()), this, SLOT(setIndexWidgetBusy())); connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this, SLOT(unsetIndexWidgetBusy())); m_IndexWidget->installEventFilter(this); connect(helpEngine.indexModel(), SIGNAL(indexCreationStarted()), this, SLOT(disableSearchLineEdit())); connect(helpEngine.indexModel(), SIGNAL(indexCreated()), this, SLOT(enableSearchLineEdit())); connect(m_IndexWidget, SIGNAL(linkActivated(QUrl,QString)), this, SLOT(linkActivated(QUrl))); connect(m_IndexWidget, SIGNAL(linksActivated(QMap,QString)), this, SLOT(linksActivated(QMap,QString))); connect(m_SearchLineEdit, SIGNAL(returnPressed()), m_IndexWidget, SLOT(activateCurrentItem())); layout->addWidget(m_IndexWidget); m_IndexWidget->viewport()->installEventFilter(this); } } void HelpIndexView::SetFocus() { if (!(m_IndexWidget->hasFocus() || m_SearchLineEdit->hasFocus())) { m_SearchLineEdit->setFocus(); } } void HelpIndexView::filterIndices(const QString &filter) { if (filter.contains(QLatin1Char('*'))) m_IndexWidget->filterIndices(filter, filter); else m_IndexWidget->filterIndices(filter, QString()); } bool HelpIndexView::eventFilter(QObject *obj, QEvent *e) { if (obj == m_SearchLineEdit && e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); QModelIndex idx = m_IndexWidget->currentIndex(); switch (ke->key()) { case Qt::Key_Up: idx = m_IndexWidget->model()->index(idx.row()-1, idx.column(), idx.parent()); if (idx.isValid()) { m_IndexWidget->setCurrentIndex(idx); return true; } break; case Qt::Key_Down: idx = m_IndexWidget->model()->index(idx.row()+1, idx.column(), idx.parent()); if (idx.isValid()) { m_IndexWidget->setCurrentIndex(idx); return true; } break; default: ; // stop complaining } } else if (obj == m_IndexWidget && e->type() == QEvent::ContextMenu) { QContextMenuEvent *ctxtEvent = static_cast(e); QModelIndex idx = m_IndexWidget->indexAt(ctxtEvent->pos()); if (idx.isValid()) { QMenu menu; QAction *curTab = menu.addAction(tr("Open Link")); QAction *newTab = menu.addAction(tr("Open Link in New Tab")); menu.move(m_IndexWidget->mapToGlobal(ctxtEvent->pos())); QAction *action = menu.exec(); if (curTab == action) m_IndexWidget->activateCurrentItem(); else if (newTab == action) { open(m_IndexWidget, idx); } } } else if (m_IndexWidget && obj == m_IndexWidget->viewport() && e->type() == QEvent::MouseButtonRelease) { QMouseEvent *mouseEvent = static_cast(e); QModelIndex idx = m_IndexWidget->indexAt(mouseEvent->pos()); if (idx.isValid()) { Qt::MouseButtons button = mouseEvent->button(); if (((button == Qt::LeftButton) && (mouseEvent->modifiers() & Qt::ControlModifier)) || (button == Qt::MidButton)) { open(m_IndexWidget, idx); } } } #ifdef Q_OS_MAC else if (obj == m_IndexWidget && e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) m_IndexWidget->activateCurrentItem(); } #endif return QObject::eventFilter(obj, e); } void HelpIndexView::enableSearchLineEdit() { m_SearchLineEdit->setDisabled(false); filterIndices(m_SearchLineEdit->text()); } void HelpIndexView::disableSearchLineEdit() { m_SearchLineEdit->setDisabled(true); } void HelpIndexView::setIndexWidgetBusy() { m_IndexWidget->setCursor(Qt::WaitCursor); } void HelpIndexView::unsetIndexWidgetBusy() { m_IndexWidget->unsetCursor(); } void HelpIndexView::setSearchLineEditText(const QString &text) { m_SearchLineEdit->setText(text); } QString HelpIndexView::searchLineEditText() const { return m_SearchLineEdit->text(); } void HelpIndexView::focusInEvent(QFocusEvent *e) { if (e->reason() != Qt::MouseFocusReason) { m_SearchLineEdit->selectAll(); m_SearchLineEdit->setFocus(); } } void HelpIndexView::open(HelpIndexWidget* indexWidget, const QModelIndex &index) { QHelpIndexModel *model = qobject_cast(indexWidget->model()); if (model) { QString keyword = model->data(index, Qt::DisplayRole).toString(); QMap links = model->linksForKeyword(keyword); QUrl url; if (links.count() > 1) { HelpTopicChooser tc(m_IndexWidget, keyword, links); if (tc.exec() == QDialog::Accepted) url = tc.link(); } else if (links.count() == 1) { url = links.constBegin().value(); } else { return; } //if (!HelpWebView::canOpenPage(url.path())) IEditorInput::Pointer input(new HelpEditorInput(url)); this->GetSite()->GetPage()->OpenEditor(input, HelpEditor::EDITOR_ID); } } void HelpIndexView::linkActivated(const QUrl& link) { IWorkbenchPage::Pointer page = this->GetSite()->GetPage(); HelpPluginActivator::linkActivated(page, link); } void HelpIndexView::linksActivated(const QMap& links, const QString& keyword) { HelpTopicChooser tc(m_IndexWidget, keyword, links); if (tc.exec() == QDialog::Accepted) { IWorkbenchPage::Pointer page = this->GetSite()->GetPage(); HelpPluginActivator::linkActivated(page, tc.link()); } } - -} +} \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.log/plugin.xml b/BlueBerry/Bundles/org.blueberry.ui.qt.log/plugin.xml index a23c512adb..5d2989f5c5 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt.log/plugin.xml +++ b/BlueBerry/Bundles/org.blueberry.ui.qt.log/plugin.xml @@ -1,15 +1,14 @@ - diff --git a/BlueBerry/Bundles/org.blueberry.ui/schema/perspectives.exsd b/BlueBerry/Bundles/org.blueberry.ui/schema/perspectives.exsd index 9796fb4d28..8e355d8ed3 100755 --- a/BlueBerry/Bundles/org.blueberry.ui/schema/perspectives.exsd +++ b/BlueBerry/Bundles/org.blueberry.ui/schema/perspectives.exsd @@ -1,180 +1,181 @@ This extension point is used to add perspective factories to the workbench. A perspective factory is used to define the initial layout and visible action sets for a perspective. The user can select a perspective by invoking the "Open Perspective" submenu of the "Window" menu. a fully qualified identifier of the target extension point an optional identifier of the extension instance an optional name of the extension instance + a unique name that will be used to identify this perspective. a translatable name that will be used in the workbench window menu bar to represent this perspective. - a fully qualified name of the class that implements + a fully qualified name of the class that implements <samp>berry::IPerspectiveFactory</samp> interface. - a relative name of the icon that will be associated + a relative name of the icon that will be associated with this perspective. indicates whether the layout of the perspective is fixed. If true, then views created by the perspective factory are not closeable, and cannot be moved. The default is false. an optional subelement whose body should contain text providing a short description of the perspective. - The following is an example of a perspective extension: + The following is an example of a perspective extension: <p> <pre> - <extension - point="org.blueberry.ui.perspectives"> - <perspective - id="org.blueberry.ui.resourcePerspective" - name="Resource" - class="berry::ResourcePerspective" - icon="resources/MyIcon.gif"> - </perspective> - </extension> + <extension + point="org.blueberry.ui.perspectives"> + <perspective + id="org.blueberry.ui.resourcePerspective" + name="Resource" + class="berry::ResourcePerspective" + icon="resources/MyIcon.gif"> + </perspective> + </extension> </pre> </p> - The value of the <samp>class</samp> attribute must be the -fully qualified name of a class that implements -<samp>berry::IPerspectiveFactory</samp>. -The class must supply the initial layout for a + The value of the <samp>class</samp> attribute must be the +fully qualified name of a class that implements +<samp>berry::IPerspectiveFactory</samp>. +The class must supply the initial layout for a perspective when asked by the workbench. <p> -The <samp>plugin_customization.ini</samp> file is used to define the default perspective. The <i>default perspective</i> is the first perspective which appears when the product is launched after install. It is also used when the user opens a page or window with no specified perspective. The default perspective is defined as a property within the plugin_customization.ini, as shown below. The user may also override this perspective from the workbench perspectives preference page. +The <samp>plugin_customization.ini</samp> file is used to define the default perspective. The <i>default perspective</i> is the first perspective which appears when the product is launched after install. It is also used when the user opens a page or window with no specified perspective. The default perspective is defined as a property within the plugin_customization.ini, as shown below. The user may also override this perspective from the workbench perspectives preference page. <pre> - defaultPerspectiveId = org.blueberry.ui.resourcePerspective + defaultPerspectiveId = org.blueberry.ui.resourcePerspective </pre> The perspectives which appear in the "Open Perspective" menu are shortcuts for perspective selection. This set is defined by the active perspective itself, and extensions made through the perspectiveExtensions extension point. - The workbench provides a "Resource Perspective". -Additional perspectives may be added by plug-ins. + The workbench provides a "Resource Perspective". +Additional perspectives may be added by plug-ins. They are selected using the "Open Perspective" submenu of the "Window" menu. Copyright (c) 2002, 2005 IBM Corporation and others.<br> All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies -this distribution, and is available at <a +this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> diff --git a/BlueBerry/Bundles/org.blueberry.ui/schema/views.exsd b/BlueBerry/Bundles/org.blueberry.ui/schema/views.exsd index 3f234b4e36..76bf00cdc7 100755 --- a/BlueBerry/Bundles/org.blueberry.ui/schema/views.exsd +++ b/BlueBerry/Bundles/org.blueberry.ui/schema/views.exsd @@ -1,310 +1,311 @@ - This extension point is used to define additional views -for the workbench. A view is a visual component -within a workbench page. It is typically used to -navigate a hierarchy of information (like the workspace), -open an editor, or display properties for -the active editor. The user can make a view -visible from the Window > Show View menu or close it from the -view local title bar. + This extension point is used to define additional views +for the workbench. A view is a visual component +within a workbench page. It is typically used to +navigate a hierarchy of information (like the workspace), +open an editor, or display properties for +the active editor. The user can make a view +visible from the Window > Show View menu or close it from the +view local title bar. <p> In order to reduce the visual clutter in the Show View Dialog, views should be grouped using categories. a fully qualified identifier of the target extension point an optional identifier of the extension instance an optional name of the extension instance a unique name that will be used to identify this category a translatable name that will be used in the UI for this category an optional path composed of category IDs separated by '/'. This allows the creation of a hierarchy of categories. + a unique name that will be used to identify this view a translatable name that will be used in the UI for this view an optional attribute that is composed of the category IDs separated by '/'. Each referenced category must be declared in a corresponding category element. - a fully qualified name of the class that implements -<samp>berry::IViewPart</samp>. A common practice + a fully qualified name of the class that implements +<samp>berry::IViewPart</samp>. A common practice is to subclass <samp>berry::ViewPart</samp> or <samp>berry::QtViewPart</samp> in order to inherit the default functionality. - a relative name of the icon that will + a relative name of the icon that will be associated with the view. the percentage of the width of the workbench that the view will take up as an active fast view. This must be defined as a floating point value and lie between 0.05 and 0.95. If no value is supplied, a default ratio will be used. flag indicating whether this view allows multiple instances to be created using IWorkbenchPage::ShowView(std::string id, std::string secondaryId). The default is false. flag indicating whether this view allows to be restored upon workbench restart. If set to false, the view will not be open after a workbench restart. The default is true. an optional subelement whose body should contain text providing a short description of the view. A sticky view is a view that will appear by default across all perspectives in a window once it is opened. Its initial placement is governemed by the location attribute, but nothing prevents it from being moved or closed by the user. Use of this element will only cause a placeholder for the view to be created, it will not show the view. Please note that usage of this element should be done with great care and should only be applied to views that truely have a need to live across perspectives. the id of the view to be made sticky. optional attribute that specifies the location of the sticky view relative to the editor area. If absent, the view will be docked to the right of the editor area. optional attribute that specifies wether the view should be closeable. If absent it will be closeable. optional attribute that specifies wether the view should be moveable. If absent it will be moveable. - The following is an example of the extension point: + The following is an example of the extension point: <p> <pre> - <extension point="org.blueberry.ui.views"> - <category - id="com.xyz.views.XYZviews" - name="XYZ"/> - <view - id="com.xyz.views.XYZView" - name="XYZ View" - category="com.xyz.views.XYZviews" - class="ns::XYZView" + <extension point="org.blueberry.ui.views"> + <category + id="com.xyz.views.XYZviews" + name="XYZ"/> + <view + id="com.xyz.views.XYZView" + name="XYZ View" + category="com.xyz.views.XYZviews" + class="ns::XYZView" icon="icons/XYZ.gif"/> - </extension> + </extension> </pre> </p> The following is an example of a sticky view declaration: <p> <pre> - <extension point="org.blueberry.ui.views"> + <extension point="org.blueberry.ui.views"> <stickyView id="com.xyz.views.XYZView" /> - </extension> + </extension> </pre> </p> - The value of the <samp>class</samp> attribute must be a -fully qualified name of the class that implements -<samp>berry::IViewPart</samp>. It is common + The value of the <samp>class</samp> attribute must be a +fully qualified name of the class that implements +<samp>berry::IViewPart</samp>. It is common practice to subclass <samp>berry::ViewPart</samp> or <samp>berry::QtViewPart<samp> when developing a new view. The BlueBerry Platform provides a number of standard views. From the user point of view, these views are no different from any other view provided by the plug-ins. All the views can be shown from the "Show View" submenu of the "Window" menu. The position of a view is persistent: it is saved when the view is closed and restored when the view is reopened in a single session. The position is also persisted between workbench sessions. Copyright (c) 2002, 2005 IBM Corporation and others.<br> All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies -this distribution, and is available at <a +this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h index 7bacb17f52..e51cbc1f1f 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveDescriptor.h @@ -1,106 +1,120 @@ /*=================================================================== BlueBerry Platform 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 BERRYIPERSPECTIVEDESCRIPTOR_H_ #define BERRYIPERSPECTIVEDESCRIPTOR_H_ #include #include #include #include "berryImageDescriptor.h" namespace berry { - /** * \ingroup org_blueberry_ui * * A perspective descriptor describes a perspective in an * IPerspectiveRegistry. *

* A perspective is a template for view visibility, layout, and action visibility * within a workbench page. There are two types of perspective: a predefined * perspective and a custom perspective. *

    *
  • A predefined perspective is defined by an extension to the workbench's * perspective extension point ("org.blueberry.ui.perspectives"). * The extension defines a id, label, and IPerspectiveFactory. * A perspective factory is used to define the initial layout for a page. *
  • *
  • A custom perspective is defined by the user. In this case a predefined * perspective is modified to suit a particular task and saved as a new * perspective. The attributes for the perspective are stored in a separate file * in the workbench's metadata directory. *
  • *
*

*

* Within a page the user can open any of the perspectives known * to the workbench's perspective registry, typically by selecting one from the * workbench's Open Perspective menu. When selected, the views * and actions within the active page rearrange to reflect the perspective. *

*

* This interface is not intended to be implemented by clients. *

* @see IPerspectiveRegistry * @noimplement This interface is not intended to be implemented by clients. */ struct BERRY_UI IPerspectiveDescriptor : public Object { + berryInterfaceMacro(IPerspectiveDescriptor, berry); - berryInterfaceMacro(IPerspectiveDescriptor, berry); - - virtual ~IPerspectiveDescriptor(); + virtual ~IPerspectiveDescriptor(); /** * Returns the description of this perspective. * This is the value of its "description" attribute. * * @return the description * @since 3.0 */ virtual std::string GetDescription() const = 0; /** * Returns this perspective's id. For perspectives declared via an extension, * this is the value of its "id" attribute. * * @return the perspective id */ virtual std::string GetId() const = 0; /** * Returns the descriptor of the image to show for this perspective. * If the extension for this perspective specifies an image, the descriptor * for it is returned. Otherwise a default image is returned. * * @return the descriptor of the image to show for this perspective */ virtual ImageDescriptor::Pointer GetImageDescriptor() const = 0; /** * Returns this perspective's label. For perspectives declared via an extension, * this is the value of its "label" attribute. * * @return the label */ virtual std::string GetLabel() const = 0; -}; + /** + * Returns true if this perspective is predefined by an + * extension. + * + * @return boolean whether this perspective is predefined by an extension + */ + virtual bool IsPredefined() const = 0; + + /** + * Return the category path of this descriptor + * + * @return the category path of this descriptor + */ + virtual std::vector GetCategoryPath() = 0; + + virtual std::vector< std::string> GetKeywordReferences() const = 0; +}; } #endif /*BERRYIPERSPECTIVEDESCRIPTOR_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h index f76644204d..1fac1737ce 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIPerspectiveRegistry.h @@ -1,130 +1,143 @@ /*=================================================================== BlueBerry Platform 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 BERRYIPERSPECTIVEREGISTRY_H_ #define BERRYIPERSPECTIVEREGISTRY_H_ #include "berryIPerspectiveDescriptor.h" #include namespace berry { /** * \ingroup org_blueberry_ui * * The workbench's global registry of perspectives. *

* This registry contains a descriptor for each perspectives in the workbench. * It is initially populated with stock perspectives from the workbench's * perspective extension point ("org.blueberry.ui.perspectives") and * with custom perspectives defined by the user. *

* This interface is not intended to be implemented by clients. *

* @see IWorkbench#getPerspectiveRegistry * @noimplement This interface is not intended to be implemented by clients. */ struct BERRY_UI IPerspectiveRegistry { virtual ~IPerspectiveRegistry(); + /** + * Create a new perspective. + * + * @param label + * the name of the new descriptor + * @param originalDescriptor + * the descriptor on which to base the new descriptor + * @return a new perspective descriptor or null if the + * creation failed. + */ + virtual IPerspectiveDescriptor::Pointer CreatePerspective(const std::string& label, + IPerspectiveDescriptor::Pointer originalDescriptor) = 0; + /** * Clones an existing perspective. * * @param id the id for the cloned perspective, which must not already be used by * any registered perspective * @param label the label assigned to the cloned perspective * @param desc the perspective to clone * @return the cloned perspective descriptor * @throws IllegalArgumentException if there is already a perspective with the given id * * @since 3.0 */ virtual IPerspectiveDescriptor::Pointer ClonePerspective(const std::string& id, const std::string& label, IPerspectiveDescriptor::Pointer desc) = 0; /** * Deletes a perspective. Has no effect if the perspective is defined in an * extension. * * @param persp the perspective to delete * @since 3.2 */ virtual void DeletePerspective(IPerspectiveDescriptor::Pointer persp) = 0; /** * Finds and returns the registered perspective with the given perspective id. * * @param perspectiveId the perspective id * @return the perspective, or null if none * @see IPerspectiveDescriptor#getId */ virtual IPerspectiveDescriptor::Pointer FindPerspectiveWithId(const std::string& perspectiveId) = 0; /** * Finds and returns the registered perspective with the given label. * * @param label the label * @return the perspective, or null if none * @see IPerspectiveDescriptor#getLabel */ virtual IPerspectiveDescriptor::Pointer FindPerspectiveWithLabel(const std::string& label) = 0; /** * Returns the id of the default perspective for the workbench. This identifies one * perspective extension within the workbench's perspective registry. *

* Returns null if there is no default perspective. *

* * @return the default perspective id, or null */ virtual std::string GetDefaultPerspective() = 0; /** * Returns a list of the perspectives known to the workbench. * * @return a list of perspectives */ virtual std::vector GetPerspectives() = 0; /** * Sets the default perspective for the workbench to the given perspective id. * If non-null, the id must correspond to a perspective extension * within the workbench's perspective registry. *

* A null id indicates no default perspective. *

* * @param id a perspective id, or null */ virtual void SetDefaultPerspective(const std::string& id) = 0; /** * Reverts a perspective back to its original definition * as specified in the plug-in manifest. * * @param perspToRevert the perspective to revert * * @since 3.0 */ virtual void RevertPerspective(IPerspectiveDescriptor::Pointer perspToRevert) = 0; }; } #endif /*BERRYIPERSPECTIVEREGISTRY_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h index ab72c8eb09..1cb28d8de2 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIViewDescriptor.h @@ -1,107 +1,107 @@ /*=================================================================== BlueBerry Platform 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 BERRYIVIEWDESCRIPTOR_H_ #define BERRYIVIEWDESCRIPTOR_H_ #include #include "berryIWorkbenchPartDescriptor.h" #include "berryIViewPart.h" #include #include #include "berryImageDescriptor.h" #include #include namespace berry { - /** * \ingroup org_blueberry_ui * * This is a view descriptor. It provides a "description" of a given * given view so that the view can later be constructed. *

* The view registry provides facilities to map from an extension * to a IViewDescriptor. *

*

* This interface is not intended to be implemented by clients. *

* * @see org.blueberry.ui.IViewRegistry */ struct BERRY_UI IViewDescriptor : public IWorkbenchPartDescriptor, public IAdaptable { - berryInterfaceMacro(IViewDescriptor, berry); ~IViewDescriptor(); /** * Creates an instance of the view defined in the descriptor. * * @return the view part * @throws CoreException thrown if there is a problem creating the part */ virtual IViewPart::Pointer CreateView() = 0; + + virtual std::vector< std::string> GetKeywordReferences() const = 0; + /** * Returns an array of strings that represent * view's category path. This array will be used * for hierarchical presentation of the * view in places like submenus. * @return array of category tokens or null if not specified. */ virtual const std::vector& GetCategoryPath() const = 0; /** * Returns the description of this view. * * @return the description */ virtual std::string GetDescription() const = 0; /** * Returns the descriptor for the icon to show for this view. */ virtual SmartPointer GetImageDescriptor() const = 0; /** * Returns whether this view allows multiple instances. * * @return whether this view allows multiple instances */ virtual bool GetAllowMultiple() const = 0; /** * Returns whether this view can be restored upon workbench restart. * * @return whether whether this view can be restored upon workbench restart */ virtual bool IsRestorable() const = 0; virtual bool operator==(const Object*) const = 0; }; - } #endif /*BERRYIVIEWDESCRIPTOR_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h index deba0cfaed..1b685bc8af 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchPage.h @@ -1,860 +1,880 @@ /*=================================================================== BlueBerry Platform 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 BERRYIWORKBENCHPAGE_H_ #define BERRYIWORKBENCHPAGE_H_ #include #include "berryIEditorReference.h" #include "berryIViewReference.h" #include "berryIPerspectiveDescriptor.h" #include "berryIEditorPart.h" #include "berryIViewPart.h" #include "berryIEditorInput.h" #include "berryIPartService.h" #include "berryISelectionService.h" #include "berryIReusableEditor.h" #include "berryIWorkbenchWindow.h" #include #include /** * \ingroup org_blueberry_ui * */ namespace berry { - /** * A workbench page consists of an arrangement of views and editors intended to * be presented together to the user in a single workbench window. *

* A page can contain 0 or more views and 0 or more editors. These views and * editors are contained wholly within the page and are not shared with other * pages. The layout and visible action set for the page is defined by a * perspective. *

* The number of views and editors within a page is restricted to simplify part * management for the user. In particular: *

    *
  • Unless a view explicitly allows for multiple instances in its plugin * declaration there will be only one instance in a given workbench page.
  • *
  • Only one editor can exist for each editor input within a page. *
  • *
*

*

* This interface is not intended to be implemented by clients. *

* * @see IPerspectiveDescriptor * @see IEditorPart * @see IViewPart */ struct BERRY_UI IWorkbenchPage : public IPartService, public ISelectionService, public Object { - berryInterfaceMacro(IWorkbenchPage, berry); /** * An optional attribute within a workspace marker (IMarker) * which identifies the preferred editor type to be opened when * openEditor is called. * * @see #openEditor(IEditorInput, String) * @see #openEditor(IEditorInput, String, boolean) * @deprecated in 3.0 since the notion of markers this is not generally * applicable. Use the IDE-specific constant * IDE.EDITOR_ID_ATTR. */ static const std::string EDITOR_ID_ATTR; // = "org.blueberry.ui.editorID"; //$NON-NLS-1$ /** * Change event id when the perspective is reset to its original state. * * @see IPerspectiveListener */ static const std::string CHANGE_RESET; // = "reset"; //$NON-NLS-1$ /** * Change event id when the perspective has completed a reset to its * original state. * * @since 3.0 * @see IPerspectiveListener */ static const std::string CHANGE_RESET_COMPLETE; // = "resetComplete"; //$NON-NLS-1$ /** * Change event id when one or more views are shown in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_VIEW_SHOW; // = "viewShow"; //$NON-NLS-1$ /** * Change event id when one or more views are hidden in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_VIEW_HIDE; // = "viewHide"; //$NON-NLS-1$ /** * Change event id when one or more editors are opened in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_EDITOR_OPEN; // = "editorOpen"; //$NON-NLS-1$ /** * Change event id when one or more editors are closed in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_EDITOR_CLOSE; // = "editorClose"; //$NON-NLS-1$ /** * Change event id when the editor area is shown in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_EDITOR_AREA_SHOW; // = "editorAreaShow"; //$NON-NLS-1$ /** * Change event id when the editor area is hidden in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_EDITOR_AREA_HIDE; // = "editorAreaHide"; //$NON-NLS-1$ /** * Change event id when an action set is shown in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_ACTION_SET_SHOW; // = "actionSetShow"; //$NON-NLS-1$ /** * Change event id when an action set is hidden in a perspective. * * @see IPerspectiveListener */ static const std::string CHANGE_ACTION_SET_HIDE; // = "actionSetHide"; //$NON-NLS-1$ /** * Show view mode that indicates the view should be made visible and * activated. Use of this mode has the same effect as calling * {@link #showView(String)}. * * @since 3.0 */ static const int VIEW_ACTIVATE; // = 1; /** * Show view mode that indicates the view should be made visible. If the * view is opened in the container that contains the active view then this * has the same effect as VIEW_CREATE. * * @since 3.0 */ static const int VIEW_VISIBLE; // = 2; /** * Show view mode that indicates the view should be made created but not * necessarily be made visible. It will only be made visible in the event * that it is opened in its own container. In other words, only if it is not * stacked with another view. * * @since 3.0 */ static const int VIEW_CREATE; // = 3; /** * Editor opening match mode specifying that no matching against existing * editors should be done. * * @since 3.2 */ static const int MATCH_NONE; // = 0; /** * Editor opening match mode specifying that the editor input should be * considered when matching against existing editors. * * @since 3.2 */ static const int MATCH_INPUT; // = 1; /** * Editor opening match mode specifying that the editor id should be * considered when matching against existing editors. * * @since 3.2 */ static const int MATCH_ID; // = 2; ~IWorkbenchPage(); - /** * Activates the given part. The part will be brought to the front and given * focus. The part must belong to this page. * * @param part * the part to activate */ virtual void Activate(IWorkbenchPart::Pointer part) = 0; /** * Adds a property change listener. * * @param listener * the property change listener to add * @since 2.0 */ //virtual void addPropertyChangeListener(IPropertyChangeListener listener); /** * Moves the given part forward in the Z order of this page so as to make it * visible, without changing which part has focus. The part must belong to * this page. * * @param part * the part to bring forward */ virtual void BringToTop(IWorkbenchPart::Pointer part) = 0; /** * Closes this workbench page. If this page is the active one, this honor is * passed along to one of the window's other pages if possible. *

* If the page has an open editor with unsaved content, the user will be * given the opportunity to save it. *

* * @return true if the page was successfully closed, and * false if it is still open */ virtual bool Close() = 0; /** * Closes all of the editors belonging to this workbench page. *

* If the page has open editors with unsaved content and save * is true, the user will be given the opportunity to save * them. *

* * @param save * * @return true if all editors were successfully closed, and * false if at least one is still open */ virtual bool CloseAllEditors(bool save) = 0; /** * Closes the given Array of editor references. The editors * must belong to this workbench page. *

* If any of the editors have unsaved content and save is * true, the user will be given the opportunity to save * them. *

* * @param editorRefs * the editors to close * @param save * true to save the editor contents if required * (recommended), and false to discard any unsaved * changes * @return true if the editors were successfully closed, and * false if the editors are still open * @since 3.0 */ virtual bool CloseEditors(const std::list& editorRefs, bool save) = 0; /** * Closes the given editor. The editor must belong to this workbench page. *

* If the editor has unsaved content and save is * true, the user will be given the opportunity to save it. *

* * @param editor * the editor to close * @param save * true to save the editor contents if required * (recommended), and false to discard any unsaved * changes * @return true if the editor was successfully closed, and * false if the editor is still open */ virtual bool CloseEditor(IEditorPart::Pointer editor, bool save) = 0; /** * Returns the view in this page with the specified id. There is at most one * view in the page with the specified id. * * @param viewId * the id of the view extension to use * @return the view, or null if none is found */ virtual IViewPart::Pointer FindView(const std::string& viewId) = 0; /** * Returns the view reference with the specified id. * * @param viewId * the id of the view extension to use * @return the view reference, or null if none is found * @since 3.0 */ virtual IViewReference::Pointer FindViewReference(const std::string& viewId) = 0; /** * Returns the view reference with the specified id and secondary id. * * @param viewId * the id of the view extension to use * @param secondaryId * the secondary id to use, or null for no * secondary id * @return the view reference, or null if none is found * @since 3.0 */ virtual IViewReference::Pointer FindViewReference(const std::string& viewId, const std::string& secondaryId) = 0; /** * Returns the active editor open in this page. *

* This is the visible editor on the page, or, if there is more than one * visible editor, this is the one most recently brought to top. *

* * @return the active editor, or null if no editor is active */ virtual IEditorPart::Pointer GetActiveEditor() = 0; /** * Returns the editor with the specified input. Returns null if there is no * opened editor with that input. * * @param input * the editor input * @return an editor with input equals to input */ virtual IEditorPart::Pointer FindEditor(IEditorInput::Pointer input) = 0; /** * Returns an array of editor references that match the given input and/or * editor id, as specified by the given match flags. Returns an empty array * if there are no matching editors, or if matchFlags is MATCH_NONE. * * @param input * the editor input, or null if MATCH_INPUT is not * specified in matchFlags * @param editorId * the editor id, or null if MATCH_ID is not * specified in matchFlags * @param matchFlags * a bit mask consisting of zero or more of the MATCH_* constants * OR-ed together * @return the references for the matching editors * * @see #MATCH_NONE * @see #MATCH_INPUT * @see #MATCH_ID * @since 3.2 */ virtual std::vector FindEditors(IEditorInput::Pointer input, const std::string& editorId, int matchFlags) = 0; /** * Returns a list of the editors open in this page. *

* Note that each page has its own editors; editors are never shared between * pages. *

* * @return a list of open editors * * @deprecated use #getEditorReferences() instead */ virtual std::vector GetEditors() = 0; /** * Returns an array of references to open editors in this page. *

* Note that each page has its own editors; editors are never shared between * pages. *

* * @return a list of open editors */ virtual std::list GetEditorReferences() = 0; /** * Returns a list of dirty editors in this page. * * @return a list of dirty editors */ virtual std::vector GetDirtyEditors() = 0; /** * Returns the input for this page. * * @return the input for this page, or null if none */ virtual IAdaptable* GetInput() = 0; /** * Returns the page label. This will be a unique identifier within the * containing workbench window. * * @return the page label */ virtual std::string GetLabel() = 0; /** * Returns the current perspective descriptor for this page, or * null if there is no current perspective. * * @return the current perspective descriptor or null * @see #setPerspective * @see #savePerspective */ virtual IPerspectiveDescriptor::Pointer GetPerspective() = 0; /** * Returns a list of the reference to views visible on this page. *

* Note that each page has its own views; views are never shared between * pages. *

* * @return a list of references to visible views */ virtual std::vector GetViewReferences() = 0; /** * Returns a list of the views visible on this page. *

* Note that each page has its own views; views are never shared between * pages. *

* * @return a list of visible views * * @deprecated use #getViewReferences() instead. */ virtual std::vector GetViews() = 0; /** * Returns the workbench window of this page. * * @return the workbench window */ virtual IWorkbenchWindow::Pointer GetWorkbenchWindow() = 0; /** * Hides the given view. The view must belong to this page. * * @param view * the view to hide */ virtual void HideView(IViewPart::Pointer view) = 0; /** * Hides the given view that belongs to the reference, if any. * * @param view * the references whos view is to be hidden * @since 3.0 */ virtual void HideView(IViewReference::Pointer view) = 0; + /** + * Returns true if perspective with given id contains view with given id + */ + virtual bool HasView(const std::string& perspectiveId, const std::string& viewId) = 0; + /** * Returns whether the specified part is visible. * * @param part * the part to test * @return boolean true if part is visible */ virtual bool IsPartVisible(IWorkbenchPart::Pointer part) = 0; + /** + * Removes the perspective specified by desc. + * + * @param desc + * the perspective that will be removed + */ + virtual void RemovePerspective(IPerspectiveDescriptor::Pointer desc) = 0; + /** * Reuses the specified editor by setting its new input. * * @param editor * the editor to be reused * @param input * the new input for the reusable editor */ virtual void ReuseEditor(IReusableEditor::Pointer editor, IEditorInput::Pointer input) = 0; /** * Opens an editor on the given input. *

* If this page already has an editor open on the target input that editor * is activated; otherwise, a new editor is opened. Two editor inputs, * input1 and input2, are considered the same if * *

    * input1.equals(input2) == true
    * 
. *

*

* The editor type is determined by mapping editorId to an * editor extension registered with the workbench. An editor id is passed * rather than an editor object to prevent the accidental creation of more * than one editor for the same input. It also guarantees a consistent * lifecycle for editors, regardless of whether they are created by the user * or restored from saved data. *

* * @param input * the editor input * @param editorId * the id of the editor extension to use * @return an open and active editor, or null if an external * editor was opened * @exception PartInitException * if the editor could not be created or initialized */ virtual IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const std::string& editorId) = 0; /** * Opens an editor on the given input. *

* If this page already has an editor open on the target input that editor * is brought to the front; otherwise, a new editor is opened. Two editor * inputs are considered the same if they equal. See * Object.equals(Object) * and IEditorInput. If activate == true the editor * will be activated. *

* The editor type is determined by mapping editorId to an editor * extension registered with the workbench. An editor id is passed rather than * an editor object to prevent the accidental creation of more than one editor * for the same input. It also guarantees a consistent lifecycle for editors, * regardless of whether they are created by the user or restored from saved * data. *

* * @param input the editor input * @param editorId the id of the editor extension to use * @param activate if true the editor will be activated * @return an open editor, or null if an external editor was opened * @exception PartInitException if the editor could not be created or initialized */ virtual IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const std::string& editorId, bool activate) = 0; /** * Opens an editor on the given input. *

* If this page already has an editor open that matches the given input * and/or editor id (as specified by the matchFlags argument), that editor * is brought to the front; otherwise, a new editor is opened. Two editor * inputs are considered the same if they equal. See * Object.equals(Object) * and IEditorInput. If activate == true the editor * will be activated. *

* The editor type is determined by mapping editorId to an editor * extension registered with the workbench. An editor id is passed rather than * an editor object to prevent the accidental creation of more than one editor * for the same input. It also guarantees a consistent lifecycle for editors, * regardless of whether they are created by the user or restored from saved * data. *

* * @param input the editor input * @param editorId the id of the editor extension to use * @param activate if true the editor will be activated * @param matchFlags a bit mask consisting of zero or more of the MATCH_* constants OR-ed together * @return an open editor, or null if an external editor was opened * @exception PartInitException if the editor could not be created or initialized * * @see #MATCH_NONE * @see #MATCH_INPUT * @see #MATCH_ID * @since 3.2 */ virtual IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const std::string& editorId, bool activate, int matchFlags) = 0; /** * Removes the property change listener. * * @param listener * the property change listener to remove * @since 2.0 */ //virtual void removePropertyChangeListener(IPropertyChangeListener listener); /** * Changes the visible views, their layout, and the visible action sets * within the page to match the current perspective descriptor. This is a * rearrangement of components and not a replacement. The contents of the * current perspective descriptor are unaffected. *

* For more information on perspective change see * setPerspective(). *

*/ virtual void ResetPerspective() = 0; /** * Saves the contents of all dirty editors belonging to this workbench page. * If there are no dirty editors this method returns without effect. *

* If confirm is true the user is prompted to * confirm the command. *

*

* Note that as of 3.2, this method also saves views that implement * ISaveablePart and are dirty. *

* * @param confirm true to ask the user before saving unsaved * changes (recommended), and false to save * unsaved changes without asking * @return true if the command succeeded, and * false if the operation was canceled by the user or * an error occurred while saving */ virtual bool SaveAllEditors(bool confirm) = 0; /** * Saves the contents of the given editor if dirty. If not, this method * returns without effect. *

* If confirm is true the user is prompted to * confirm the command. Otherwise, the save happens without prompt. *

*

* The editor must belong to this workbench page. *

* * @param editor * the editor to close * @param confirm * true to ask the user before saving unsaved * changes (recommended), and false to save * unsaved changes without asking * @return true if the command succeeded, and * false if the editor was not saved */ virtual bool SaveEditor(IEditorPart::Pointer editor, bool confirm) = 0; /** * Saves the visible views, their layout, and the visible action sets for * this page to the current perspective descriptor. The contents of the * current perspective descriptor are overwritten. */ virtual void SavePerspective() = 0; /** * Saves the visible views, their layout, and the visible action sets for * this page to the given perspective descriptor. The contents of the given * perspective descriptor are overwritten and it is made the current one for * this page. * * @param perspective * the perspective descriptor to save to */ virtual void SavePerspectiveAs(IPerspectiveDescriptor::Pointer perspective) = 0; /** * Changes the visible views, their layout, and the visible action sets * within the page to match the given perspective descriptor. This is a * rearrangement of components and not a replacement. The contents of the * old perspective descriptor are unaffected. *

* When a perspective change occurs the old perspective is deactivated * (hidden) and cached for future reference. Then the new perspective is * activated (shown). The views within the page are shared by all existing * perspectives to make it easy for the user to switch between one * perspective and another quickly without loss of context. *

*

* During activation the action sets are modified. If an action set is * specified in the new perspective which is not visible in the old one it * will be created. If an old action set is not specified in the new * perspective it will be disposed. *

*

* The visible views and their layout within the page also change. If a view * is specified in the new perspective which is not visible in the old one a * new instance of the view will be created. If an old view is not specified * in the new perspective it will be hidden. This view may reappear if the * user selects it from the View menu or if they switch to a perspective * (which may be the old one) where the view is visible. *

*

* The open editors are not modified by this method. *

* * @param perspective * the perspective descriptor */ virtual void SetPerspective(IPerspectiveDescriptor::Pointer perspective) = 0; /** * Shows the view identified by the given view id in this page and gives it * focus. If there is a view identified by the given view id (and with no * secondary id) already open in this page, it is given focus. * * @param viewId * the id of the view extension to use * @return the shown view * @exception PartInitException * if the view could not be initialized */ virtual IViewPart::Pointer ShowView(const std::string& viewId) = 0; /** * Shows a view in this page with the given id and secondary id. The * behaviour of this method varies based on the supplied mode. If * VIEW_ACTIVATE is supplied, the view is focus. If * VIEW_VISIBLE is supplied, then it is made visible but not * given focus. Finally, if VIEW_CREATE is supplied the view * is created and will only be made visible if it is not created in a folder * that already contains visible views. *

* This allows multiple instances of a particular view to be created. They * are disambiguated using the secondary id. If a secondary id is given, the * view must allow multiple instances by having specified * allowMultiple="true" in its extension. *

* * @param viewId * the id of the view extension to use * @param secondaryId * the secondary id to use, or null for no * secondary id * @param mode * the activation mode. Must be {@link #VIEW_ACTIVATE}, * {@link #VIEW_VISIBLE} or {@link #VIEW_CREATE} * @return a view * @exception PartInitException * if the view could not be initialized * @exception IllegalArgumentException * if the supplied mode is not valid * @since 3.0 */ virtual IViewPart::Pointer ShowView(const std::string& viewId, const std::string& secondaryId, int mode) = 0; /** * Returns true if the editor is pinned and should not be * reused. * * @param editor * the editor to test * @return boolean whether the editor is pinned */ virtual bool IsEditorPinned(IEditorPart::Pointer editor) = 0; /** * Returns the perspective shortcuts associated with the current * perspective. Returns an empty array if there is no current perspective. * * @see IPageLayout#addPerspectiveShortcut(String) * @return an array of perspective identifiers * @since 3.1 */ virtual std::vector GetPerspectiveShortcuts() = 0; /** * Returns the show view shortcuts associated with the current perspective. * Returns an empty array if there is no current perspective. * * @see IPageLayout#addShowViewShortcut(String) * @return an array of view identifiers * @since 3.1 */ virtual std::vector GetShowViewShortcuts() = 0; /** * Returns the descriptors for the perspectives that are open in this page, * in the order in which they were opened. * * @return the open perspective descriptors, in order of opening * @since 3.1 */ virtual std::vector GetOpenPerspectives() = 0; /** * Returns the descriptors for the perspectives that are open in this page, * in the order in which they were activated (oldest first). * * @return the open perspective descriptors, in order of activation * @since 3.1 */ virtual std::vector GetSortedPerspectives() = 0; + /** + * Closes current perspective. If last perspective, then entire page + * is closed. + * + * @param saveParts + * whether the page's parts should be saved if closed + * @param closePage + * whether the page itself should be closed if last perspective + */ + virtual void CloseCurrentPerspective(bool saveParts, bool closePage) = 0; + /** * Closes the specified perspective in this page. If the last perspective in * this page is closed, then all editors are closed. Views that are not * shown in other perspectives are closed as well. If saveParts * is true, the user will be prompted to save any unsaved * changes for parts that are being closed. The page itself is closed if * closePage is true. * * @param desc * the descriptor of the perspective to be closed * @param saveParts * whether the page's parts should be saved if closed * @param closePage * whether the page itself should be closed if last perspective * @since 3.1 */ virtual void ClosePerspective(IPerspectiveDescriptor::Pointer desc, bool saveParts, bool closePage) = 0; /** * Closes all perspectives in this page. All editors are closed, prompting * to save any unsaved changes if saveEditors is * true. The page itself is closed if closePage * is true. * * @param saveEditors * whether the page's editors should be saved * @param closePage * whether the page itself should be closed * @since 3.1 */ virtual void CloseAllPerspectives(bool saveEditors, bool closePage) = 0; /** * Find the part reference for the given part. A convenience method to * quickly go from part to part reference. * * @param part * The part to search for. It can be null. * @return The reference for the given part, or null if no * reference can be found. * @since 3.2 */ virtual IWorkbenchPartReference::Pointer GetReference(IWorkbenchPart::Pointer part) = 0; }; - } // namespace berry #endif /*BERRYIWORKBENCHPAGE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h index 4fe572a07c..a4263d0c0f 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/berryIWorkbenchWindow.h @@ -1,206 +1,213 @@ /*=================================================================== BlueBerry Platform 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 BERRYIWORKBENCHWINDOW_H_ #define BERRYIWORKBENCHWINDOW_H_ #include #include #include #include "berryIPageService.h" #include "berryShell.h" #include "services/berryIServiceLocator.h" namespace berry { struct IPartService; struct ISelectionService; struct IWorkbenchPage; struct IWorkbench; /** * \ingroup org_blueberry_ui * * A workbench window is a top level window in a workbench. Visually, a * workbench window has a menubar, a toolbar, a status bar, and a main area for * displaying a single page consisting of a collection of views and editors. *

* Each workbench window has a collection of 0 or more pages; the active page is * the one that is being presented to the end user; at most one page is active * in a window at a time. *

*

* The workbench window supports a few {@link IServiceLocator services} by * default. If these services are used to allocate resources, it is important to * remember to clean up those resources after you are done with them. Otherwise, * the resources will exist until the workbench window is closed. The supported * services are: *

*
    *
  • {@link ICommandService}
  • *
  • {@link IContextService}
  • *
  • {@link IHandlerService}
  • *
  • {@link IBindingService}. Resources allocated through this service will * not be cleaned up until the workbench shuts down.
  • *
*

* This interface is not intended to be implemented by clients. *

* * @see IWorkbenchPage * @noimplement This interface is not intended to be implemented by clients. * */ struct BERRY_UI IWorkbenchWindow : public IPageService, public IServiceLocator, public virtual Object { berryInterfaceMacro(IWorkbenchWindow, berry); /** * Closes this workbench window. *

* If the window has an open editor with unsaved content, the user will be * given the opportunity to save it. *

* * @return true if the window was successfully closed, and * false if it is still open */ virtual bool Close() = 0; + virtual SmartPointer GetPage(int i) = 0; + /** * Returns the currently active page for this workbench window. * * @return the active page, or null if none */ virtual SmartPointer GetActivePage() = 0; /** * Sets or clears the currently active page for this workbench window. * * @param page * the new active page */ virtual void SetActivePage(SmartPointer page) = 0; /** * Returns the part service which tracks part activation within this * workbench window. * * @return the part service */ virtual IPartService* GetPartService() = 0; /** * Returns the selection service which tracks selection within this * workbench window. * * @return the selection service */ virtual ISelectionService* GetSelectionService() = 0; /** * Returns this workbench window's shell. * * @return the shell containing this window's controls or null * if the shell has not been created yet or if the window has been closed */ virtual Shell::Pointer GetShell() = 0; /** * Returns the workbench for this window. * * @return the workbench */ virtual IWorkbench* GetWorkbench() = 0; /** * Returns whether the specified menu is an application menu as opposed to * a part menu. Application menus contain items which affect the workbench * or window. Part menus contain items which affect the active part (view * or editor). *

* This is typically used during "in place" editing. Application menus * should be preserved during menu merging. All other menus may be removed * from the window. *

* * @param menuId * the menu id * @return true if the specified menu is an application * menu, and false if it is not */ //virtual bool IsApplicationMenu(const std::string& menuId) = 0; /** * Creates and opens a new workbench page. The perspective of the new page * is defined by the specified perspective ID. The new page become active. *

* Note: Since release 2.0, a window is limited to contain at most * one page. If a page exist in the window when this method is used, then * another window is created for the new page. Callers are strongly * recommended to use the IWorkbench.showPerspective APIs to * programmatically show a perspective. *

* * @param perspectiveId * the perspective id for the window's initial page * @param input * the page input, or null if there is no current * input. This is used to seed the input for the new page's * views. * @return the new workbench page * @exception WorkbenchException * if a page could not be opened * * @see IWorkbench#showPerspective(String, IWorkbenchWindow, IAdaptable) */ virtual SmartPointer OpenPage(const std::string& perspectiveId, IAdaptable* input) = 0; /** * Creates and opens a new workbench page. The default perspective is used * as a template for creating the page. The page becomes active. *

* Note: Since release 2.0, a window is limited to contain at most * one page. If a page exist in the window when this method is used, then * another window is created for the new page. Callers are strongly * recommended to use the IWorkbench.showPerspective APIs to * programmatically show a perspective. *

* * @param input * the page input, or null if there is no current * input. This is used to seed the input for the new page's * views. * @return the new workbench window * @exception WorkbenchException * if a page could not be opened * * @see IWorkbench#showPerspective(String, IWorkbenchWindow, IAdaptable) */ virtual SmartPointer OpenPage(IAdaptable* input) = 0; + virtual void SetPerspectiveExcludeList(std::vector v) = 0; + virtual std::vector GetPerspectiveExcludeList() = 0; + + virtual void SetViewExcludeList(std::vector v) = 0; + virtual std::vector GetViewExcludeList() = 0; virtual ~IWorkbenchWindow(); }; } #endif /*BERRYIWORKBENCHWINDOW_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp index 1661d690fa..208f6899d0 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryFolderLayout.cpp @@ -1,97 +1,96 @@ /*=================================================================== BlueBerry Platform 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 "berryFolderLayout.h" #include "berryPartPlaceholder.h" #include "berryWorkbenchPlugin.h" #include "berryPageLayout.h" #include "berryLayoutHelper.h" #include "berryUIException.h" namespace berry { - FolderLayout::FolderLayout(PageLayout::Pointer pageLayout, PartStack::Pointer folder, ViewFactory* viewFactory) { this->folder = folder; this->viewFactory = viewFactory; this->pageLayout = pageLayout; } void FolderLayout::AddPlaceholder(const std::string& viewId) { if (!pageLayout->CheckValidPlaceholderId(viewId)) { return; } // Create the placeholder. LayoutPart::Pointer newPart(new PartPlaceholder(viewId)); this->LinkPartToPageLayout(viewId, newPart); // Add it to the folder layout. folder->Add(newPart); } void FolderLayout::AddView(const std::string& viewId) { + pageLayout->AddShowViewShortcut(viewId); if (pageLayout->CheckPartInLayout(viewId)) { return; } try { IViewDescriptor::Pointer descriptor = viewFactory->GetViewRegistry()->Find( ViewFactory::ExtractPrimaryId(viewId)); if (descriptor == 0) { throw PartInitException("View descriptor not found: " + viewId); //$NON-NLS-1$ } PartPane::Pointer newPart = LayoutHelper::CreateView(pageLayout->GetViewFactory(), viewId); this->LinkPartToPageLayout(viewId, newPart); folder->Add(newPart); } catch (PartInitException& e) { // cannot safely open the dialog so log the problem WorkbenchPlugin::Log(this->GetClassName(), "AddView(const std::string&)", e); //$NON-NLS-1$ } } std::string FolderLayout::GetProperty(const std::string& id) { return folder->GetProperty(id); } void FolderLayout::SetProperty(const std::string& id, const std::string& value) { folder->SetProperty(id, value); } void FolderLayout::LinkPartToPageLayout(const std::string& viewId, LayoutPart::Pointer newPart) { pageLayout->SetRefPart(viewId, newPart); pageLayout->SetFolderPart(viewId, folder); // force creation of the view layout rec pageLayout->GetViewLayoutRec(viewId, true); } - -} +} \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp index 028013cd3d..67671fe310 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPageLayout.cpp @@ -1,673 +1,670 @@ /*=================================================================== BlueBerry Platform 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 "berryPageLayout.h" #include "berryWorkbenchPlugin.h" #include "berryLayoutHelper.h" #include "berryViewLayout.h" #include "berryPresentationFactoryUtil.h" #include "berryFolderLayout.h" #include "berryPlaceholderFolderLayout.h" #include "berryUIException.h" #include "berryConstants.h" namespace berry { - PageLayout::PageLayout() : editorVisible(true) { //no-op } PageLayout::PageLayout(ViewSashContainer::Pointer container, ViewFactory* viewFactory, LayoutPart::Pointer editorFolder, IPerspectiveDescriptor::Pointer descriptor) : editorVisible(true) { this->viewFactory = viewFactory; this->rootLayoutContainer = container; this->editorFolder = editorFolder; this->descriptor = descriptor; this->Prefill(); } void PageLayout::AddEditorArea() { try { // Create the part. LayoutPart::Pointer newPart = this->CreateView(ID_EDITOR_AREA); if (newPart == 0) { // this should never happen as long as newID is the editor ID. return; } this->SetRefPart(ID_EDITOR_AREA, newPart); // Add it to the layout. rootLayoutContainer->Add(newPart); } catch (PartInitException& e) { WorkbenchPlugin::Log(this->GetClassName(), "AddEditorArea()", e); //$NON-NLS-1$ } } ViewLayoutRec::Pointer PageLayout::GetViewLayoutRec(const std::string& id, bool create) { ViewLayoutRec::Pointer rec = mapIDtoViewLayoutRec[id]; if (rec == 0 && create) { rec = new ViewLayoutRec(); // set up the view layout appropriately if the page layout is fixed if (this->IsFixed()) { rec->isCloseable = false; rec->isMoveable = false; } mapIDtoViewLayoutRec[id] = rec; } return rec; } void PageLayout::AddPart(LayoutPart::Pointer newPart, const std::string& partId, int relationship, float ratio, const std::string& refId) { - this->SetRefPart(partId, newPart); // If the referenced part is inside a folder, // then use the folder as the reference part. LayoutPart::Pointer refPart = this->GetFolderPart(refId); if (refPart == 0) { refPart = this->GetRefPart(refId); } // Add it to the layout. if (refPart != 0) { ratio = this->NormalizeRatio(ratio); rootLayoutContainer->Add(newPart, this->GetPartSashConst(relationship), ratio, refPart); } else { WorkbenchPlugin::Log("Reference part does not exist yet: " + refId); rootLayoutContainer->Add(newPart); } } void PageLayout::AddPerspectiveShortcut(const std::string& id) { if (std::find(perspectiveShortcuts.begin(), perspectiveShortcuts.end(), id) == perspectiveShortcuts.end()) { perspectiveShortcuts.push_back(id); } } void PageLayout::AddPlaceholder(const std::string& viewId, int relationship, float ratio, const std::string& refId) { if (!this->CheckValidPlaceholderId(viewId)) { return; } // Create the placeholder. PartPlaceholder::Pointer newPart(new PartPlaceholder(viewId)); this->AddPart(newPart, viewId, relationship, ratio, refId); // force creation of the view layout rec this->GetViewLayoutRec(viewId, true); } bool PageLayout::CheckValidPlaceholderId(const std::string& id) { // Check that view is not already in layout. // This check is done even if the id has a wildcard, since it's incorrect to create // multiple placeholders with the same id, wildcard or not. if (this->CheckPartInLayout(id)) { return false; } // check that primary view id is valid, but only if it has no wildcard std::string primaryId = ViewFactory::ExtractPrimaryId(id); if (!ViewFactory::HasWildcard(primaryId)) { IViewRegistry* reg = WorkbenchPlugin::GetDefault()->GetViewRegistry(); IViewDescriptor::Pointer desc = reg->Find(primaryId); if (desc == 0) { // cannot safely open the dialog so log the problem WorkbenchPlugin::Log("Unable to find view with id: " + primaryId + ", when creating perspective " + this->GetDescriptor()->GetId()); //$NON-NLS-1$ //$NON-NLS-2$ return false; } } return true; } void PageLayout::AddShowInPart(const std::string& id) { if (std::find(showInPartIds.begin(), showInPartIds.end(), id) == showInPartIds.end()) { showInPartIds.push_back(id); } } void PageLayout::AddShowViewShortcut(const std::string& id) { - if (std::find(showViewShortcuts.begin(), showViewShortcuts.end(), id) == showInPartIds.end()) + if (std::find(showViewShortcuts.begin(), showViewShortcuts.end(), id) == showViewShortcuts.end()) { showViewShortcuts.push_back(id); } } void PageLayout::AddView(const std::string& viewId, int relationship, float ratio, const std::string& refId) { this->AddView(viewId, relationship, ratio, refId, false, false, true); } void PageLayout::AddView(const std::string& viewId, int relationship, float ratio, const std::string& refId, bool minimized) { this->AddView(viewId, relationship, ratio, refId, minimized, false, true); } void PageLayout::AddView(const std::string& viewId, int relationship, float ratio, const std::string& refId, bool /*minimized*/, bool standalone, bool showTitle) { + this->AddShowViewShortcut(viewId); if (this->CheckPartInLayout(viewId)) { return; } try { // Create the part. LayoutPart::Pointer newPart = this->CreateView(viewId); if (newPart == 0) { this->AddPlaceholder(viewId, relationship, ratio, refId); LayoutHelper::AddViewActivator(PageLayout::Pointer(this), viewId); } else { int appearance = PresentationFactoryUtil::ROLE_VIEW; if (standalone) { if (showTitle) { appearance = PresentationFactoryUtil::ROLE_STANDALONE; } else { appearance = PresentationFactoryUtil::ROLE_STANDALONE_NOTITLE; } } // PartStack for views PartStack::Pointer newFolder(new PartStack(rootLayoutContainer->page, true, appearance, 0)); newFolder->Add(newPart); this->SetFolderPart(viewId, newFolder); this->AddPart(newFolder, viewId, relationship, ratio, refId); // force creation of the view layout rec this->GetViewLayoutRec(viewId, true); // Capture any minimized stacks // if (minimized) // { // // Remember the minimized stacks so we can // // move them to the trim when the Perspective // // activates... // minimizedStacks.add(newFolder); // } } } catch (PartInitException& e) { WorkbenchPlugin::Log(this->GetClassName(), "AddView()", e); //$NON-NLS-1$ } } // List getMinimizedStacks() { // return minimizedStacks; // } bool PageLayout::CheckPartInLayout(const std::string& partId) { if (partId == ID_EDITOR_AREA) return true; if (this->GetRefPart(partId) != 0) // || this->IsFastViewId(partId)) { WorkbenchPlugin::Log("Part already exists in page layout: " + partId); return true; } if (this->GetFolderPart(partId) != 0) // || this->IsFastViewId(partId)) { WorkbenchPlugin::Log("Part already exists in page layout: " + partId); return true; } return false; } IFolderLayout::Pointer PageLayout::CreateFolder(const std::string& folderId, int relationship, float ratio, const std::string& refId) { if (this->CheckPartInLayout(folderId)) { ILayoutContainer::Pointer folder = this->GetFolderPart(folderId); return mapFolderToFolderLayout[folder].Cast(); } // Create the folder. PartStack::Pointer folder(new PartStack(rootLayoutContainer->page)); folder->SetID(folderId); this->AddPart(folder, folderId, relationship, ratio, refId); // Create a wrapper. FolderLayout::Pointer layout(new FolderLayout(PageLayout::Pointer(this), folder, viewFactory)); mapFolderToFolderLayout.insert(std::make_pair(folder, layout)); return layout; } IPlaceholderFolderLayout::Pointer PageLayout::CreatePlaceholderFolder( const std::string& folderId, int relationship, float ratio, const std::string& refId) { if (this->CheckPartInLayout(folderId)) { ContainerPlaceholder::Pointer folder = this->GetRefPart(folderId).Cast(); return mapFolderToFolderLayout[folder]; } // Create the folder. ContainerPlaceholder::Pointer folder(new ContainerPlaceholder("")); folder->SetContainer(rootLayoutContainer); folder->SetRealContainer(ILayoutContainer::Pointer(new PartStack(rootLayoutContainer->page))); folder->SetID(folderId); this->AddPart(folder, folderId, relationship, ratio, refId); // Create a wrapper. IPlaceholderFolderLayout::Pointer layout(new PlaceholderFolderLayout(PageLayout::Pointer(this), folder)); mapFolderToFolderLayout.insert(std::make_pair(folder, layout)); return layout; } LayoutPart::Pointer PageLayout::CreateView(const std::string& partID) { if (partID == ID_EDITOR_AREA) { return editorFolder; } // IViewDescriptor::Pointer viewDescriptor = viewFactory->GetViewRegistry() // ->Find(ViewFactory::ExtractPrimaryId(partID)); // if (WorkbenchActivityHelper.filterItem(viewDescriptor)) // { // return null; // } return LayoutHelper::CreateView(this->GetViewFactory(), partID); } IPerspectiveDescriptor::Pointer PageLayout::GetDescriptor() { return descriptor; } std::string PageLayout::GetEditorArea() { return ID_EDITOR_AREA; } PartStack::Pointer PageLayout::GetFolderPart(const std::string& viewId) { return mapIDtoFolder[viewId].Cast(); } int PageLayout::GetPartSashConst(int nRelationship) { return nRelationship; } std::vector PageLayout::GetPerspectiveShortcuts() { return perspectiveShortcuts; } LayoutPart::Pointer PageLayout::GetRefPart(const std::string& partID) { return mapIDtoPart[partID]; } PartSashContainer::Pointer PageLayout::GetRootLayoutContainer() { return rootLayoutContainer; } std::vector PageLayout::GetShowInPartIds() { return showInPartIds; } std::vector PageLayout::GetShowViewShortcuts() { return showViewShortcuts; } ViewFactory* PageLayout::GetViewFactory() { return viewFactory; } bool PageLayout::IsEditorAreaVisible() { return editorVisible; } float PageLayout::NormalizeRatio(float in) { if (in < RATIO_MIN) { in = RATIO_MIN; } if (in > RATIO_MAX) { in = RATIO_MAX; } return in; } void PageLayout::Prefill() { this->AddEditorArea(); //TODO action sets // Add default action sets. // ActionSetRegistry reg = WorkbenchPlugin.getDefault() // .getActionSetRegistry(); // IActionSetDescriptor[] array = reg.getActionSets(); // int count = array.length; // for (int nX = 0; nX < count; nX++) // { // IActionSetDescriptor desc = array[nX]; // if (desc.isInitiallyVisible()) // { // addActionSet(desc.getId()); // } // } } void PageLayout::SetEditorAreaVisible(bool showEditorArea) { editorVisible = showEditorArea; } void PageLayout::SetFixed(bool fixed) { this->fixed = fixed; } bool PageLayout::IsFixed() { return fixed; } void PageLayout::SetFolderPart(const std::string& viewId, ContainerPlaceholder::Pointer container) { LayoutPart::Pointer tabFolder = container->GetRealContainer(); mapIDtoFolder[viewId] = tabFolder.Cast(); } void PageLayout::SetFolderPart(const std::string& viewId, PartStack::Pointer folder) { mapIDtoFolder[viewId] = folder.Cast(); } void PageLayout::SetFolderPart(const std::string& viewId, ILayoutContainer::Pointer folder) { mapIDtoFolder[viewId] = folder; } void PageLayout::SetRefPart(const std::string& partID, LayoutPart::Pointer part) { mapIDtoPart[partID] = part; } void PageLayout::StackPart(LayoutPart::Pointer newPart, const std::string& viewId, const std::string& refId) { this->SetRefPart(viewId, newPart); // force creation of the view layout rec this->GetViewLayoutRec(viewId, true); // If ref part is in a folder than just add the // new view to that folder. PartStack::Pointer folder = this->GetFolderPart(refId).Cast(); if (folder != 0) { folder->Add(newPart); this->SetFolderPart(viewId, folder); return; } // parts are now always contained in folders // // If the ref part is in the page layout then create // // a new folder and add the new view. // LayoutPart::Pointer refPart = this->GetRefPart(refId); // if (refPart != 0) // && (refPart instanceof PartPane || refPart instanceof PartPlaceholder)) // { // PartStack::Pointer newFolder(new PartStack(rootLayoutContainer->page)); // rootLayoutContainer->Replace(refPart, newFolder); // newFolder->Add(refPart); // newFolder->Add(newPart); // this->SetFolderPart(refId, newFolder); // this->SetFolderPart(viewId, newFolder); // return; // } // If ref part is not found then just do add. WorkbenchPlugin::Log("Referenced part does not exist yet: " + refId); PartStack::Pointer newFolder(new PartStack(rootLayoutContainer->page)); newFolder->Add(newPart); this->SetFolderPart(viewId, newFolder); rootLayoutContainer->Add(newFolder); } void PageLayout::StackPlaceholder(const std::string& viewId, const std::string& refId) { if (this->CheckPartInLayout(viewId)) { return; } // Create the placeholder. PartPlaceholder::Pointer newPart(new PartPlaceholder(viewId)); LayoutPart::Pointer refPart = this->GetRefPart(refId); if (refPart != 0) { newPart->SetContainer(refPart->GetContainer()); } this->StackPart(newPart, viewId, refId); } void PageLayout::StackView(const std::string& viewId, const std::string& refId) { if (this->CheckPartInLayout(viewId)) { return; } // Create the new part. try { LayoutPart::Pointer newPart = this->CreateView(viewId); if (newPart == 0) { this->StackPlaceholder(viewId, refId); LayoutHelper::AddViewActivator(PageLayout::Pointer(this), viewId); } else { this->StackPart(newPart, viewId, refId); } } catch (PartInitException& e) { WorkbenchPlugin::Log(this->GetClassName(), "StackView", e); //$NON-NLS-1$ } } int PageLayout::ConstantToLayoutPosition(int constant) { if (constant == Constants::TOP) return IPageLayout::TOP; if (constant == Constants::BOTTOM) return IPageLayout::BOTTOM; if (constant == Constants::RIGHT) return IPageLayout::RIGHT; if (constant == Constants::LEFT) return IPageLayout::LEFT; return -1; } void PageLayout::AddStandaloneView(const std::string& viewId, bool showTitle, int relationship, float ratio, const std::string& refId) { this->AddView(viewId, relationship, ratio, refId, false, true, showTitle); ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(viewId, true); rec->isStandalone = true; rec->showTitle = showTitle; } void PageLayout::AddStandaloneViewPlaceholder(const std::string& viewId, int relationship, float ratio, const std::string& refId, bool showTitle) { - std::string stackId = viewId + ".standalonefolder"; //$NON-NLS-1$ // Check to see if the view is already in the layout if (!this->CheckValidPlaceholderId(viewId)) { return; } // Create the folder. ContainerPlaceholder::Pointer folder(new ContainerPlaceholder("")); folder->SetContainer(rootLayoutContainer); int appearance = PresentationFactoryUtil::ROLE_STANDALONE; if (!showTitle) { appearance = PresentationFactoryUtil::ROLE_STANDALONE_NOTITLE; } folder->SetRealContainer(ILayoutContainer::Pointer(new PartStack(rootLayoutContainer->page, true, appearance, 0))); folder->SetID(stackId); this->AddPart(folder, stackId, relationship, ratio, refId); // Create a wrapper. PlaceholderFolderLayout::Pointer placeHolder(new PlaceholderFolderLayout(PageLayout::Pointer(this), folder)); // Add the standalone view immediately placeHolder->AddPlaceholder(viewId); ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(viewId, true); rec->isStandalone = true; rec->showTitle = showTitle; } IViewLayout::Pointer PageLayout::GetViewLayout(const std::string& viewId) { ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(viewId, true); if (rec == 0) { return IViewLayout::Pointer(0); } return IViewLayout::Pointer(new ViewLayout(PageLayout::Pointer(this), rec)); } std::map PageLayout::GetIDtoViewLayoutRecMap() { return mapIDtoViewLayoutRec; } void PageLayout::RemovePlaceholder(const std::string& id) { LayoutPart::Pointer part = this->GetRefPart(id); if (part->IsPlaceHolder()) { ILayoutContainer::Pointer stack = this->GetFolderPart(id); if (stack != 0) { stack->Remove(part); } else { //rootLayoutContainer->Remove(part); WorkbenchPlugin::Log("Not removing placeholder: Folder for placeholder " + id + " not found"); } mapIDtoPart.erase(id); mapIDtoFolder.erase(id); mapIDtoViewLayoutRec.erase(id); } } IPlaceholderFolderLayout::Pointer PageLayout::GetFolderForView( const std::string& viewId) { if (mapIDtoFolder[viewId] == 0) return IPlaceholderFolderLayout::Pointer(0); ILayoutContainer::Pointer folder = mapIDtoFolder[viewId]; IPlaceholderFolderLayout::Pointer layout; if (mapFolderToFolderLayout[folder] == 0) { layout = new FolderLayout(PageLayout::Pointer(this), folder.Cast(), viewFactory); mapFolderToFolderLayout[folder] = layout; } else { layout = mapFolderToFolderLayout[folder]; } return layout; } - -} +} \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp index 2c8e5003e2..65c86fe45b 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.cpp @@ -1,1763 +1,1771 @@ /*=================================================================== BlueBerry Platform 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 "tweaklets/berryGuiWidgetsTweaklet.h" #include "berryPerspective.h" #include "berryPerspectiveHelper.h" #include "berryWorkbenchPlugin.h" #include "berryWorkbenchConstants.h" #include "berryPerspectiveExtensionReader.h" #include "berryEditorSashContainer.h" #include "berryPartSite.h" #include "berryViewSite.h" #include "berryEditorAreaHelper.h" #include "intro/berryIntroConstants.h" #include "dialogs/berryMessageDialog.h" #include "berryWorkbenchWindow.h" #include "presentations/berryIStackPresentationSite.h" namespace berry { - const std::string Perspective::VERSION_STRING = "0.016"; Perspective::Perspective(PerspectiveDescriptor::Pointer desc, WorkbenchPage::Pointer page) : descriptor(desc) { this->Init(page); if (desc.IsNotNull()) { this->CreatePresentation(desc); } } Perspective::Perspective(WorkbenchPage::Pointer page) { this->Init(page); } void Perspective::Init(WorkbenchPage::Pointer page) { editorHidden = false; editorAreaState = IStackPresentationSite::STATE_RESTORED; fixed = false; presentation = 0; shouldHideEditorsOnActivate = false; this->page = page.GetPointer(); this->editorArea = page->GetEditorPresentation()->GetLayoutPart(); this->viewFactory = page->GetViewFactory(); } bool Perspective::BringToTop(IViewReference::Pointer ref) { return presentation->BringPartToTop(this->GetPane(ref)); } bool Perspective::ContainsView(IViewPart::Pointer view) { IViewSite::Pointer site = view->GetViewSite(); IViewReference::Pointer ref = this->FindView(site->GetId(), site->GetSecondaryId()); if (ref.IsNull()) { return false; } return (view.Cast() == ref->GetPart(false)); } +bool Perspective::ContainsView(const std::string& viewId) +{ + if (mapIDtoViewLayoutRec.find(viewId)!=mapIDtoViewLayoutRec.end()) + return true; + return false; +} + void Perspective::CreatePresentation(PerspectiveDescriptor::Pointer persp) { if (persp->HasCustomDefinition()) { this->LoadCustomPersp(persp); } else { this->LoadPredefinedPersp(persp); } } Perspective::~Perspective() { // Get rid of presentation. if (presentation == 0) { DisposeViewRefs(); return; } presentation->Deactivate(); // Release each view. std::vector refs(this->GetViewReferences()); for (std::vector::size_type i = 0, length = refs.size(); i < length; i++) { this->GetViewFactory()->ReleaseView(refs[i]); } mapIDtoViewLayoutRec.clear(); } void Perspective::DisposeViewRefs() { if (!memento) { return; } std::vector views(memento->GetChildren(WorkbenchConstants::TAG_VIEW)); for (std::size_t x = 0; x < views.size(); x++) { // Get the view details. IMemento::Pointer childMem = views[x]; std::string id; childMem->GetString(WorkbenchConstants::TAG_ID, id); // skip creation of the intro reference - it's handled elsewhere. if (id == IntroConstants::INTRO_VIEW_ID) { continue; } std::string secondaryId = ViewFactory::ExtractSecondaryId(id); if (!secondaryId.empty()) { id = ViewFactory::ExtractPrimaryId(id); } std::string removed; childMem->GetString(WorkbenchConstants::TAG_REMOVED, removed); if (removed != "true") { IViewReference::Pointer ref = viewFactory->GetView(id, secondaryId); if (ref) { viewFactory->ReleaseView(ref); } } } } IViewReference::Pointer Perspective::FindView(const std::string& viewId) { return this->FindView(viewId, ""); } IViewReference::Pointer Perspective::FindView(const std::string& id, const std::string& secondaryId) { std::vector refs(this->GetViewReferences()); for (unsigned int i = 0; i < refs.size(); i++) { IViewReference::Pointer ref = refs[i]; if (id == ref->GetId() && (secondaryId == ref->GetSecondaryId())) { return ref; } } return IViewReference::Pointer(0); } void* Perspective::GetClientComposite() { return page->GetClientComposite(); } IPerspectiveDescriptor::Pointer Perspective::GetDesc() { return descriptor; } PartPane::Pointer Perspective::GetPane(IViewReference::Pointer ref) { return ref.Cast()->GetPane(); } std::vector Perspective::GetPerspectiveShortcuts() { return perspectiveShortcuts; } PerspectiveHelper* Perspective::GetPresentation() const { return presentation; } std::vector Perspective::GetShowViewShortcuts() { return showViewShortcuts; } ViewFactory* Perspective::GetViewFactory() { return viewFactory; } std::vector Perspective::GetViewReferences() { // Get normal views. if (presentation == 0) { return std::vector(); } std::vector panes; presentation->CollectViewPanes(panes); std::vector result; // List fastViews = (fastViewManager != 0) ? // fastViewManager.getFastViews(0) // : new ArrayList(); // IViewReference[] resultArray = new IViewReference[panes.size() // + fastViews.size()]; // // // Copy fast views. // int nView = 0; // for (int i = 0; i < fastViews.size(); i++) // { // resultArray[nView] = (IViewReference) fastViews.get(i); // ++nView; // } // Copy normal views. for (std::vector::iterator iter = panes.begin(); iter != panes.end(); ++iter) { PartPane::Pointer pane = *iter; result.push_back(pane->GetPartReference().Cast()); } return result; } void Perspective::HideEditorArea() { if (!this->IsEditorAreaVisible()) { return; } // Show the editor in the appropriate location if (this->UseNewMinMax(Perspective::Pointer(this))) { // If it's the currently maximized part we have to restore first // if (this->GetPresentation().getMaximizedStack().Cast() != 0) // { // getPresentation().getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED); // } bool isMinimized = editorAreaState == IStackPresentationSite::STATE_MINIMIZED; if (!isMinimized) this->HideEditorAreaLocal(); //else // this->SetEditorAreaTrimVisibility(false); } else { this->HideEditorAreaLocal(); } editorHidden = true; } void Perspective::HideEditorAreaLocal() { if (editorHolder != 0) { return; } // Replace the editor area with a placeholder so we // know where to put it back on show editor area request. editorHolder = new PartPlaceholder(editorArea->GetID()); presentation->GetLayout()->Replace(editorArea, editorHolder); } bool Perspective::HideView(IViewReference::Pointer ref) { // If the view is locked just return. PartPane::Pointer pane = this->GetPane(ref); presentation->RemovePart(pane); // Dispose view if ref count == 0. this->GetViewFactory()->ReleaseView(ref); return true; } bool Perspective::IsEditorAreaVisible() { return !editorHidden; } ViewLayoutRec::Pointer Perspective::GetViewLayoutRec(IViewReference::Pointer ref, bool create) { ViewLayoutRec::Pointer result = this->GetViewLayoutRec(ViewFactory::GetKey(ref), create); if (result.IsNull() && create==false) { result = this->GetViewLayoutRec(ref->GetId(), false); } return result; } ViewLayoutRec::Pointer Perspective::GetViewLayoutRec(const std::string& viewId, bool create) { ViewLayoutRec::Pointer rec = mapIDtoViewLayoutRec[viewId]; if (rec.IsNull() && create) { rec = new ViewLayoutRec(); mapIDtoViewLayoutRec[viewId] = rec; } return rec; } bool Perspective::IsFixedLayout() { //@issue is there a difference between a fixed //layout and a fixed perspective?? If not the API //may need some polish, WorkbenchPage, PageLayout //and Perspective all have isFixed methods. //PageLayout and Perspective have their own fixed //attribute, we are assuming they are always in sync. //WorkbenchPage delegates to the perspective. return fixed; } bool Perspective::IsStandaloneView(IViewReference::Pointer ref) { ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(ref, false); return rec.IsNotNull() && rec->isStandalone; } bool Perspective::GetShowTitleView(IViewReference::Pointer ref) { ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(ref, false); return rec.IsNotNull() && rec->showTitle; } void Perspective::LoadCustomPersp(PerspectiveDescriptor::Pointer persp) { //get the layout from the registry PerspectiveRegistry* perspRegistry = dynamic_cast(WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()); try { IMemento::Pointer memento = perspRegistry->GetCustomPersp(persp->GetId()); // Restore the layout state. // MultiStatus status = new MultiStatus( // PlatformUI.PLUGIN_ID, // IStatus.OK, // NLS.bind(WorkbenchMessages.Perspective_unableToRestorePerspective, persp.getLabel()), // 0); // status.merge(restoreState(memento)); // status.merge(restoreState()); bool okay = true; okay &= this->RestoreState(memento); okay &= this->RestoreState(); if (!okay) { this->UnableToOpenPerspective(persp, "Unable to open perspective: " + persp->GetLabel()); } } //catch (IOException e) //{ // unableToOpenPerspective(persp, 0); //} catch (WorkbenchException& e) { this->UnableToOpenPerspective(persp, e.displayText()); } } void Perspective::UnableToOpenPerspective(PerspectiveDescriptor::Pointer persp, const std::string& status) { PerspectiveRegistry* perspRegistry = dynamic_cast(WorkbenchPlugin ::GetDefault()->GetPerspectiveRegistry()); perspRegistry->DeletePerspective(persp); // If this is a predefined perspective, we will not be able to delete // the perspective (we wouldn't want to). But make sure to delete the // customized portion. persp->DeleteCustomDefinition(); std::string title = "Restoring problems"; std::string msg = "Unable to read workbench state."; if (status == "") { MessageDialog::OpenError(Shell::Pointer(0), title, msg); } else { //TODO error dialog //ErrorDialog.openError((Shell) 0, title, msg, status); MessageDialog::OpenError(Shell::Pointer(0), title, msg + "\n" + status); } } void Perspective::LoadPredefinedPersp(PerspectiveDescriptor::Pointer persp) { // Create layout engine. IPerspectiveFactory::Pointer factory; try { factory = persp->CreateFactory(); } catch (CoreException& /*e*/) { throw WorkbenchException("Unable to load perspective: " + persp->GetId()); } /* * IPerspectiveFactory#createFactory() can return 0 */ if (factory == 0) { throw WorkbenchException("Unable to load perspective: " + persp->GetId()); } // Create layout factory. ViewSashContainer::Pointer container(new ViewSashContainer(page, this->GetClientComposite())); layout = new PageLayout(container, this->GetViewFactory(), editorArea, descriptor); layout->SetFixed(descriptor->GetFixed()); // // add the placeholders for the sticky folders and their contents IPlaceholderFolderLayout::Pointer stickyFolderRight, stickyFolderLeft, stickyFolderTop, stickyFolderBottom; std::vector descs(WorkbenchPlugin::GetDefault() ->GetViewRegistry()->GetStickyViews()); for (std::size_t i = 0; i < descs.size(); i++) { IStickyViewDescriptor::Pointer stickyViewDescriptor = descs[i]; std::string id = stickyViewDescriptor->GetId(); int location = stickyViewDescriptor->GetLocation(); if (location == IPageLayout::RIGHT) { if (stickyFolderRight == 0) { stickyFolderRight = layout ->CreatePlaceholderFolder( StickyViewDescriptor::STICKY_FOLDER_RIGHT, IPageLayout::RIGHT, .75f, IPageLayout::ID_EDITOR_AREA); } stickyFolderRight->AddPlaceholder(id); } else if (location == IPageLayout::LEFT) { if (stickyFolderLeft == 0) { stickyFolderLeft = layout->CreatePlaceholderFolder( StickyViewDescriptor::STICKY_FOLDER_LEFT, IPageLayout::LEFT, .25f, IPageLayout::ID_EDITOR_AREA); } stickyFolderLeft->AddPlaceholder(id); } else if (location == IPageLayout::TOP) { if (stickyFolderTop == 0) { stickyFolderTop = layout->CreatePlaceholderFolder( StickyViewDescriptor::STICKY_FOLDER_TOP, IPageLayout::TOP, .25f, IPageLayout::ID_EDITOR_AREA); } stickyFolderTop->AddPlaceholder(id); } else if (location == IPageLayout::BOTTOM) { if (stickyFolderBottom == 0) { stickyFolderBottom = layout->CreatePlaceholderFolder( StickyViewDescriptor::STICKY_FOLDER_BOTTOM, IPageLayout::BOTTOM, .75f, IPageLayout::ID_EDITOR_AREA); } stickyFolderBottom->AddPlaceholder(id); } //should never be 0 as we've just added the view above IViewLayout::Pointer viewLayout = layout->GetViewLayout(id); viewLayout->SetCloseable(stickyViewDescriptor->IsCloseable()); viewLayout->SetMoveable(stickyViewDescriptor->IsMoveable()); } // Run layout engine. factory->CreateInitialLayout(layout); PerspectiveExtensionReader extender; extender.ExtendLayout(descriptor->GetId(), layout); // Retrieve view layout info stored in the page layout. std::map layoutInfo = layout->GetIDtoViewLayoutRecMap(); mapIDtoViewLayoutRec.insert(layoutInfo.begin(), layoutInfo.end()); //TODO Perspective action sets // Create action sets. //List temp = new ArrayList(); //this->CreateInitialActionSets(temp, layout.getActionSets()); // IContextService service = 0; // if (page != 0) // { // service = (IContextService) page.getWorkbenchWindow().getService( // IContextService.class); // } // try // { // if (service!=0) // { // service.activateContext(ContextAuthority.DEFER_EVENTS); // } // for (Iterator iter = temp.iterator(); iter.hasNext();) // { // IActionSetDescriptor descriptor = (IActionSetDescriptor) iter // .next(); // addAlwaysOn(descriptor); // } // }finally // { // if (service!=0) // { // service.activateContext(ContextAuthority.SEND_EVENTS); // } // } // newWizardShortcuts = layout.getNewWizardShortcuts(); // showViewShortcuts = layout.getShowViewShortcuts(); // perspectiveShortcuts = layout.getPerspectiveShortcuts(); // showInPartIds = layout.getShowInPartIds(); // // // Retrieve fast views // if (fastViewManager != 0) // { // ArrayList fastViews = layout.getFastViews(); // for (Iterator fvIter = fastViews.iterator(); fvIter.hasNext();) // { // IViewReference ref = (IViewReference) fvIter.next(); // fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref, // !fvIter.hasNext()); // } // } // Is the layout fixed fixed = layout->IsFixed(); + showViewShortcuts = layout->GetShowViewShortcuts(); // Create presentation. presentation = new PerspectiveHelper(page, container, Perspective::Pointer(this)); // Hide editor area if requested by factory if (!layout->IsEditorAreaVisible()) { this->HideEditorArea(); } - } void Perspective::OnActivate() { // Update editor area state. if (editorArea->GetControl() != 0) { bool visible = this->IsEditorAreaVisible(); bool inTrim = editorAreaState == IStackPresentationSite::STATE_MINIMIZED; editorArea->SetVisible(visible && !inTrim); } // // Update fast views. // // Make sure the control for the fastviews are created so they can // // be activated. // if (fastViewManager != 0) // { // List fastViews = fastViewManager.getFastViews(0); // for (int i = 0; i < fastViews.size(); i++) // { // ViewPane pane = getPane((IViewReference) fastViews.get(i)); // if (pane != 0) // { // Control ctrl = pane.getControl(); // if (ctrl == 0) // { // pane.createControl(getClientComposite()); // ctrl = pane.getControl(); // } // ctrl.setEnabled(false); // Remove focus support. // } // } // } // // Set the visibility of all fast view pins // setAllPinsVisible(true); // Trim Stack Support bool useNewMinMax = Perspective::UseNewMinMax(Perspective::Pointer(this)); bool hideEditorArea = shouldHideEditorsOnActivate || (editorHidden && editorHolder == 0); // We have to set the editor area's stack state -before- // activating the presentation since it's used there to determine // size of the resulting stack if (useNewMinMax && !hideEditorArea) { this->RefreshEditorAreaVisibility(); } // Show the layout presentation->Activate(this->GetClientComposite()); // if (useNewMinMax) // { // fastViewManager.activate(); // // // Move any minimized extension stacks to the trim // if (layout != 0) // { // // Turn aimations off // IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); // bool useAnimations = preferenceStore // .getbool(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS); // preferenceStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, false); // // List minStacks = layout.getMinimizedStacks(); // for (Iterator msIter = minStacks.iterator(); msIter.hasNext();) // { // ViewStack vs = (ViewStack) msIter.next(); // vs.setMinimized(true); // } // // // Restore the animation pref // preferenceStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS, useAnimations); // // // this is a one-off deal...set during the extension reading // minStacks.clear(); // layout = 0; // } // } // else // { // // Update the FVB only if not using the new min/max // // // WorkbenchWindow wbw = (WorkbenchWindow) page.getWorkbenchWindow(); //// if (wbw != 0) //// { //// ITrimManager tbm = wbw.getTrimManager(); //// if (tbm != 0) //// { //// IWindowTrim fvb = tbm.getTrim(FastViewBar.FASTVIEWBAR_ID); //// if (fvb instanceof FastViewBar) //// { //// ((FastViewBar)fvb).update(true); //// } //// } //// } // } // // If we are -not- using the new min/max then ensure that there // // are no stacks in the trim. This can happen when a user switches // // back to the 3.0 presentation... // if (!Perspective.useNewMinMax(this) && fastViewManager != 0) // { // bool stacksWereRestored = fastViewManager.restoreAllTrimStacks(); // setEditorAreaTrimVisibility(false); // // // Restore any 'maximized' view stack since we've restored // // the minimized stacks // if (stacksWereRestored && presentation.getMaximizedStack().Cast() != 0) // { // ViewStack vs = (ViewStack) presentation.getMaximizedStack(); // vs.setPresentationState(IStackPresentationSite.STATE_RESTORED); // presentation.setMaximizedStack(0); // } // } // We hide the editor area -after- the presentation activates if (hideEditorArea) { // We do this here to ensure that createPartControl is called on the // top editor // before it is hidden. See bug 20166. this->HideEditorArea(); shouldHideEditorsOnActivate = false; // // this is an override so it should handle both states // if (useNewMinMax) // setEditorAreaTrimVisibility(editorAreaState == IStackPresentationSite.STATE_MINIMIZED); } layout = 0; } void Perspective::OnDeactivate() { presentation->Deactivate(); //setActiveFastView(0); //setAllPinsVisible(false); // // Update fast views. // if (fastViewManager != 0) // { // List fastViews = fastViewManager.getFastViews(0); // for (int i = 0; i < fastViews.size(); i++) // { // ViewPane pane = getPane((IViewReference) fastViews.get(i)); // if (pane != 0) // { // Control ctrl = pane.getControl(); // if (ctrl != 0) // { // ctrl.setEnabled(true); // Add focus support. // } // } // } // // fastViewManager.deActivate(); // } // // // Ensure that the editor area trim is hidden as well // setEditorAreaTrimVisibility(false); } void Perspective::PartActivated(IWorkbenchPart::Pointer /*activePart*/) { // // If a fastview is open close it. // if (activeFastView != 0 // && activeFastView.getPart(false) != activePart) // { // setActiveFastView(0); // } } void Perspective::PerformedShowIn(const std::string& /*partId*/) { //showInTimes.insert(std::make_pair(partId, new Long(System.currentTimeMillis()))); } bool Perspective::RestoreState(IMemento::Pointer memento) { - // MultiStatus result = new MultiStatus( // PlatformUI.PLUGIN_ID, // IStatus.OK, // WorkbenchMessages.Perspective_problemsRestoringPerspective, 0); bool result = true; // Create persp descriptor. descriptor = new PerspectiveDescriptor("", "", PerspectiveDescriptor::Pointer(0)); //result.add(descriptor.restoreState(memento)); result &= descriptor->RestoreState(memento); PerspectiveDescriptor::Pointer desc = WorkbenchPlugin::GetDefault()-> GetPerspectiveRegistry()->FindPerspectiveWithId(descriptor->GetId()).Cast(); if (desc) { descriptor = desc; + } else + { + try + { + WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()->CreatePerspective(descriptor->GetLabel(), descriptor.Cast()); + } catch (...) + { + std::cout << "Perspective could not be loaded" << std::endl; + } } this->memento = memento; // Add the visible views. std::vector views(memento->GetChildren(WorkbenchConstants::TAG_VIEW)); //result.merge(createReferences(views)); result &= this->CreateReferences(views); memento = memento->GetChild(WorkbenchConstants::TAG_FAST_VIEWS); if (memento) { views = memento->GetChildren(WorkbenchConstants::TAG_VIEW); //result.merge(createReferences(views)); result &= this->CreateReferences(views); } return result; } bool Perspective::CreateReferences(const std::vector& views) { // MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, // WorkbenchMessages.Perspective_problemsRestoringViews, 0); bool result = true; for (std::size_t x = 0; x < views.size(); x++) { // Get the view details. IMemento::Pointer childMem = views[x]; std::string id; childMem->GetString(WorkbenchConstants::TAG_ID, id); // skip creation of the intro reference - it's handled elsewhere. if (id == IntroConstants::INTRO_VIEW_ID) { continue; } std::string secondaryId(ViewFactory::ExtractSecondaryId(id)); if (!secondaryId.empty()) { id = ViewFactory::ExtractPrimaryId(id); } // Create and open the view. try { std::string rm; childMem->GetString(WorkbenchConstants::TAG_REMOVED, rm); if (rm != "true") { viewFactory->CreateView(id, secondaryId); } } catch (const PartInitException& e) { childMem->PutString(WorkbenchConstants::TAG_REMOVED, "true"); // result.add(StatusUtil.newStatus(IStatus.ERR, // e.getMessage() == 0 ? "" : e.getMessage(), //$NON-NLS-1$ // e)); WorkbenchPlugin::Log(e.displayText(), e); result &= true; } } return result; } bool Perspective::RestoreState() { if (this->memento == 0) { //return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", 0); //$NON-NLS-1$ return true; } // MultiStatus result = new MultiStatus( // PlatformUI.PLUGIN_ID, // IStatus.OK, // WorkbenchMessages.Perspective_problemsRestoringPerspective, 0); bool result = true; IMemento::Pointer memento = this->memento; this->memento = 0; const IMemento::Pointer boundsMem(memento->GetChild(WorkbenchConstants::TAG_WINDOW)); if (boundsMem) { Rectangle r(0, 0, 0, 0); boundsMem->GetInteger(WorkbenchConstants::TAG_X, r.x); boundsMem->GetInteger(WorkbenchConstants::TAG_Y, r.y); boundsMem->GetInteger(WorkbenchConstants::TAG_HEIGHT, r.height); boundsMem->GetInteger(WorkbenchConstants::TAG_WIDTH, r.width); //StartupThreading.runWithoutExceptions(new StartupRunnable() // { - // void runWithException() throws Throwable // { if (page->GetWorkbenchWindow()->GetActivePage() == 0) { page->GetWorkbenchWindow()->GetShell()->SetBounds(r); } // } // }); - } // Create an empty presentation.. PerspectiveHelper* pres; //StartupThreading.runWithoutExceptions(new StartupRunnable() // { - // void runWithException() throws Throwable // { ViewSashContainer::Pointer mainLayout(new ViewSashContainer(page, this->GetClientComposite())); pres = new PerspectiveHelper(page, mainLayout, Perspective::Pointer(this)); // }}); // Read the layout. // result.merge(pres.restoreState(memento // .getChild(IWorkbenchConstants.TAG_LAYOUT))); result &= pres->RestoreState(memento->GetChild(WorkbenchConstants::TAG_LAYOUT)); //StartupThreading.runWithoutExceptions(new StartupRunnable() // { - // void runWithException() throws Throwable // { // Add the editor workbook. Do not hide it now. pres->ReplacePlaceholderWithPart(editorArea); // }}); // Add the visible views. std::vector views(memento->GetChildren(WorkbenchConstants::TAG_VIEW)); for (std::size_t x = 0; x < views.size(); x++) { // Get the view details. IMemento::Pointer childMem = views[x]; std::string id; childMem->GetString(WorkbenchConstants::TAG_ID, id); std::string secondaryId(ViewFactory::ExtractSecondaryId(id)); if (!secondaryId.empty()) { id = ViewFactory::ExtractPrimaryId(id); } // skip the intro as it is restored higher up in workbench. if (id == IntroConstants::INTRO_VIEW_ID) { continue; } // Create and open the view. IViewReference::Pointer viewRef = viewFactory->GetView(id, secondaryId); WorkbenchPartReference::Pointer ref = viewRef.Cast(); // report error if (ref == 0) { std::string key = ViewFactory::GetKey(id, secondaryId); // result.add(new Status(IStatus.ERR, PlatformUI.PLUGIN_ID, 0, // NLS.bind(WorkbenchMessages.Perspective_couldNotFind, key ), 0)); WorkbenchPlugin::Log("Could not find view: " + key); continue; } bool willPartBeVisible = pres->WillPartBeVisible(ref->GetId(), secondaryId); if (willPartBeVisible) { IViewPart::Pointer view = ref->GetPart(true).Cast(); if (view) { ViewSite::Pointer site = view->GetSite().Cast(); pres->ReplacePlaceholderWithPart(site->GetPane().Cast()); } } else { pres->ReplacePlaceholderWithPart(ref->GetPane()); } } // // Load the fast views // if (fastViewManager != 0) // fastViewManager.restoreState(memento, result); // Load the view layout recs std::vector recMementos(memento ->GetChildren(WorkbenchConstants::TAG_VIEW_LAYOUT_REC)); for (std::size_t i = 0; i < recMementos.size(); i++) { IMemento::Pointer recMemento = recMementos[i]; std::string compoundId; if (recMemento->GetString(WorkbenchConstants::TAG_ID, compoundId)) { ViewLayoutRec::Pointer rec = GetViewLayoutRec(compoundId, true); std::string closeablestr; recMemento->GetString(WorkbenchConstants::TAG_CLOSEABLE, closeablestr); if (WorkbenchConstants::FALSE_VAL == closeablestr) { rec->isCloseable = false; } std::string moveablestr; recMemento->GetString(WorkbenchConstants::TAG_MOVEABLE, moveablestr); if (WorkbenchConstants::FALSE_VAL == moveablestr) { rec->isMoveable = false; } std::string standalonestr; recMemento->GetString(WorkbenchConstants::TAG_STANDALONE, standalonestr); if (WorkbenchConstants::TRUE_VAL == standalonestr) { rec->isStandalone = true; std::string showstr; recMemento->GetString(WorkbenchConstants::TAG_SHOW_TITLE, showstr); rec->showTitle = WorkbenchConstants::FALSE_VAL != showstr; } } } //final IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class); try { // one big try block, don't kill me here // // defer context events // if (service != 0) // { // service.activateContext(ContextAuthority.DEFER_EVENTS); // } // // HashSet knownActionSetIds = new HashSet(); // // // Load the always on action sets. std::vector actions; // = memento // .getChildren(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET); // for (int x = 0; x < actions.length; x++) // { // String actionSetID = actions[x] // .getString(IWorkbenchConstants.TAG_ID); // final IActionSetDescriptor d = WorkbenchPlugin.getDefault() // .getActionSetRegistry().findActionSet(actionSetID); // if (d != 0) // { // StartupThreading // .runWithoutExceptions(new StartupRunnable() // { // void runWithException() throws Throwable // { // addAlwaysOn(d); // } // }); // // knownActionSetIds.add(actionSetID); // } // } // // // Load the always off action sets. // actions = memento // .getChildren(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET); // for (int x = 0; x < actions.length; x++) // { // String actionSetID = actions[x] // .getString(IWorkbenchConstants.TAG_ID); // final IActionSetDescriptor d = WorkbenchPlugin.getDefault() // .getActionSetRegistry().findActionSet(actionSetID); // if (d != 0) // { // StartupThreading // .runWithoutExceptions(new StartupRunnable() // { // void runWithException() throws Throwable // { // addAlwaysOff(d); // } // }); // knownActionSetIds.add(actionSetID); // } // } // Load "show view actions". actions = memento->GetChildren(WorkbenchConstants::TAG_SHOW_VIEW_ACTION); for (std::size_t x = 0; x < actions.size(); x++) { std::string id; actions[x]->GetString(WorkbenchConstants::TAG_ID, id); showViewShortcuts.push_back(id); } // // Load "show in times". // actions = memento.getChildren(IWorkbenchConstants.TAG_SHOW_IN_TIME); // for (int x = 0; x < actions.length; x++) // { // String id = actions[x].getString(IWorkbenchConstants.TAG_ID); // String timeStr = actions[x] // .getString(IWorkbenchConstants.TAG_TIME); // if (id != 0 && timeStr != 0) // { // try // { // long time = Long.parseLong(timeStr); // showInTimes.put(id, new Long(time)); // } // catch (NumberFormatException e) // { // // skip this one // } // } // } // Load "show in parts" from registry, not memento showInPartIds = this->GetShowInIdsFromRegistry(); // // Load "new wizard actions". // actions = memento // .getChildren(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION); // newWizardShortcuts = new ArrayList(actions.length); // for (int x = 0; x < actions.length; x++) // { // String id = actions[x].getString(IWorkbenchConstants.TAG_ID); // newWizardShortcuts.add(id); // } // Load "perspective actions". actions = memento->GetChildren(WorkbenchConstants::TAG_PERSPECTIVE_ACTION); for (std::size_t x = 0; x < actions.size(); x++) { std::string id; actions[x]->GetString(WorkbenchConstants::TAG_ID, id); perspectiveShortcuts.push_back(id); } // ArrayList extActionSets = getPerspectiveExtensionActionSets(); // for (int i = 0; i < extActionSets.size(); i++) // { // String actionSetID = (String) extActionSets.get(i); // if (knownActionSetIds.contains(actionSetID)) // { // continue; // } // final IActionSetDescriptor d = WorkbenchPlugin.getDefault() // .getActionSetRegistry().findActionSet(actionSetID); // if (d != 0) // { // StartupThreading // .runWithoutExceptions(new StartupRunnable() // { // void runWithException() throws Throwable // { // addAlwaysOn(d); // } // }); // knownActionSetIds.add(d.getId()); // } // } // // Add the visible set of action sets to our knownActionSetIds // // Now go through the registry to ensure we pick up any new action // // sets // // that have been added but not yet considered by this perspective. // ActionSetRegistry reg = WorkbenchPlugin.getDefault() // .getActionSetRegistry(); // IActionSetDescriptor[] array = reg.getActionSets(); // int count = array.length; // for (int i = 0; i < count; i++) // { // IActionSetDescriptor desc = array[i]; // if ((!knownActionSetIds.contains(desc.getId())) // && (desc.isInitiallyVisible())) // { // addActionSet(desc); // } // } } catch (...) { // // restart context changes // if (service != 0) // { // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // void runWithException() throws Throwable // { // service.activateContext(ContextAuthority.SEND_EVENTS); // } // }); // } } // Save presentation. presentation = pres; // Hide the editor area if needed. Need to wait for the // presentation to be fully setup first. int areaVisible = 0; bool areaVisibleExists = memento->GetInteger(WorkbenchConstants::TAG_AREA_VISIBLE, areaVisible); // Rather than hiding the editors now we must wait until after their // controls // are created. This ensures that if an editor is instantiated, // createPartControl // is also called. See bug 20166. shouldHideEditorsOnActivate = (areaVisibleExists && areaVisible == 0); // // Restore the trim state of the editor area // IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); // bool useNewMinMax = preferenceStore.getbool(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); // if (useNewMinMax) // { // Integer trimStateInt = memento.getInteger(IWorkbenchConstants.TAG_AREA_TRIM_STATE); // if (trimStateInt != 0) // { // editorAreaState = trimStateInt.intValue() & 0x3; // low order two bits contain the state // editorAreaRestoreOnUnzoom = (trimStateInt.intValue() & 4) != 0; // } // } // restore the fixed state int isFixed = 0; fixed = (memento->GetInteger(WorkbenchConstants::TAG_FIXED, isFixed) && isFixed == 1); return true; } std::vector Perspective::GetShowInIdsFromRegistry() { PerspectiveExtensionReader reader; std::vector tags; tags.push_back(WorkbenchRegistryConstants::TAG_SHOW_IN_PART); reader.SetIncludeOnlyTags(tags); PageLayout::Pointer layout(new PageLayout()); reader.ExtendLayout(descriptor->GetOriginalId(), layout); return layout->GetShowInPartIds(); } void Perspective::SaveDesc() { this->SaveDescAs(descriptor); } void Perspective::SaveDescAs(IPerspectiveDescriptor::Pointer /*desc*/) { //TODO Perspective SaveDescAs // PerspectiveDescriptor::Pointer realDesc = desc.Cast(); // //get the layout from the registry // PerspectiveRegistry* perspRegistry = dynamic_cast(WorkbenchPlugin // ::GetDefault()->GetPerspectiveRegistry()); // // Capture the layout state. // XMLMemento memento = XMLMemento.createWriteRoot("perspective");//$NON-NLS-1$ // IStatus status = saveState(memento, realDesc, false); // if (status.getSeverity() == IStatus.ERR) // { // ErrorDialog.openError((Shell) 0, WorkbenchMessages.Perspective_problemSavingTitle, // WorkbenchMessages.Perspective_problemSavingMessage, // status); // return; // } // //save it to the preference store // try // { // perspRegistry.saveCustomPersp(realDesc, memento); // descriptor = realDesc; // } // catch (IOException e) // { // perspRegistry.deletePerspective(realDesc); // MessageDialog.openError((Shell) 0, WorkbenchMessages.Perspective_problemSavingTitle, // WorkbenchMessages.Perspective_problemSavingMessage); // } } bool Perspective::SaveState(IMemento::Pointer memento) { // MultiStatus result = new MultiStatus( // PlatformUI.PLUGIN_ID, // IStatus.OK, // WorkbenchMessages.Perspective_problemsSavingPerspective, 0); // // result.merge(saveState(memento, descriptor, true)); bool result = true; result &= this->SaveState(memento, descriptor, true); return result; } bool Perspective::SaveState(IMemento::Pointer memento, PerspectiveDescriptor::Pointer p, bool saveInnerViewState) { - // MultiStatus result = new MultiStatus( // PlatformUI.PLUGIN_ID, // IStatus.OK, // WorkbenchMessages.Perspective_problemsSavingPerspective, 0); bool result = true; if (this->memento) { memento->PutMemento(this->memento); return result; } // Save the version number. memento->PutString(WorkbenchConstants::TAG_VERSION, VERSION_STRING); //result.add(p.saveState(memento)); result &= p->SaveState(memento); if (!saveInnerViewState) { Rectangle bounds(page->GetWorkbenchWindow()->GetShell()->GetBounds()); IMemento::Pointer boundsMem = memento ->CreateChild(WorkbenchConstants::TAG_WINDOW); boundsMem->PutInteger(WorkbenchConstants::TAG_X, bounds.x); boundsMem->PutInteger(WorkbenchConstants::TAG_Y, bounds.y); boundsMem->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height); boundsMem->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width); } // // Save the "always on" action sets. // Iterator itr = alwaysOnActionSets.iterator(); // while (itr.hasNext()) // { // IActionSetDescriptor desc = (IActionSetDescriptor) itr.next(); // IMemento child = memento // .createChild(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET); // child.putString(IWorkbenchConstants.TAG_ID, desc.getId()); // } // // Save the "always off" action sets. // itr = alwaysOffActionSets.iterator(); // while (itr.hasNext()) // { // IActionSetDescriptor desc = (IActionSetDescriptor) itr.next(); // IMemento child = memento // .createChild(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET); // child.putString(IWorkbenchConstants.TAG_ID, desc.getId()); // } // Save "show view actions" for (std::vector::iterator itr = showViewShortcuts.begin(); itr != showViewShortcuts.end(); ++itr) { IMemento::Pointer child = memento ->CreateChild(WorkbenchConstants::TAG_SHOW_VIEW_ACTION); child->PutString(WorkbenchConstants::TAG_ID, *itr); } // // Save "show in times" // itr = showInTimes.keySet().iterator(); // while (itr.hasNext()) // { // String id = (String) itr.next(); // Long time = (Long) showInTimes.get(id); // IMemento child = memento // .createChild(IWorkbenchConstants.TAG_SHOW_IN_TIME); // child.putString(IWorkbenchConstants.TAG_ID, id); // child.putString(IWorkbenchConstants.TAG_TIME, time.toString()); // } // // Save "new wizard actions". // itr = newWizardShortcuts.iterator(); // while (itr.hasNext()) // { // String str = (String) itr.next(); // IMemento child = memento // .createChild(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION); // child.putString(IWorkbenchConstants.TAG_ID, str); // } // Save "perspective actions". for (std::vector::iterator itr = perspectiveShortcuts.begin(); itr != perspectiveShortcuts.end(); ++itr) { IMemento::Pointer child = memento ->CreateChild(WorkbenchConstants::TAG_PERSPECTIVE_ACTION); child->PutString(WorkbenchConstants::TAG_ID, *itr); } // Get visible views. std::vector viewPanes; presentation->CollectViewPanes(viewPanes); // Save the views. for (std::vector::iterator itr = viewPanes.begin(); itr != viewPanes.end(); ++itr) { IWorkbenchPartReference::Pointer ref((*itr)->GetPartReference()); IViewDescriptor::Pointer desc = page->GetViewFactory()->GetViewRegistry() ->Find(ref->GetId()); if(desc && desc->IsRestorable()) { IMemento::Pointer viewMemento = memento ->CreateChild(WorkbenchConstants::TAG_VIEW); viewMemento->PutString(WorkbenchConstants::TAG_ID, ViewFactory::GetKey(ref.Cast())); } } // // save all fastview state // if (fastViewManager != 0) // fastViewManager.saveState(memento); // Save the view layout recs. for (std::map::iterator i = mapIDtoViewLayoutRec.begin(); i != mapIDtoViewLayoutRec.end(); ++i) { std::string compoundId(i->first); ViewLayoutRec::Pointer rec(i->second); if (rec && (!rec->isCloseable || !rec->isMoveable || rec->isStandalone)) { IMemento::Pointer layoutMemento(memento ->CreateChild(WorkbenchConstants::TAG_VIEW_LAYOUT_REC)); layoutMemento->PutString(WorkbenchConstants::TAG_ID, compoundId); if (!rec->isCloseable) { layoutMemento->PutString(WorkbenchConstants::TAG_CLOSEABLE, WorkbenchConstants::FALSE_VAL); } if (!rec->isMoveable) { layoutMemento->PutString(WorkbenchConstants::TAG_MOVEABLE, WorkbenchConstants::FALSE_VAL); } if (rec->isStandalone) { layoutMemento->PutString(WorkbenchConstants::TAG_STANDALONE, WorkbenchConstants::TRUE_VAL); layoutMemento->PutString(WorkbenchConstants::TAG_SHOW_TITLE, rec->showTitle ? WorkbenchConstants::TRUE_VAL : WorkbenchConstants::FALSE_VAL); } } } // Save the layout. IMemento::Pointer childMem(memento->CreateChild(WorkbenchConstants::TAG_LAYOUT)); //result.add(presentation.saveState(childMem)); result &= presentation->SaveState(childMem); // Save the editor visibility state if (this->IsEditorAreaVisible()) { memento->PutInteger(WorkbenchConstants::TAG_AREA_VISIBLE, 1); } else { memento->PutInteger(WorkbenchConstants::TAG_AREA_VISIBLE, 0); } // // Save the trim state of the editor area if using the new min/max // IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); // bool useNewMinMax = preferenceStore.getbool(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); // if (useNewMinMax) // { // int trimState = editorAreaState; // trimState |= editorAreaRestoreOnUnzoom ? 4 : 0; // memento.putInteger(IWorkbenchConstants.TAG_AREA_TRIM_STATE, trimState); // } // Save the fixed state if (fixed) { memento->PutInteger(WorkbenchConstants::TAG_FIXED, 1); } else { memento->PutInteger(WorkbenchConstants::TAG_FIXED, 0); } return result; } void Perspective::SetPerspectiveActionIds(const std::vector& list) { perspectiveShortcuts = list; } void Perspective::SetShowInPartIds(const std::vector& list) { showInPartIds = list; } void Perspective::SetShowViewActionIds(const std::vector& list) { showViewShortcuts = list; } void Perspective::ShowEditorArea() { if (this->IsEditorAreaVisible()) { return; } editorHidden = false; // Show the editor in the appropriate location if (this->UseNewMinMax(Perspective::Pointer(this))) { bool isMinimized = editorAreaState == IStackPresentationSite::STATE_MINIMIZED; if (!isMinimized) { // If the editor area is going to show then we have to restore // if (getPresentation().getMaximizedStack() != 0) // getPresentation().getMaximizedStack().setState(IStackPresentationSite.STATE_RESTORED); this->ShowEditorAreaLocal(); } // else // setEditorAreaTrimVisibility(true); } else { this->ShowEditorAreaLocal(); } } void Perspective::ShowEditorAreaLocal() { if (editorHolder == 0 || editorHidden) { return; } // Replace the part holder with the editor area. presentation->GetLayout()->Replace(editorHolder, editorArea); editorHolder = 0; } void Perspective::SetEditorAreaState(int newState) { if (newState == editorAreaState) return; editorAreaState = newState; // // reset the restore flag if we're not minimized // if (newState != IStackPresentationSite::STATE_MINIMIZED) // editorAreaRestoreOnUnzoom = false; this->RefreshEditorAreaVisibility(); } int Perspective::GetEditorAreaState() { return editorAreaState; } void Perspective::RefreshEditorAreaVisibility() { // Nothing shows up if the editor area isn't visible at all if (editorHidden) { this->HideEditorAreaLocal(); //setEditorAreaTrimVisibility(false); return; } PartStack::Pointer editorStack = editorArea.Cast()->GetUpperRightEditorStack(); if (editorStack == 0) return; // Whatever we're doing, make the current editor stack match it //editorStack->SetStateLocal(editorAreaState); // If it's minimized then it's in the trim if (editorAreaState == IStackPresentationSite::STATE_MINIMIZED) { // Hide the editor area and show its trim this->HideEditorAreaLocal(); //setEditorAreaTrimVisibility(true); } else { // Show the editor area and hide its trim //setEditorAreaTrimVisibility(false); this->ShowEditorAreaLocal(); // if (editorAreaState == IStackPresentationSite::STATE_MAXIMIZED) // getPresentation().setMaximizedStack(editorStack); } } IViewReference::Pointer Perspective::GetViewReference(const std::string& viewId, const std::string& secondaryId) { IViewReference::Pointer ref = page->FindViewReference(viewId, secondaryId); if (ref == 0) { ViewFactory* factory = this->GetViewFactory(); try { ref = factory->CreateView(viewId, secondaryId); } catch (PartInitException& /*e*/) { // IStatus status = StatusUtil.newStatus(IStatus.ERR, // e.getMessage() == 0 ? "" : e.getMessage(), //$NON-NLS-1$ // e); // StatusUtil.handleStatus(status, "Failed to create view: id=" + viewId, //$NON-NLS-1$ // StatusManager.LOG); //TODO Perspective status message WorkbenchPlugin::Log("Failed to create view: id=" + viewId); } } return ref; } IViewPart::Pointer Perspective::ShowView(const std::string& viewId, const std::string& secondaryId) { ViewFactory* factory = this->GetViewFactory(); IViewReference::Pointer ref = factory->CreateView(viewId, secondaryId); IViewPart::Pointer part = ref->GetPart(true).Cast(); if (part == 0) { throw PartInitException("Could not create view: " + ref->GetId()); } PartSite::Pointer site = part->GetSite().Cast(); PartPane::Pointer pane = site->GetPane(); //TODO Perspective preference store // IPreferenceStore store = WorkbenchPlugin.getDefault() // .getPreferenceStore(); // int openViewMode = store.getInt(IPreferenceConstants.OPEN_VIEW_MODE); // // if (openViewMode == IPreferenceConstants.OVM_FAST && // fastViewManager != 0) // { // fastViewManager.addViewReference(FastViewBar.FASTVIEWBAR_ID, -1, ref, true); // setActiveFastView(ref); // } // else if (openViewMode == IPreferenceConstants.OVM_FLOAT // && presentation.canDetach()) // { // presentation.addDetachedPart(pane); // } // else // { if (this->UseNewMinMax(Perspective::Pointer(this))) { // Is this view going to show in the trim? // LayoutPart vPart = presentation.findPart(viewId, secondaryId); // Determine if there is a trim stack that should get the view std::string trimId; // // If we can locate the correct trim stack then do so // if (vPart != 0) // { // String id = 0; // ILayoutContainer container = vPart.getContainer(); // if (container.Cast() != 0) // id = ((ContainerPlaceholder)container).getID(); // else if (container.Cast() != 0) // id = ((ViewStack)container).getID(); // // // Is this place-holder in the trim? // if (id != 0 && fastViewManager.getFastViews(id).size()> 0) // { // trimId = id; // } // } // // // No explicit trim found; If we're maximized then we either have to find an // // arbitrary stack... // if (trimId == 0 && presentation.getMaximizedStack() != 0) // { // if (vPart == 0) // { // ViewStackTrimToolBar blTrimStack = fastViewManager.getBottomRightTrimStack(); // if (blTrimStack != 0) // { // // OK, we've found a trim stack to add it to... // trimId = blTrimStack.getId(); // // // Since there was no placeholder we have to add one // LayoutPart blPart = presentation.findPart(trimId, 0); // if (blPart.Cast() != 0) // { // ContainerPlaceholder cph = (ContainerPlaceholder) blPart; // if (cph.getRealContainer().Cast() != 0) // { // ViewStack vs = (ViewStack) cph.getRealContainer(); // // // Create a 'compound' id if this is a multi-instance part // String compoundId = ref.getId(); // if (ref.getSecondaryId() != 0) // compoundId = compoundId + ':' + ref.getSecondaryId(); // // // Add the new placeholder // vs.add(new PartPlaceholder(compoundId)); // } // } // } // } // } // // // If we have a trim stack located then add the view to it // if (trimId != "") // { // fastViewManager.addViewReference(trimId, -1, ref, true); // } // else // { // bool inMaximizedStack = vPart != 0 && vPart.getContainer() == presentation.getMaximizedStack(); // Do the default behavior presentation->AddPart(pane); // // Now, if we're maximized then we have to minimize the new stack // if (presentation.getMaximizedStack() != 0 && !inMaximizedStack) // { // vPart = presentation.findPart(viewId, secondaryId); // if (vPart != 0 && vPart.getContainer().Cast() != 0) // { // ViewStack vs = (ViewStack)vPart.getContainer(); // vs.setState(IStackPresentationSite.STATE_MINIMIZED); // // // setting the state to minimized will create the trim toolbar // // so we don't need a 0 pointer check here... // fastViewManager.getViewStackTrimToolbar(vs.getID()).setRestoreOnUnzoom(true); // } // } // } } else { presentation->AddPart(pane); } //} // Ensure that the newly showing part is enabled if (pane != 0 && pane->GetControl() != 0) Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetEnabled(pane->GetControl(), true); return part; } IWorkbenchPartReference::Pointer Perspective::GetOldPartRef() { return oldPartRef; } void Perspective::SetOldPartRef(IWorkbenchPartReference::Pointer oldPartRef) { this->oldPartRef = oldPartRef; } bool Perspective::IsCloseable(IViewReference::Pointer reference) { ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(reference, false); if (rec != 0) { return rec->isCloseable; } return true; } bool Perspective::IsMoveable(IViewReference::Pointer reference) { ViewLayoutRec::Pointer rec = this->GetViewLayoutRec(reference, false); if (rec != 0) { return rec->isMoveable; } return true; } void Perspective::DescribeLayout(std::string& buf) const { // std::vector fastViews = getFastViews(); // // if (fastViews.length != 0) // { // buf.append("fastviews ("); //$NON-NLS-1$ // for (int idx = 0; idx < fastViews.length; idx++) // { // IViewReference ref = fastViews[idx]; // // if (idx> 0) // { // buf.append(", "); //$NON-NLS-1$ // } // // buf.append(ref.getPartName()); // } // buf.append("), "); //$NON-NLS-1$ // } this->GetPresentation()->DescribeLayout(buf); } void Perspective::TestInvariants() { this->GetPresentation()->GetLayout()->TestInvariants(); } bool Perspective::UseNewMinMax(Perspective::Pointer activePerspective) { // We need to have an active perspective if (activePerspective == 0) return false; // We need to have a trim manager (if we don't then we // don't create a FastViewManager because it'd be useless) // if (activePerspective->GetFastViewManager() == 0) // return false; // Make sure we don't NPE anyplace WorkbenchWindow::Pointer wbw = activePerspective->page->GetWorkbenchWindow().Cast(); if (wbw == 0) return false; // WorkbenchWindowConfigurer* configurer = wbw->GetWindowConfigurer(); // if (configurer == 0) // return false; IPresentationFactory* factory = WorkbenchPlugin::GetDefault()->GetPresentationFactory(); if (factory == 0) return false; // Ok, we should be good to go, return the pref //IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); //bool useNewMinMax = preferenceStore.getbool(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX); return true; } - -} +} \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h index c174fb6531..904d635be2 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspective.h @@ -1,628 +1,630 @@ /*=================================================================== BlueBerry Platform 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 BERRYPERSPECTIVE_H_ #define BERRYPERSPECTIVE_H_ #include #include "berryPerspectiveDescriptor.h" #include "berryPartPlaceholder.h" #include "berryViewLayoutRec.h" #include "berryWorkbenchPage.h" #include "berryLayoutPart.h" #include "berryPageLayout.h" #include "berryPartPane.h" #include "berryIWorkbenchPartReference.h" #include "berryIViewReference.h" #include "berryIViewPart.h" #include #include #include namespace berry { class ViewFactory; class PerspectiveHelper; /** * \ingroup org_blueberry_ui_internal * */ class Perspective : public Object { public: berryObjectMacro(Perspective); friend class WorkbenchPage; + bool ContainsView(const std::string& viewId); + private: ViewFactory* viewFactory; std::map mapIDtoViewLayoutRec; static const std::string VERSION_STRING; // = "0.016";//$NON-NLS-1$ /** * Reference to the part that was previously active * when this perspective was deactivated. */ IWorkbenchPartReference::Pointer oldPartRef; protected: PerspectiveDescriptor::Pointer descriptor; WorkbenchPage* page; // Editor Area management LayoutPart::Pointer editorArea; PartPlaceholder::Pointer editorHolder; bool editorHidden; int editorAreaState; //ArrayList alwaysOnActionSets; //ArrayList alwaysOffActionSets; std::vector showViewShortcuts; std::vector perspectiveShortcuts; bool fixed; std::vector showInPartIds; //HashMap showInTimes; IMemento::Pointer memento; PerspectiveHelper* presentation; bool shouldHideEditorsOnActivate; PageLayout::Pointer layout; /** * ViewManager constructor comment. */ public: Perspective(PerspectiveDescriptor::Pointer desc, WorkbenchPage::Pointer page); /** * ViewManager constructor comment. */ protected: Perspective(WorkbenchPage::Pointer page); protected: void Init(WorkbenchPage::Pointer page); /** * Moves a part forward in the Z order of a perspective so it is visible. * * @param part the part to bring to move forward * @return true if the part was brought to top, false if not. */ public: bool BringToTop(IViewReference::Pointer ref); /** * Returns whether a view exists within the perspective. */ public: bool ContainsView(IViewPart::Pointer view); /** * Create the initial list of action sets. */ // protected: void CreateInitialActionSets(List outputList, List stringList) { // ActionSetRegistry reg = WorkbenchPlugin.getDefault() // .getActionSetRegistry(); // Iterator iter = stringList.iterator(); // while (iter.hasNext()) { // String id = (String) iter.next(); // IActionSetDescriptor desc = reg.findActionSet(id); // if (desc != null) { // outputList.add(desc); // } else { // WorkbenchPlugin.log("Unable to find Action Set: " + id);//$NON-NLS-1$ // } // } // } /** * Create a presentation for a perspective. */ private: void CreatePresentation(PerspectiveDescriptor::Pointer persp); /** * Dispose the perspective and all views contained within. */ public: ~Perspective(); private: void DisposeViewRefs(); /** * Finds the view with the given ID that is open in this page, or null * if not found. * * @param viewId the view ID */ public: IViewReference::Pointer FindView(const std::string& viewId); /** * Finds the view with the given id and secondary id that is open in this page, * or null if not found. * * @param viewId the view ID * @param secondaryId the secondary ID */ public: IViewReference::Pointer FindView(const std::string& id, const std::string& secondaryId); /** * Returns the window's client composite widget * which views and editor area will be parented. */ public: void* GetClientComposite(); /** * Returns the perspective. */ public: IPerspectiveDescriptor::Pointer GetDesc(); /** * Returns the pane for a view reference. */ protected: PartPane::Pointer GetPane(IViewReference::Pointer ref); /** * Returns the perspective shortcuts associated with this perspective. * * @return an array of perspective identifiers */ public: std::vector GetPerspectiveShortcuts(); /** * Returns the presentation. */ public: PerspectiveHelper* GetPresentation() const; /** * Returns the show view shortcuts associated with this perspective. * * @return an array of view identifiers */ public: std::vector GetShowViewShortcuts(); /** * Returns the view factory. */ public: ViewFactory* GetViewFactory(); /** * See IWorkbenchPage. */ public: std::vector GetViewReferences(); /** * Hide the editor area if visible */ protected: void HideEditorArea(); /** * Hide the editor area if visible */ protected: void HideEditorAreaLocal(); public: bool HideView(IViewReference::Pointer ref); /* * Return whether the editor area is visible or not. */ protected: bool IsEditorAreaVisible(); /** * Returns the view layout rec for the given view reference, * or null if not found. If create is true, it creates the record * if not already created. */ public: ViewLayoutRec::Pointer GetViewLayoutRec(IViewReference::Pointer ref, bool create); /** * Returns the view layout record for the given view id * or null if not found. If create is true, it creates the record * if not already created. */ private: ViewLayoutRec::Pointer GetViewLayoutRec(const std::string& viewId, bool create); /** * Returns true if a layout or perspective is fixed. */ public: bool IsFixedLayout(); /** * Returns true if a view is standalone. * * @since 3.0 */ public: bool IsStandaloneView(IViewReference::Pointer ref); /** * Returns whether the title for a view should * be shown. This applies only to standalone views. * * @since 3.0 */ public: bool GetShowTitleView(IViewReference::Pointer ref); /** * Creates a new presentation from a persistence file. * Note: This method should not modify the current state of the perspective. */ private: void LoadCustomPersp(PerspectiveDescriptor::Pointer persp); private: void UnableToOpenPerspective(PerspectiveDescriptor::Pointer persp, const std::string& status); /** * Create a presentation for a perspective. * Note: This method should not modify the current state of the perspective. */ protected: void LoadPredefinedPersp(PerspectiveDescriptor::Pointer persp); // private: void RemoveAlwaysOn(IActionSetDescriptor::Pointer descriptor) { // if (descriptor == null) { // return; // } // if (!alwaysOnActionSets.contains(descriptor)) { // return; // } // // alwaysOnActionSets.remove(descriptor); // if (page != null) { // page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_HIDE); // } // } // protected: void AddAlwaysOff(IActionSetDescriptor descriptor) { // if (descriptor == null) { // return; // } // if (alwaysOffActionSets.contains(descriptor)) { // return; // } // alwaysOffActionSets.add(descriptor); // if (page != null) { // page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_MASK); // } // removeAlwaysOn(descriptor); // } // protected: void AddAlwaysOn(IActionSetDescriptor descriptor) { // if (descriptor == null) { // return; // } // if (alwaysOnActionSets.contains(descriptor)) { // return; // } // alwaysOnActionSets.add(descriptor); // if (page != null) { // page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_SHOW); // } // removeAlwaysOff(descriptor); // } // private: void RemoveAlwaysOff(IActionSetDescriptor descriptor) { // if (descriptor == null) { // return; // } // if (!alwaysOffActionSets.contains(descriptor)) { // return; // } // alwaysOffActionSets.remove(descriptor); // if (page != null) { // page.perspectiveActionSetChanged(this, descriptor, ActionSetManager.CHANGE_UNMASK); // } // } /** * activate. */ protected: void OnActivate(); /** * deactivate. */ protected: void OnDeactivate(); /** * Notifies that a part has been activated. */ public: void PartActivated(IWorkbenchPart::Pointer activePart); /** * The user successfully performed a Show In... action on the specified part. * Update the history. */ public: void PerformedShowIn(const std::string& partId); /** * Fills a presentation with layout data. * Note: This method should not modify the current state of the perspective. */ public: bool RestoreState(IMemento::Pointer memento); bool CreateReferences(const std::vector& views); /** * Fills a presentation with layout data. * Note: This method should not modify the current state of the perspective. */ public: bool RestoreState(); /** * Returns the ActionSets read from perspectiveExtensions in the registry. */ // protected: ArrayList GetPerspectiveExtensionActionSets() { // PerspectiveExtensionReader reader = new PerspectiveExtensionReader(); // reader // .setIncludeOnlyTags(new String[] { IWorkbenchRegistryConstants.TAG_ACTION_SET }); // PageLayout layout = new PageLayout(); // reader.extendLayout(null, descriptor.getOriginalId(), layout); // return layout.getActionSets(); // } /** * Returns the Show In... part ids read from the registry. */ protected: std::vector GetShowInIdsFromRegistry(); /** * Save the layout. */ public: void SaveDesc(); /** * Save the layout. */ public: void SaveDescAs(IPerspectiveDescriptor::Pointer desc); /** * Save the layout. */ public: bool SaveState(IMemento::Pointer memento); /** * Save the layout. */ private: bool SaveState(IMemento::Pointer memento, PerspectiveDescriptor::Pointer p, bool saveInnerViewState); // public: void turnOnActionSets(IActionSetDescriptor[] newArray) { // for (int i = 0; i < newArray.length; i++) { // IActionSetDescriptor descriptor = newArray[i]; // // addAlwaysOn(descriptor); // } // } // public: void turnOffActionSets(IActionSetDescriptor[] toDisable) { // for (int i = 0; i < toDisable.length; i++) { // IActionSetDescriptor descriptor = toDisable[i]; // // turnOffActionSet(descriptor); // } // } // public: void turnOffActionSet(IActionSetDescriptor toDisable) { // addAlwaysOff(toDisable); // } /** * Sets the perspective actions for this page. * This is List of Strings. */ public: void SetPerspectiveActionIds(const std::vector& list); /** * Sets the ids of the parts to list in the Show In... prompter. * This is a List of Strings. */ public: void SetShowInPartIds(const std::vector& list); /** * Sets the ids of the views to list in the Show View shortcuts. * This is a List of Strings. */ public: void SetShowViewActionIds(const std::vector& list); /** * Show the editor area if not visible */ protected: void ShowEditorArea(); /** * Show the editor area if not visible */ protected: void ShowEditorAreaLocal(); public: void SetEditorAreaState(int newState); public: int GetEditorAreaState(); /** * */ public: void RefreshEditorAreaVisibility(); /** * Resolves a view's id into its reference, creating the * view if necessary. * * @param viewId The primary id of the view (must not be * null * @param secondaryId The secondary id of a multiple-instance view * (may be null). * * @return The reference to the specified view. This may be null if the * view fails to create (i.e. thrown a PartInitException) */ public: IViewReference::Pointer GetViewReference(const std::string& viewId, const std::string& secondaryId); /** * Shows the view with the given id and secondary id. */ public: IViewPart::Pointer ShowView(const std::string& viewId, const std::string& secondaryId); /** * Returns the old part reference. * Returns null if there was no previously active part. * * @return the old part reference or null */ public: IWorkbenchPartReference::Pointer GetOldPartRef(); /** * Sets the old part reference. * * @param oldPartRef The old part reference to set, or null */ public: void SetOldPartRef(IWorkbenchPartReference::Pointer oldPartRef); // //for dynamic UI // protected: void AddActionSet(IActionSetDescriptor newDesc) { // IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class); // try { // service.activateContext(ContextAuthority.DEFER_EVENTS); // for (int i = 0; i < alwaysOnActionSets.size(); i++) { // IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets // .get(i); // if (desc.getId().equals(newDesc.getId())) { // removeAlwaysOn(desc); // removeAlwaysOff(desc); // break; // } // } // addAlwaysOn(newDesc); // } finally { // service.activateContext(ContextAuthority.SEND_EVENTS); // } // } // // for dynamic UI // /* package */void removeActionSet(String id) { // IContextService service = (IContextService)page.getWorkbenchWindow().getService(IContextService.class); // try { // service.activateContext(ContextAuthority.DEFER_EVENTS); // for (int i = 0; i < alwaysOnActionSets.size(); i++) { // IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOnActionSets // .get(i); // if (desc.getId().equals(id)) { // removeAlwaysOn(desc); // break; // } // } // // for (int i = 0; i < alwaysOffActionSets.size(); i++) { // IActionSetDescriptor desc = (IActionSetDescriptor) alwaysOffActionSets // .get(i); // if (desc.getId().equals(id)) { // removeAlwaysOff(desc); // break; // } // } // } finally { // service.activateContext(ContextAuthority.SEND_EVENTS); // } // } // void removeActionSet(IActionSetDescriptor toRemove) { // removeAlwaysOn(toRemove); // removeAlwaysOff(toRemove); // } /** * Returns whether the given view is closeable in this perspective. * * @since 3.0 */ public: bool IsCloseable(IViewReference::Pointer reference); /** * Returns whether the given view is moveable in this perspective. * * @since 3.0 */ public: bool IsMoveable(IViewReference::Pointer reference); /** * Writes a description of the layout to the given string buffer. * This is used for drag-drop test suites to determine if two layouts are the * same. Like a hash code, the description should compare as equal iff the * layouts are the same. However, it should be user-readable in order to * help debug failed tests. Although these are english readable strings, * they should not be translated or equality tests will fail. *

* This is only intended for use by test suites. *

* * @param buf */ public: void DescribeLayout(std::string& buf) const; /** * Sanity-checks the LayoutParts in this perspective. Throws an Assertation exception * if an object's internal state is invalid. */ public: void TestInvariants(); // public: IActionSetDescriptor[] getAlwaysOnActionSets() { // return (IActionSetDescriptor[]) alwaysOnActionSets.toArray(new IActionSetDescriptor[alwaysOnActionSets.size()]); // } // public: IActionSetDescriptor[] getAlwaysOffActionSets() { // return (IActionSetDescriptor[]) alwaysOffActionSets.toArray(new IActionSetDescriptor[alwaysOffActionSets.size()]); // } /** * Used to restrict the use of the new min/max behavior to envoronments * in which it has a chance of working... * * @param activePerspective We pass this in as an arg so others won't have * to check it for 'null' (which is one of the failure cases) * */ public: static bool UseNewMinMax(Perspective::Pointer activePerspective); }; } #endif /*BERRYPERSPECTIVE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp index de532d0501..9c8e99e01e 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.cpp @@ -1,306 +1,341 @@ /*=================================================================== BlueBerry Platform 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 "berryPerspectiveDescriptor.h" #include "berryWorkbenchRegistryConstants.h" #include "berryWorkbenchPlugin.h" #include "berryWorkbenchConstants.h" #include "berryPerspectiveRegistry.h" namespace berry { - PerspectiveDescriptor::PerspectiveDescriptor(const std::string& id, const std::string& label, PerspectiveDescriptor::Pointer originalDescriptor) : singleton(false), fixed(false) { this->id = id; this->label = label; if (originalDescriptor != 0) { this->originalId = originalDescriptor->GetOriginalId(); this->imageDescriptor = originalDescriptor->imageDescriptor; // This perspective is based on a perspective in some bundle -- if // that // bundle goes away then I think it makes sense to treat this // perspective // the same as any other -- so store it with the original // descriptor's // bundle's list. // // It might also make sense the other way...removing the following // line // will allow the perspective to stay around when the originating // bundle // is unloaded. // // This might also have an impact on upgrade cases -- should we // really be // destroying all user customized perspectives when the older // version is // removed? // // I'm leaving this here for now since its a good example, but // wouldn't be // surprised if we ultimately decide on the opposite. // // The reason this line is important is that this is the value used // to // put the object into the UI level registry. When that bundle goes // away, // the registry will remove the entire list of objects. So if this // desc // has been put into that list -- it will go away. this->pluginId = originalDescriptor->GetPluginId(); } } PerspectiveDescriptor::PerspectiveDescriptor(const std::string& id, IConfigurationElement::Pointer configElement) : singleton(false), fixed(false) { this->configElement = configElement; this->id = id; // Sanity check. if ((this->GetId() == "") || (this->GetLabel() == "") || (this->GetFactoryClassName() == "")) { throw CoreException("Invalid extension (missing label, id or class name): " + this->GetId()); } } IPerspectiveFactory::Pointer PerspectiveDescriptor::CreateFactory() { // if there is an originalId, then use that descriptor instead if (originalId != "") { // Get the original descriptor to create the factory. If the // original is gone then nothing can be done. IPerspectiveDescriptor::Pointer target = dynamic_cast (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()) ->FindPerspectiveWithId( originalId); return target == 0 ? IPerspectiveFactory::Pointer(0) : target.Cast< PerspectiveDescriptor> ()->CreateFactory(); } // otherwise try to create the executable extension if (configElement != 0) { try { IPerspectiveFactory::Pointer factory( configElement ->CreateExecutableExtension ( WorkbenchRegistryConstants::ATT_CLASS)); if (factory.IsNull()) { // support legacy BlueBerry extensions factory = configElement ->CreateExecutableExtension ( WorkbenchRegistryConstants::ATT_CLASS, IPerspectiveFactory::GetManifestName()); } return factory; } catch (CoreException& /*e*/) { // do nothing } } return IPerspectiveFactory::Pointer(0); } void PerspectiveDescriptor::DeleteCustomDefinition() { dynamic_cast (WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry())->DeleteCustomDefinition( PerspectiveDescriptor::Pointer(this)); } std::string PerspectiveDescriptor::GetDescription() const { return configElement == 0 ? description : RegistryReader::GetDescription( configElement); } bool PerspectiveDescriptor::GetFixed() const { if (configElement == 0) return fixed; bool val = false; configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_FIXED, val); return val; } +std::vector< std::string> PerspectiveDescriptor::GetKeywordReferences() const +{ + std::vector result; + if (configElement.IsNull()) + { + return result; + } + + std::string keywordRefId; + std::vector keywordRefs; + berry::IConfigurationElement::vector::iterator keywordRefsIt; + keywordRefs = configElement->GetChildren("keywordReference"); + for (keywordRefsIt = keywordRefs.begin() + ; keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs + { + (*keywordRefsIt)->GetAttribute("id", keywordRefId); + result.push_back(keywordRefId); + } + return result; +} + std::string PerspectiveDescriptor::GetId() const { return id; } std::string PerspectiveDescriptor::GetPluginId() const { return configElement == 0 ? pluginId : configElement->GetContributor(); } ImageDescriptor::Pointer PerspectiveDescriptor::GetImageDescriptor() const { if (imageDescriptor) return imageDescriptor; if (configElement) { std::string icon; configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON, icon); if (!icon.empty()) { imageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin( configElement->GetContributor(), icon); } - } if (!imageDescriptor) { imageDescriptor = ImageDescriptor::GetMissingImageDescriptor(); } return imageDescriptor; } +std::vector PerspectiveDescriptor::GetCategoryPath() +{ + std::string category; + categoryPath.clear(); + + if (configElement.IsNotNull() && configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY, category)) + { + Poco::StringTokenizer stok(category, "/", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); + // Parse the path tokens and store them + for (Poco::StringTokenizer::Iterator iter = stok.begin(); iter != stok.end(); ++iter) + { + categoryPath.push_back(*iter); + } + } + return categoryPath; +} + std::string PerspectiveDescriptor::GetLabel() const { if (configElement == 0) return label; std::string val; configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, val); return val; } std::string PerspectiveDescriptor::GetOriginalId() const { if (originalId == "") { return this->GetId(); } return originalId; } bool PerspectiveDescriptor::HasCustomDefinition() const { return dynamic_cast (WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry())->HasCustomDefinition( PerspectiveDescriptor::ConstPointer(this)); } bool PerspectiveDescriptor::HasDefaultFlag() const { if (configElement == 0) { return false; } bool val = false; configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_DEFAULT, val); return val; } bool PerspectiveDescriptor::IsPredefined() const { return this->GetFactoryClassName() != "" && configElement != 0; } bool PerspectiveDescriptor::IsSingleton() const { if (configElement == 0) return singleton; bool val = false; configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_SINGLETON, val); return val; } bool PerspectiveDescriptor::RestoreState(IMemento::Pointer memento) { IMemento::Pointer childMem(memento->GetChild( WorkbenchConstants::TAG_DESCRIPTOR)); if (childMem) { childMem->GetString(WorkbenchConstants::TAG_ID, id); childMem->GetString(WorkbenchConstants::TAG_DESCRIPTOR, originalId); childMem->GetString(WorkbenchConstants::TAG_LABEL, label); childMem->GetString(WorkbenchConstants::TAG_CLASS, className); int singletonVal; singleton = childMem->GetInteger(WorkbenchConstants::TAG_SINGLETON, singletonVal); // Find a descriptor in the registry. IPerspectiveDescriptor::Pointer descriptor = WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry()->FindPerspectiveWithId( this->GetOriginalId()); if (descriptor) { // Copy the state from the registred descriptor. imageDescriptor = descriptor->GetImageDescriptor(); } } //return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); //$NON-NLS-1$ return true; } void PerspectiveDescriptor::RevertToPredefined() { if (this->IsPredefined()) { this->DeleteCustomDefinition(); } } bool PerspectiveDescriptor::SaveState(IMemento::Pointer memento) { IMemento::Pointer childMem(memento->CreateChild( WorkbenchConstants::TAG_DESCRIPTOR)); childMem->PutString(WorkbenchConstants::TAG_ID, GetId()); if (!originalId.empty()) { childMem->PutString(WorkbenchConstants::TAG_DESCRIPTOR, originalId); } childMem->PutString(WorkbenchConstants::TAG_LABEL, GetLabel()); childMem->PutString(WorkbenchConstants::TAG_CLASS, GetFactoryClassName()); if (singleton) { childMem->PutInteger(WorkbenchConstants::TAG_SINGLETON, 1); } //return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, "", null); return true; } IConfigurationElement::Pointer PerspectiveDescriptor::GetConfigElement() const { return configElement; } std::string PerspectiveDescriptor::GetFactoryClassName() const { return configElement == 0 ? className : RegistryReader::GetClassValue( configElement, WorkbenchRegistryConstants::ATT_CLASS); } - } diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h index ac8d0eb442..e8956d298d 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveDescriptor.h @@ -1,233 +1,240 @@ /*=================================================================== BlueBerry Platform 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 BERRYPERSPECTIVEDESCRIPTOR_H_ #define BERRYPERSPECTIVEDESCRIPTOR_H_ #include #include "berryIPerspectiveDescriptor.h" #include "berryIPerspectiveFactory.h" #include "berryIMemento.h" #include namespace berry { - /** * \ingroup org_blueberry_ui_internal * * PerspectiveDescriptor. *

* A PerspectiveDesciptor has 3 states: *

*
    *
  1. It isPredefined(), in which case it was defined from an * extension point.
  2. *
  3. It isPredefined() and hasCustomFile, in * which case the user has customized a predefined perspective.
  4. *
  5. It hasCustomFile, in which case the user created a new * perspective.
  6. *
* */ class PerspectiveDescriptor : public IPerspectiveDescriptor { - public: berryObjectMacro(PerspectiveDescriptor); private: std::string id; std::string pluginId; std::string originalId; std::string label; std::string className; std::string description; bool singleton; bool fixed; mutable ImageDescriptor::Pointer imageDescriptor; IConfigurationElement::Pointer configElement; + std::vector categoryPath; + /** * Create a new empty descriptor. * * @param id * the id of the new descriptor * @param label * the label of the new descriptor * @param originalDescriptor * the descriptor that this descriptor is based on */ public: PerspectiveDescriptor(const std::string& id, const std::string& label, PerspectiveDescriptor::Pointer originalDescriptor); /** * Create a descriptor from a config element. * * @param id * the id of the element to create * @param configElement * the element to base this perspective on * @throws CoreException * thrown if there are any missing attributes */ public: PerspectiveDescriptor(const std::string& id, IConfigurationElement::Pointer configElement); /** * Creates a factory for a predefined perspective. If the perspective is not * predefined return null. * * @return the IPerspectiveFactory or null * @throws CoreException * if the object could not be instantiated. */ public: IPerspectiveFactory::Pointer CreateFactory(); /** * Deletes the custom definition for a perspective.. */ public: void DeleteCustomDefinition(); /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveDescriptor#getDescription() */ public: std::string GetDescription() const; +public: void SetDescription(std::string desc) {description = desc; } + std::vector< std::string> GetKeywordReferences() const; /** * Returns whether or not this perspective is fixed. * * @return whether or not this perspective is fixed */ public: bool GetFixed() const; /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveDescriptor#getId() */ public: std::string GetId() const; public: std::string GetPluginId() const; /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveDescriptor#getImageDescriptor() */ public: ImageDescriptor::Pointer GetImageDescriptor() const; /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveDescriptor#getLabel() */ public: std::string GetLabel() const; /** * Return the original id of this descriptor. * * @return the original id of this descriptor */ public: std::string GetOriginalId() const; /** * Returns true if this perspective has a custom definition. * * @return whether this perspective has a custom definition */ public: bool HasCustomDefinition() const; /** * Returns true if this perspective wants to be default. * * @return whether this perspective wants to be default */ public: bool HasDefaultFlag() const; /** * Returns true if this perspective is predefined by an * extension. * * @return boolean whether this perspective is predefined by an extension */ public: bool IsPredefined() const; /** * Returns true if this perspective is a singleton. * * @return whether this perspective is a singleton */ public: bool IsSingleton() const; /** * Restore the state of a perspective from a memento. * * @param memento * the memento to restore from * @return the IStatus of the operation * @see org.blueberry.ui.IPersistableElement */ public: bool RestoreState(IMemento::Pointer memento); /** * Revert to the predefined extension template. Does nothing if this * descriptor is user defined. */ public: void RevertToPredefined(); /** * Save the state of a perspective to a memento. * * @param memento * the memento to restore from * @return the IStatus of the operation * @see org.blueberry.ui.IPersistableElement */ public: bool SaveState(IMemento::Pointer memento); /** * Return the configuration element used to create this perspective, if one * was used. * * @return the configuration element used to create this perspective * @since 3.0 */ public: IConfigurationElement::Pointer GetConfigElement() const; /** * Returns the factory class name for this descriptor. * * @return the factory class name for this descriptor * @since 3.1 */ public: std::string GetFactoryClassName() const; + /** + * Return the category path of this descriptor + * + * @return the category path of this descriptor + */ + public: std::vector GetCategoryPath(); }; - } #endif /*BERRYPERSPECTIVEDESCRIPTOR_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp index 26372149c8..9c50f1908f 100755 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.cpp @@ -1,593 +1,606 @@ /*=================================================================== BlueBerry Platform 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 "berryPerspectiveRegistry.h" #include "berryWorkbench.h" #include "berryWorkbenchPlugin.h" #include "berryPerspectiveRegistryReader.h" #include namespace berry { - const std::string PerspectiveRegistry::EXT = "_persp.xml"; const std::string PerspectiveRegistry::ID_DEF_PERSP = "PerspectiveRegistry.DEFAULT_PERSP"; const std::string PerspectiveRegistry::PERSP = "_persp"; const char PerspectiveRegistry::SPACE_DELIMITER = ' '; PerspectiveRegistry::PerspectiveRegistry() { //IExtensionTracker tracker = PlatformUI.getWorkbench() .getExtensionTracker(); //tracker.registerHandler(this, null); //this->InitializePreferenceChangeListener(); //WorkbenchPlugin::GetDefault()->GetPreferenceStore()->AddPropertyChangeListener( // preferenceListener); - } void PerspectiveRegistry::AddPerspective(PerspectiveDescriptor::Pointer desc) { if (desc == 0) { return; } this->Add(desc); } -PerspectiveDescriptor::Pointer PerspectiveRegistry::CreatePerspective(const std::string& label, - PerspectiveDescriptor::Pointer originalDescriptor) +IPerspectiveDescriptor::Pointer PerspectiveRegistry::CreatePerspective(const std::string& label, + IPerspectiveDescriptor::Pointer originalDescriptor) { // Sanity check to avoid invalid or duplicate labels. if (!this->ValidateLabel(label)) { - return PerspectiveDescriptor::Pointer(0); + throw Poco::InvalidArgumentException(); } if (this->FindPerspectiveWithLabel(label) != 0) { - return PerspectiveDescriptor::Pointer(0); + throw Poco::InvalidArgumentException(); } // Calculate ID. std::string id(label); std::replace(id.begin(), id.end(), ' ', '_'); Poco::trimInPlace(id); + + if (this->FindPerspectiveWithId(id) != 0) + { + throw Poco::InvalidArgumentException(); + } + // Create descriptor. - PerspectiveDescriptor::Pointer desc( - new PerspectiveDescriptor(id, label, originalDescriptor)); - this->Add(desc); + IPerspectiveDescriptor::Pointer desc; + + desc = new PerspectiveDescriptor(id, label, originalDescriptor.Cast()); + + this->Add(desc.Cast()); return desc; } void PerspectiveRegistry::RevertPerspectives( const std::list& perspToRevert) { // indicate that the user is removing these perspectives for (std::list::const_iterator iter = perspToRevert.begin(); iter != perspToRevert.end(); ++iter) { PerspectiveDescriptor::Pointer desc = *iter; perspToRemove.push_back(desc->GetId()); desc->RevertToPredefined(); } } void PerspectiveRegistry::DeletePerspectives( const std::list& perspToDelete) { for (std::list::const_iterator iter = perspToDelete.begin(); iter != perspToDelete.end(); ++iter) { this->DeletePerspective(*iter); } } void PerspectiveRegistry::DeletePerspective(IPerspectiveDescriptor::Pointer in) { PerspectiveDescriptor::Pointer desc = in.Cast(); // Don't delete predefined perspectives if (!desc->IsPredefined()) { perspToRemove.push_back(desc->GetId()); perspectives.remove(desc); desc->DeleteCustomDefinition(); this->VerifyDefaultPerspective(); } } IPerspectiveDescriptor::Pointer PerspectiveRegistry::FindPerspectiveWithId(const std::string& id) { for (std::list::iterator iter = perspectives.begin(); iter != perspectives.end(); ++iter) { PerspectiveDescriptor::Pointer desc = *iter; if (desc->GetId() == id) { // if (WorkbenchActivityHelper.restrictUseOf(desc)) // { // return null; // } return desc; } } return IPerspectiveDescriptor::Pointer(0); } IPerspectiveDescriptor::Pointer PerspectiveRegistry::FindPerspectiveWithLabel( const std::string& label) { for (std::list::iterator iter = perspectives.begin(); iter != perspectives.end(); ++iter) { PerspectiveDescriptor::Pointer desc = *iter; if (desc->GetLabel() == label) { // if (WorkbenchActivityHelper.restrictUseOf(desc)) // { // return 0; // } return desc; } } return IPerspectiveDescriptor::Pointer(0); } std::string PerspectiveRegistry::GetDefaultPerspective() { return defaultPerspID; } std::vector PerspectiveRegistry::GetPerspectives() { // Collection descs = WorkbenchActivityHelper.restrictCollection(perspectives, // new ArrayList()); // return (IPerspectiveDescriptor[]) descs.toArray( // new IPerspectiveDescriptor[descs.size()]); std::vector result; for (std::list::iterator iter = perspectives.begin(); iter != perspectives.end(); ++iter) { result.push_back(iter->Cast()); } return result; } void PerspectiveRegistry::Load() { // Load the registries. this->LoadPredefined(); this->LoadCustom(); // Get default perspective. // Get it from the R1.0 dialog settings first. Fixes bug 17039 // IDialogSettings dialogSettings = // WorkbenchPlugin.getDefault() .getDialogSettings(); // std::string str = dialogSettings.get(ID_DEF_PERSP); // if (str != null && str.length() > 0) // { // this->SetDefaultPerspective(str); // dialogSettings.put(ID_DEF_PERSP, ""); //$NON-NLS-1$ // } this->VerifyDefaultPerspective(); } //void PerspectiveRegistry::SaveCustomPersp(PerspectiveDescriptor::Pointer desc, // XMLMemento::Pointer memento) //{ // // IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore(); // // // Save it to the preference store. // Writer writer = new StringWriter(); // // memento.save(writer); // writer.close(); // store.setValue(desc.getId() + PERSP, writer.toString()); // //} IMemento::Pointer PerspectiveRegistry::GetCustomPersp(const std::string& /*id*/) { //TODO CustomPersp // Reader reader = null; // // IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore(); // std::string xmlString = store.getString(id + PERSP); // if (xmlString != null && xmlString.length() != 0) // { // defined in store // reader = new StringReader(xmlString); // } // XMLMemento memento = XMLMemento.createReadRoot(reader); // reader.close(); // return memento; return IMemento::Pointer(0); } void PerspectiveRegistry::SetDefaultPerspective(const std::string& id) { IPerspectiveDescriptor::Pointer desc = this->FindPerspectiveWithId(id); if (desc != 0) { defaultPerspID = id; //TODO Preferences // PrefUtil.getAPIPreferenceStore().setValue( // IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID, id); } } bool PerspectiveRegistry::ValidateLabel(const std::string& label) { return !Poco::trim(label).empty(); } IPerspectiveDescriptor::Pointer PerspectiveRegistry::ClonePerspective(const std::string& id, const std::string& label, IPerspectiveDescriptor::Pointer originalDescriptor) { - // Check for invalid labels if (label == "" || Poco::trim(label).empty()) { throw Poco::InvalidArgumentException(); } + // Calculate ID. + std::string newId(label); + std::replace(newId.begin(), newId.end(), ' ', '_'); + Poco::trimInPlace(newId); + // Check for duplicates - IPerspectiveDescriptor::Pointer desc = this->FindPerspectiveWithId(id); + IPerspectiveDescriptor::Pointer desc = this->FindPerspectiveWithId(newId); if (desc != 0) { throw Poco::InvalidArgumentException(); } + if (this->FindPerspectiveWithLabel(label) != 0) + { + throw Poco::InvalidArgumentException(); + } + // Create descriptor. desc - = new PerspectiveDescriptor(id, label, originalDescriptor.Cast()); + = new PerspectiveDescriptor(newId, label, originalDescriptor.Cast()); this->Add(desc.Cast()); return desc; } void PerspectiveRegistry::RevertPerspective(IPerspectiveDescriptor::Pointer perspToRevert) { PerspectiveDescriptor::Pointer desc = perspToRevert.Cast(); perspToRemove.push_back(desc->GetId()); desc->RevertToPredefined(); } PerspectiveRegistry::~PerspectiveRegistry() { // PlatformUI.getWorkbench().getExtensionTracker().unregisterHandler(this); // WorkbenchPlugin.getDefault().getPreferenceStore() .removePropertyChangeListener( // preferenceListener); } void PerspectiveRegistry::DeleteCustomDefinition(PerspectiveDescriptor::Pointer /*desc*/) { //TODO Preferences // remove the entry from the preference store. //IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore(); /* * To delete the perspective definition from the preference store, use * the setToDefault method. Since no default is defined, this will * remove the entry */ //store.setToDefault(desc.getId() + PERSP); - } bool PerspectiveRegistry::HasCustomDefinition(PerspectiveDescriptor::ConstPointer /*desc*/) const { //TODO Preferences //IPreferenceStore store = WorkbenchPlugin::GetDefault()->GetPreferenceStore(); //return store.contains(desc.getId() + PERSP); return false; } void PerspectiveRegistry::InitializePreferenceChangeListener() { // preferenceListener = new IPropertyChangeListener() // { // public void propertyChange(PropertyChangeEvent event) // { // /* // * To ensure the that no custom perspective definitions are // * deleted when preferences are imported, merge old and new // * values // */ // if (event.getProperty().endsWith(PERSP)) // { // /* A Perspective is being changed, merge */ // mergePerspectives(event); // } // else if (event.getProperty().equals( // IPreferenceConstants.PERSPECTIVES)) // { // /* The list of perpsectives is being changed, merge */ // updatePreferenceList((IPreferenceStore) event.getSource()); // } // } // // void MergePerspectives(PropertyChangeEvent::Pointer event) // { // IPreferenceStore store = (IPreferenceStore) event.getSource(); // if (event.getNewValue() == null // || event.getNewValue().equals("")) // { //$NON-NLS-1$ // /* // * Perpsective is being removed; if the user has deleted or // * reverted a custom perspective, let the change pass // * through. Otherwise, restore the custom perspective entry // */ // // // Find the matching descriptor in the registry // IPerspectiveDescriptor[] perspectiveList = getPerspectives(); // for (int i = 0; i < perspectiveList.length; i++) // { // std::string id = perspectiveList[i].getId(); // if (event.getProperty().equals(id + PERSP)) // { // found // // descriptor // // see if the perspective has been flagged for // // reverting or deleting // if (!perspToRemove.contains(id)) // { // restore // store.setValue(id + PERSP, (std::string) event // .getOldValue()); // } // else // { // remove element from the list // perspToRemove.remove(id); // } // } // } // } // else if ((event.getOldValue() == null || event.getOldValue() // .equals(""))) // { //$NON-NLS-1$ // // /* // * New perspective is being added, update the // * perspectiveRegistry to contain the new custom perspective // */ // // std::string id = event.getProperty().substring(0, // event.getProperty().lastIndexOf(PERSP)); // if (findPerspectiveWithId(id) == null) // { // // perspective does not already exist in registry, add // // it // PerspectiveDescriptor desc = new PerspectiveDescriptor( // null, null, null); // StringReader reader = new StringReader((std::string) event // .getNewValue()); // try // { // XMLMemento memento = XMLMemento // .createReadRoot(reader); // desc.restoreState(memento); // addPerspective(desc); // } // catch (WorkbenchException e) // { // unableToLoadPerspective(e.getStatus()); // } // } // } // /* If necessary, add to the list of perspectives */ // updatePreferenceList(store); // } // // void UpdatePreferenceList(IPreferenceStore store) // { // IPerspectiveDescriptor[] perspectiveList = getPerspectives(); // StringBuffer perspBuffer = new StringBuffer(); // for (int i = 0; i < perspectiveList.length; i++) // { // PerspectiveDescriptor desc = (PerspectiveDescriptor) perspectiveList[i]; // if (hasCustomDefinition(desc)) // { // perspBuffer.append(desc.getId()) // .append(SPACE_DELIMITER); // } // } // std::string newList = perspBuffer.toString().trim(); // store.setValue(IPreferenceConstants.PERSPECTIVES, newList); // } // }; } void PerspectiveRegistry::Add(PerspectiveDescriptor::Pointer desc) { perspectives.push_back(desc); // IConfigurationElement::Pointer element = desc->GetConfigElement(); // if (element != 0) // { // PlatformUI::GetWorkbench().getExtensionTracker().registerObject( // element.getDeclaringExtension(), desc, IExtensionTracker.REF_WEAK); // } } void PerspectiveRegistry::InternalDeletePerspective(PerspectiveDescriptor::Pointer desc) { perspToRemove.push_back(desc->GetId()); perspectives.remove(desc); desc->DeleteCustomDefinition(); this->VerifyDefaultPerspective(); } void PerspectiveRegistry::LoadCustom() { // Reader reader = null; // // /* Get the entries from the Preference store */ // IPreferenceStore store = WorkbenchPlugin.getDefault() .getPreferenceStore(); // // /* Get the space-delimited list of custom perspective ids */ // std::string customPerspectives = store .getString( // IPreferenceConstants.PERSPECTIVES); // std::string[] perspectivesList = StringConverter.asArray(customPerspectives); // // for (int i = 0; i < perspectivesList.length; i++) // { // try // { // std::string xmlString = store.getString(perspectivesList[i] + PERSP); // if (xmlString != null && xmlString.length() != 0) // { // reader = new StringReader(xmlString); // } // // // Restore the layout state. // XMLMemento memento = XMLMemento.createReadRoot(reader); // PerspectiveDescriptor newPersp = // new PerspectiveDescriptor(null, null, null); // newPersp.restoreState(memento); // std::string id = newPersp.getId(); // IPerspectiveDescriptor oldPersp = findPerspectiveWithId(id); // if (oldPersp == null) // { // add(newPersp); // } // reader.close(); // } catch (IOException e) // { // unableToLoadPerspective(null); // } catch (WorkbenchException e) // { // unableToLoadPerspective(e.getStatus()); // } // } // // // Get the entries from files, if any // // if -data @noDefault specified the state location may not be // // initialized // IPath path = WorkbenchPlugin.getDefault().getDataLocation(); // if (path == null) // { // return; // } // // File folder = path.toFile(); // // if (folder.isDirectory()) // { // File[] fileList = folder.listFiles(); // int nSize = fileList.length; // for (int nX = 0; nX < nSize; nX++) // { // File file = fileList[nX]; // if (file.getName().endsWith(EXT)) // { // // get the memento // InputStream stream = null; // try // { // stream = new FileInputStream(file); // reader = new BufferedReader(new InputStreamReader(stream, "utf-8")); //$NON-NLS-1$ // // // Restore the layout state. // XMLMemento memento = XMLMemento.createReadRoot(reader); // PerspectiveDescriptor newPersp = // new PerspectiveDescriptor(null, null, null); // newPersp.restoreState(memento); // IPerspectiveDescriptor oldPersp = findPerspectiveWithId( // newPersp .getId()); // if (oldPersp == null) // { // add(newPersp); // } // // // save to the preference store // saveCustomPersp(newPersp, memento); // // // delete the file // file.delete(); // // reader.close(); // stream.close(); // } catch (IOException e) // { // unableToLoadPerspective(null); // } catch (WorkbenchException e) // { // unableToLoadPerspective(e.getStatus()); // } // } // } // } } void PerspectiveRegistry::UnableToLoadPerspective(const std::string& status) { std::string msg = "Unable to load perspective"; if (status == "") { WorkbenchPlugin::Log(msg); //IStatus errStatus = // new Status(IStatus.ERR, WorkbenchPlugin.PI_WORKBENCH, msg); //StatusManager.getManager().handle(errStatus, StatusManager.SHOW); } else { WorkbenchPlugin::Log(status + ": " + msg); //IStatus errStatus = StatusUtil.newStatus(status, msg); //StatusManager.getManager().handle(errStatus, StatusManager.SHOW); } } void PerspectiveRegistry::LoadPredefined() { PerspectiveRegistryReader reader; reader.ReadPerspectives(this); } void PerspectiveRegistry::VerifyDefaultPerspective() { // Step 1: Try current defPerspId value. IPerspectiveDescriptor::Pointer desc; if (defaultPerspID != "") { desc = this->FindPerspectiveWithId(defaultPerspID); } if (desc != 0) { return; } // Step 2. Read default value. //TODO Preferences // std::string str = PrefUtil.getAPIPreferenceStore().getString( // IWorkbenchPreferenceConstants.DEFAULT_PERSPECTIVE_ID); // if (str != null && str.length() > 0) // { // desc = this->FindPerspectiveWithId(str); // } // if (desc != 0) // { // defaultPerspID = str; // return; // } // Step 3. Use application-specific default defaultPerspID = Workbench::GetInstance()->GetDefaultPerspectiveId(); } - -} +} \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h index a0f9d300f5..9560648a16 100755 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistry.h @@ -1,309 +1,309 @@ /*=================================================================== BlueBerry Platform 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 BERRYPERSPECTIVEREGISTRY_H_ #define BERRYPERSPECTIVEREGISTRY_H_ #include "berryIPerspectiveRegistry.h" #include "berryPerspectiveDescriptor.h" #include namespace berry { /** * Perspective registry. */ class PerspectiveRegistry : public IPerspectiveRegistry { // IExtensionChangeHandler { friend class PerspectiveDescriptor; private: std::string defaultPerspID; static const std::string EXT; // = "_persp.xml"; static const std::string ID_DEF_PERSP; // = "PerspectiveRegistry.DEFAULT_PERSP"; static const std::string PERSP; // = "_persp"; static const char SPACE_DELIMITER; // = ' '; std::list perspectives; // keep track of the perspectives the user has selected to remove or revert std::list perspToRemove; //IPropertyChangeListener::Pointer preferenceListener; public: /** * Construct a new registry. */ PerspectiveRegistry(); /** * Adds a perspective. This is typically used by the reader. * * @param desc */ void AddPerspective(PerspectiveDescriptor::Pointer desc); /** * Create a new perspective. * * @param label * the name of the new descriptor * @param originalDescriptor * the descriptor on which to base the new descriptor * @return a new perspective descriptor or null if the * creation failed. */ - PerspectiveDescriptor::Pointer CreatePerspective(const std::string& label, - PerspectiveDescriptor::Pointer originalDescriptor); + IPerspectiveDescriptor::Pointer CreatePerspective(const std::string& label, + IPerspectiveDescriptor::Pointer originalDescriptor); /** * Reverts a list of perspectives back to the plugin definition * * @param perspToRevert */ void RevertPerspectives(const std::list& perspToRevert); /** * Deletes a list of perspectives * * @param perspToDelete */ void DeletePerspectives(const std::list& perspToDelete); /** * Delete a perspective. Has no effect if the perspective is defined in an * extension. * * @param in */ void DeletePerspective(IPerspectiveDescriptor::Pointer in); /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveRegistry#findPerspectiveWithId(java.lang.std::string) */ IPerspectiveDescriptor::Pointer FindPerspectiveWithId(const std::string& id); /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveRegistry#findPerspectiveWithLabel(java.lang.std::string) */ IPerspectiveDescriptor::Pointer FindPerspectiveWithLabel(const std::string& label); /** * @see IPerspectiveRegistry#getDefaultPerspective() */ std::string GetDefaultPerspective(); /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveRegistry#getPerspectives() */ std::vector GetPerspectives(); /** * Loads the registry. */ void Load(); /** * Saves a custom perspective definition to the preference store. * * @param desc * the perspective * @param memento * the memento to save to * @throws IOException */ // void SaveCustomPersp(PerspectiveDescriptor::Pointer desc, XMLMemento::Pointer memento); /** * Gets the Custom perspective definition from the preference store. * * @param id * the id of the perspective to find * @return IMemento a memento containing the perspective description * * @throws WorkbenchException * @throws IOException */ IMemento::Pointer GetCustomPersp(const std::string& id); /** * @see IPerspectiveRegistry#setDefaultPerspective(std::string) */ void SetDefaultPerspective(const std::string& id); /** * Return true if a label is valid. This checks only the * given label in isolation. It does not check whether the given label is * used by any existing perspectives. * * @param label * the label to test * @return whether the label is valid */ bool ValidateLabel(const std::string& label); /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveRegistry#clonePerspective(java.lang.std::string, * java.lang.std::string, org.blueberry.ui.IPerspectiveDescriptor) */ IPerspectiveDescriptor::Pointer ClonePerspective(const std::string& id, const std::string& label, IPerspectiveDescriptor::Pointer originalDescriptor); /* * (non-Javadoc) * * @see org.blueberry.ui.IPerspectiveRegistry#revertPerspective(org.blueberry.ui.IPerspectiveDescriptor) */ void RevertPerspective(IPerspectiveDescriptor::Pointer perspToRevert); /** * Dispose the receiver. */ ~PerspectiveRegistry(); /* * (non-Javadoc) * * @see org.blueberry.core.runtime.dynamicHelpers.IExtensionChangeHandler#removeExtension(org.blueberry.core.runtime.IExtension, * java.lang.Object[]) */ // void removeExtension(IExtension source, Object[] objects) { // for (int i = 0; i < objects.length; i++) { // if (objects[i] instanceof PerspectiveDescriptor) { // // close the perspective in all windows // IWorkbenchWindow[] windows = PlatformUI.getWorkbench() // .getWorkbenchWindows(); // PerspectiveDescriptor desc = (PerspectiveDescriptor) objects[i]; // for (int w = 0; w < windows.length; ++w) { // IWorkbenchWindow window = windows[w]; // IWorkbenchPage[] pages = window.getPages(); // for (int p = 0; p < pages.length; ++p) { // WorkbenchPage page = (WorkbenchPage) pages[p]; // ClosePerspectiveHandler.closePerspective(page, page // .findPerspective(desc)); // } // } // // // ((Workbench)PlatformUI.getWorkbench()).getPerspectiveHistory().removeItem(desc); // // internalDeletePerspective(desc); // } // // } // } /* * (non-Javadoc) * * @see org.blueberry.core.runtime.dynamicHelpers.IExtensionChangeHandler#addExtension(org.blueberry.core.runtime.dynamicHelpers.IExtensionTracker, * org.blueberry.core.runtime.IExtension) */ // void addExtension(IExtensionTracker tracker, // IExtension addedExtension) { // IConfigurationElement[] addedElements = addedExtension // .getConfigurationElements(); // for (int i = 0; i < addedElements.length; i++) { // PerspectiveRegistryReader reader = new PerspectiveRegistryReader( // this); // reader.readElement(addedElements[i]); // } // } protected: /** * Removes the custom definition of a perspective from the preference store * * @param desc */ /* package */ void DeleteCustomDefinition(PerspectiveDescriptor::Pointer desc); /** * Method hasCustomDefinition. * * @param desc */ /* package */ bool HasCustomDefinition(PerspectiveDescriptor::ConstPointer desc) const; private: /** * Initialize the preference change listener. */ void InitializePreferenceChangeListener(); /** * @param desc */ void Add(PerspectiveDescriptor::Pointer desc); /** * Delete a perspective. This will remove perspectives defined in * extensions. * * @param desc * the perspective to delete * @since 3.1 */ void InternalDeletePerspective(PerspectiveDescriptor::Pointer desc); /** * Read children from the file system. */ void LoadCustom(); /** * @param status */ void UnableToLoadPerspective(const std::string& status); /** * Read children from the plugin registry. */ void LoadPredefined(); /** * Verifies the id of the default perspective. If the default perspective is * invalid use the workbench default. */ void VerifyDefaultPerspective(); }; } #endif /* BERRYPERSPECTIVEREGISTRY_H_ */ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp index 6b3b893be9..4eb7ff8487 100755 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryPerspectiveRegistryReader.cpp @@ -1,62 +1,64 @@ /*=================================================================== BlueBerry Platform 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 "berryPerspectiveRegistryReader.h" #include "berryPerspectiveRegistry.h" #include "berryWorkbenchPlugin.h" #include "berryPlatformUI.h" #include "berryWorkbenchRegistryConstants.h" namespace berry { - PerspectiveRegistryReader::PerspectiveRegistryReader() { - } void PerspectiveRegistryReader::ReadPerspectives(PerspectiveRegistry* out) { registry = out; this->ReadRegistry(PlatformUI::PLUGIN_ID, WorkbenchRegistryConstants::PL_PERSPECTIVES); } bool PerspectiveRegistryReader::ReadElement(IConfigurationElement::Pointer element) { if (element->GetName() == WorkbenchRegistryConstants::TAG_PERSPECTIVE) { try { std::string id; element->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id); + std::vector childs = element->GetChildren("description"); PerspectiveDescriptor::Pointer desc( new PerspectiveDescriptor(id, element)); + if (childs.size() > 0) + { + desc->SetDescription(childs[0]->GetValue()); + } registry->AddPerspective(desc); } catch (CoreException e) { // log an error since its not safe to open a dialog here WorkbenchPlugin::Log("Unable to create layout descriptor.", e);//$NON-NLS-1$ } return true; } return false; } - -} +} \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp index 052d3d59fe..efce111c1c 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.cpp @@ -1,213 +1,228 @@ /*=================================================================== BlueBerry Platform 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 "berryViewDescriptor.h" #include "service/berryIConfigurationElement.h" #include "berryPlatformException.h" #include "berryRegistryReader.h" #include "berryWorkbenchRegistryConstants.h" #include "berryImageDescriptor.h" #include "berryAbstractUIPlugin.h" #include "berryAbstractUICTKPlugin.h" #include "berryImageDescriptor.h" #include "handlers/berryIHandlerActivation.h" #include #include namespace berry { - ViewDescriptor::ViewDescriptor(IConfigurationElement::Pointer e) : configElement(e) { this->LoadFromExtension(); } IViewPart::Pointer ViewDescriptor::CreateView() { IViewPart::Pointer part(configElement->CreateExecutableExtension ( WorkbenchRegistryConstants::ATT_CLASS)); if (part.IsNull()) { // support legacy BlueBerry extensions part = configElement->CreateExecutableExtension ( WorkbenchRegistryConstants::ATT_CLASS, IViewPart::GetManifestName()); } return part; } const std::vector& ViewDescriptor::GetCategoryPath() const { return categoryPath; } IConfigurationElement::Pointer ViewDescriptor::GetConfigurationElement() const { return configElement; } std::string ViewDescriptor::GetDescription() const { return RegistryReader::GetDescription(configElement); } std::string ViewDescriptor::GetId() const { return id; } bool ViewDescriptor::operator==(const Object* o) const { if (const IViewDescriptor* other = dynamic_cast(o)) return this->GetId() == other->GetId(); return false; } ImageDescriptor::Pointer ViewDescriptor::GetImageDescriptor() const { if (imageDescriptor) { return imageDescriptor; } std::string iconName; configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON, iconName); // If the icon attribute was omitted, use the default one if (iconName.empty()) { //TODO default image descriptor //return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW); return ImageDescriptor::GetMissingImageDescriptor(); } const IExtension* extension(configElement->GetDeclaringExtension()); const std::string extendingPluginId(extension->GetNamespace()); imageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin( extendingPluginId, iconName); if (!imageDescriptor) { // Try legacy BlueBerry method imageDescriptor = AbstractUIPlugin::ImageDescriptorFromPlugin( extendingPluginId, iconName); } // If the icon attribute was invalid, use the error icon if (!imageDescriptor) { imageDescriptor = ImageDescriptor::GetMissingImageDescriptor(); } return imageDescriptor; } std::string ViewDescriptor::GetLabel() const { std::string label; configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, label); return label; } std::string ViewDescriptor::GetAccelerator() const { std::string accel; configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ACCELERATOR, accel); return accel; } bool ViewDescriptor::GetAllowMultiple() const { bool allow = false; configElement->GetBoolAttribute(WorkbenchRegistryConstants::ATT_ALLOW_MULTIPLE, allow); return allow; } bool ViewDescriptor::IsRestorable() const { std::string string; if (configElement->GetAttribute(WorkbenchRegistryConstants::ATT_RESTORABLE, string)) { return Poco::icompare(string, "true") == 0; } else { return true; } } Poco::Any ViewDescriptor::GetAdapter(const std::string& adapter) { if (adapter == IConfigurationElement::GetStaticClassName()) { return Poco::Any(GetConfigurationElement()); } return Poco::Any(); } void ViewDescriptor::ActivateHandler() { //TODO ViewDescriptor handler activation // if (!handlerActivation) // { // IHandler::Pointer handler(new ShowViewHandler(this->GetId())); // IHandlerService::Pointer handlerService( // PlatformUI::GetWorkbench()->GetService(IHandlerService::GetManifestName()).Cast()); // handlerActivation = handlerService // ->ActivateHandler(this->GetId(), handler); // } } void ViewDescriptor::DeactivateHandler() { //TODO ViewDescriptor handler deactivation // if (handlerActivation) // { // IHandlerService::Pointer handlerService( // PlatformUI::GetWorkbench()->GetService(IHandlerService::GetManifestName()).Cast()); // handlerService->DeactivateHandler(handlerActivation); // handlerActivation = 0; // } } +std::vector< std::string> ViewDescriptor::GetKeywordReferences() const +{ + std::vector result; + std::string keywordRefId; + std::vector keywordRefs; + berry::IConfigurationElement::vector::iterator keywordRefsIt; + keywordRefs = configElement->GetChildren("keywordReference"); + for (keywordRefsIt = keywordRefs.begin() + ; keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs + { + (*keywordRefsIt)->GetAttribute("id", keywordRefId); + result.push_back(keywordRefId); + } + return result; +} + + void ViewDescriptor::LoadFromExtension() { configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID, id); // Sanity check. std::string name; if ((configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME, name) == false) || (RegistryReader::GetClassValue(configElement, WorkbenchRegistryConstants::ATT_CLASS) == "")) { throw CoreException( "Invalid extension (missing label or class name)", id); } std::string category; if (configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY, category)) { Poco::StringTokenizer stok(category, "/", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); // Parse the path tokens and store them for (Poco::StringTokenizer::Iterator iter = stok.begin(); iter != stok.end(); ++iter) { categoryPath.push_back(*iter); } } } - -} // namespace berry +} // namespace berry \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h index f7027d7768..8882a72a84 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewDescriptor.h @@ -1,152 +1,152 @@ /*=================================================================== BlueBerry Platform 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 BERRYVIEWDESCRIPTOR_H_ #define BERRYVIEWDESCRIPTOR_H_ #include "berryIViewPart.h" #include "berryIViewDescriptor.h" #include "service/berryIConfigurationElement.h" #include #include namespace berry { - struct IHandlerActivation; /** * \ingroup org_blueberry_ui_internal * */ class ViewDescriptor : public IViewDescriptor { private: std::string id; mutable SmartPointer imageDescriptor; IConfigurationElement::Pointer configElement; std::vector categoryPath; /** * The activation token returned when activating the show view handler with * the workbench. */ SmartPointer handlerActivation; public: berryObjectMacro(ViewDescriptor); /** * Create a new ViewDescriptor for an extension. * * @param e the configuration element * @throws CoreException thrown if there are errors in the configuration */ ViewDescriptor(IConfigurationElement::Pointer e); /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#createView() */ IViewPart::Pointer CreateView(); /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#getCategoryPath() */ const std::vector& GetCategoryPath() const; /** * Return the configuration element for this descriptor. * * @return the configuration element */ IConfigurationElement::Pointer GetConfigurationElement() const; /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#getDescription() */ std::string GetDescription() const; + std::vector< std::string> GetKeywordReferences() const; + /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPartDescriptor#getId() */ std::string GetId() const; /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPartDescriptor#getImageDescriptor() */ SmartPointer GetImageDescriptor() const; /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPartDescriptor#getLabel() */ std::string GetLabel() const; /** * Return the accelerator attribute. * * @return the accelerator attribute */ std::string GetAccelerator() const; /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#getAllowMultiple() */ bool GetAllowMultiple() const; /* (non-Javadoc) * @see org.eclipse.ui.views.IViewDescriptor#getRestorable() */ bool IsRestorable() const; bool operator==(const Object*) const; /** * Activates a show view handler for this descriptor. This handler can later * be deactivated by calling {@link ViewDescriptor#deactivateHandler()}. * This method will only activate the handler if it is not currently active. * */ void ActivateHandler(); /** * Deactivates the show view handler for this descriptor. This handler was * previously activated by calling {@link ViewDescriptor#activateHandler()}. * This method will only deactivative the handler if it is currently active. * */ void DeactivateHandler(); protected: /* (non-Javadoc) * @see IAdaptable#GetAdapterImpl(const std::type_info&) */ Poco::Any GetAdapter(const std::string& adapter); private: /** * load a view descriptor from the registry. */ void LoadFromExtension(); }; - } #endif /*BERRYVIEWDESCRIPTOR_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp index 3dcaa8fde8..976393c818 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryViewReference.cpp @@ -1,438 +1,441 @@ /*=================================================================== BlueBerry Platform 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 "berryViewReference.h" #include #include "berryUIException.h" #include "tweaklets/berryWorkbenchPageTweaklet.h" #include "berryPlatformUI.h" #include "berryImageDescriptor.h" #include "berryWorkbenchPage.h" #include "berryWorkbenchConstants.h" #include "berryViewDescriptor.h" #include "berryViewFactory.h" #include "berryViewRegistry.h" #include "berryViewSite.h" #include "berryPartTester.h" #include "berryWorkbenchPlugin.h" #include "berryErrorViewPart.h" namespace berry { ViewReference::ViewReference(ViewFactory* fac, const std::string& id, const std::string& secId, IMemento::Pointer m) : factory(fac), secondaryId(secId), memento(m) { ViewDescriptor::Pointer desc = this->factory->GetViewRegistry()->Find(id).Cast (); ImageDescriptor::Pointer iDesc; std::string title; if (!desc.IsNull()) { iDesc = desc->GetImageDescriptor(); title = desc->GetLabel(); } std::string name; if (!memento.IsNull()) { // name = memento.getString(IWorkbenchConstants.TAG_PART_NAME); // IMemento propBag = memento.getChild(IWorkbenchConstants.TAG_PROPERTIES); // if (propBag != null) { // IMemento[] props = propBag // .getChildren(IWorkbenchConstants.TAG_PROPERTY); // for (int i = 0; i < props.length; i++) { // propertyCache.put(props[i].getID(), props[i].getTextData()); // } // } } if (name.empty()) { name = title; } this->Init(id, "", iDesc, name, ""); //$NON-NLS-1$//$NON-NLS-2$ } void ViewReference::DoDisposePart() { IViewPart::Pointer view = part.Cast (); //WorkbenchPartReference::DoDisposePart(); if (!view.IsNull()) { // Free action bars, pane, etc. //PartSite site = (PartSite) view.getSite(); //ViewActionBars actionBars = (ViewActionBars) site.getActionBars(); // // 3.3 start // //IMenuService menuService = (IMenuService) site // .getService(IMenuService.class); //menuService.releaseContributions((ContributionManager) site.getActionBars() // .getMenuManager()); //menuService.releaseContributions((ContributionManager) site.getActionBars() // .getToolBarManager()); // 3.3 end //actionBars.dispose(); // and now dispose the delegates since the // PluginActionContributionItem // can no longer do that // if (actionBuilder != null) { // actionBuilder.dispose(); // actionBuilder = null; // } // Free the site. //site.dispose(); } } IWorkbenchPage::Pointer ViewReference::GetPage() const { return IWorkbenchPage::Pointer(this->factory->GetWorkbenchPage()); } std::string ViewReference::GetRegisteredName() { if (!part.IsNull() && !part->GetSite().IsNull()) { return part->GetSite()->GetRegisteredName(); } const IViewRegistry* reg = this->factory->GetViewRegistry(); IViewDescriptor::Pointer desc = reg->Find(this->GetId()); if (!desc.IsNull()) { return desc->GetLabel(); } return this->GetPartName(); } std::string ViewReference::GetSecondaryId() { return secondaryId; } IViewPart::Pointer ViewReference::GetView(bool restore) { return this->GetPart(restore).Cast (); } IWorkbenchPart::Pointer ViewReference::CreatePart() { // Check the status of this part IWorkbenchPart::Pointer result; PartInitException exception; bool error = false; // Try to restore the view -- this does the real work of restoring the // view // try { result = this->CreatePartHelper(); } catch (PartInitException e) { exception = e; error = true; } // If unable to create the part, create an error part instead // and pass the error to the status handling facility if (error) { // IStatus partStatus = exception.getStatus(); // IStatus displayStatus = StatusUtil.newStatus(partStatus, // NLS.bind(WorkbenchMessages.ViewFactory_initException, partStatus.getMessage())); // IStatus logStatus = StatusUtil // .newStatus( // partStatus, // NLS // .bind( // "Unable to create view ID {0}: {1}", getId(), partStatus.getMessage())); //$NON-NLS-1$ // Pass the error to the status handling facility // StatusManager.getManager().handle(logStatus); std::string errorTitle = "Unable to create view ID " + this->GetId(); WorkbenchPlugin::Log(errorTitle + ": " + exception.displayText()); IViewDescriptor::Pointer desc = factory->GetViewRegistry()->Find( this->GetId()); std::string label = this->GetId(); if (!desc.IsNull()) { label = desc->GetLabel(); } std::string errorMsg = exception.displayText(); errorMsg += "
  • Check your shared library for unresolved symbols
  • " "
  • Check your class attribute in your plugin.xml file
  • " "
  • Check your manifest.cpp file
" "
For a comprehensive check-list, see http://www.mitk.org/wiki/How_to_fix_your_plug-in_DLL"; ErrorViewPart::Pointer part(new ErrorViewPart(errorTitle, errorMsg)); //PartPane pane = getPane(); IViewReference::Pointer viewRef(this); ViewSite::Pointer site(new ViewSite(viewRef, part, factory->GetWorkbenchPage(), GetId(), PlatformUI::PLUGIN_ID, label)); //site.setActionBars(new ViewActionBars(factory.page.getActionBars(), // site, (ViewPane) pane)); try { part->Init(site); } catch (PartInitException e) { BERRY_ERROR << e.displayText(); //StatusUtil.handleStatus(e, StatusManager.SHOW // | StatusManager.LOG); return IWorkbenchPart::Pointer(0); } part->SetPartName(label); void* parent = pane->GetControl(); try { part->CreatePartControl(parent); } catch (std::exception e) { BERRY_ERROR << "Error creating view: " << e.what() << std::endl; // StatusUtil.handleStatus(e, StatusManager.SHOW // | StatusManager.LOG); return IWorkbenchPart::Pointer(0); } result = part.Cast (); } return result; } PartPane::Pointer ViewReference::CreatePane() { IWorkbenchPartReference::Pointer partRef(this); PartPane::Pointer pane(new PartPane(partRef, this->factory->GetWorkbenchPage())); return pane; //return Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateViewPane(this, this->factory->GetWorkbenchPage()); } IWorkbenchPart::Pointer ViewReference::CreatePartHelper() { IWorkbenchPart::Pointer result; IMemento::Pointer stateMem; if (!memento.IsNull()) { stateMem = memento->GetChild(WorkbenchConstants::TAG_VIEW_STATE); } IViewDescriptor::Pointer desc = factory->GetViewRegistry()->Find(GetId()); if (desc.IsNull()) { throw PartInitException("Could not create view", this->GetId()); } // Create the part pane PartPane::Pointer pane = this->GetPane(); // Create the pane's top-level control pane->CreateControl(factory->GetWorkbenchPage()->GetClientComposite()); std::string label = desc->GetLabel(); // debugging only // Things that will need to be disposed if an exception occurs (they are // listed here // in the order they should be disposed) //Composite content = null; IViewPart::Pointer initializedView; ViewSite::Pointer site; //ViewActionBars actionBars = null; // End of things that need to be explicitly disposed from the try block try { IViewPart::Pointer view; view = desc->CreateView(); + if (view.IsNull()) + return result; + this->CreatePartProperties(view); // Create site IViewReference::Pointer viewRef(this); site = new ViewSite(viewRef, view, factory->GetWorkbenchPage(), desc); //actionBars = new ViewActionBars(factory.page.getActionBars(), site, // (ViewPane) pane); //site.setActionBars(actionBars); view->Init(site, stateMem); // Once we've called init, we MUST dispose the view. Remember // the fact that // we've initialized the view in case an exception is thrown. initializedView = view; if (view->GetSite() != site) { throw PartInitException("View initialization failed. Site is incorrect."); } // Create the top-level composite { void* parent = pane->GetControl(); view->CreatePartControl(parent); } // Install the part's tools and menu { // // 3.3 start // // IMenuService menuService = (IMenuService) site // .getService(IMenuService.class); // menuService.populateContributionManager( // (ContributionManager) site.getActionBars() // .getMenuManager(), "menu:" //$NON-NLS-1$ // + site.getId()); // menuService // .populateContributionManager((ContributionManager) site // .getActionBars().getToolBarManager(), // "toolbar:" + site.getId()); //$NON-NLS-1$ // 3.3 end // actionBuilder = new ViewActionBuilder(); // actionBuilder.readActionExtensions(view); // ActionDescriptor[] actionDescriptors = actionBuilder // .getExtendedActions(); // IKeyBindingService keyBindingService = view.getSite() // .getKeyBindingService(); // // if (actionDescriptors != null) { // for (int i = 0; i < actionDescriptors.length; i++) { // ActionDescriptor actionDescriptor = actionDescriptors[i]; // // if (actionDescriptor != null) { // IAction action = actionDescriptors[i].getAction(); // // if (action != null // && action.getActionDefinitionId() != null) { // keyBindingService.registerAction(action); // } // } // } // } // // site.getActionBars().updateActionBars(); } // The part should now be fully created. Exercise its public // interface, and sanity-check // it wherever possible. If it's going to throw exceptions or behave // badly, it's much better // that it does so now while we can still cancel creation of the // part. PartTester::TestView(view); result = view.Cast (); // IConfigurationElement::Pointer element = desc->GetConfigurationElement(); // if (!element.IsNull()) { // factory.page.getExtensionTracker().registerObject( // element.getDeclaringExtension(), view, // IExtensionTracker.REF_WEAK); // } } catch (const Poco::Exception& e) { // if ((e instanceof Error) && !(e instanceof LinkageError)) { // throw (Error) e; // } // An exception occurred. First deallocate anything we've allocated // in the try block (see the top // of the try block for a list of objects that need to be explicitly // disposed) // if (content != null) { // try { // content.dispose(); // } catch (RuntimeException re) { // StatusManager.getManager().handle( // StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, // re)); // } // } // // if (initializedView != null) { // try { // initializedView.dispose(); // } catch (RuntimeException re) { // StatusManager.getManager().handle( // StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, // re)); // } // } // // if (site != null) { // try { // site.dispose(); // } catch (RuntimeException re) { // StatusManager.getManager().handle( // StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, // re)); // } // } // // if (actionBars != null) { // try { // actionBars.dispose(); // } catch (RuntimeException re) { // StatusManager.getManager().handle( // StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, // re)); // } // } throw PartInitException(e.message(), e, e.code()); } catch (const std::exception& e) { throw PartInitException(e.what()); } return result; } IMemento::Pointer ViewReference::GetMemento() { return memento; } } // namespace berry diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp index dc7eca49d6..dc7655fe53 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.cpp @@ -1,4111 +1,4113 @@ /*=================================================================== BlueBerry Platform 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 "berryLog.h" #include "tweaklets/berryGuiWidgetsTweaklet.h" #include "tweaklets/berryWorkbenchPageTweaklet.h" #include "berryWorkbenchPage.h" #include "berryPartSite.h" #include "berryWorkbenchRegistryConstants.h" #include "berryPerspective.h" #include "berryLayoutPartSash.h" #include "berryWorkbenchPlugin.h" #include "berryEditorAreaHelper.h" #include "berrySaveablesList.h" #include "berryPerspectiveHelper.h" #include "berryLayoutTreeNode.h" #include "berryWorkbench.h" #include "berryWorkbenchConstants.h" #include "berryPartService.h" #include "berryStickyViewManager.h" #include "intro/berryIntroConstants.h" #include "intro/berryViewIntroAdapterPart.h" #include "dialogs/berryMessageDialog.h" #include "berryWorkbenchWindow.h" #include "berryUIException.h" #include "berryPlatformUI.h" #include "berryPartPane.h" #include "berryImageDescriptor.h" #include #include namespace berry { - WorkbenchPage::ActivationOrderPred::ActivationOrderPred( WorkbenchPage::ActivationList* al) : activationList(al) { - } bool WorkbenchPage::ActivationOrderPred::operator()( const IViewReference::Pointer o1, const IViewReference::Pointer o2) const { WorkbenchPage::ActivationList::PartListIter pos1 = activationList->IndexOf( o1.Cast ()); WorkbenchPage::ActivationList::PartListIter pos2 = activationList->IndexOf( o2.Cast ()); return pos1 < pos2; } void WorkbenchPage::PerspectiveList::UpdateActionSets( Perspective::Pointer /*oldPersp*/, Perspective::Pointer /*newPersp*/) { //TODO WorkbenchPage action sets // // Update action sets // // IContextService service = (IContextService) window // .getService(IContextService.class); // try { // service.activateContext(ContextAuthority.DEFER_EVENTS); // if (newPersp != 0) { // IActionSetDescriptor[] newAlwaysOn = newPersp // .getAlwaysOnActionSets(); // for (int i = 0; i < newAlwaysOn.length; i++) { // IActionSetDescriptor descriptor = newAlwaysOn[i]; // // actionSets.showAction(descriptor); // } // // IActionSetDescriptor[] newAlwaysOff = newPersp // .getAlwaysOffActionSets(); // for (int i = 0; i < newAlwaysOff.length; i++) { // IActionSetDescriptor descriptor = newAlwaysOff[i]; // // actionSets.maskAction(descriptor); // } // } // // if (oldPersp != 0) { // IActionSetDescriptor[] newAlwaysOn = oldPersp // .getAlwaysOnActionSets(); // for (int i = 0; i < newAlwaysOn.length; i++) { // IActionSetDescriptor descriptor = newAlwaysOn[i]; // // actionSets.hideAction(descriptor); // } // // IActionSetDescriptor[] newAlwaysOff = oldPersp // .getAlwaysOffActionSets(); // for (int i = 0; i < newAlwaysOff.length; i++) { // IActionSetDescriptor descriptor = newAlwaysOff[i]; // // actionSets.unmaskAction(descriptor); // } // } // } finally { // service.activateContext(ContextAuthority.SEND_EVENTS); // } } WorkbenchPage::PerspectiveList::PerspectiveList() { - } void WorkbenchPage::PerspectiveList::Reorder( IPerspectiveDescriptor::Pointer perspective, int newLoc) { PerspectiveListType::iterator oldLocation = openedList.end(); Perspective::Pointer movedPerspective; for (PerspectiveListType::iterator iterator = openedList.begin(); iterator != openedList.end(); ++iterator) { Perspective::Pointer openPerspective = *iterator; if (openPerspective->GetDesc() == perspective) { oldLocation = std::find(openedList.begin(), openedList.end(), openPerspective); movedPerspective = openPerspective; } } PerspectiveListType::iterator newLocation = openedList.begin(); for (int i = 0; i < newLoc; ++i, ++newLocation) ; if (oldLocation == newLocation) { return; } openedList.erase(oldLocation); openedList.insert(newLocation, movedPerspective); - } WorkbenchPage::PerspectiveList::PerspectiveListType WorkbenchPage::PerspectiveList::GetSortedPerspectives() { return usedList; } bool WorkbenchPage::PerspectiveList::Add(Perspective::Pointer perspective) { openedList.push_back(perspective); usedList.push_front(perspective); //It will be moved to top only when activated. return true; } WorkbenchPage::PerspectiveList::PerspectiveListType::iterator WorkbenchPage::PerspectiveList::Begin() { return openedList.begin(); } WorkbenchPage::PerspectiveList::PerspectiveListType::iterator WorkbenchPage::PerspectiveList::End() { return openedList.end(); } WorkbenchPage::PerspectiveList::PerspectiveListType WorkbenchPage::PerspectiveList::GetOpenedPerspectives() { return openedList; } bool WorkbenchPage::PerspectiveList::Remove(Perspective::Pointer perspective) { if (active == perspective) { this->UpdateActionSets(active, Perspective::Pointer(0)); active = 0; } usedList.remove(perspective); PerspectiveListType::size_type origSize = openedList.size(); openedList.remove(perspective); return openedList.size() != origSize; } void WorkbenchPage::PerspectiveList::Swap(Perspective::Pointer oldPerspective, Perspective::Pointer newPerspective) { PerspectiveListType::iterator oldIter = std::find(openedList.begin(), openedList.end(), oldPerspective); PerspectiveListType::iterator newIter = std::find(openedList.begin(), openedList.end(), newPerspective); if (oldIter == openedList.end() || newIter == openedList.end()) { return; } std::iter_swap(oldIter, newIter); } bool WorkbenchPage::PerspectiveList::IsEmpty() { return openedList.empty(); } Perspective::Pointer WorkbenchPage::PerspectiveList::GetActive() { return active; } Perspective::Pointer WorkbenchPage::PerspectiveList::GetNextActive() { if (active == 0) { if (usedList.empty()) { return Perspective::Pointer(0); } else { return usedList.back(); } } else { if (usedList.size() < 2) { return Perspective::Pointer(0); } else { return *(++usedList.rbegin()); } } } WorkbenchPage::PerspectiveList::PerspectiveListType::size_type WorkbenchPage::PerspectiveList::Size() { return openedList.size(); } void WorkbenchPage::PerspectiveList::SetActive(Perspective::Pointer perspective) { if (perspective == active) { return; } this->UpdateActionSets(active, perspective); active = perspective; if (perspective != 0) { usedList.remove(perspective); usedList.push_back(perspective); } } WorkbenchPage::ActivationList::ActivationList(WorkbenchPage* page) : page(page) { - } void WorkbenchPage::ActivationList::SetActive(SmartPointer part) { if (parts.empty()) { return; } IWorkbenchPartReference::Pointer ref(page->GetReference(part)); if (ref) { if (ref == parts.back()) { return; } parts.erase(std::find(parts.begin(), parts.end(), ref)); parts.push_back(ref); } } void WorkbenchPage::ActivationList::BringToTop(SmartPointer< IWorkbenchPartReference> ref) { ILayoutContainer::Pointer targetContainer(page->GetContainer(ref)); PartListIter newIndex = this->LastIndexOfContainer(targetContainer); if (newIndex != parts.end() && ref == *newIndex) { return; } if (newIndex == parts.end()) { parts.push_back(ref); } else { PartListType::size_type index = newIndex - parts.begin(); parts.erase(std::find(parts.begin(), parts.end(), ref)); PartListIter insertIndex = parts.begin() + index; parts.insert(insertIndex, ref); } } WorkbenchPage::ActivationList::PartListIter WorkbenchPage::ActivationList::LastIndexOfContainer( SmartPointer container) { PartListReverseIter i = parts.rbegin(); while (i != parts.rend()) { IWorkbenchPartReference::Pointer ref(*i); ILayoutContainer::Pointer cnt(page->GetContainer(ref)); if (cnt == container) { return --i.base(); } ++i; } return parts.end(); } void WorkbenchPage::ActivationList::SetActive(SmartPointer< IWorkbenchPartReference> ref) { this->SetActive(ref->GetPart(true)); } void WorkbenchPage::ActivationList::Add( SmartPointer ref) { if (std::find(parts.begin(), parts.end(), ref) != parts.end()) { return; } ref->GetPart(false); parts.push_front(ref); } SmartPointer WorkbenchPage::ActivationList::GetActive() { if (parts.empty()) { return IWorkbenchPart::Pointer(0); } return this->GetActive(parts.end()); } SmartPointer WorkbenchPage::ActivationList::GetPreviouslyActive() { if (parts.size() < 2) { return IWorkbenchPart::Pointer(0); } return this->GetActive(--parts.end()); } SmartPointer WorkbenchPage::ActivationList::GetActiveReference( bool editorsOnly) { return this->GetActiveReference(parts.end(), editorsOnly); } WorkbenchPage::ActivationList::PartListIter WorkbenchPage::ActivationList::IndexOf( SmartPointer part) { IWorkbenchPartReference::Pointer ref(page->GetReference(part)); if (ref == 0) { return parts.end(); } return std::find(parts.begin(), parts.end(), ref); } WorkbenchPage::ActivationList::PartListIter WorkbenchPage::ActivationList::IndexOf( SmartPointer ref) { return std::find(parts.begin(), parts.end(), ref); } bool WorkbenchPage::ActivationList::Remove( SmartPointer ref) { bool contains = std::find(parts.begin(), parts.end(), ref) != parts.end(); parts.erase(std::find(parts.begin(), parts.end(), ref)); return contains; } SmartPointer WorkbenchPage::ActivationList::GetTopEditor() { IEditorReference::Pointer editor = this->GetActiveReference(parts.end(), true).Cast (); if (editor == 0) { return IEditorPart::Pointer(0); } return editor->GetEditor(true); } SmartPointer WorkbenchPage::ActivationList::GetActive( PartListIter start) { IWorkbenchPartReference::Pointer ref(this->GetActiveReference(start, false)); if (!ref) { return IWorkbenchPart::Pointer(0); } return ref->GetPart(true); } SmartPointer WorkbenchPage::ActivationList::GetActiveReference( PartListIter start, bool editorsOnly) { // First look for parts that aren't obscured by the current zoom state IWorkbenchPartReference::Pointer nonObscured = this->GetActiveReference( start, editorsOnly, true); if (nonObscured) { return nonObscured; } // Now try all the rest of the parts return this->GetActiveReference(start, editorsOnly, false); } SmartPointer WorkbenchPage::ActivationList::GetActiveReference( PartListIter start, bool editorsOnly, bool /*skipPartsObscuredByZoom*/) { std::vector views = page->GetViewReferences(); PartListReverseIter i(start); while (i != parts.rend()) { WorkbenchPartReference::Pointer ref(i->Cast ()); if (editorsOnly && (ref.Cast () == 0)) { ++i; continue; } // Skip parts whose containers have disabled auto-focus PartPane::Pointer pane(ref->GetPane()); if (pane) { if (!pane->AllowsAutoFocus()) { ++i; continue; } // if (skipPartsObscuredByZoom) { // if (pane.isObscuredByZoom()) { // continue; // } // } } // Skip fastviews (unless overridden) if (IViewReference::Pointer viewRef = ref.Cast()) { //if (ref == getActiveFastView() || !((IViewReference) ref).isFastView()) { for (unsigned int j = 0; j < views.size(); j++) { if (views[j] == viewRef) { return viewRef.Cast (); } } //} } else { return ref.Cast (); } ++i; } return IWorkbenchPartReference::Pointer(0); } std::vector > WorkbenchPage::ActivationList::GetEditors() { std::vector editors; for (PartListIter i = parts.begin(); i != parts.end(); ++i) { if (IEditorReference::Pointer part = i->Cast()) { editors.push_back(part); } } return editors; } std::vector > WorkbenchPage::ActivationList::GetParts() { std::vector views(page->GetViewReferences()); std::vector resultList; for (PartListIter iterator = parts.begin(); iterator != parts.end(); ++iterator) { - if (IViewReference::Pointer ref = iterator->Cast()) { //Filter views from other perspectives for (unsigned int i = 0; i < views.size(); i++) { if (ref == views[i]) { resultList.push_back(ref); break; } } } else { resultList.push_back(*iterator); } } return resultList; } void WorkbenchPage::ActionSwitcher::UpdateActivePart( IWorkbenchPart::Pointer newPart) { IWorkbenchPart::Pointer _activePart = this->activePart.Lock(); IEditorPart::Pointer _topEditor = this->topEditor.Lock(); if (_activePart == newPart) { return; } bool isNewPartAnEditor = newPart.Cast ().IsNotNull(); if (isNewPartAnEditor) { std::string oldId; if (_topEditor) { oldId = _topEditor->GetSite()->GetId(); } std::string newId = newPart->GetSite()->GetId(); // if the active part is an editor and the new editor // is the same kind of editor, then we don't have to do // anything if (activePart == topEditor && newId == oldId) { activePart = newPart; topEditor = newPart.Cast (); return; } // remove the contributions of the old editor // if it is a different kind of editor if (oldId != newId) { this->DeactivateContributions(_topEditor, true); } // if a view was the active part, disable its contributions if (_activePart && _activePart != _topEditor) { this->DeactivateContributions(_activePart, true); } // show (and enable) the contributions of the new editor // if it is a different kind of editor or if the // old active part was a view if (newId != oldId || _activePart != _topEditor) { this->ActivateContributions(newPart, true); } - } else if (newPart.IsNull()) { if (_activePart) { // remove all contributions this->DeactivateContributions(_activePart, true); } } else { // new part is a view // if old active part is a view, remove all contributions, // but if old part is an editor only disable if (_activePart) { this->DeactivateContributions(_activePart, _activePart.Cast ().IsNotNull()); } this->ActivateContributions(newPart, true); } //TODO WorkbenchPage action sets // ArrayList newActionSets = 0; // if (isNewPartAnEditor || (activePart == topEditor && newPart == 0)) // { // newActionSets = calculateActionSets(newPart, 0); // } // else // { // newActionSets = calculateActionSets(newPart, topEditor); // } // // if (!updateActionSets(newActionSets)) // { // updateActionBars(); // } if (isNewPartAnEditor) { topEditor = newPart.Cast (); } else if (activePart == topEditor && newPart.IsNull()) { // since we removed all the contributions, we clear the top // editor topEditor.Reset(); } activePart = newPart; } void WorkbenchPage::ActionSwitcher::UpdateTopEditor( IEditorPart::Pointer newEditor) { if (topEditor.Lock() == newEditor) { return; } if (activePart == topEditor) { this->UpdateActivePart(newEditor); return; } std::string oldId; if (!topEditor.Expired()) { oldId = topEditor.Lock()->GetSite()->GetId(); } std::string newId; if (newEditor.IsNotNull()) { newId = newEditor->GetSite()->GetId(); } if (oldId == newId) { // we don't have to change anything topEditor = newEditor; return; } // Remove the contributions of the old editor if (!topEditor.Expired()) { this->DeactivateContributions(topEditor.Lock(), true); } // Show (disabled) the contributions of the new editor if (newEditor.IsNotNull()) { this->ActivateContributions(newEditor, false); } // ArrayList newActionSets = calculateActionSets(activePart, newEditor); // if (!updateActionSets(newActionSets)) // { // updateActionBars(); // } topEditor = newEditor; } void WorkbenchPage::ActionSwitcher::ActivateContributions( IWorkbenchPart::Pointer /*part*/, bool /*enable*/) { //PartSite::Pointer site = part->GetSite().Cast (); //site->ActivateActionBars(enable); } void WorkbenchPage::ActionSwitcher::DeactivateContributions( IWorkbenchPart::Pointer /*part*/, bool /*remove*/) { //PartSite::Pointer site = part->GetSite().Cast (); //site->DeactivateActionBars(remove); } const IExtensionPoint* WorkbenchPage::GetPerspectiveExtensionPoint() { return Platform::GetExtensionPointService()->GetExtensionPoint( PlatformUI::PLUGIN_ID + "." + WorkbenchRegistryConstants::PL_PERSPECTIVE_EXTENSIONS); } WorkbenchPage::WorkbenchPage(WorkbenchWindow* w, const std::string& layoutID, IAdaptable* input) { if (layoutID == "") { throw WorkbenchException("Perspective ID is undefined"); } this->Register(); this->Init(w, layoutID, input, true); this->UnRegister(false); } WorkbenchPage::WorkbenchPage(WorkbenchWindow* w, IAdaptable* input) { this->Register(); this->Init(w, "", input, false); this->UnRegister(false); } void WorkbenchPage::Activate(IWorkbenchPart::Pointer part) { // Sanity check. if (!this->CertifyPart(part)) { return; } if (window->IsClosing()) { return; } // if (composite!=0 && composite.isVisible() && !((GrabFocus)Tweaklets.get(GrabFocus.KEY)).grabFocusAllowed(part)) // { // return; // } // Activate part. //if (window.getActivePage() == this) { IWorkbenchPartReference::Pointer ref = this->GetReference(part); this->InternalBringToTop(ref); this->SetActivePart(part); } void WorkbenchPage::ActivatePart(const IWorkbenchPart::Pointer part) { // Platform.run(new SafeRunnable(WorkbenchMessages.WorkbenchPage_ErrorActivatingView) // { // public void WorkbenchPage::run() // { if (part.IsNotNull()) { //part.setFocus(); PartPane::Pointer pane = this->GetPane(part); pane->SetFocus(); PartSite::Pointer site = part->GetSite().Cast (); pane->ShowFocus(true); //this->UpdateTabList(part); //SubActionBars bars = (SubActionBars) site.getActionBars(); //bars.partChanged(part); } // } // } // ); } void WorkbenchPage::AddPartListener(IPartListener::Pointer l) { partList->GetPartService()->AddPartListener(l); } void WorkbenchPage::AddSelectionListener(ISelectionListener::Pointer listener) { selectionService->AddSelectionListener(listener); } void WorkbenchPage::AddSelectionListener(const std::string& partId, ISelectionListener::Pointer listener) { selectionService->AddSelectionListener(partId, listener); } void WorkbenchPage::AddPostSelectionListener( ISelectionListener::Pointer listener) { selectionService->AddPostSelectionListener(listener); } void WorkbenchPage::AddPostSelectionListener(const std::string& partId, ISelectionListener::Pointer listener) { selectionService->AddPostSelectionListener(partId, listener); } ILayoutContainer::Pointer WorkbenchPage::GetContainer( IWorkbenchPart::Pointer part) { PartPane::Pointer pane = this->GetPane(part); if (pane == 0) { return ILayoutContainer::Pointer(0); } return pane->GetContainer(); } ILayoutContainer::Pointer WorkbenchPage::GetContainer( IWorkbenchPartReference::Pointer part) { PartPane::Pointer pane = this->GetPane(part); if (pane == 0) { return ILayoutContainer::Pointer(0); } return pane->GetContainer(); } PartPane::Pointer WorkbenchPage::GetPane(IWorkbenchPart::Pointer part) { if (part.IsNull()) { return PartPane::Pointer(0); } return this->GetPane(this->GetReference(part)); } PartPane::Pointer WorkbenchPage::GetPane(IWorkbenchPartReference::Pointer part) { if (part.IsNull()) { return PartPane::Pointer(0); } return part.Cast ()->GetPane(); } bool WorkbenchPage::InternalBringToTop(IWorkbenchPartReference::Pointer part) { - bool broughtToTop = false; // Move part. if (part.Cast ().IsNotNull()) { ILayoutContainer::Pointer container = this->GetContainer(part); if (container.Cast () != 0) { PartStack::Pointer stack = container.Cast (); PartPane::Pointer newPart = this->GetPane(part); if (stack->GetSelection() != newPart) { stack->SetSelection(newPart); } broughtToTop = true; } } else if (part.Cast ().IsNotNull()) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { broughtToTop = persp->BringToTop(part.Cast ()); } } // Ensure that this part is considered the most recently activated part // in this stack activationList->BringToTop(part); return broughtToTop; } void WorkbenchPage::BringToTop(IWorkbenchPart::Pointer part) { // Sanity check. Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0 || !this->CertifyPart(part)) { return; } // if (!((GrabFocus)Tweaklets.get(GrabFocus.KEY)).grabFocusAllowed(part)) // { // return; // } // std::string label; // debugging only // if (UIStats.isDebugging(UIStats.BRING_PART_TO_TOP)) // { // label = part != 0 ? part.getTitle() : "none"; //$NON-NLS-1$ // } IWorkbenchPartReference::Pointer ref = this->GetReference(part); ILayoutContainer::Pointer activeEditorContainer = this->GetContainer( this->GetActiveEditor().Cast ()); ILayoutContainer::Pointer activePartContainer = this->GetContainer( this->GetActivePart()); ILayoutContainer::Pointer newPartContainer = this->GetContainer(part); if (newPartContainer == activePartContainer) { this->MakeActive(ref); } else if (newPartContainer == activeEditorContainer) { if (ref.Cast () != 0) { if (part != 0) { IWorkbenchPartSite::Pointer site = part->GetSite(); if (site.Cast () != 0) { ref = site.Cast ()->GetPane()->GetPartReference(); } } this->MakeActiveEditor(ref.Cast ()); } else { this->MakeActiveEditor(IEditorReference::Pointer(0)); } } else { this->InternalBringToTop(ref); if (ref != 0) { partList->FirePartBroughtToTop(ref); } } - } void WorkbenchPage::BusyResetPerspective() { - ViewIntroAdapterPart::Pointer introViewAdapter = dynamic_cast (GetWorkbenchWindow() ->GetWorkbench()->GetIntroManager())->GetIntroAdapterPart().Cast< ViewIntroAdapterPart> (); // PartPane introPane = 0; // boolean introFullScreen = false; // if (introViewAdapter != 0) // { // introPane = ((PartSite) introViewAdapter.getSite()).getPane(); // introViewAdapter.setHandleZoomEvents(false); // introFullScreen = introPane.isZoomed(); // } // //try to prevent intro flicker. // if (introFullScreen) // { // window.getShell().setRedraw(false); // } // try // { - // // Always unzoom // if (isZoomed()) // { // zoomOut(); // } // Get the current perspective. // This describes the working layout of the page and differs from // the original template. Perspective::Pointer oldPersp = this->GetActivePerspective(); // Map the current perspective to the original template. // If the original template cannot be found then it has been deleted. // In that case just return. (PR#1GDSABU). IPerspectiveRegistry* reg = WorkbenchPlugin::GetDefault() ->GetPerspectiveRegistry(); PerspectiveDescriptor::Pointer desc = reg->FindPerspectiveWithId( oldPersp->GetDesc()->GetId()).Cast (); if (desc == 0) { desc = reg->FindPerspectiveWithId(oldPersp ->GetDesc().Cast< PerspectiveDescriptor> ()->GetOriginalId()).Cast< PerspectiveDescriptor> (); } if (desc == 0) { return; } // Notify listeners that we are doing a reset. window->FirePerspectiveChanged(IWorkbenchPage::Pointer(this), desc, CHANGE_RESET); // Create new persp from original template. // Suppress the perspectiveOpened and perspectiveClosed events otherwise it looks like two // instances of the same perspective are open temporarily (see bug 127470). Perspective::Pointer newPersp = this->CreatePerspective(desc, false); if (newPersp == 0) { // We're not going through with the reset, so it is complete. window->FirePerspectiveChanged(IWorkbenchPage::Pointer(this), desc, CHANGE_RESET_COMPLETE); return; } // Update the perspective list and shortcut perspList.Swap(oldPersp, newPersp); // Install new persp. this->SetPerspective(newPersp); // Destroy old persp. this->DisposePerspective(oldPersp, false); // Update the Coolbar layout. this->ResetToolBarLayout(); // restore the maximized intro if (introViewAdapter) { try { // ensure that the intro is visible in the new perspective ShowView(IntroConstants::INTRO_VIEW_ID); // if (introFullScreen) // { // toggleZoom(introPane.getPartReference()); // } } catch (PartInitException& e) { //TODO IStatus WorkbenchPlugin::Log("Could not restore intro", e); // WorkbenchPlugin.getStatus(e)); } // finally // { // // we want the intro back to a normal state before we fire the event // introViewAdapter.setHandleZoomEvents(true); // } } // Notify listeners that we have completed our reset. window->FirePerspectiveChanged(IWorkbenchPage::Pointer(this), desc, CHANGE_RESET_COMPLETE); // } // finally // { // // reset the handling of zoom events (possibly for the second time) in case there was // // an exception thrown // if (introViewAdapter != 0) // { // introViewAdapter.setHandleZoomEvents(true); // } // // if (introFullScreen) // { // window.getShell().setRedraw(true); // } // } +} +void WorkbenchPage::RemovePerspective(IPerspectiveDescriptor::Pointer desc) +{ + Perspective::Pointer newPersp; + PerspectiveDescriptor::Pointer realDesc = desc.Cast (); + newPersp = this->FindPerspective(desc); + perspList.Remove(newPersp); } + void WorkbenchPage::BusySetPerspective(IPerspectiveDescriptor::Pointer desc) { // Create new layout. std::string label = desc->GetId(); // debugging only Perspective::Pointer newPersp; //try //{ //UIStats.start(UIStats.SWITCH_PERSPECTIVE, label); PerspectiveDescriptor::Pointer realDesc = desc.Cast (); newPersp = this->FindPerspective(realDesc); if (newPersp == 0) { newPersp = this->CreatePerspective(realDesc, true); if (newPersp == 0) { return; } } // Change layout. this->SetPerspective(newPersp); // } // catch (std::exception& e) // { // UIStats.end(UIStats.SWITCH_PERSPECTIVE, desc.getId(), label); // throw e; // } } IViewPart::Pointer WorkbenchPage::BusyShowView(const std::string& viewID, const std::string& secondaryID, int mode) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return IViewPart::Pointer(0); } // If this view is already visible just return. IViewReference::Pointer ref = persp->FindView(viewID, secondaryID); IViewPart::Pointer view; if (ref != 0) { view = ref->GetView(true); } if (view != 0) { this->BusyShowView(view, mode); return view; } // Show the view. view = persp->ShowView(viewID, secondaryID); if (view != 0) { this->BusyShowView(view, mode); IWorkbenchPartReference::Pointer partReference = this->GetReference(view); PartPane::Pointer partPane = this->GetPane(partReference); partPane->SetInLayout(true); IWorkbenchPage::Pointer thisPage(this); window->FirePerspectiveChanged(thisPage, GetPerspective(), partReference, CHANGE_VIEW_SHOW); window->FirePerspectiveChanged(thisPage, GetPerspective(), CHANGE_VIEW_SHOW); } return view; } void WorkbenchPage::BusyShowView(IViewPart::Pointer part, int mode) { // if (!((GrabFocus) Tweaklets.get(GrabFocus.KEY)).grabFocusAllowed(part)) // { // return; // } if (mode == VIEW_ACTIVATE) { this->Activate(part); } else if (mode == VIEW_VISIBLE) { IWorkbenchPartReference::Pointer ref = this->GetActivePartReference(); // if there is no active part or it's not a view, bring to top if (ref == 0 || ref.Cast () == 0) { this->BringToTop(part); } else { // otherwise check to see if the we're in the same stack as the active view IViewReference::Pointer activeView = ref.Cast (); std::vector viewStack = this->GetViewReferenceStack(part); for (unsigned int i = 0; i < viewStack.size(); i++) { if (viewStack[i] == activeView) { return; } } this->BringToTop(part); } } } bool WorkbenchPage::CertifyPart(IWorkbenchPart::Pointer part) { //Workaround for bug 22325 if (part != 0 && part->GetSite().Cast () == 0) { return false; } if (part.Cast () != 0) { IEditorReference::Pointer ref = this->GetReference(part).Cast< IEditorReference> (); return ref != 0 && this->GetEditorManager()->ContainsEditor(ref); } if (part.Cast () != 0) { Perspective::Pointer persp = this->GetActivePerspective(); return persp != 0 && persp->ContainsView(part.Cast ()); } return false; } bool WorkbenchPage::Close() { bool ret; //BusyIndicator.showWhile(0, new Runnable() // { // public void WorkbenchPage::run() // { ret = window->ClosePage(IWorkbenchPage::Pointer(this), true); // } // }); return ret; } bool WorkbenchPage::CloseAllSavedEditors() { // get the Saved editors std::list editors = this->GetEditorReferences(); std::list savedEditors; for (std::list::iterator iter = editors.begin(); iter != editors.end(); ++iter) { IEditorReference::Pointer editor = *iter; if (!editor->IsDirty()) { savedEditors.push_back(editor); } } //there are no unsaved editors if (savedEditors.empty()) { return true; } return this->CloseEditors(savedEditors, false); } bool WorkbenchPage::CloseAllEditors(bool save) { return this->CloseEditors(this->GetEditorReferences(), save); } void WorkbenchPage::UpdateActivePart() { - if (this->IsDeferred()) { return; } IWorkbenchPartReference::Pointer oldActivePart = partList->GetActivePartReference(); IWorkbenchPartReference::Pointer oldActiveEditor = partList->GetActiveEditorReference(); IWorkbenchPartReference::Pointer newActivePart; IEditorReference::Pointer newActiveEditor; if (!window->IsClosing()) { // If an editor is active, try to keep an editor active if (oldActiveEditor && oldActivePart == oldActiveEditor) { newActiveEditor = activationList->GetActiveReference(true).Cast< IEditorReference> (); newActivePart = newActiveEditor; if (newActivePart == 0) { // Only activate a non-editor if there's no editors left newActivePart = activationList->GetActiveReference(false); } } else { // If a non-editor is active, activate whatever was activated most recently newActivePart = activationList->GetActiveReference(false); if (newActivePart.Cast () != 0) { // If that happens to be an editor, make it the active editor as well newActiveEditor = newActivePart.Cast (); } else { // Otherwise, select whatever editor was most recently active newActiveEditor = activationList->GetActiveReference(true).Cast< IEditorReference> (); } } } if (oldActiveEditor != newActiveEditor) { this->MakeActiveEditor(newActiveEditor); } if (newActivePart != oldActivePart) { this->MakeActive(newActivePart); } } void WorkbenchPage::MakeActive(IWorkbenchPartReference::Pointer ref) { if (ref == 0) { this->SetActivePart(IWorkbenchPart::Pointer(0)); } else { IWorkbenchPart::Pointer newActive = ref->GetPart(true); if (newActive == 0) { this->SetActivePart(IWorkbenchPart::Pointer(0)); } else { this->Activate(newActive); } } } void WorkbenchPage::MakeActiveEditor(IEditorReference::Pointer ref) { if (ref == this->GetActiveEditorReference()) { return; } IEditorPart::Pointer part = (ref == 0) ? IEditorPart::Pointer(0) : ref->GetEditor(true); if (part) { editorMgr->SetVisibleEditor(ref, false); //navigationHistory.MarkEditor(part); } actionSwitcher.UpdateTopEditor(part); if (ref) { activationList->BringToTop(this->GetReference(part)); } partList->SetActiveEditor(ref); } bool WorkbenchPage::CloseEditors( const std::list& refArray, bool save) { if (refArray.empty()) { return true; } IWorkbenchPage::Pointer thisPage(this); // Check if we're being asked to close any parts that are already closed or cannot // be closed at this time std::vector editorRefs; for (std::list::const_iterator iter = refArray.begin(); iter != refArray.end(); ++iter) { IEditorReference::Pointer reference = *iter; // If we're in the middle of creating this part, this is a programming error. Abort the entire // close operation. This usually occurs if someone tries to open a dialog in a method that // isn't allowed to do so, and a *syncExec tries to close the part. If this shows up in a log // file with a dialog's event loop on the stack, then the code that opened the dialog is usually // at fault. if (partBeingActivated == reference) { Poco::RuntimeException re( "WARNING: Blocked recursive attempt to close part " //$NON-NLS-1$ + partBeingActivated->GetId() + " while still in the middle of activating it"); WorkbenchPlugin::Log(re); return false; } // if (reference.Cast () != 0) // { // WorkbenchPartReference::Pointer ref = reference.Cast(); // // // If we're being asked to close a part that is disposed (ie: already closed), // // skip it and proceed with closing the remaining parts. // if (ref.isDisposed()) // { // continue; // } // } editorRefs.push_back(reference); } // notify the model manager before the close std::list partsToClose; for (unsigned int i = 0; i < editorRefs.size(); i++) { IWorkbenchPart::Pointer refPart = editorRefs[i]->GetPart(false); if (refPart != 0) { partsToClose.push_back(refPart); } } SaveablesList::Pointer modelManager; SaveablesList::PostCloseInfo::Pointer postCloseInfo; if (partsToClose.size() > 0) { modelManager = this->GetWorkbenchWindow()->GetService( ISaveablesLifecycleListener::GetManifestName()).Cast (); // this may prompt for saving and return 0 if the user canceled: postCloseInfo = modelManager->PreCloseParts(partsToClose, save, this->GetWorkbenchWindow()); if (postCloseInfo == 0) { return false; } } // Fire pre-removal changes for (unsigned int i = 0; i < editorRefs.size(); i++) { IEditorReference::Pointer ref = editorRefs[i]; // Notify interested listeners before the close window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref, CHANGE_EDITOR_CLOSE); - } this->DeferUpdates(true); try { if (modelManager != 0) { modelManager->PostClose(postCloseInfo); } // Close all editors. for (unsigned int i = 0; i < editorRefs.size(); i++) { IEditorReference::Pointer ref = editorRefs[i]; // Remove editor from the presentation editorPresentation->CloseEditor(ref); this->PartRemoved(ref.Cast ()); } } catch (...) { } this->DeferUpdates(false); // Notify interested listeners after the close window->FirePerspectiveChanged(thisPage, this->GetPerspective(), CHANGE_EDITOR_CLOSE); // Return true on success. return true; } void WorkbenchPage::DeferUpdates(bool shouldDefer) { if (shouldDefer) { if (deferCount == 0) { this->StartDeferring(); } deferCount++; } else { deferCount--; if (deferCount == 0) { this->HandleDeferredEvents(); } } } void WorkbenchPage::StartDeferring() { //editorPresentation.getLayoutPart().deferUpdates(true); } void WorkbenchPage::HandleDeferredEvents() { editorPresentation->GetLayoutPart()->DeferUpdates(false); this->UpdateActivePart(); std::vector disposals = pendingDisposals; pendingDisposals.clear(); for (unsigned int i = 0; i < disposals.size(); i++) { this->DisposePart(disposals[i]); } - } bool WorkbenchPage::IsDeferred() { return deferCount > 0; } bool WorkbenchPage::CloseEditor(IEditorReference::Pointer editorRef, bool save) { std::list list; list.push_back(editorRef); return this->CloseEditors(list, save); } bool WorkbenchPage::CloseEditor(IEditorPart::Pointer editor, bool save) { IWorkbenchPartReference::Pointer ref = this->GetReference(editor); if (ref.Cast ().IsNotNull()) { std::list list; list.push_back(ref.Cast ()); return this->CloseEditors(list, save); } return false; } +void WorkbenchPage::CloseCurrentPerspective(bool saveParts, bool closePage) +{ + Perspective::Pointer persp = this->GetActivePerspective(); + if (persp != 0) + { + this->ClosePerspective(persp, saveParts, closePage); + } +} + void WorkbenchPage::ClosePerspective(IPerspectiveDescriptor::Pointer desc, bool saveParts, bool closePage) { Perspective::Pointer persp = this->FindPerspective(desc); if (persp != 0) { this->ClosePerspective(persp, saveParts, closePage); } } void WorkbenchPage::ClosePerspective(Perspective::Pointer persp, bool saveParts, bool closePage) { - // // Always unzoom // if (isZoomed()) // { // zoomOut(); // } std::vector partsToSave; std::list viewsToClose; // collect views that will go away and views that are dirty std::vector viewReferences = persp->GetViewReferences(); for (unsigned int i = 0; i < viewReferences.size(); i++) { IViewReference::Pointer reference = viewReferences[i]; if (this->GetViewFactory()->GetReferenceCount(reference) == 1) { IViewPart::Pointer viewPart = reference->GetView(false); if (viewPart != 0) { viewsToClose.push_back(viewPart); if (saveParts && reference->IsDirty()) { partsToSave.push_back(viewPart); } } } } if (saveParts && perspList.Size() == 1) { // collect editors that are dirty std::list editorReferences = this->GetEditorReferences(); for (std::list::iterator refIter = editorReferences.begin(); refIter != editorReferences.end(); ++refIter) { IEditorReference::Pointer reference = *refIter; if (reference->IsDirty()) { IEditorPart::Pointer editorPart = reference->GetEditor(false); if (editorPart != 0) { partsToSave.push_back(editorPart); } } } } if (saveParts && !partsToSave.empty()) { if (!EditorManager::SaveAll(partsToSave, true, true, false, IWorkbenchWindow::Pointer(window))) { // user canceled return; } } // Close all editors on last perspective close if (perspList.Size() == 1 && this->GetEditorManager()->GetEditorCount() > 0) { // Close all editors if (!this->CloseAllEditors(false)) { return; } } // closeAllEditors already notified the saveables list about the editors. SaveablesList::Pointer saveablesList = this->GetWorkbenchWindow()->GetWorkbench()->GetService( ISaveablesLifecycleListener::GetManifestName()).Cast< SaveablesList> (); // we took care of the saving already, so pass in false (postCloseInfo will be non-0) SaveablesList::PostCloseInfo::Pointer postCloseInfo = saveablesList->PreCloseParts(viewsToClose, false, this->GetWorkbenchWindow()); saveablesList->PostClose(postCloseInfo); // Dispose of the perspective bool isActive = (perspList.GetActive() == persp); if (isActive) { this->SetPerspective(perspList.GetNextActive()); } this->DisposePerspective(persp, true); if (closePage && perspList.Size() == 0) { this->Close(); } } void WorkbenchPage::CloseAllPerspectives(bool saveEditors, bool closePage) { - if (perspList.IsEmpty()) { return; } // // Always unzoom // if (isZoomed()) // { // zoomOut(); // } if (saveEditors) { if (!this->SaveAllEditors(true)) { return; } } // Close all editors if (!this->CloseAllEditors(false)) { return; } // Deactivate the active perspective and part this->SetPerspective(Perspective::Pointer(0)); // Close each perspective in turn PerspectiveList oldList = perspList; perspList = PerspectiveList(); for (PerspectiveList::iterator itr = oldList.Begin(); itr != oldList.End(); ++itr) { this->ClosePerspective(*itr, false, false); } if (closePage) { this->Close(); } } void WorkbenchPage::CreateClientComposite() { void* parent = window->GetPageComposite(); // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // // public void WorkbenchPage::runWithException() // { composite = Tweaklets::Get(WorkbenchPageTweaklet::KEY)->CreateClientComposite( parent); Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(composite, false); // Make visible on activate. // force the client composite to be layed out // parent.layout(); // } // }); - } Perspective::Pointer WorkbenchPage::CreatePerspective( PerspectiveDescriptor::Pointer desc, bool notify) { std::string label = desc->GetId(); // debugging only try { //UIStats.start(UIStats.CREATE_PERSPECTIVE, label); WorkbenchPage::Pointer thisPage(this); Perspective::Pointer persp(new Perspective(desc, thisPage)); perspList.Add(persp); if (notify) { window->FirePerspectiveOpened(thisPage, desc); } //if the perspective is fresh and uncustomzied then it is not dirty //no reset will be prompted for if (!desc->HasCustomDefinition()) { dirtyPerspectives.erase(desc->GetId()); } return persp; } catch (WorkbenchException& /*e*/) { if (!window->GetWorkbenchImpl()->IsStarting()) { MessageDialog::OpenError(window->GetShell(), "Error", "Problems opening perspective \"" + desc->GetId() + "\""); } return Perspective::Pointer(0); } // finally // { // UIStats.end(UIStats.CREATE_PERSPECTIVE, desc.getId(), label); // } } void WorkbenchPage::PartAdded(WorkbenchPartReference::Pointer ref) { activationList->Add(ref); partList->AddPart(ref); this->UpdateActivePart(); } void WorkbenchPage::PartRemoved(WorkbenchPartReference::Pointer ref) { activationList->Remove(ref); this->DisposePart(ref); } void WorkbenchPage::DisposePart(WorkbenchPartReference::Pointer ref) { if (this->IsDeferred()) { pendingDisposals.push_back(ref); } else { partList->RemovePart(ref); ref->Dispose(); } } void WorkbenchPage::DeactivatePart(IWorkbenchPart::Pointer part) { if (part.IsNotNull()) { PartSite::Pointer site = part->GetSite().Cast (); site->GetPane()->ShowFocus(false); } } void WorkbenchPage::DetachView(IViewReference::Pointer ref) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return; } PerspectiveHelper* presentation = persp->GetPresentation(); presentation->DetachPart(ref); } void WorkbenchPage::AttachView(IViewReference::Pointer ref) { PerspectiveHelper* presentation = this->GetPerspectivePresentation(); presentation->AttachPart(ref); } WorkbenchPage::~WorkbenchPage() { // increment reference count to prevent recursive deletes this->Register(); { { - this->MakeActiveEditor(IEditorReference::Pointer(0)); this->MakeActive(IWorkbenchPartReference::Pointer(0)); // Close and dispose the editors. this->CloseAllEditors(false); // Need to make sure model data is cleaned up when the page is // disposed. Collect all the views on the page and notify the // saveable list of a pre/post close. This will free model data. std::vector partsToClose = this->GetOpenParts(); std::list dirtyParts; for (unsigned int i = 0; i < partsToClose.size(); i++) { IWorkbenchPart::Pointer part = partsToClose[i]->GetPart(false); if (part != 0 && part.Cast () != 0) { dirtyParts.push_back(part); } } SaveablesList::Pointer saveablesList = this->GetWorkbenchWindow()->GetWorkbench()->GetService( ISaveablesLifecycleListener::GetManifestName()).Cast< SaveablesList> (); SaveablesList::PostCloseInfo::Pointer postCloseInfo = saveablesList->PreCloseParts(dirtyParts, false, this->GetWorkbenchWindow()); saveablesList->PostClose(postCloseInfo); IWorkbenchPage::Pointer thisPage(this); // Get rid of perspectives. This will close the views for (PerspectiveList::iterator itr = perspList.Begin(); itr != perspList.End(); ++itr) { Perspective::Pointer perspective = *itr; window->FirePerspectiveClosed(thisPage, perspective->GetDesc()); //perspective->Dispose(); } perspList = PerspectiveList(); // Capture views. std::vector refs = viewFactory->GetViews(); // if (refs.size() > 0) // { // // Dispose views. // for (unsigned int i = 0; i < refs.size(); i++) // { // WorkbenchPartReference::Pointer ref = refs[i].Cast(); // //partList.RemovePart(ref); // //this->FirePartClosed(refs[i]); // // Platform.run(new SafeRunnable() { // // public void run() { // // // WorkbenchPlugin.log(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH, // // // Status.OK, "WorkbenchPage leaked a refcount for view " + ref.getId(), 0)); //$NON-NLS-1$//$NON-NLS-2$ // // ref.dispose(); // // } // // // public void handleException(Throwable e) { // // } // // }); // } // } // Get rid of editor presentation. //editorPresentation->Dispose(); // Get rid of composite. //composite.dispose(); //navigationHistory.dispose(); //stickyViewMan.clear(); // if (tracker != 0) // { // tracker.close(); // } // // if we're destroying a window in a non-shutdown situation then we should // // clean up the working set we made. // if (!window->GetWorkbench()->IsClosing()) // { // if (aggregateWorkingSet != 0) // { // PlatformUI.getWorkbench().getWorkingSetManager().removeWorkingSet( // aggregateWorkingSet); // } // } } partBeingActivated = 0; pendingDisposals.clear(); stickyViewMan = 0; delete viewFactory; delete editorPresentation; delete editorMgr; delete activationList; deferredActivePersp = 0; dirtyPerspectives.clear(); delete selectionService; partList = 0; - } // decrement reference count again, without explicit deletion this->UnRegister(false); } void WorkbenchPage::DisposePerspective(Perspective::Pointer persp, bool notify) { // Get rid of perspective. perspList.Remove(persp); if (notify) { IWorkbenchPage::Pointer thisPage(this); window->FirePerspectiveClosed(thisPage, persp->GetDesc()); } //persp->Dispose(); stickyViewMan->Remove(persp->GetDesc()->GetId()); } Perspective::Pointer WorkbenchPage::FindPerspective( IPerspectiveDescriptor::Pointer desc) { for (PerspectiveList::iterator itr = perspList.Begin(); itr != perspList.End(); ++itr) { Perspective::Pointer mgr = *itr; if (desc->GetId() == mgr->GetDesc()->GetId()) { return mgr; } } return Perspective::Pointer(0); } IViewPart::Pointer WorkbenchPage::FindView(const std::string& id) { IViewReference::Pointer ref = this->FindViewReference(id); if (ref == 0) { return IViewPart::Pointer(0); } return ref->GetView(true); } IViewReference::Pointer WorkbenchPage::FindViewReference( const std::string& viewId) { return this->FindViewReference(viewId, ""); } IViewReference::Pointer WorkbenchPage::FindViewReference( const std::string& viewId, const std::string& secondaryId) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return IViewReference::Pointer(0); } return persp->FindView(viewId, secondaryId); } IEditorPart::Pointer WorkbenchPage::GetActiveEditor() { return partList->GetActiveEditor(); } IEditorReference::Pointer WorkbenchPage::GetActiveEditorReference() { return partList->GetActiveEditorReference(); } IWorkbenchPart::Pointer WorkbenchPage::GetActivePart() { return partList->GetActivePart(); } IWorkbenchPartReference::Pointer WorkbenchPage::GetActivePartReference() { return partList->GetActivePartReference(); } Perspective::Pointer WorkbenchPage::GetActivePerspective() { return perspList.GetActive(); } void* WorkbenchPage::GetClientComposite() { return composite; } EditorManager* WorkbenchPage::GetEditorManager() { return editorMgr; } PerspectiveHelper* WorkbenchPage::GetPerspectivePresentation() { if (this->GetActivePerspective() != 0) { return this->GetActivePerspective()->GetPresentation(); } return 0; } +bool WorkbenchPage::HasView(const std::string& perspectiveId, const std::string& viewId) +{ + PerspectiveList::PerspectiveListType list = perspList.GetSortedPerspectives(); + for ( PerspectiveList::PerspectiveListType::iterator it = list.begin(); it!=list.end(); it++) + { + SmartPointer p = *it; + if ( p->GetDesc()->GetId()==perspectiveId) + { + if (p->ContainsView(viewId) ) + { + return true; + } + } + } + return false; +} + /** * Answer the editor presentation. */ EditorAreaHelper* WorkbenchPage::GetEditorPresentation() { return editorPresentation; } std::vector WorkbenchPage::GetEditors() { std::list refs = this->GetEditorReferences(); std::vector result; //Display d = getWorkbenchWindow().getShell().getDisplay(); //Must be backward compatible. // d.syncExec(new Runnable() // { // public void WorkbenchPage::run() // { for (std::list::iterator iter = refs.begin(); iter != refs.end(); ++iter) { IEditorPart::Pointer part = (*iter)->GetEditor(true); if (part != 0) { result.push_back(part); } } // } // }); return result; } std::vector WorkbenchPage::GetDirtyEditors() { return this->GetEditorManager()->GetDirtyEditors(); } std::vector WorkbenchPage::GetDirtyParts() { std::vector result; std::vector allParts = this->GetAllParts(); for (unsigned int i = 0; i < allParts.size(); i++) { IWorkbenchPartReference::Pointer reference = allParts[i]; IWorkbenchPart::Pointer part = reference->GetPart(false); if (part != 0 && part.Cast () != 0) { ISaveablePart::Pointer saveable = part.Cast (); if (saveable->IsDirty()) { result.push_back(saveable); } } } return result; } IEditorPart::Pointer WorkbenchPage::FindEditor(IEditorInput::Pointer input) { return this->GetEditorManager()->FindEditor(input); } std::vector WorkbenchPage::FindEditors( IEditorInput::Pointer input, const std::string& editorId, int matchFlags) { return this->GetEditorManager()->FindEditors(input, editorId, matchFlags); } std::list WorkbenchPage::GetEditorReferences() { return editorPresentation->GetEditors(); } IAdaptable* WorkbenchPage::GetInput() { return input; } std::string WorkbenchPage::GetLabel() { std::string label = ""; // IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util.getAdapter(input, // IWorkbenchAdapter.class); // if (adapter != 0) // { // label = adapter.getLabel(input); // } Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { label = label + " - " + persp->GetDesc()->GetLabel(); } else if (deferredActivePersp != 0) { label = label + " - " + deferredActivePersp->GetLabel(); } return label; } IPerspectiveDescriptor::Pointer WorkbenchPage::GetPerspective() { if (deferredActivePersp != 0) { return deferredActivePersp; } Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { return persp->GetDesc(); } else { return IPerspectiveDescriptor::Pointer(0); } } ISelection::ConstPointer WorkbenchPage::GetSelection() const { return selectionService->GetSelection(); } ISelection::ConstPointer WorkbenchPage::GetSelection(const std::string& partId) { return selectionService->GetSelection(partId); } //ISelectionService::SelectionEvents& WorkbenchPage::GetSelectionEvents(const std::string& partId) //{ // return selectionService->GetSelectionEvents(partId); //} ViewFactory* WorkbenchPage::GetViewFactory() { if (viewFactory == 0) { viewFactory = new ViewFactory(this, WorkbenchPlugin::GetDefault()->GetViewRegistry()); } return viewFactory; } std::vector WorkbenchPage::GetViewReferences() { Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { return persp->GetViewReferences(); } else { return std::vector(); } } std::vector WorkbenchPage::GetViews() { return this->GetViews(Perspective::Pointer(0), true); } std::vector WorkbenchPage::GetViews( Perspective::Pointer persp, bool restore) { if (persp == 0) { persp = this->GetActivePerspective(); } std::vector parts; if (persp != 0) { std::vector refs = persp->GetViewReferences(); for (unsigned int i = 0; i < refs.size(); i++) { IViewPart::Pointer part = refs[i]->GetPart(restore).Cast (); if (part != 0) { parts.push_back(part); } } } return parts; } IWorkbenchWindow::Pointer WorkbenchPage::GetWorkbenchWindow() { return IWorkbenchWindow::Pointer(window); } void WorkbenchPage::HideView(IViewReference::Pointer ref) { - // Sanity check. if (ref == 0) { return; } Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return; } bool promptedForSave = false; IViewPart::Pointer view = ref->GetView(false); if (view != 0) { - if (!this->CertifyPart(view)) { return; } // Confirm. if (view.Cast () != 0) { ISaveablePart::Pointer saveable = view.Cast (); if (saveable->IsSaveOnCloseNeeded()) { IWorkbenchWindow::Pointer window = view->GetSite()->GetWorkbenchWindow(); std::vector partsToSave; partsToSave.push_back(view); bool success = EditorManager::SaveAll(partsToSave, true, true, false, window); if (!success) { // the user cancelled. return; } promptedForSave = true; } } } int refCount = this->GetViewFactory()->GetReferenceCount(ref); SaveablesList::Pointer saveablesList; SaveablesList::PostCloseInfo::Pointer postCloseInfo; if (refCount == 1) { IWorkbenchPart::Pointer actualPart = ref->GetPart(false); if (actualPart != 0) { saveablesList = actualPart->GetSite()->GetService( ISaveablesLifecycleListener::GetManifestName()).Cast< SaveablesList> (); std::list partsToClose; partsToClose.push_back(actualPart); postCloseInfo = saveablesList->PreCloseParts(partsToClose, !promptedForSave, this->GetWorkbenchWindow()); if (postCloseInfo == 0) { // cancel return; } } } IWorkbenchPage::Pointer thisPage(this); // Notify interested listeners before the hide window->FirePerspectiveChanged(thisPage, persp->GetDesc(), ref, CHANGE_VIEW_HIDE); PartPane::Pointer pane = this->GetPane(ref.Cast ()); pane->SetInLayout(false); this->UpdateActivePart(); if (saveablesList != 0) { saveablesList->PostClose(postCloseInfo); } // Hide the part. persp->HideView(ref); // Notify interested listeners after the hide window->FirePerspectiveChanged(thisPage, this->GetPerspective(), CHANGE_VIEW_HIDE); } void WorkbenchPage::RefreshActiveView() { this->UpdateActivePart(); } void WorkbenchPage::HideView(IViewPart::Pointer view) { this->HideView(this->GetReference(view).Cast ()); } void WorkbenchPage::Init(WorkbenchWindow* w, const std::string& layoutID, IAdaptable* input, bool openExtras) { // Save args. this->window = w; this->input = input; this->composite = 0; this->viewFactory = 0; this->activationList = new ActivationList(this); this->selectionService = new PageSelectionService(this); this->partList = new WorkbenchPagePartList(this->selectionService); this->stickyViewMan = new StickyViewManager(this); //actionSets = new ActionSetManager(w); deferCount = 0; // Create presentation. this->CreateClientComposite(); editorPresentation = new EditorAreaHelper(this); editorMgr = new EditorManager(WorkbenchWindow::Pointer(window), WorkbenchPage::Pointer(this), editorPresentation); //TODO WorkbenchPage perspective reorder listener? // // add this page as a client to be notified when the UI has re-ordered perspectives // // so that the order can be properly maintained in the receiver. // // E.g. a UI might support drag-and-drop and will need to make this known to ensure // // #saveState and #restoreState do not lose this re-ordering // w.addPerspectiveReorderListener(new IReorderListener() // { // public void WorkbenchPage::reorder(Object perspective, int newLoc) // { // perspList.reorder((IPerspectiveDescriptor)perspective, newLoc); // } // }); if (openExtras) { this->OpenPerspectiveExtras(); } // Get perspective descriptor. if (layoutID != "") { PerspectiveDescriptor::Pointer desc = WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()->FindPerspectiveWithId( layoutID).Cast (); if (desc == 0) { throw WorkbenchException("Unable to create Perspective " + layoutID + ". There is no corresponding perspective extension."); } Perspective::Pointer persp = this->FindPerspective(desc); if (persp == 0) { persp = this->CreatePerspective(desc, true); } perspList.SetActive(persp); window->FirePerspectiveActivated(IWorkbenchPage::Pointer(this), desc); } // getExtensionTracker() .registerHandler(perspectiveChangeHandler, // ExtensionTracker .createExtensionPointFilter( // getPerspectiveExtensionPoint())); } void WorkbenchPage::OpenPerspectiveExtras() { //TODO WorkbenchPage perspectice extras std::string extras = ""; //PrefUtil.getAPIPreferenceStore().getString( // IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS); Poco::StringTokenizer tok(extras, ", ", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY); //$NON-NLS-1$ std::vector descs; for (Poco::StringTokenizer::Iterator itr = tok.begin(); itr != tok.end(); ++itr) { std::string id = *itr; IPerspectiveDescriptor::Pointer desc = WorkbenchPlugin::GetDefault()->GetPerspectiveRegistry()->FindPerspectiveWithId( id); if (desc != 0) { descs.push_back(desc); } } // HACK: The perspective switcher currently adds the button for a new perspective to the beginning of the list. // So, we process the extra perspectives in reverse order here to have their buttons appear in the order declared. for (int i = (int) descs.size(); --i >= 0;) { PerspectiveDescriptor::Pointer desc = descs[i].Cast (); if (this->FindPerspective(desc) == 0) { this->CreatePerspective(desc, true); } } } bool WorkbenchPage::IsPartVisible(IWorkbenchPart::Pointer part) { PartPane::Pointer pane = this->GetPane(part); return pane != 0 && pane->GetVisible(); } bool WorkbenchPage::IsEditorAreaVisible() { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return false; } return persp->IsEditorAreaVisible(); } bool WorkbenchPage::IsFastView(IViewReference::Pointer /*ref*/) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { //return persp->IsFastView(ref); return false; } else { return false; } } bool WorkbenchPage::IsCloseable(IViewReference::Pointer ref) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { return persp->IsCloseable(ref); } return false; } bool WorkbenchPage::IsMoveable(IViewReference::Pointer ref) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { return persp->IsMoveable(ref); } return false; } bool WorkbenchPage::IsFixedLayout() { Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { return persp->IsFixedLayout(); } else { return false; } } bool WorkbenchPage::IsSaveNeeded() { return this->GetEditorManager()->IsSaveAllNeeded(); } void WorkbenchPage::OnActivate() { Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(composite, true); Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { persp->OnActivate(); this->UpdateVisibility(Perspective::Pointer(0), persp); } } void WorkbenchPage::OnDeactivate() { this->MakeActiveEditor(IEditorReference::Pointer(0)); this->MakeActive(IWorkbenchPartReference::Pointer(0)); if (this->GetActivePerspective() != 0) { this->GetActivePerspective()->OnDeactivate(); } Tweaklets::Get(GuiWidgetsTweaklet::KEY)->SetVisible(composite, false); } void WorkbenchPage::ReuseEditor(IReusableEditor::Pointer editor, IEditorInput::Pointer input) { - // Rather than calling editor.setInput on the editor directly, we do it through the part reference. // This case lets us detect badly behaved editors that are not firing a PROP_INPUT event in response // to the input change... but if all editors obeyed their API contract, the "else" branch would be // sufficient. IWorkbenchPartReference::Pointer ref = this->GetReference(editor); if (ref.Cast () != 0) { EditorReference::Pointer editorRef = ref.Cast (); editorRef->SetInput(input); } else { editor->SetInput(input); } //navigationHistory.markEditor(editor); } IEditorPart::Pointer WorkbenchPage::OpenEditor(IEditorInput::Pointer input, const std::string& editorID) { return this->OpenEditor(input, editorID, true, MATCH_INPUT); } IEditorPart::Pointer WorkbenchPage::OpenEditor(IEditorInput::Pointer input, const std::string& editorID, bool activate) { return this->OpenEditor(input, editorID, activate, MATCH_INPUT); } IEditorPart::Pointer WorkbenchPage::OpenEditor( const IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags) { return this->OpenEditor(input, editorID, activate, matchFlags, IMemento::Pointer(0)); } IEditorPart::Pointer WorkbenchPage::OpenEditor( const IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags, IMemento::Pointer editorState) { if (input == 0 || editorID == "") { throw Poco::InvalidArgumentException(); } // BusyIndicator.showWhile(window.getWorkbench().getDisplay(), // new Runnable() // { // public void WorkbenchPage::run() // { return this->BusyOpenEditor(input, editorID, activate, matchFlags, editorState); } IEditorPart::Pointer WorkbenchPage::OpenEditorFromDescriptor( IEditorInput::Pointer input, IEditorDescriptor::Pointer editorDescriptor, bool activate, IMemento::Pointer editorState) { if (input == 0 || !(editorDescriptor.Cast () != 0)) { throw Poco::InvalidArgumentException(); } // BusyIndicator.showWhile(window.getWorkbench().getDisplay(), // new Runnable() // { // public void WorkbenchPage::run() // { return this->BusyOpenEditorFromDescriptor(input, editorDescriptor.Cast< EditorDescriptor> (), activate, editorState); // } // }); - } IEditorPart::Pointer WorkbenchPage::BusyOpenEditor(IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags, IMemento::Pointer editorState) { - Workbench* workbench = this->GetWorkbenchWindow().Cast ()->GetWorkbenchImpl(); workbench->LargeUpdateStart(); IEditorPart::Pointer result; try { result = this->BusyOpenEditorBatched(input, editorID, activate, matchFlags, editorState); - } catch (std::exception& e) { workbench->LargeUpdateEnd(); throw e; } workbench->LargeUpdateEnd(); return result; } IEditorPart::Pointer WorkbenchPage::BusyOpenEditorFromDescriptor( IEditorInput::Pointer input, EditorDescriptor::Pointer editorDescriptor, bool activate, IMemento::Pointer editorState) { - Workbench* workbench = this->GetWorkbenchWindow().Cast ()->GetWorkbenchImpl(); workbench->LargeUpdateStart(); IEditorPart::Pointer result; try { result = this->BusyOpenEditorFromDescriptorBatched(input, editorDescriptor, activate, editorState); - } catch (std::exception& e) { workbench->LargeUpdateEnd(); throw e; } workbench->LargeUpdateEnd(); return result; } IEditorPart::Pointer WorkbenchPage::BusyOpenEditorBatched( IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags, IMemento::Pointer editorState) { - // If an editor already exists for the input, use it. IEditorPart::Pointer editor; // Reuse an existing open editor, unless we are in "new editor tab management" mode editor = this->GetEditorManager()->FindEditor(editorID, input, matchFlags); if (editor != 0) { if (IEditorRegistry::SYSTEM_EXTERNAL_EDITOR_ID == editorID) { if (editor->IsDirty()) { std::vector dlgLabels; dlgLabels.push_back("Yes"); dlgLabels.push_back("No"); dlgLabels.push_back("Cancel"); IDialog::Pointer dialog = MessageDialog::CreateMessageDialog( this->GetWorkbenchWindow()->GetShell(), "Save", (void*) 0, // accept the default window icon "\"" + input->GetName() + "\" is opened and has unsaved changes. Do you want to save it?", IDialog::QUESTION, dlgLabels, 0); int saveFile = dialog->Open(); if (saveFile == 0) { // try // { IEditorPart::Pointer editorToSave = editor; // getWorkbenchWindow().run(false, false, // new IRunnableWithProgress() // { // public void WorkbenchPage::run(IProgressMonitor monitor) // throws InvocationTargetException, // InterruptedException // { //TODO progress monitor editorToSave->DoSave();//monitor); // } // }); // } // catch (InvocationTargetException& e) // { // throw(RuntimeException) e->GetTargetException(); // } // catch (InterruptedException& e) // { // return 0; // } } else if (saveFile == 2) { return IEditorPart::Pointer(0); } } } else { // // do the IShowEditorInput notification before showing the editor // // to reduce flicker // if (editor.Cast () != 0) // { // ((IShowEditorInput) editor).showEditorInput(input); // } this->ShowEditor(activate, editor); return editor; } } // Otherwise, create a new one. This may cause the new editor to // become the visible (i.e top) editor. IEditorReference::Pointer ref = this->GetEditorManager()->OpenEditor( editorID, input, true, editorState); if (ref != 0) { editor = ref->GetEditor(true); } if (editor != 0) { this->SetEditorAreaVisible(true); if (activate) { this->Activate(editor); } else { this->BringToTop(editor); } IWorkbenchPage::Pointer thisPage(this); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref, CHANGE_EDITOR_OPEN); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), CHANGE_EDITOR_OPEN); } return editor; } /* * Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program. * See openEditorFromDescriptor(). */ IEditorPart::Pointer WorkbenchPage::BusyOpenEditorFromDescriptorBatched( IEditorInput::Pointer input, EditorDescriptor::Pointer editorDescriptor, bool activate, IMemento::Pointer editorState) { - IEditorPart::Pointer editor; // Create a new one. This may cause the new editor to // become the visible (i.e top) editor. IEditorReference::Pointer ref; ref = this->GetEditorManager()->OpenEditorFromDescriptor(editorDescriptor, input, editorState); if (ref != 0) { editor = ref->GetEditor(true); } if (editor != 0) { this->SetEditorAreaVisible(true); if (activate) { - this->Activate(editor); - } else { this->BringToTop(editor); } IWorkbenchPage::Pointer thisPage(this); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref, CHANGE_EDITOR_OPEN); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), CHANGE_EDITOR_OPEN); } return editor; } void WorkbenchPage::OpenEmptyTab() { IEditorPart::Pointer editor; EditorReference::Pointer ref; ref = this->GetEditorManager()->OpenEmptyTab().Cast (); if (ref != 0) { editor = ref->GetEmptyEditor( dynamic_cast (WorkbenchPlugin::GetDefault()->GetEditorRegistry())->FindEditor( EditorRegistry::EMPTY_EDITOR_ID).Cast ()); } if (editor != 0) { this->SetEditorAreaVisible(true); this->Activate(editor); IWorkbenchPage::Pointer thisPage(this); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), ref, CHANGE_EDITOR_OPEN); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), CHANGE_EDITOR_OPEN); } } void WorkbenchPage::ShowEditor(bool activate, IEditorPart::Pointer editor) { this->SetEditorAreaVisible(true); if (activate) { //zoomOutIfNecessary(editor); this->Activate(editor); } else { this->BringToTop(editor); } } bool WorkbenchPage::IsEditorPinned(IEditorPart::Pointer editor) { WorkbenchPartReference::Pointer ref = this->GetReference(editor).Cast< WorkbenchPartReference> (); return ref != 0 && ref->IsPinned(); } /** * Removes an IPartListener from the part service. */ void WorkbenchPage::RemovePartListener(IPartListener::Pointer l) { partList->GetPartService()->RemovePartListener(l); } /** * Implements IWorkbenchPage * * @see org.blueberry.ui.IWorkbenchPage#removePropertyChangeListener(IPropertyChangeListener) * @since 2.0 * @deprecated individual views should store a working set if needed and * register a property change listener directly with the * working set manager to receive notification when the view * working set is removed. */ // void WorkbenchPage::RemovePropertyChangeListener(IPropertyChangeListener listener) { // propertyChangeListeners.remove(listener); // } void WorkbenchPage::RemoveSelectionListener( ISelectionListener::Pointer listener) { selectionService->RemoveSelectionListener(listener); } void WorkbenchPage::RemoveSelectionListener(const std::string& partId, ISelectionListener::Pointer listener) { selectionService->RemoveSelectionListener(partId, listener); } void WorkbenchPage::RemovePostSelectionListener( ISelectionListener::Pointer listener) { selectionService->RemovePostSelectionListener(listener); } void WorkbenchPage::RemovePostSelectionListener(const std::string& partId, ISelectionListener::Pointer listener) { selectionService->RemovePostSelectionListener(partId, listener); } void WorkbenchPage::RequestActivation(IWorkbenchPart::Pointer part) { // Sanity check. if (!this->CertifyPart(part)) { return; } // Real work. this->SetActivePart(part); } /** * Resets the layout for the perspective. The active part in the old layout * is activated in the new layout for consistent user context. */ void WorkbenchPage::ResetPerspective() { // Run op in busy cursor. // Use set redraw to eliminate the "flash" that can occur in the // coolbar as the perspective is reset. // ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); // try // { // mgr.getControl2().setRedraw(false); // BusyIndicator.showWhile(0, new Runnable() // { // public void WorkbenchPage::run() // { this->BusyResetPerspective(); // } // }); // }finally // { // mgr.getControl2().setRedraw(true); // } } bool WorkbenchPage::RestoreState(IMemento::Pointer memento, const IPerspectiveDescriptor::Pointer activeDescriptor) { // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // // public void WorkbenchPage::runWithException() throws Throwable // { this->DeferUpdates(true); // }}); try { // Restore working set std::string pageName; memento->GetString(WorkbenchConstants::TAG_LABEL, pageName); // String label = 0; // debugging only // if (UIStats.isDebugging(UIStats.RESTORE_WORKBENCH)) // { // label = pageName == 0 ? "" : "::" + pageName; //$NON-NLS-1$ //$NON-NLS-2$ // } try { //UIStats.start(UIStats.RESTORE_WORKBENCH, "WorkbenchPage" + label); //$NON-NLS-1$ // MultiStatus result = // new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, NLS.bind( // WorkbenchMessages.WorkbenchPage_unableToRestorePerspective, // pageName), 0); bool result = true; // String workingSetName = memento .getString( // IWorkbenchConstants.TAG_WORKING_SET); // if (workingSetName != 0) // { // AbstractWorkingSetManager // workingSetManager = // (AbstractWorkingSetManager) getWorkbenchWindow() .getWorkbench().getWorkingSetManager(); // setWorkingSet(workingSetManager.getWorkingSet(workingSetName)); // } // // IMemento workingSetMem = memento .getChild( // IWorkbenchConstants.TAG_WORKING_SETS); // if (workingSetMem != 0) // { // std::vector workingSetChildren = // workingSetMem .getChildren(IWorkbenchConstants.TAG_WORKING_SET); // List workingSetList = new ArrayList(workingSetChildren.length); // for (int i = 0; i < workingSetChildren.length; i++) // { // IWorkingSet // set = // getWorkbenchWindow().getWorkbench() .getWorkingSetManager().getWorkingSet( // workingSetChildren[i].getID()); // if (set != 0) // { // workingSetList.add(set); // } // } // // workingSets = (IWorkingSet[]) workingSetList .toArray( // new IWorkingSet[workingSetList.size()]); // } // // aggregateWorkingSetId = memento.getString(ATT_AGGREGATE_WORKING_SET_ID); // // IWorkingSet setWithId = // window.getWorkbench().getWorkingSetManager().getWorkingSet( // aggregateWorkingSetId); // // // check to see if the set has already been made and assign it if it has // if (setWithId.Cast () != 0) // { // aggregateWorkingSet = (AggregateWorkingSet) setWithId; // } // Restore editor manager. IMemento::Pointer childMem = memento->GetChild( WorkbenchConstants::TAG_EDITORS); //result.merge(getEditorManager().restoreState(childMem)); result &= this->GetEditorManager()->RestoreState(childMem); childMem = memento->GetChild(WorkbenchConstants::TAG_VIEWS); if (childMem) { //result.merge(getViewFactory().restoreState(childMem)); result &= this->GetViewFactory()->RestoreState(childMem); } // Get persp block. childMem = memento->GetChild(WorkbenchConstants::TAG_PERSPECTIVES); std::string activePartID; childMem->GetString(WorkbenchConstants::TAG_ACTIVE_PART, activePartID); std::string activePartSecondaryID; if (!activePartID.empty()) { activePartSecondaryID = ViewFactory::ExtractSecondaryId(activePartID); if (!activePartSecondaryID.empty()) { activePartID = ViewFactory::ExtractPrimaryId(activePartID); } } std::string activePerspectiveID; childMem->GetString(WorkbenchConstants::TAG_ACTIVE_PERSPECTIVE, activePerspectiveID); // Restore perspectives. std::vector perspMems(childMem->GetChildren( WorkbenchConstants::TAG_PERSPECTIVE)); Perspective::Pointer activePerspective; + IPerspectiveDescriptor::Pointer validPersp; for (std::size_t i = 0; i < perspMems.size(); i++) { - IMemento::Pointer current = perspMems[i]; // StartupThreading // .runWithoutExceptions(new StartupRunnable() // { // // public void WorkbenchPage::runWithException() throws Throwable // { Perspective::Pointer persp(new Perspective( - PerspectiveDescriptor::Pointer(0), WorkbenchPage::Pointer(this))); + + PerspectiveDescriptor::Pointer(0), WorkbenchPage::Pointer(this))); //result.merge(persp.restoreState(current)); result &= persp->RestoreState(current); IPerspectiveDescriptor::Pointer desc = persp->GetDesc(); + if (desc.IsNotNull()) + { + validPersp=desc; + } else + { + IPerspectiveDescriptor::Pointer desc = WorkbenchPlugin::GetDefault()-> + GetPerspectiveRegistry()->CreatePerspective("Hallo",validPersp); + } if (desc == activeDescriptor) { activePerspective = persp; } else if ((activePerspective == 0) && desc->GetId() == activePerspectiveID) { activePerspective = persp; } perspList.Add(persp); + + //berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry()->Add window->FirePerspectiveOpened(WorkbenchPage::Pointer(this), desc); // } // }); } bool restoreActivePerspective = false; if (!activeDescriptor) { restoreActivePerspective = true; - } else if (activePerspective && activePerspective->GetDesc() == activeDescriptor) { restoreActivePerspective = true; } else { restoreActivePerspective = false; activePerspective = this->CreatePerspective(activeDescriptor.Cast< PerspectiveDescriptor> (), true); if (activePerspective == 0) { // result .merge( // new Status(IStatus.ERR, PlatformUI.PLUGIN_ID, 0, NLS.bind( // WorkbenchMessages.Workbench_showPerspectiveError, // activeDescriptor.getId()), 0)); result &= false; } } perspList.SetActive(activePerspective); // Make sure we have a valid perspective to work with, // otherwise return. activePerspective = perspList.GetActive(); if (activePerspective == 0) { activePerspective = perspList.GetNextActive(); perspList.SetActive(activePerspective); } if (activePerspective && restoreActivePerspective) { //result.merge(activePerspective.restoreState()); result &= activePerspective->RestoreState(); } if (activePerspective) { Perspective::Pointer myPerspective = activePerspective; std::string myActivePartId = activePartID; std::string mySecondaryId = activePartSecondaryID; // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // // public void WorkbenchPage::runWithException() throws Throwable // { window->FirePerspectiveActivated(WorkbenchPage::Pointer(this), myPerspective->GetDesc()); // Restore active part. if (!myActivePartId.empty()) { IWorkbenchPartReference::Pointer ref = myPerspective->FindView( myActivePartId, mySecondaryId); if (ref) { activationList->SetActive(ref); } } // }}); - } // childMem = memento->GetChild(WorkbenchConstants::TAG_NAVIGATION_HISTORY); // if (childMem) // { // navigationHistory.restoreState(childMem); // } // else if (GetActiveEditor()) // { // navigationHistory.markEditor(getActiveEditor()); // } // // restore sticky view state stickyViewMan->Restore(memento); // std::string blame = activeDescriptor == 0 ? pageName // : activeDescriptor.getId(); // UIStats.end(UIStats.RESTORE_WORKBENCH, blame, "WorkbenchPage" + label); //$NON-NLS-1$ // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // public void WorkbenchPage::runWithException() throws Throwable // { DeferUpdates(false); // } // }); return result; } catch (...) { // std::string blame = activeDescriptor == 0 ? pageName // : activeDescriptor.getId(); // UIStats.end(UIStats.RESTORE_WORKBENCH, blame, "WorkbenchPage" + label); //$NON-NLS-1$ throw ; } } catch (...) { // StartupThreading.runWithoutExceptions(new StartupRunnable() // { // public void WorkbenchPage::runWithException() throws Throwable // { DeferUpdates(false); // } // }); throw; } - } bool WorkbenchPage::SaveAllEditors(bool confirm) { return this->SaveAllEditors(confirm, false); } bool WorkbenchPage::SaveAllEditors(bool confirm, bool addNonPartSources) { return this->GetEditorManager()->SaveAll(confirm, false, addNonPartSources); } bool WorkbenchPage::SavePart(ISaveablePart::Pointer saveable, IWorkbenchPart::Pointer part, bool confirm) { // Do not certify part do allow editors inside a multipageeditor to // call this. return this->GetEditorManager()->SavePart(saveable, part, confirm); } bool WorkbenchPage::SaveEditor(IEditorPart::Pointer editor, bool confirm) { return this->SavePart(editor, editor, confirm); } /** * Saves the current perspective. */ void WorkbenchPage::SavePerspective() { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return; } // // Always unzoom. // if (isZoomed()) // { // zoomOut(); // } persp->SaveDesc(); } /** * Saves the perspective. */ void WorkbenchPage::SavePerspectiveAs(IPerspectiveDescriptor::Pointer newDesc) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return; } IPerspectiveDescriptor::Pointer oldDesc = persp->GetDesc(); // // Always unzoom. // if (isZoomed()) // { // zoomOut(); // } persp->SaveDescAs(newDesc); window->FirePerspectiveSavedAs(IWorkbenchPage::Pointer(this), oldDesc, newDesc); } /** * Save the state of the page. */ bool WorkbenchPage::SaveState(IMemento::Pointer memento) { // // We must unzoom to get correct layout. // if (isZoomed()) // { // zoomOut(); // } // MultiStatus // result = // new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, NLS.bind( // WorkbenchMessages.WorkbenchPage_unableToSavePerspective, // getLabel()), 0); bool result = true; // Save editor manager. IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_EDITORS); //result.merge(editorMgr.saveState(childMem)); result &= editorMgr->SaveState(childMem); childMem = memento->CreateChild(WorkbenchConstants::TAG_VIEWS); //result.merge(getViewFactory().saveState(childMem)); result &= this->GetViewFactory()->SaveState(childMem); // Create persp block. childMem = memento->CreateChild(WorkbenchConstants::TAG_PERSPECTIVES); if (this->GetPerspective()) { childMem->PutString(WorkbenchConstants::TAG_ACTIVE_PERSPECTIVE, this->GetPerspective()->GetId()); } if (this->GetActivePart() != 0) { if (this->GetActivePart().Cast ()) { IViewReference::Pointer ref = this->GetReference(this->GetActivePart()).Cast(); if (ref) { childMem->PutString(WorkbenchConstants::TAG_ACTIVE_PART, ViewFactory::GetKey(ref)); } } else { childMem->PutString(WorkbenchConstants::TAG_ACTIVE_PART, this->GetActivePart()->GetSite()->GetId()); } } // Save each perspective in opened order for (PerspectiveList::PerspectiveListType::iterator itr = perspList.Begin(); itr != perspList.End(); ++itr) { IMemento::Pointer gChildMem = childMem->CreateChild( WorkbenchConstants::TAG_PERSPECTIVE); //result.merge(persp.saveState(gChildMem)); result &= (*itr)->SaveState(gChildMem); } // // Save working set if set // if (workingSet != 0) // { // memento.putString(IWorkbenchConstants.TAG_WORKING_SET, // workingSet .getName()); // } // // IMemento workingSetMem = memento .createChild( // IWorkbenchConstants.TAG_WORKING_SETS); // for (int i = 0; i < workingSets.length; i++) // { // workingSetMem.createChild(IWorkbenchConstants.TAG_WORKING_SET, // workingSets[i].getName()); // } // // if (aggregateWorkingSetId != 0) // { // memento.putString(ATT_AGGREGATE_WORKING_SET_ID, aggregateWorkingSetId); // } // // navigationHistory.saveState(memento .createChild( // IWorkbenchConstants.TAG_NAVIGATION_HISTORY)); // // save the sticky activation state stickyViewMan->Save(memento); return result; } std::string WorkbenchPage::GetId(IWorkbenchPart::Pointer part) { return this->GetId(this->GetReference(part)); } std::string WorkbenchPage::GetId(IWorkbenchPartReference::Pointer ref) { if (ref == 0) { return "0"; //$NON-NLS-1$ } return ref->GetId(); } void WorkbenchPage::SetActivePart(IWorkbenchPart::Pointer newPart) { // Optimize it. if (this->GetActivePart() == newPart) { return; } if (partBeingActivated != 0) { if (partBeingActivated->GetPart(false) != newPart) { WorkbenchPlugin::Log(Poco::RuntimeException( "WARNING: Prevented recursive attempt to activate part " + this->GetId(newPart) + " while still in the middle of activating part " + this->GetId( partBeingActivated))); } return; } //No need to change the history if the active editor is becoming the // active part // String label = 0; // debugging only // if (UIStats.isDebugging(UIStats.ACTIVATE_PART)) // { // label = newPart != 0 ? newPart.getTitle() : "none"; //$NON-NLS-1$ // } try { IWorkbenchPartReference::Pointer partref = this->GetReference(newPart); IWorkbenchPartReference::Pointer realPartRef; if (newPart != 0) { IWorkbenchPartSite::Pointer site = newPart->GetSite(); if (site.Cast () != 0) { realPartRef = site.Cast ()->GetPane()->GetPartReference(); } } partBeingActivated = realPartRef; //UIStats.start(UIStats.ACTIVATE_PART, label); // Notify perspective. It may deactivate fast view. Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { persp->PartActivated(newPart); } // Deactivate old part IWorkbenchPart::Pointer oldPart = this->GetActivePart(); if (oldPart != 0) { this->DeactivatePart(oldPart); } // Set active part. if (newPart != 0) { activationList->SetActive(newPart); if (newPart.Cast () != 0) { this->MakeActiveEditor(realPartRef.Cast ()); } } this->ActivatePart(newPart); actionSwitcher.UpdateActivePart(newPart); partList->SetActivePart(partref); } catch (std::exception& e) { partBeingActivated = 0; // Object blame = newPart == 0 ? (Object) this : newPart; // UIStats.end(UIStats.ACTIVATE_PART, blame, label); throw e; } partBeingActivated = 0; } void WorkbenchPage::SetEditorAreaVisible(bool showEditorArea) { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return; } if (showEditorArea == persp->IsEditorAreaVisible()) { return; } // // If parts change always update zoom. // if (isZoomed()) // { // zoomOut(); // } // Update editor area visibility. IWorkbenchPage::Pointer thisPage(this); if (showEditorArea) { persp->ShowEditorArea(); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), CHANGE_EDITOR_AREA_SHOW); } else { persp->HideEditorArea(); this->UpdateActivePart(); window->FirePerspectiveChanged(thisPage, this->GetPerspective(), CHANGE_EDITOR_AREA_HIDE); } } /** * Sets the layout of the page. Assumes the new perspective is not 0. * Keeps the active part if possible. Updates the window menubar and * toolbar if necessary. */ void WorkbenchPage::SetPerspective(Perspective::Pointer newPersp) { // Don't do anything if already active layout Perspective::Pointer oldPersp = this->GetActivePerspective(); if (oldPersp == newPersp) { return; } window->LargeUpdateStart(); std::exception exc; bool exceptionOccured = false; try { IWorkbenchPage::Pointer thisPage(this); if (oldPersp != 0) { // fire the pre-deactivate window->FirePerspectivePreDeactivate(thisPage, oldPersp->GetDesc()); } if (newPersp != 0) { bool status = newPersp->RestoreState(); if (!status) { std::string title = "Restoring problems"; std::string msg = "Unable to read workbench state."; MessageDialog::OpenError(this->GetWorkbenchWindow()->GetShell(), title, msg); } } // Deactivate the old layout if (oldPersp != 0) { oldPersp->OnDeactivate(); // Notify listeners of deactivation window->FirePerspectiveDeactivated(thisPage, oldPersp->GetDesc()); } // Activate the new layout perspList.SetActive(newPersp); if (newPersp != 0) { newPersp->OnActivate(); // Notify listeners of activation window->FirePerspectiveActivated(thisPage, newPersp->GetDesc()); } this->UpdateVisibility(oldPersp, newPersp); // Update the window //TODO action sets //window->UpdateActionSets(); // Update sticky views stickyViewMan->Update(oldPersp, newPersp); - } catch (std::exception& e) { exc = e; exceptionOccured = true; } window->LargeUpdateEnd(); if (newPersp == 0) { return; } IPerspectiveDescriptor::Pointer desc = newPersp->GetDesc(); if (desc == 0) { return; } if (dirtyPerspectives.erase(desc->GetId())) { this->SuggestReset(); } if (exceptionOccured) throw exc; } void WorkbenchPage::UpdateVisibility(Perspective::Pointer oldPersp, Perspective::Pointer newPersp) { - // Flag all parts in the old perspective std::vector oldRefs; if (oldPersp != 0) { oldRefs = oldPersp->GetViewReferences(); for (unsigned int i = 0; i < oldRefs.size(); i++) { PartPane::Pointer pane = oldRefs[i].Cast ()->GetPane(); pane->SetInLayout(false); } } PerspectiveHelper* pres = 0; // Make parts in the new perspective visible if (newPersp != 0) { pres = newPersp->GetPresentation(); std::vector newRefs = newPersp->GetViewReferences(); for (unsigned int i = 0; i < newRefs.size(); i++) { WorkbenchPartReference::Pointer ref = newRefs[i].Cast< WorkbenchPartReference> (); PartPane::Pointer pane = ref->GetPane(); if (pres->IsPartVisible(ref)) { activationList->BringToTop(ref); } pane->SetInLayout(true); } } this->UpdateActivePart(); // Hide any parts in the old perspective that are no longer visible for (unsigned int i = 0; i < oldRefs.size(); i++) { WorkbenchPartReference::Pointer ref = oldRefs[i].Cast< WorkbenchPartReference> (); PartPane::Pointer pane = ref->GetPane(); if (pres == 0 || !pres->IsPartVisible(ref)) { pane->SetVisible(false); } } } /** * Sets the perspective. * * @param desc * identifies the new perspective. */ void WorkbenchPage::SetPerspective(IPerspectiveDescriptor::Pointer desc) { if (this->GetPerspective() == desc) { return; } // // Going from multiple to single rows can make the coolbar // // and its adjacent views appear jumpy as perspectives are // // switched. Turn off redraw to help with this. // ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); std::exception exc; bool exceptionOccured = false; try { //mgr.getControl2().setRedraw(false); //getClientComposite().setRedraw(false); // Run op in busy cursor. // BusyIndicator.showWhile(0, new Runnable() // { // public void WorkbenchPage::run() // { this->BusySetPerspective(desc); // } // }); } catch (std::exception& e) { exc = e; exceptionOccured = true; } // getClientComposite().setRedraw(true); // mgr.getControl2().setRedraw(true); IWorkbenchPart::Pointer part = this->GetActivePart(); if (part != 0) { part->SetFocus(); } if (exceptionOccured) throw exc; } PartService* WorkbenchPage::GetPartService() { return dynamic_cast (partList->GetPartService()); } void WorkbenchPage::ResetToolBarLayout() { // ICoolBarManager2 mgr = (ICoolBarManager2) window.getCoolBarManager2(); // mgr.resetItemOrder(); } IViewPart::Pointer WorkbenchPage::ShowView(const std::string& viewID) { return this->ShowView(viewID, "", VIEW_ACTIVATE); } IViewPart::Pointer WorkbenchPage::ShowView(const std::string& viewID, const std::string& secondaryID, int mode) { - if (secondaryID != "") { if (secondaryID.size() == 0 || secondaryID.find_first_of( ViewFactory::ID_SEP) != std::string::npos) { throw Poco::InvalidArgumentException( "Illegal secondary id (cannot be empty or contain a colon)"); } } if (!this->CertifyMode(mode)) { throw Poco::InvalidArgumentException("Illegal view mode"); } // Run op in busy cursor. // BusyIndicator.showWhile(0, new Runnable() // { // public void WorkbenchPage::run() // { // try // { return this->BusyShowView(viewID, secondaryID, mode); // } catch (PartInitException& e) // { // result = e; // } // } // }); - } bool WorkbenchPage::CertifyMode(int mode) { if (mode == VIEW_ACTIVATE || mode == VIEW_VISIBLE || mode == VIEW_CREATE) return true; return false; } std::vector WorkbenchPage::GetSortedEditors() { return activationList->GetEditors(); } std::vector WorkbenchPage::GetOpenPerspectives() { std::list opened = perspList.GetOpenedPerspectives(); std::vector result; for (std::list::iterator iter = opened.begin(); iter != opened.end(); ++iter) { result.push_back((*iter)->GetDesc()); } return result; } std::list WorkbenchPage::GetOpenInternalPerspectives() { return perspList.GetOpenedPerspectives(); } Perspective::Pointer WorkbenchPage::GetFirstPerspectiveWithView( IViewPart::Pointer part) { std::list perspectives = perspList.GetSortedPerspectives(); for (std::list::reverse_iterator iter = perspectives.rbegin(); iter != perspectives.rend(); ++iter) { if ((*iter)->ContainsView(part)) { return *iter; } } // we should never get here return Perspective::Pointer(0); } std::vector WorkbenchPage::GetSortedPerspectives() { std::list sortedArray = perspList.GetSortedPerspectives(); std::vector result; for (std::list::iterator iter = sortedArray.begin(); iter != sortedArray.end(); ++iter) { result.push_back((*iter)->GetDesc()); } return result; } std::vector WorkbenchPage::GetSortedParts() { //return partList->GetParts(this->GetViewReferences()); return activationList->GetParts(); } IWorkbenchPartReference::Pointer WorkbenchPage::GetReference( IWorkbenchPart::Pointer part) { if (part == 0) { return IWorkbenchPartReference::Pointer(0); } IWorkbenchPartSite::Pointer site = part->GetSite(); if (site.Cast () == 0) { return IWorkbenchPartReference::Pointer(0); } PartSite::Pointer partSite = site.Cast (); PartPane::Pointer pane = partSite->GetPane(); return partSite->GetPartReference(); } // for dynamic UI void WorkbenchPage::AddPerspective(Perspective::Pointer persp) { perspList.Add(persp); IWorkbenchPage::Pointer thisPage(this); window->FirePerspectiveOpened(thisPage, persp->GetDesc()); } std::vector WorkbenchPage::GetViewReferenceStack( IViewPart::Pointer part) { // Sanity check. Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0 || !this->CertifyPart(part)) { return std::vector(); } ILayoutContainer::Pointer container = part->GetSite().Cast ()->GetPane()->GetContainer(); if (container.Cast () != 0) { PartStack::Pointer folder = container.Cast (); std::vector list; ILayoutContainer::ChildrenType children = folder->GetChildren(); for (ILayoutContainer::ChildrenType::iterator childIter = children.begin(); childIter != children.end(); ++childIter) { LayoutPart::Pointer stackablePart = *childIter; if (stackablePart.Cast () != 0) { IViewReference::Pointer view = stackablePart.Cast ()->GetPartReference().Cast< IViewReference> (); if (view != 0) { list.push_back(view); } } } // sort the list by activation order (most recently activated first) std::sort(list.begin(), list.end(), ActivationOrderPred(activationList)); return list; } std::vector result; result.push_back(this->GetReference(part).Cast ()); return result; } std::vector WorkbenchPage::GetViewStack( IViewPart::Pointer part) { std::vector refStack = this->GetViewReferenceStack( part); std::vector result; for (unsigned int i = 0; i < refStack.size(); i++) { IViewPart::Pointer next = refStack[i]->GetView(false); if (next != 0) { result.push_back(next); } } return result; } void WorkbenchPage::ResizeView(IViewPart::Pointer part, int width, int height) { SashInfo sashInfo; PartPane::Pointer pane = part->GetSite().Cast ()->GetPane(); ILayoutContainer::Pointer container = pane->GetContainer(); LayoutTree::Pointer tree = this->GetPerspectivePresentation()->GetLayout()->GetLayoutTree()->Find( container.Cast ()); // retrieve our layout sashes from the layout tree this->FindSashParts(tree, pane->FindSashes(), sashInfo); // first set the width int deltaWidth = width - pane->GetBounds().width; if (sashInfo.right != 0) { Rectangle rightBounds = sashInfo.rightNode->GetBounds(); // set the new ratio sashInfo.right->SetRatio(static_cast((deltaWidth + sashInfo.right->GetBounds().x) - rightBounds.x) / rightBounds.width); // complete the resize sashInfo.rightNode->SetBounds(rightBounds); } else if (sashInfo.left != 0) { Rectangle leftBounds = sashInfo.leftNode->GetBounds(); // set the ratio sashInfo.left->SetRatio(static_cast((sashInfo.left->GetBounds().x - deltaWidth) - leftBounds.x) / leftBounds.width); // complete the resize sashInfo.leftNode->SetBounds(sashInfo.leftNode->GetBounds()); } // next set the height int deltaHeight = height - pane->GetBounds().height; if (sashInfo.bottom != 0) { Rectangle bottomBounds = sashInfo.bottomNode->GetBounds(); // set the new ratio sashInfo.bottom->SetRatio(static_cast((deltaHeight + sashInfo.bottom->GetBounds().y) - bottomBounds.y) / bottomBounds.height); // complete the resize sashInfo.bottomNode->SetBounds(bottomBounds); } else if (sashInfo.top != 0) { Rectangle topBounds = sashInfo.topNode->GetBounds(); // set the ratio sashInfo.top->SetRatio(static_cast((sashInfo.top->GetBounds().y - deltaHeight) - topBounds.y) / topBounds.height); // complete the resize sashInfo.topNode->SetBounds(topBounds); } - } void WorkbenchPage::FindSashParts(LayoutTree::Pointer tree, const PartPane::Sashes& sashes, SashInfo& info) { LayoutTree::Pointer parent(tree->GetParent()); if (parent == 0) { return; } if (parent->part.Cast () != 0) { // get the layout part sash from this tree node LayoutPartSash::Pointer sash = parent->part.Cast (); // make sure it has a sash control void* control = sash->GetControl(); if (control != 0) { // check for a vertical sash if (sash->IsVertical()) { if (sashes.left == control) { info.left = sash; info.leftNode = parent->FindSash(sash); } else if (sashes.right == control) { info.right = sash; info.rightNode = parent->FindSash(sash); } } // check for a horizontal sash else { if (sashes.top == control) { info.top = sash; info.topNode = parent->FindSash(sash); } else if (sashes.bottom == control) { info.bottom = sash; info.bottomNode = parent->FindSash(sash); } } } } // recursive call to continue up the tree this->FindSashParts(parent, sashes, info); } std::vector WorkbenchPage::GetAllParts() { std::vector views = viewFactory->GetViews(); std::list editors = this->GetEditorReferences(); std::vector result; for (unsigned int i = 0; i < views.size(); i++) { result.push_back(views[i]); } for (std::list::iterator iter = editors.begin(); iter != editors.end(); ++iter) { result.push_back(*iter); } return result; } std::vector WorkbenchPage::GetOpenParts() { std::vector refs = this->GetAllParts(); std::vector result; for (unsigned int i = 0; i < refs.size(); i++) { IWorkbenchPartReference::Pointer reference = refs[i]; IWorkbenchPart::Pointer part = reference->GetPart(false); if (part != 0) { result.push_back(reference); } } return result; } void WorkbenchPage::TestInvariants() { Perspective::Pointer persp = this->GetActivePerspective(); if (persp != 0) { - persp->TestInvariants(); // When we have widgets, ensure that there is no situation where the editor area is visible // and the perspective doesn't want an editor area. if (this->GetClientComposite() && editorPresentation->GetLayoutPart()->IsVisible()) { poco_assert(persp->IsEditorAreaVisible()); } } - } /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPage#getExtensionTracker() */ // IExtensionTracker WorkbenchPage::GetExtensionTracker() // { // if (tracker == 0) // { // tracker = new UIExtensionTracker(getWorkbenchWindow().getWorkbench().getDisplay()); // } // return tracker; // } /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage#getPerspectiveShortcuts() */ std::vector WorkbenchPage::GetPerspectiveShortcuts() { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return std::vector(); } return persp->GetPerspectiveShortcuts(); } std::vector WorkbenchPage::GetShowViewShortcuts() { Perspective::Pointer persp = this->GetActivePerspective(); if (persp == 0) { return std::vector(); } return persp->GetShowViewShortcuts(); } void WorkbenchPage::SuggestReset() { IWorkbench* workbench = this->GetWorkbenchWindow()->GetWorkbench(); // workbench.getDisplay().asyncExec(new Runnable() // { // public void WorkbenchPage::run() // { Shell::Pointer parentShell; IWorkbenchWindow::Pointer window = workbench->GetActiveWorkbenchWindow(); if (window == 0) { if (workbench->GetWorkbenchWindowCount() == 0) { return; } window = workbench->GetWorkbenchWindows()[0]; } parentShell = window->GetShell(); if (MessageDialog::OpenQuestion(parentShell, "Reset Perspective?", "Changes to installed plug-ins have affected this perspective. Would you like to reset this perspective to accept these changes?")) { IWorkbenchPage::Pointer page = window->GetActivePage(); if (page == 0) { return; } page->ResetPerspective(); } // } // }); - } bool WorkbenchPage::IsPartVisible( IWorkbenchPartReference::Pointer reference) { IWorkbenchPart::Pointer part = reference->GetPart(false); // Can't be visible if it isn't created yet if (part == 0) { return false; } return this->IsPartVisible(part); } - -} +} \ No newline at end of file diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h index a81c8d1659..2995dcc713 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchPage.h @@ -1,1786 +1,1801 @@ /*=================================================================== BlueBerry Platform 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 BERRYWORKBENCHPAGE_H_ #define BERRYWORKBENCHPAGE_H_ #include #include #include "berryIWorkbenchPage.h" #include "berryIWorkbenchPartReference.h" #include "berryIReusableEditor.h" #include "berryILayoutContainer.h" #include "berryIStickyViewManager.h" #include "berryWorkbenchPagePartList.h" #include "berryWorkbenchPartReference.h" #include "berryPageSelectionService.h" #include "berryEditorManager.h" #include "berryViewFactory.h" #include "berryPartPane.h" #include namespace berry { - //class PartPane; //class PartPane::Sashes; class EditorAreaHelper; class WorkbenchWindow; class Perspective; class PerspectiveHelper; class PerspectiveDescriptor; class LayoutPartSash; class LayoutTree; class LayoutTreeNode; class PartService; /** * \ingroup org_blueberry_ui_internal * * A collection of views and editors in a workbench. */ class BERRY_UI WorkbenchPage: public IWorkbenchPage { - public: berryObjectMacro(WorkbenchPage); protected: //TODO Weakpointer WorkbenchWindow* window; friend class ViewFactory; friend class WorkbenchWindow; friend class EditorAreaHelper; friend class WWinPartService; private: /** * Manages editor contributions and action set part associations. */ class ActionSwitcher { private: IWorkbenchPart::WeakPtr activePart; IEditorPart::WeakPtr topEditor; /** * Updates the contributions given the new part as the active part. * * @param newPart * the new active part, may be null */ public: void UpdateActivePart(IWorkbenchPart::Pointer newPart); - /** * Updates the contributions given the new part as the topEditor. * * @param newEditor * the new top editor, may be null */ public: void UpdateTopEditor(IEditorPart::Pointer newEditor); /** * Activates the contributions of the given part. If enable * is true the contributions are visible and enabled, * otherwise they are disabled. * * @param part * the part whose contributions are to be activated * @param enable * true the contributions are to be enabled, * not just visible. */ private: void ActivateContributions(IWorkbenchPart::Pointer part, bool enable); /** * Deactivates the contributions of the given part. If remove * is true the contributions are removed, otherwise they * are disabled. * * @param part * the part whose contributions are to be deactivated * @param remove * true the contributions are to be removed, * not just disabled. */ private: void DeactivateContributions(IWorkbenchPart::Pointer part, bool remove); - }; class ActivationList { - public: //List of parts in the activation order (oldest first) typedef std::deque PartListType; typedef std::deque::iterator PartListIter; typedef std::deque::reverse_iterator PartListReverseIter; private: PartListType parts; WorkbenchPage* page; public: - ActivationList(WorkbenchPage* page); /* * Add/Move the active part to end of the list; */ void SetActive(SmartPointer part); /* * Ensures that the given part appears AFTER any other part in the same * container. */ void BringToTop(SmartPointer ref); /* * Returns the last (most recent) iterator (index) of the given container in the activation list, or returns * end() if the given container does not appear in the activation list. */ PartListIter LastIndexOfContainer(SmartPointer container); /* * Add/Move the active part to end of the list; */ void SetActive(SmartPointer ref); /* * Add the active part to the beginning of the list. */ void Add(SmartPointer ref); /* * Return the active part. Filter fast views. */ SmartPointer GetActive(); /* * Return the previously active part. Filter fast views. */ SmartPointer GetPreviouslyActive(); SmartPointer GetActiveReference(bool editorsOnly); /* * Retuns the index of the part within the activation list. The higher * the index, the more recently it was used. */ PartListIter IndexOf(SmartPointer part); /* * Returns the index of the part reference within the activation list. * The higher the index, the more recent it was used. */ PartListIter IndexOf(SmartPointer ref); /* * Remove a part from the list */ bool Remove(SmartPointer ref); /* * Returns the topmost editor on the stack, or null if none. */ SmartPointer GetTopEditor(); /* * Returns the editors in activation order (oldest first). */ std::vector > GetEditors(); /* * Return a list with all parts (editors and views). */ std::vector > GetParts(); private: SmartPointer GetActive(PartListIter start); SmartPointer GetActiveReference(PartListIter start, bool editorsOnly); /* * Find a part in the list starting from the end and filter * and views from other perspectives. Will filter fast views * unless 'includeActiveFastViews' is true; */ SmartPointer GetActiveReference(PartListIter start, bool editorsOnly, bool skipPartsObscuredByZoom); - }; /** * Helper class to keep track of all opened perspective. Both the opened * and used order is kept. */ struct PerspectiveList { - public: typedef std::list > PerspectiveListType; typedef PerspectiveListType::iterator iterator; private: /** * List of perspectives in the order they were opened; */ PerspectiveListType openedList; /** * List of perspectives in the order they were used. Last element is * the most recently used, and first element is the least recently * used. */ PerspectiveListType usedList; /** * The perspective explicitly set as being the active one */ SmartPointer active; void UpdateActionSets(SmartPointer oldPersp, SmartPointer newPersp); public: /** * Creates an empty instance of the perspective list */ PerspectiveList(); /** * Update the order of the perspectives in the opened list * * @param perspective * @param newLoc */ void Reorder(IPerspectiveDescriptor::Pointer perspective, int newLoc); /** * Return all perspectives in the order they were activated. * * @return an array of perspectives sorted by activation order, least * recently activated perspective last. */ PerspectiveListType GetSortedPerspectives(); /** * Adds a perspective to the list. No check is done for a duplicate when * adding. * @param perspective the perspective to add * @return boolean true if the perspective was added */ bool Add(SmartPointer perspective); /** * Returns an iterator on the perspective list in the order they were * opened. */ PerspectiveListType::iterator Begin(); PerspectiveListType::iterator End(); /** * Returns an array with all opened perspectives */ PerspectiveListType GetOpenedPerspectives(); /** * Removes a perspective from the list. */ bool Remove(SmartPointer perspective); /** * Swap the opened order of old perspective with the new perspective. */ void Swap(SmartPointer oldPerspective, SmartPointer newPerspective); /** * Returns whether the list contains any perspectives */ bool IsEmpty(); /** * Returns the most recently used perspective in the list. */ SmartPointer GetActive(); /** * Returns the next most recently used perspective in the list. */ SmartPointer GetNextActive(); /** * Returns the number of perspectives opened */ PerspectiveListType::size_type Size(); /** * Marks the specified perspective as the most recently used one in the * list. */ void SetActive(SmartPointer perspective); - }; IAdaptable* input; void* composite; //Could be delete. This information is in the active part list; ActivationList* activationList; EditorManager* editorMgr; EditorAreaHelper* editorPresentation; //ListenerList propertyChangeListeners = new ListenerList(); PageSelectionService* selectionService; WorkbenchPagePartList::Pointer partList; // = new WorkbenchPagePartList(selectionService); //IActionBars actionBars; ViewFactory* viewFactory; PerspectiveList perspList; SmartPointer deferredActivePersp; //NavigationHistory navigationHistory = new NavigationHistory(this); IStickyViewManager::Pointer stickyViewMan; + + + /** + * Returns true if perspective with given id contains view with given id + */ + bool HasView(const std::string& perspectiveId, const std::string& viewId); + /** * If we're in the process of activating a part, this points to the new part. * Otherwise, this is null. */ IWorkbenchPartReference::Pointer partBeingActivated; /** * Contains a list of perspectives that may be dirty due to plugin * installation and removal. */ std::set dirtyPerspectives; ActionSwitcher actionSwitcher; //IExtensionTracker tracker; // Deferral count... delays disposing parts and sending certain events if nonzero int deferCount; // Parts waiting to be disposed std::vector pendingDisposals; const IExtensionPoint* GetPerspectiveExtensionPoint(); public: /** * Constructs a new page with a given perspective and input. * * @param w * the parent window * @param layoutID * must not be null * @param input * the page input * @throws WorkbenchException * on null layout id */ WorkbenchPage(WorkbenchWindow* w, const std::string& layoutID, IAdaptable* input); /** * Constructs a page. restoreState(IMemento) should be * called to restore this page from data stored in a persistance file. * * @param w * the parent window * @param input * the page input * @throws WorkbenchException */ WorkbenchPage(WorkbenchWindow* w, IAdaptable* input); ~WorkbenchPage(); /** * Activates a part. The part will be brought to the front and given focus. * * @param part * the part to activate */ void Activate(IWorkbenchPart::Pointer part); /** * Activates a part. The part is given focus, the pane is hilighted. */ private: void ActivatePart(const IWorkbenchPart::Pointer part); /** * Adds an IPartListener to the part service. */ public: void AddPartListener(IPartListener::Pointer l); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void AddSelectionListener(ISelectionListener::Pointer listener); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void AddSelectionListener(const std::string& partId, ISelectionListener::Pointer listener); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void AddPostSelectionListener(ISelectionListener::Pointer listener); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void AddPostSelectionListener(const std::string& partId, ISelectionListener::Pointer listener); private: ILayoutContainer::Pointer GetContainer(IWorkbenchPart::Pointer part); private: ILayoutContainer::Pointer GetContainer(IWorkbenchPartReference::Pointer part); private: SmartPointer GetPane(IWorkbenchPart::Pointer part); private: SmartPointer GetPane(IWorkbenchPartReference::Pointer part); /** * Brings a part to the front of its stack. Does not update the active part or * active editor. This should only be called if the caller knows that the part * is not in the same stack as the active part or active editor, or if the caller * is prepared to update activation after the call. * * @param part */ private: bool InternalBringToTop(IWorkbenchPartReference::Pointer part); /** * Moves a part forward in the Z order of a perspective so it is visible. * If the part is in the same stack as the active part, the new part is * activated. * * @param part * the part to bring to move forward */ public: void BringToTop(IWorkbenchPart::Pointer part); /** * Resets the layout for the perspective. The active part in the old layout * is activated in the new layout for consistent user context. * * Assumes the busy cursor is active. */ private: void BusyResetPerspective(); /** * Implements setPerspective. * * Assumes that busy cursor is active. * * @param desc * identifies the new perspective. */ private: void BusySetPerspective(IPerspectiveDescriptor::Pointer desc); + /** + * Removes the perspective which match the given description. + * + * @param desc + * identifies the perspective to be removed. + */ + public: + void RemovePerspective(IPerspectiveDescriptor::Pointer desc); /** * Shows a view. * * Assumes that a busy cursor is active. */ protected: IViewPart::Pointer BusyShowView(const std::string& viewID, const std::string& secondaryID, int mode); /* * Performs showing of the view in the given mode. */ private: void BusyShowView(IViewPart::Pointer part, int mode); /** * Returns whether a part exists in the current page. */ private: bool CertifyPart(IWorkbenchPart::Pointer part); /** * Closes the perspective. */ public: bool Close(); /** * See IWorkbenchPage */ public: bool CloseAllSavedEditors(); /** * See IWorkbenchPage */ public: bool CloseAllEditors(bool save); private: void UpdateActivePart(); /** * Makes the given part active. Brings it in front if necessary. Permits null * (indicating that no part should be active). * * @since 3.1 * * @param ref new active part (or null) */ private: void MakeActive(IWorkbenchPartReference::Pointer ref); /** * Makes the given editor active. Brings it to front if necessary. Permits null * (indicating that no editor is active). * * @since 3.1 * * @param ref the editor to make active, or null for no active editor */ private: void MakeActiveEditor(IEditorReference::Pointer ref); /** * See IWorkbenchPage */ public: bool CloseEditors(const std::list& refArray, bool save); /** * Enables or disables listener notifications. This is used to delay listener notifications until the * end of a public method. * * @param shouldDefer */ private: void DeferUpdates(bool shouldDefer); private: void StartDeferring(); private: void HandleDeferredEvents(); private: bool IsDeferred(); /** * See IWorkbenchPage#closeEditor */ public: bool CloseEditor(IEditorReference::Pointer editorRef, bool save); /** * See IWorkbenchPage#closeEditor */ public: bool CloseEditor(IEditorPart::Pointer editor, bool save); /** * @see IWorkbenchPage#closePerspective(IPerspectiveDescriptor, boolean, boolean) */ public: + + void CloseCurrentPerspective(bool saveParts, bool closePage); + /** + * Closes current perspective. If last perspective, then entire page + * is closed. + * + * @param saveParts + * whether the page's parts should be saved if closed + * @param closePage + * whether the page itself should be closed if last perspective + */ + void ClosePerspective(IPerspectiveDescriptor::Pointer desc, bool saveParts, bool closePage); /** * Closes the specified perspective. If last perspective, then entire page * is closed. * * @param persp * the perspective to be closed * @param saveParts * whether the parts that are being closed should be saved * (editors if last perspective, views if not shown in other * parspectives) */ /* package */ protected: void ClosePerspective(SmartPointer persp, bool saveParts, bool closePage); /** * @see IWorkbenchPage#closeAllPerspectives(boolean, boolean) */ public: void CloseAllPerspectives(bool saveEditors, bool closePage); /** * Creates the client composite. */ private: void CreateClientComposite(); /** * Creates a new view set. Return null on failure. * * @param desc the perspective descriptor * @param notify whether to fire a perspective opened event */ private: SmartPointer CreatePerspective(SmartPointer desc, bool notify); /** * This is called by child objects after a part has been added to the page. * The page will in turn notify its listeners. */ /* package */ protected: void PartAdded(WorkbenchPartReference::Pointer ref); /** * This is called by child objects after a part has been added to the page. * The part will be queued for disposal after all listeners have been notified */ /* package */ protected: void PartRemoved(WorkbenchPartReference::Pointer ref); private: void DisposePart(WorkbenchPartReference::Pointer ref); /** * Deactivates a part. The pane is unhilighted. */ private: void DeactivatePart(IWorkbenchPart::Pointer part); /** * Detaches a view from the WorkbenchWindow. */ public: void DetachView(IViewReference::Pointer ref); /** * Removes a detachedwindow. */ public: void AttachView(IViewReference::Pointer ref); /** * Dispose a perspective. * * @param persp the perspective descriptor * @param notify whether to fire a perspective closed event */ private: void DisposePerspective(SmartPointer persp, bool notify); /** * Returns the first view manager with given ID. */ public: SmartPointer FindPerspective(IPerspectiveDescriptor::Pointer desc); /** * See IWorkbenchPage@findView. */ public: IViewPart::Pointer FindView(const std::string& id); /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage */ public: IViewReference::Pointer FindViewReference(const std::string& viewId); /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage */ public: IViewReference::Pointer FindViewReference(const std::string& viewId, const std::string& secondaryId); /** * Notify property change listeners about a property change. * * @param changeId * the change id * @param oldValue * old property value * @param newValue * new property value */ //private: void FirePropertyChange(String changeId, Object oldValue, // Object newValue) { // // UIListenerLogging.logPagePropertyChanged(this, changeId, oldValue, newValue); // // Object[] listeners = propertyChangeListeners.getListeners(); // PropertyChangeEvent event = new PropertyChangeEvent(this, changeId, // oldValue, newValue); // // for (int i = 0; i < listeners.length; i++) { // ((IPropertyChangeListener) listeners[i]).propertyChange(event); // } // } /** * @see IWorkbenchPage */ public: IEditorPart::Pointer GetActiveEditor(); /** * Returns the reference for the active editor, or null * if there is no active editor. * * @return the active editor reference or null */ public: IEditorReference::Pointer GetActiveEditorReference(); /* * (non-Javadoc) Method declared on IPartService */ public: IWorkbenchPart::Pointer GetActivePart(); /* * (non-Javadoc) Method declared on IPartService */ public: IWorkbenchPartReference::Pointer GetActivePartReference(); /** * Returns the active perspective for the page, null if * none. */ public: SmartPointer GetActivePerspective(); /** * Returns the client composite. */ public: void* GetClientComposite(); // for dynamic UI - change access from private to protected // for testing purposes only, changed from protected to public /** * Answer the editor manager for this window. */ public: EditorManager* GetEditorManager(); /** * Answer the perspective presentation. */ public: PerspectiveHelper* GetPerspectivePresentation(); /** * Answer the editor presentation. */ public: EditorAreaHelper* GetEditorPresentation(); /** * Allow access to the part service for this page ... used internally to * propogate certain types of events to the page part listeners. * @return the part service for this page. */ public: PartService* GetPartService(); /** * See IWorkbenchPage. */ public: std::vector GetEditors(); public: std::vector GetDirtyEditors(); public: std::vector GetDirtyParts(); /** * See IWorkbenchPage. */ public: IEditorPart::Pointer FindEditor(IEditorInput::Pointer input); /** * See IWorkbenchPage. */ public: std::vector FindEditors( IEditorInput::Pointer input, const std::string& editorId, int matchFlags); /** * See IWorkbenchPage. */ public: std::list GetEditorReferences(); /** * @see IWorkbenchPage */ public: IAdaptable* GetInput(); /** * Returns the page label. This is a combination of the page input and * active perspective. */ public: std::string GetLabel(); /** * Returns the perspective. */ public: IPerspectiveDescriptor::Pointer GetPerspective(); /* * (non-Javadoc) Method declared on ISelectionService */ public: ISelection::ConstPointer GetSelection() const; /* * (non-Javadoc) Method declared on ISelectionService */ public: ISelection::ConstPointer GetSelection(const std::string& partId); //public: // SelectionEvents& GetSelectionEvents(const std::string& partId = ""); /* * Returns the view factory. */ public: ViewFactory* GetViewFactory(); /** * See IWorkbenchPage. */ public: std::vector GetViewReferences(); /** * See IWorkbenchPage. */ public: std::vector GetViews(); /** * Returns all view parts in the specified perspective * * @param persp the perspective * @return an array of view parts * @since 3.1 */ /*package*/ protected: std::vector GetViews(SmartPointer persp, bool restore); /** * See IWorkbenchPage. */ public: IWorkbenchWindow::Pointer GetWorkbenchWindow(); /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage#hideView(org.blueberry.ui.IViewReference) */ public: void HideView(IViewReference::Pointer ref); /* package */ protected: void RefreshActiveView(); /** * See IPerspective */ public: void HideView(IViewPart::Pointer view); /** * Initialize the page. * * @param w * the parent window * @param layoutID * may be null if restoring from file * @param input * the page input * @param openExtras * whether to process the perspective extras preference */ private: void Init(WorkbenchWindow* w, const std::string& layoutID, IAdaptable* input, bool openExtras); /** * Opens the perspectives specified in the PERSPECTIVE_BAR_EXTRAS preference (see bug 84226). */ public: void OpenPerspectiveExtras(); /** * See IWorkbenchPage. */ public: bool IsPartVisible(IWorkbenchPart::Pointer part); /** * See IWorkbenchPage. */ public: bool IsEditorAreaVisible(); /** * Returns whether the view is fast. */ public: bool IsFastView(IViewReference::Pointer ref); /** * Return whether the view is closeable or not. * * @param ref the view reference to check. Must not be null. * @return true if the part is closeable. * @since 3.1.1 */ public: bool IsCloseable(IViewReference::Pointer ref); /** * Return whether the view is moveable or not. * * @param ref the view reference to check. Must not be null. * @return true if the part is moveable. * @since 3.1.1 */ public: bool IsMoveable(IViewReference::Pointer ref); /** * Returns whether the layout of the active * perspective is fixed. */ public: bool IsFixedLayout(); /** * Return true if the perspective has a dirty editor. */ protected: bool IsSaveNeeded(); /** * This method is called when the page is activated. */ protected: void OnActivate(); /** * This method is called when the page is deactivated. */ protected: void OnDeactivate(); /** * See IWorkbenchPage. */ public: void ReuseEditor(IReusableEditor::Pointer editor, IEditorInput::Pointer input); /** * See IWorkbenchPage. */ public: IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const std::string& editorID); /** * See IWorkbenchPage. */ public: IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const std::string& editorID, bool activate); /** * See IWorkbenchPage. */ public: IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags); /** * This is not public API but for use internally. editorState can be null. */ public: IEditorPart::Pointer OpenEditor(IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags, IMemento::Pointer editorState); /* * Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program. * Opens a new editor using the given input and descriptor. (Normally, editors are opened using * an editor ID and an input.) */ public: IEditorPart::Pointer OpenEditorFromDescriptor(IEditorInput::Pointer input, IEditorDescriptor::Pointer editorDescriptor, bool activate, IMemento::Pointer editorState); /** * @see #openEditor(IEditorInput, String, boolean, int) */ private: IEditorPart::Pointer BusyOpenEditor(IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags, IMemento::Pointer editorState); /* * Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program. * See openEditorFromDescriptor(). */ private: IEditorPart::Pointer BusyOpenEditorFromDescriptor( IEditorInput::Pointer input, EditorDescriptor::Pointer editorDescriptor, bool activate, IMemento::Pointer editorState); /** * Do not call this method. Use busyOpenEditor. * * @see IWorkbenchPage#openEditor(IEditorInput, String, boolean) */ protected: IEditorPart::Pointer BusyOpenEditorBatched(IEditorInput::Pointer input, const std::string& editorID, bool activate, int matchFlags, IMemento::Pointer editorState); /* * Added to fix Bug 178235 [EditorMgmt] DBCS 3.3 - Cannot open file with external program. * See openEditorFromDescriptor(). */ private: IEditorPart::Pointer BusyOpenEditorFromDescriptorBatched( IEditorInput::Pointer input, EditorDescriptor::Pointer editorDescriptor, bool activate, IMemento::Pointer editorState); public: void OpenEmptyTab(); protected: void ShowEditor(bool activate, IEditorPart::Pointer editor); /** * See IWorkbenchPage. */ public: bool IsEditorPinned(IEditorPart::Pointer editor); /** * Removes an IPartListener from the part service. */ public: void RemovePartListener(IPartListener::Pointer l); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void RemoveSelectionListener(ISelectionListener::Pointer listener); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void RemoveSelectionListener(const std::string& partId, ISelectionListener::Pointer listener); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void RemovePostSelectionListener(ISelectionListener::Pointer listener); /* * (non-Javadoc) Method declared on ISelectionListener. */ public: void RemovePostSelectionListener(const std::string& partId, ISelectionListener::Pointer listener); /** * This method is called when a part is activated by clicking within it. In * response, the part, the pane, and all of its actions will be activated. * * In the current design this method is invoked by the part pane when the * pane, the part, or any children gain focus. */ public: void RequestActivation(IWorkbenchPart::Pointer part); /** * Resets the layout for the perspective. The active part in the old layout * is activated in the new layout for consistent user context. */ public: void ResetPerspective(); /** * Restore this page from the memento and ensure that the active * perspective is equals the active descriptor otherwise create a new * perspective for that descriptor. If activeDescriptor is null active the * old perspective. */ public: /*IStatus*/bool RestoreState(IMemento::Pointer memento, IPerspectiveDescriptor::Pointer activeDescriptor); /** * See IWorkbenchPage */ public: bool SaveAllEditors(bool confirm); /** * @param confirm * @param addNonPartSources true if saveables from non-part sources should be saved too * @return false if the user cancelled * */ public: bool SaveAllEditors(bool confirm, bool addNonPartSources); /* * Saves the workbench part. */ protected: bool SavePart(ISaveablePart::Pointer saveable, IWorkbenchPart::Pointer part, bool confirm); /** * Saves an editors in the workbench. If confirm is true * the user is prompted to confirm the command. * * @param confirm * if user confirmation should be sought * @return true if the command succeeded, or false * if the user cancels the command */ public: bool SaveEditor(IEditorPart::Pointer editor, bool confirm); /** * Saves the current perspective. */ public: void SavePerspective(); /** * Saves the perspective. */ public: void SavePerspectiveAs(IPerspectiveDescriptor::Pointer newDesc); /** * Save the state of the page. */ public: /*IStatus*/bool SaveState(IMemento::Pointer memento); private: std::string GetId(IWorkbenchPart::Pointer part); private: std::string GetId(IWorkbenchPartReference::Pointer ref); /** * Sets the active part. */ private: void SetActivePart(IWorkbenchPart::Pointer newPart); /** * See IWorkbenchPage. */ public: void SetEditorAreaVisible(bool showEditorArea); /** * Sets the layout of the page. Assumes the new perspective is not null. * Keeps the active part if possible. Updates the window menubar and * toolbar if necessary. */ private: void SetPerspective(SmartPointer newPersp); /* * Update visibility state of all views. */ private: void UpdateVisibility(SmartPointer oldPersp, SmartPointer newPersp); /** * Sets the perspective. * * @param desc * identifies the new perspective. */ public: void SetPerspective(IPerspectiveDescriptor::Pointer desc); /** * Restore the toolbar layout for the active perspective. */ protected: void ResetToolBarLayout(); /** * See IWorkbenchPage. */ public: IViewPart::Pointer ShowView(const std::string& viewID); /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage#showView(java.lang.String, * java.lang.String, int) */ public: IViewPart::Pointer ShowView(const std::string& viewID, const std::string& secondaryID, int mode); /** * @param mode the mode to test * @return whether the mode is recognized * @since 3.0 */ private: bool CertifyMode(int mode); /* * Returns the editors in activation order (oldest first). */ public: std::vector GetSortedEditors(); /** * @see IWorkbenchPage#getOpenPerspectives() */ public: std::vector GetOpenPerspectives(); /** * Return all open Perspective objects. * * @return all open Perspective objects * @since 3.1 */ /*package*/ protected: std::list > GetOpenInternalPerspectives(); /** * Checks perspectives in the order they were activiated * for the specfied part. The first sorted perspective * that contains the specified part is returned. * * @param part specified part to search for * @return the first sorted perspespective containing the part * @since 3.1 */ /*package*/ protected: SmartPointer GetFirstPerspectiveWithView(IViewPart::Pointer part); /** * Returns the perspectives in activation order (oldest first). */ public: std::vector GetSortedPerspectives(); /* * Returns the parts in activation order (oldest first). */ public: std::vector GetSortedParts(); /** * Returns the reference to the given part, or null if it has no reference * (i.e. it is not a top-level part in this workbench page). * * @param part the part * @return the part's reference or null if the given part does not belong * to this workbench page */ public: IWorkbenchPartReference::Pointer GetReference(IWorkbenchPart::Pointer part); // private: class ActivationList { // //List of parts in the activation order (oldest first) // List parts = new ArrayList(); // // /* // * Add/Move the active part to end of the list; // */ // void setActive(IWorkbenchPart part) { // if (parts.size() <= 0) { // return; // } // IWorkbenchPartReference ref = getReference(part); // if (ref != null) { // if (ref == parts.get(parts.size() - 1)) { // return; // } // parts.remove(ref); // parts.add(ref); // } // } // // /* // * Ensures that the given part appears AFTER any other part in the same // * container. // */ // void bringToTop(IWorkbenchPartReference ref) { // ILayoutContainer targetContainer = getContainer(ref); // // int newIndex = lastIndexOfContainer(targetContainer); // // //New index can be -1 if there is no last index // if (newIndex >= 0 && ref == parts.get(newIndex)) // return; // // parts.remove(ref); // if(newIndex >= 0) // parts.add(newIndex, ref); // else // parts.add(ref); // } // // /* // * Returns the last (most recent) index of the given container in the activation list, or returns // * -1 if the given container does not appear in the activation list. // */ // int lastIndexOfContainer(ILayoutContainer container) { // for (int i = parts.size() - 1; i >= 0; i--) { // IWorkbenchPartReference ref = (IWorkbenchPartReference)parts.get(i); // // ILayoutContainer cnt = getContainer(ref); // if (cnt == container) { // return i; // } // } // // return -1; // } // // /* // * Add/Move the active part to end of the list; // */ // void setActive(IWorkbenchPartReference ref) { // setActive(ref.getPart(true)); // } // // /* // * Add the active part to the beginning of the list. // */ // void add(IWorkbenchPartReference ref) { // if (parts.indexOf(ref) >= 0) { // return; // } // // IWorkbenchPart part = ref.getPart(false); // if (part != null) { // PartPane pane = ((PartSite) part.getSite()).getPane(); // if (pane instanceof MultiEditorInnerPane) { // MultiEditorInnerPane innerPane = (MultiEditorInnerPane) pane; // add(innerPane.getParentPane().getPartReference()); // return; // } // } // parts.add(0, ref); // } // // /* // * Return the active part. Filter fast views. // */ // IWorkbenchPart getActive() { // if (parts.isEmpty()) { // return null; // } // return getActive(parts.size() - 1); // } // // /* // * Return the previously active part. Filter fast views. // */ // IWorkbenchPart getPreviouslyActive() { // if (parts.size() < 2) { // return null; // } // return getActive(parts.size() - 2); // } // // private: IWorkbenchPart getActive(int start) { // IWorkbenchPartReference ref = getActiveReference(start, false); // // if (ref == null) { // return null; // } // // return ref.getPart(true); // } // // public: IWorkbenchPartReference getActiveReference(boolean editorsOnly) { // return getActiveReference(parts.size() - 1, editorsOnly); // } // // private: IWorkbenchPartReference getActiveReference(int start, boolean editorsOnly) { // // First look for parts that aren't obscured by the current zoom state // IWorkbenchPartReference nonObscured = getActiveReference(start, editorsOnly, true); // // if (nonObscured != null) { // return nonObscured; // } // // // Now try all the rest of the parts // return getActiveReference(start, editorsOnly, false); // } // // /* // * Find a part in the list starting from the end and filter // * and views from other perspectives. Will filter fast views // * unless 'includeActiveFastViews' is true; // */ // private: IWorkbenchPartReference getActiveReference(int start, boolean editorsOnly, boolean skipPartsObscuredByZoom) { // IWorkbenchPartReference[] views = getViewReferences(); // for (int i = start; i >= 0; i--) { // WorkbenchPartReference ref = (WorkbenchPartReference) parts // .get(i); // // if (editorsOnly && !(ref instanceof IEditorReference)) { // continue; // } // // // Skip parts whose containers have disabled auto-focus // PartPane pane = ref.getPane(); // // if (pane != null) { // if (!pane.allowsAutoFocus()) { // continue; // } // // if (skipPartsObscuredByZoom) { // if (pane.isObscuredByZoom()) { // continue; // } // } // } // // // Skip fastviews (unless overridden) // if (ref instanceof IViewReference) { // if (ref == getActiveFastView() || !((IViewReference) ref).isFastView()) { // for (int j = 0; j < views.length; j++) { // if (views[j] == ref) { // return ref; // } // } // } // } else { // return ref; // } // } // return null; // } // // /* // * Retuns the index of the part within the activation list. The higher // * the index, the more recently it was used. // */ // int indexOf(IWorkbenchPart part) { // IWorkbenchPartReference ref = getReference(part); // if (ref == null) { // return -1; // } // return parts.indexOf(ref); // } // // /* // * Returns the index of the part reference within the activation list. // * The higher the index, the more recent it was used. // */ // int indexOf(IWorkbenchPartReference ref) { // return parts.indexOf(ref); // } // // /* // * Remove a part from the list // */ // boolean remove(IWorkbenchPartReference ref) { // return parts.remove(ref); // } // // /* // * Returns the editors in activation order (oldest first). // */ // private: IEditorReference[] getEditors() { // ArrayList editors = new ArrayList(parts.size()); // for (Iterator i = parts.iterator(); i.hasNext();) { // IWorkbenchPartReference part = (IWorkbenchPartReference) i // .next(); // if (part instanceof IEditorReference) { // editors.add(part); // } // } // return (IEditorReference[]) editors // .toArray(new IEditorReference[editors.size()]); // } // // /* // * Return a list with all parts (editors and views). // */ // private: IWorkbenchPartReference[] getParts() { // IWorkbenchPartReference[] views = getViewReferences(); // ArrayList resultList = new ArrayList(parts.size()); // for (Iterator iterator = parts.iterator(); iterator.hasNext();) { // IWorkbenchPartReference ref = (IWorkbenchPartReference) iterator // .next(); // if (ref instanceof IViewReference) { // //Filter views from other perspectives // for (int i = 0; i < views.length; i++) { // if (views[i] == ref) { // resultList.add(ref); // break; // } // } // } else { // resultList.add(ref); // } // } // IWorkbenchPartReference[] result = new IWorkbenchPartReference[resultList // .size()]; // return (IWorkbenchPartReference[]) resultList.toArray(result); // } // // /* // * Returns the topmost editor on the stack, or null if none. // */ // IEditorPart getTopEditor() { // IEditorReference editor = (IEditorReference)getActiveReference(parts.size() - 1, true); // // if (editor == null) { // return null; // } // // return editor.getEditor(true); // } // }; // for dynamic UI protected: void AddPerspective(SmartPointer persp); /** * Find the stack of view references stacked with this view part. * * @param part * the part * @return the stack of references * @since 3.0 */ private: std::vector GetViewReferenceStack( IViewPart::Pointer part); /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage#getViewStack(org.blueberry.ui.IViewPart) */ public: std::vector GetViewStack(IViewPart::Pointer part); /** * Allow for programmatically resizing a part. *

* EXPERIMENTAL *

*

* Known limitations: *

    *
  • currently applies only to views
  • *
  • has no effect when view is zoomed
  • *
*/ public: void ResizeView(IViewPart::Pointer part, int width, int height); private: struct ActivationOrderPred : std::binary_function { ActivationOrderPred(ActivationList* partList); ActivationList* activationList; bool operator()(const IViewReference::Pointer o1, const IViewReference::Pointer o2) const; }; // provides sash information for the given pane struct SashInfo { - SmartPointer right; SmartPointer left; SmartPointer top; SmartPointer bottom; SmartPointer rightNode; SmartPointer leftNode; SmartPointer topNode; SmartPointer bottomNode; }; void FindSashParts(SmartPointer tree, const PartPane::Sashes& sashes, SashInfo& info); /** * Returns all parts that are owned by this page * * @return */ protected: std::vector GetAllParts(); /** * Returns all open parts that are owned by this page (that is, all parts * for which a part opened event would have been sent -- these would be * activated parts whose controls have already been created. */ protected: std::vector GetOpenParts(); /** * Sanity-checks the objects in this page. Throws an Assertation exception * if an object's internal state is invalid. ONLY INTENDED FOR USE IN THE * UI TEST SUITES. */ public: void TestInvariants(); /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPage#getExtensionTracker() */ //public: IExtensionTracker GetExtensionTracker(); /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage#getPerspectiveShortcuts() */ public: std::vector GetPerspectiveShortcuts(); /* * (non-Javadoc) * * @see org.blueberry.ui.IWorkbenchPage#getShowViewShortcuts() */ public: std::vector GetShowViewShortcuts(); /** * @since 3.1 */ private: void SuggestReset(); public: bool IsPartVisible(IWorkbenchPartReference::Pointer reference); - }; - } #endif /*BERRYWORKBENCHPAGE_H_*/ diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp index 8b914c99a6..891f15e5fd 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.cpp @@ -1,1790 +1,1825 @@ /*=================================================================== BlueBerry Platform 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 "berryWorkbenchWindow.h" #include "berryIWorkbenchPage.h" #include "berryIPerspectiveDescriptor.h" #include "berryUIException.h" #include "berryConstants.h" #include "intro/berryIntroConstants.h" #include "berryWorkbenchPlugin.h" #include "berryWorkbenchPage.h" #include "berryWorkbench.h" #include "berryWorkbenchConstants.h" #include "berryPartSite.h" #include "berryIServiceLocatorCreator.h" #include "tweaklets/berryGuiWidgetsTweaklet.h" #include "tweaklets/berryWorkbenchTweaklet.h" #include "services/berryIServiceFactory.h" #include "berryPlatformUI.h" #include "berryDebugUtil.h" namespace berry { const int WorkbenchWindow::FILL_ALL_ACTION_BARS = ActionBarAdvisor::FILL_MENU_BAR | ActionBarAdvisor::FILL_COOL_BAR | ActionBarAdvisor::FILL_STATUS_LINE; WorkbenchWindow::WorkbenchWindow(int number) : Window(Shell::Pointer(0)), pageComposite(0), windowAdvisor(0), actionBarAdvisor(0), number(number), largeUpdates(0), closing(false), shellActivated(false), updateDisabled(true), emptyWindowContentsCreated( false), emptyWindowContents(0), asMaximizedState(false), partService( this), serviceLocatorOwner( new ServiceLocatorOwner(this)) { this->Register(); // increase the reference count to avoid deleting // this object when temporary smart pointers // go out of scope // Make sure there is a workbench. This call will throw // an exception if workbench not created yet. IWorkbench* workbench = PlatformUI::GetWorkbench(); IServiceLocatorCreator::Pointer slc = workbench->GetService(IServiceLocatorCreator::GetManifestName()).Cast< IServiceLocatorCreator> (); IServiceLocator::Pointer locator(workbench); this->serviceLocator = slc->CreateServiceLocator(IServiceLocator::WeakPtr( locator), IServiceFactory::ConstPointer(0), IDisposable::WeakPtr( serviceLocatorOwner)).Cast (); // initializeDefaultServices(); // Add contribution managers that are exposed to other plugins. //addMenuBar(); //addCoolBar(SWT.NONE); // style is unused //addStatusLine(); this->FireWindowOpening(); // Fill the action bars this->FillActionBars(FILL_ALL_ACTION_BARS); this->UnRegister(false); // decrease reference count and avoid deleting // the window } WorkbenchWindow::~WorkbenchWindow() { //BERRY_INFO << "WorkbenchWindow::~WorkbenchWindow()"; } Object::Pointer WorkbenchWindow::GetService(const std::string& key) { return serviceLocator->GetService(key); } bool WorkbenchWindow::HasService(const std::string& key) const { return serviceLocator->HasService(key); } Shell::Pointer WorkbenchWindow::GetShell() { return Window::GetShell(); } bool WorkbenchWindow::ClosePage(IWorkbenchPage::Pointer in, bool save) { // Validate the input. if (!pageList.Contains(in)) { return false; } WorkbenchPage::Pointer oldPage = in.Cast (); // Save old perspective. if (save && oldPage->IsSaveNeeded()) { if (!oldPage->SaveAllEditors(true)) { return false; } } // If old page is activate deactivate. bool oldIsActive = (oldPage == this->GetActivePage()); if (oldIsActive) { this->SetActivePage(IWorkbenchPage::Pointer(0)); } // Close old page. pageList.Remove(oldPage); partService.PageClosed(oldPage); //this->FirePageClosed(oldPage); //oldPage->Dispose(); // Activate new page. if (oldIsActive) { IWorkbenchPage::Pointer newPage = pageList.GetNextActive(); if (newPage != 0) { this->SetActivePage(newPage); } } if (!closing && pageList.IsEmpty()) { this->ShowEmptyWindowContents(); } return true; } void WorkbenchWindow::AddPerspectiveListener(IPerspectiveListener::Pointer l) { perspectiveEvents.AddListener(l); } void WorkbenchWindow::RemovePerspectiveListener(IPerspectiveListener::Pointer l) { perspectiveEvents.RemoveListener(l); } IPerspectiveListener::Events& WorkbenchWindow::GetPerspectiveEvents() { return perspectiveEvents; } void WorkbenchWindow::FireWindowOpening() { // let the application do further configuration this->GetWindowAdvisor()->PreWindowOpen(); } void WorkbenchWindow::FireWindowRestored() { //StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() { // public void runWithException() throws Throwable { this->GetWindowAdvisor()->PostWindowRestore(); // } //}); } void WorkbenchWindow::FireWindowCreated() { this->GetWindowAdvisor()->PostWindowCreate(); } void WorkbenchWindow::FireWindowOpened() { this->GetWorkbenchImpl()->FireWindowOpened(IWorkbenchWindow::Pointer(this)); this->GetWindowAdvisor()->PostWindowOpen(); } bool WorkbenchWindow::FireWindowShellClosing() { return this->GetWindowAdvisor()->PreWindowShellClose(); } void WorkbenchWindow::FireWindowClosed() { // let the application do further deconfiguration this->GetWindowAdvisor()->PostWindowClose(); this->GetWorkbenchImpl()->FireWindowClosed(IWorkbenchWindow::Pointer(this)); } ///** // * Fires page activated // */ //void WorkbenchWindow::FirePageActivated(IWorkbenchPage::Pointer page) { //// String label = null; // debugging only //// if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { //// label = "activated " + page.getLabel(); //$NON-NLS-1$ //// } //// try { //// UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); //// UIListenerLogging.logPageEvent(this, page, //// UIListenerLogging.WPE_PAGE_ACTIVATED); // pageEvents.FirePageActivated(page); // partService.pageActivated(page); //// } finally { //// UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); //// } //} // ///** // * Fires page closed // */ //void WorkbenchWindow::FirePageClosed(IWorkbenchPage::Pointer page) { // String label = null; // debugging only // if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { // label = "closed " + page.getLabel(); //$NON-NLS-1$ // } // try { // UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); // UIListenerLogging.logPageEvent(this, page, // UIListenerLogging.WPE_PAGE_CLOSED); // pageListeners.firePageClosed(page); // partService.pageClosed(page); // } finally { // UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); // } // //} // ///** // * Fires page opened // */ //void WorkbenchWindow::FirePageOpened(IWorkbenchPage::Pointer page) { // String label = null; // debugging only // if (UIStats.isDebugging(UIStats.NOTIFY_PAGE_LISTENERS)) { // label = "opened " + page.getLabel(); //$NON-NLS-1$ // } // try { // UIStats.start(UIStats.NOTIFY_PAGE_LISTENERS, label); // UIListenerLogging.logPageEvent(this, page, // UIListenerLogging.WPE_PAGE_OPENED); // pageListeners.firePageOpened(page); // partService.pageOpened(page); // } finally { // UIStats.end(UIStats.NOTIFY_PAGE_LISTENERS, page.getLabel(), label); // } //} void WorkbenchWindow::FirePerspectiveActivated(IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective) { // UIListenerLogging.logPerspectiveEvent(this, page, perspective, // UIListenerLogging.PLE_PERSP_ACTIVATED); perspectiveEvents.perspectiveActivated(page, perspective); } void WorkbenchWindow::FirePerspectivePreDeactivate( IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective) { // UIListenerLogging.logPerspectiveEvent(this, page, perspective, // UIListenerLogging.PLE_PERSP_PRE_DEACTIVATE); perspectiveEvents.perspectivePreDeactivate(page, perspective); } void WorkbenchWindow::FirePerspectiveDeactivated(IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective) { // UIListenerLogging.logPerspectiveEvent(this, page, perspective, // UIListenerLogging.PLE_PERSP_DEACTIVATED); perspectiveEvents.perspectiveDeactivated(page, perspective); } void WorkbenchWindow::FirePerspectiveChanged(IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective, const std::string& changeId) { // Some callers call this even when there is no active perspective. // Just ignore this case. if (perspective != 0) { // UIListenerLogging.logPerspectiveChangedEvent(this, page, // perspective, null, changeId); perspectiveEvents.perspectiveChanged(page, perspective, changeId); } } void WorkbenchWindow::FirePerspectiveChanged(IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective, IWorkbenchPartReference::Pointer partRef, const std::string& changeId) { // Some callers call this even when there is no active perspective. // Just ignore this case. if (perspective != 0) { // UIListenerLogging.logPerspectiveChangedEvent(this, page, // perspective, partRef, changeId); perspectiveEvents.perspectivePartChanged(page, perspective, partRef, changeId); } } void WorkbenchWindow::FirePerspectiveClosed(IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective) { // UIListenerLogging.logPerspectiveEvent(this, page, perspective, // UIListenerLogging.PLE_PERSP_CLOSED); perspectiveEvents.perspectiveClosed(page, perspective); } void WorkbenchWindow::FirePerspectiveOpened(IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer perspective) { // UIListenerLogging.logPerspectiveEvent(this, page, perspective, // UIListenerLogging.PLE_PERSP_OPENED); perspectiveEvents.perspectiveOpened(page, perspective); } void WorkbenchWindow::FirePerspectiveSavedAs(IWorkbenchPage::Pointer page, IPerspectiveDescriptor::Pointer oldPerspective, IPerspectiveDescriptor::Pointer newPerspective) { // UIListenerLogging.logPerspectiveSavedAs(this, page, oldPerspective, // newPerspective); perspectiveEvents.perspectiveSavedAs(page, oldPerspective, newPerspective); } void WorkbenchWindow::FillActionBars(int flags) { // Workbench workbench = getWorkbenchImpl(); // workbench.largeUpdateStart(); //try { this->GetActionBarAdvisor()->FillActionBars(flags); // final IMenuService menuService = (IMenuService) serviceLocator // .getService(IMenuService.class); // menuService.populateContributionManager( // (ContributionManager) getActionBars().getMenuManager(), // MenuUtil.MAIN_MENU); // ICoolBarManager coolbar = getActionBars().getCoolBarManager(); // if (coolbar != null) { // menuService.populateContributionManager( // (ContributionManager) coolbar, // MenuUtil.MAIN_TOOLBAR); // } // // } finally { // workbench.largeUpdateEnd(); // } } Point WorkbenchWindow::GetInitialSize() { return this->GetWindowConfigurer()->GetInitialSize(); } bool WorkbenchWindow::Close() { //BERRY_INFO << "WorkbenchWindow::Close()"; if (controlResizeListener) { Tweaklets::Get(GuiWidgetsTweaklet::KEY)->RemoveControlListener(GetShell()->GetControl(), controlResizeListener); } bool ret = false; //BusyIndicator.showWhile(null, new Runnable() { // public void run() { ret = this->BusyClose(); // } // }); if (!ret && controlResizeListener) { Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(GetShell()->GetControl(), controlResizeListener); } return ret; } bool WorkbenchWindow::BusyClose() { // Whether the window was actually closed or not bool windowClosed = false; // Setup internal flags to indicate window is in // progress of closing and no update should be done. closing = true; updateDisabled = true; try { // Only do the check if it is OK to close if we are not closing // via the workbench as the workbench will check this itself. Workbench* workbench = this->GetWorkbenchImpl(); std::size_t count = workbench->GetWorkbenchWindowCount(); // also check for starting - if the first window dies on startup // then we'll need to open a default window. if (!workbench->IsStarting() && !workbench->IsClosing() && count <= 1 && workbench->GetWorkbenchConfigurer() ->GetExitOnLastWindowClose()) { windowClosed = workbench->Close(); } else { if (this->OkToClose()) { windowClosed = this->HardClose(); } } } catch (std::exception& exc) { if (!windowClosed) { // Reset the internal flags if window was not closed. closing = false; updateDisabled = false; } throw exc; } // if (windowClosed && tracker != null) { // tracker.close(); // } return windowClosed; } void WorkbenchWindow::MakeVisible() { Shell::Pointer shell = GetShell(); if (shell) { // see bug 96700 and bug 4414 for a discussion on the use of open() // here shell->Open(); } } bool WorkbenchWindow::OkToClose() { // Save all of the editors. if (!this->GetWorkbenchImpl()->IsClosing()) { if (!this->SaveAllPages(true)) { return false; } } return true; } bool WorkbenchWindow::SaveAllPages(bool bConfirm) { bool bRet = true; PageList::iterator itr = pageList.Begin(); while (bRet && itr != pageList.End()) { bRet = (*itr)->SaveAllEditors(bConfirm); ++itr; } return bRet; } bool WorkbenchWindow::HardClose() { std::exception exc; bool exceptionOccured = false; try { // Clear the action sets, fix for bug 27416. //getActionPresentation().clearActionSets(); // Remove the handler submissions. Bug 64024. /* final IWorkbench workbench = getWorkbench(); final IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class); handlerService.deactivateHandlers(handlerActivations); final Iterator activationItr = handlerActivations.iterator(); while (activationItr.hasNext()) { final IHandlerActivation activation = (IHandlerActivation) activationItr .next(); activation.getHandler().dispose(); } handlerActivations.clear(); globalActionHandlersByCommandId.clear(); */ // Remove the enabled submissions. Bug 64024. /* final IContextService contextService = (IContextService) workbench.getService(IContextService.class); contextService.unregisterShell(getShell()); */ this->CloseAllPages(); this->FireWindowClosed(); // time to wipe out our populate /* IMenuService menuService = (IMenuService) workbench .getService(IMenuService.class); menuService .releaseContributions(((ContributionManager) getActionBars() .getMenuManager())); ICoolBarManager coolbar = getActionBars().getCoolBarManager(); if (coolbar != null) { menuService .releaseContributions(((ContributionManager) coolbar)); } */ //getActionBarAdvisor().dispose(); //getWindowAdvisor().dispose(); //detachedWindowShells.dispose(); delete windowAdvisor; windowAdvisor = 0; // Null out the progress region. Bug 64024. //progressRegion = null; // Remove drop targets /* DragUtil.removeDragTarget(null, trimDropTarget); DragUtil.removeDragTarget(getShell(), trimDropTarget); trimDropTarget = null; if (trimMgr2 != null) { trimMgr2.dispose(); trimMgr2 = null; } if (trimContributionMgr != null) { trimContributionMgr.dispose(); trimContributionMgr = null; } */ } catch (std::exception& e) { exc = e; exceptionOccured = true; } bool result = Window::Close(); // Bring down all of the services ... after the window goes away serviceLocator->Dispose(); //menuRestrictions.clear(); if (exceptionOccured) throw exc; return result; } void WorkbenchWindow::CloseAllPages() { // Deactivate active page. this->SetActivePage(IWorkbenchPage::Pointer(0)); // Clone and deref all so that calls to getPages() returns // empty list (if called by pageClosed event handlers) PageList oldList = pageList; pageList.Clear(); // Close all. for (PageList::iterator itr = oldList.Begin(); itr != oldList.End(); ++itr) { partService.PageClosed(*itr); //(*itr)->FirePageClosed(page); //page.dispose(); } if (!closing) { this->ShowEmptyWindowContents(); } } +void WorkbenchWindow::SetPerspectiveExcludeList(std::vector v) +{ + perspectiveExcludeList = v; +} + +std::vector WorkbenchWindow::GetPerspectiveExcludeList() +{ + return perspectiveExcludeList; +} + +void WorkbenchWindow::SetViewExcludeList(std::vector v) +{ + viewExcludeList = v; +} + +std::vector WorkbenchWindow::GetViewExcludeList() +{ + return viewExcludeList; +} + +IWorkbenchPage::Pointer WorkbenchWindow::GetPage(int i) +{ + std::list pages = pageList.GetPages(); + std::list::iterator it; + int j=-1; + for (it = pages.begin(); it!=pages.end(); it++) + { + j++; + if (j==i) + break; + } + if (j==i) + return *it; +} + IWorkbenchPage::Pointer WorkbenchWindow::GetActivePage() { return pageList.GetActive(); } IWorkbench* WorkbenchWindow::GetWorkbench() { return PlatformUI::GetWorkbench(); } IPartService* WorkbenchWindow::GetPartService() { return &partService; } ISelectionService* WorkbenchWindow::GetSelectionService() { return partService.GetSelectionService(); } bool WorkbenchWindow::IsClosing() { return closing || this->GetWorkbenchImpl()->IsClosing(); } int WorkbenchWindow::Open() { if (pageList.IsEmpty()) { this->ShowEmptyWindowContents(); } this->FireWindowCreated(); this->GetWindowAdvisor()->OpenIntro(); int result = Window::Open(); // It's time for a layout ... to insure that if TrimLayout // is in play, it updates all of the trim it's responsible // for. We have to do this before updating in order to get // the PerspectiveBar management correct...see defect 137334 //getShell().layout(); this->FireWindowOpened(); // if (perspectiveSwitcher != null) { // perspectiveSwitcher.updatePerspectiveBar(); // perspectiveSwitcher.updateBarParent(); // } return result; } void* WorkbenchWindow::GetPageComposite() { return pageComposite; } void* WorkbenchWindow::CreateContents(Shell::Pointer parent) { // we know from Window.create that the parent is a Shell. this->GetWindowAdvisor()->CreateWindowContents(parent); // the page composite must be set by createWindowContents poco_assert(pageComposite != 0) ; // "createWindowContents must call configurer.createPageComposite"); //$NON-NLS-1$ return pageComposite; } void WorkbenchWindow::CreateDefaultContents(Shell::Pointer shell) { //pageComposite = Tweaklets::Get(WorkbenchTweaklet::KEY)->CreateDefaultWindowContents(shell); this->CreatePageComposite(shell->GetControl()); } bool WorkbenchWindow::UnableToRestorePage(IMemento::Pointer pageMem) { std::string pageName; pageMem->GetString(WorkbenchConstants::TAG_LABEL, pageName); // return new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, NLS.bind( // WorkbenchMessages.WorkbenchWindow_unableToRestorePerspective, // pageName), null); WorkbenchPlugin::Log("Unable to restore perspective: " + pageName); return false; } bool WorkbenchWindow::RestoreState(IMemento::Pointer memento, IPerspectiveDescriptor::Pointer activeDescriptor) { //TODO WorkbenchWindow restore state poco_assert(GetShell()); // final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, // WorkbenchMessages.WorkbenchWindow_problemsRestoringWindow, null); bool result = true; // Restore the window advisor state. IMemento::Pointer windowAdvisorState = memento ->GetChild(WorkbenchConstants::TAG_WORKBENCH_WINDOW_ADVISOR); if (windowAdvisorState) { //result.add(getWindowAdvisor().restoreState(windowAdvisorState)); result &= GetWindowAdvisor()->RestoreState(windowAdvisorState); } // Restore actionbar advisor state. IMemento::Pointer actionBarAdvisorState = memento ->GetChild(WorkbenchConstants::TAG_ACTION_BAR_ADVISOR); if (actionBarAdvisorState) { // result.add(getActionBarAdvisor() // .restoreState(actionBarAdvisorState)); result &= GetActionBarAdvisor() ->RestoreState(actionBarAdvisorState); } // Read window's bounds and state. Rectangle displayBounds; // StartupThreading.runWithoutExceptions(new StartupRunnable() { // // public void runWithException() { displayBounds = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetScreenSize(); //displayBounds = GetShell()->GetDisplay()->GetBounds(); // }}); Rectangle shellBounds; // final IMemento fastViewMem = memento // .getChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); // if (fastViewMem != null) { // if (fastViewBar != null) { // StartupThreading.runWithoutExceptions(new StartupRunnable() { // // public void runWithException() { // fastViewBar.restoreState(fastViewMem); // }}); // // } // } memento->GetInteger(WorkbenchConstants::TAG_X, shellBounds.x); memento->GetInteger(WorkbenchConstants::TAG_Y, shellBounds.y); memento->GetInteger(WorkbenchConstants::TAG_WIDTH, shellBounds.width); memento->GetInteger(WorkbenchConstants::TAG_HEIGHT, shellBounds.height); if (!shellBounds.IsEmpty()) { // StartupThreading.runWithoutExceptions(new StartupRunnable() { // // public void runWithException() { if (!shellBounds.Intersects(displayBounds)) { Rectangle clientArea(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetAvailableScreenSize()); shellBounds.x = clientArea.x; shellBounds.y = clientArea.y; } GetShell()->SetBounds(shellBounds); // }}); } std::string maximized; memento->GetString(WorkbenchConstants::TAG_MAXIMIZED, maximized); if (maximized == "true") { // StartupThreading.runWithoutExceptions(new StartupRunnable() { // // public void runWithException() { GetShell()->SetMaximized(true); // }}); } std::string minimized; memento->GetString(WorkbenchConstants::TAG_MINIMIZED, minimized); if (minimized == "true") { // getShell().setMinimized(true); } // // restore the width of the perspective bar // if (perspectiveSwitcher != null) { // perspectiveSwitcher.restoreState(memento); // } // // Restore the cool bar order by creating all the tool bar contribution // // items // // This needs to be done before pages are created to ensure proper // // canonical creation // // of cool items // final ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); // if (coolBarMgr != null) { // IMemento coolBarMem = memento // .getChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); // if (coolBarMem != null) { // // Check if the layout is locked // final Integer lockedInt = coolBarMem // .getInteger(IWorkbenchConstants.TAG_LOCKED); // StartupThreading.runWithoutExceptions(new StartupRunnable(){ // // public void runWithException() { // if ((lockedInt != null) && (lockedInt.intValue() == 1)) { // coolBarMgr.setLockLayout(true); // } else { // coolBarMgr.setLockLayout(false); // } // }}); // // // The new layout of the cool bar manager // ArrayList coolBarLayout = new ArrayList(); // // Traverse through all the cool item in the memento // IMemento contributionMems[] = coolBarMem // .getChildren(IWorkbenchConstants.TAG_COOLITEM); // for (int i = 0; i < contributionMems.length; i++) { // IMemento contributionMem = contributionMems[i]; // String type = contributionMem // .getString(IWorkbenchConstants.TAG_ITEM_TYPE); // if (type == null) { // // Do not recognize that type // continue; // } // String id = contributionMem // .getString(IWorkbenchConstants.TAG_ID); // // // Prevent duplicate items from being read back in. // IContributionItem existingItem = coolBarMgr.find(id); // if ((id != null) && (existingItem != null)) { // if (Policy.DEBUG_TOOLBAR_DISPOSAL) { // System.out // .println("Not loading duplicate cool bar item: " + id); //$NON-NLS-1$ // } // coolBarLayout.add(existingItem); // continue; // } // IContributionItem newItem = null; // if (type.equals(IWorkbenchConstants.TAG_TYPE_SEPARATOR)) { // if (id != null) { // newItem = new Separator(id); // } else { // newItem = new Separator(); // } // } else if (id != null) { // if (type // .equals(IWorkbenchConstants.TAG_TYPE_GROUPMARKER)) { // newItem = new GroupMarker(id); // // } else if (type // .equals(IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION) // || type // .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { // // // Get Width and height // Integer width = contributionMem // .getInteger(IWorkbenchConstants.TAG_ITEM_X); // Integer height = contributionMem // .getInteger(IWorkbenchConstants.TAG_ITEM_Y); // // Look for the object in the current cool bar // // manager // IContributionItem oldItem = coolBarMgr.find(id); // // If a tool bar contribution item already exists // // for this id then use the old object // if (oldItem != null) { // newItem = oldItem; // } else { // IActionBarPresentationFactory actionBarPresentation = getActionBarPresentationFactory(); // newItem = actionBarPresentation.createToolBarContributionItem( // actionBarPresentation.createToolBarManager(), id); // if (type // .equals(IWorkbenchConstants.TAG_TYPE_PLACEHOLDER)) { // IToolBarContributionItem newToolBarItem = (IToolBarContributionItem) newItem; // if (height != null) { // newToolBarItem.setCurrentHeight(height // .intValue()); // } // if (width != null) { // newToolBarItem.setCurrentWidth(width // .intValue()); // } // newItem = new PlaceholderContributionItem( // newToolBarItem); // } // // make it invisible by default // newItem.setVisible(false); // // Need to add the item to the cool bar manager // // so that its canonical order can be preserved // IContributionItem refItem = findAlphabeticalOrder( // IWorkbenchActionConstants.MB_ADDITIONS, // id, coolBarMgr); // if (refItem != null) { // coolBarMgr.insertAfter(refItem.getId(), // newItem); // } else { // coolBarMgr.add(newItem); // } // } // // Set the current height and width // if ((width != null) // && (newItem instanceof IToolBarContributionItem)) { // ((IToolBarContributionItem) newItem) // .setCurrentWidth(width.intValue()); // } // if ((height != null) // && (newItem instanceof IToolBarContributionItem)) { // ((IToolBarContributionItem) newItem) // .setCurrentHeight(height.intValue()); // } // } // } // // Add new item into cool bar manager // if (newItem != null) { // coolBarLayout.add(newItem); // newItem.setParent(coolBarMgr); // coolBarMgr.markDirty(); // } // } // // // We need to check if we have everything we need in the layout. // boolean newlyAddedItems = false; // IContributionItem[] existingItems = coolBarMgr.getItems(); // for (int i = 0; i < existingItems.length && !newlyAddedItems; i++) { // IContributionItem existingItem = existingItems[i]; // // /* // * This line shouldn't be necessary, but is here for // * robustness. // */ // if (existingItem == null) { // continue; // } // // boolean found = false; // Iterator layoutItemItr = coolBarLayout.iterator(); // while (layoutItemItr.hasNext()) { // IContributionItem layoutItem = (IContributionItem) layoutItemItr // .next(); // if ((layoutItem != null) // && (layoutItem.equals(existingItem))) { // found = true; // break; // } // } // // if (!found) { // if (existingItem != null) { // newlyAddedItems = true; // } // } // } // // // Set the cool bar layout to the given layout. // if (!newlyAddedItems) { // final IContributionItem[] itemsToSet = new IContributionItem[coolBarLayout // .size()]; // coolBarLayout.toArray(itemsToSet); // StartupThreading // .runWithoutExceptions(new StartupRunnable() { // // public void runWithException() { // coolBarMgr.setItems(itemsToSet); // } // }); // } // // } else { // // For older workbenchs // coolBarMem = memento // .getChild(IWorkbenchConstants.TAG_TOOLBAR_LAYOUT); // if (coolBarMem != null) { // // Restore an older layout // restoreOldCoolBar(coolBarMem); // } // } // } // Recreate each page in the window. IWorkbenchPage::Pointer newActivePage; std::vector pageArray = memento ->GetChildren(WorkbenchConstants::TAG_PAGE); for (std::size_t i = 0; i < pageArray.size(); i++) { IMemento::Pointer pageMem = pageArray[i]; std::string strFocus; pageMem->GetString(WorkbenchConstants::TAG_FOCUS, strFocus); if (strFocus.empty()) { continue; } // Get the input factory. IAdaptable* input = 0; IMemento::Pointer inputMem = pageMem->GetChild(WorkbenchConstants::TAG_INPUT); if (inputMem) { std::string factoryID; inputMem->GetString(WorkbenchConstants::TAG_FACTORY_ID, factoryID); if (factoryID.empty()) { WorkbenchPlugin ::Log("Unable to restore page - no input factory ID."); //result.add(unableToRestorePage(pageMem)); result &= UnableToRestorePage(pageMem); continue; } // try { // UIStats.start(UIStats.RESTORE_WORKBENCH, // "WorkbenchPageFactory"); //$NON-NLS-1$ // StartupThreading // .runWithoutExceptions(new StartupRunnable() { // // public void runWithException() throws Throwable { // IElementFactory factory = PlatformUI // .getWorkbench().getElementFactory( // factoryID); // if (factory == null) { // WorkbenchPlugin // .log("Unable to restore page - cannot instantiate input factory: " + factoryID); //$NON-NLS-1$ // result // .add(unableToRestorePage(pageMem)); // return; // } // // // Get the input element. // input[0] = factory.createElement(inputMem); // } // }); // // if (input[0] == null) { // WorkbenchPlugin // .log("Unable to restore page - cannot instantiate input element: " + factoryID); //$NON-NLS-1$ // result.add(unableToRestorePage(pageMem)); // continue; // } // } finally { // UIStats.end(UIStats.RESTORE_WORKBENCH, factoryID, // "WorkbenchPageFactory"); //$NON-NLS-1$ // } } // Open the perspective. IAdaptable* finalInput = input; WorkbenchPage::Pointer newPage; try { // StartupThreading.runWithWorkbenchExceptions(new StartupRunnable(){ // // public void runWithException() throws WorkbenchException { newPage = new WorkbenchPage(this, finalInput); // }}); //result.add(newPage[0].restoreState(pageMem, activeDescriptor)); result &= newPage->RestoreState(pageMem, activeDescriptor); pageList.Add(newPage); // StartupThreading.runWithoutExceptions(new StartupRunnable() { // // public void runWithException() throws Throwable { partService.PageOpened(newPage); // firePageOpened(newPage[0]); // }}); } catch (const WorkbenchException& e) { WorkbenchPlugin::Log( "Unable to restore perspective - constructor failed.", e); //$NON-NLS-1$ //result.add(e.getStatus()); continue; } if (!strFocus.empty()) { newActivePage = newPage; } } // If there are no pages create a default. if (pageList.IsEmpty()) { try { const std::string defPerspID = this->GetWorkbenchImpl()->GetPerspectiveRegistry() ->GetDefaultPerspective(); if (!defPerspID.empty()) { WorkbenchPage::Pointer newPage; //StartupThreading.runWithWorkbenchExceptions(new StartupRunnable() { // public void runWithException() throws Throwable { newPage = new WorkbenchPage(this, defPerspID, this->GetDefaultPageInput()); // }}); pageList.Add(newPage); //StartupThreading.runWithoutExceptions(new StartupRunnable() { // public void runWithException() throws Throwable { // firePageOpened(newPage[0]); partService.PageOpened(newPage); // }}); } } catch (WorkbenchException& e) { WorkbenchPlugin ::Log( "Unable to create default perspective - constructor failed.", e); result = false; //TODO set product name // String productName = WorkbenchPlugin.getDefault() // .getProductName(); // if (productName == null) { // productName = ""; //$NON-NLS-1$ // } // getShell().setText(productName); } } // Set active page. if (newActivePage.IsNull()) { newActivePage = pageList.GetNextActive().Cast(); } //StartupThreading.runWithoutExceptions(new StartupRunnable() { // public void runWithException() throws Throwable { this->SetActivePage(newActivePage); // }}); IMemento::Pointer introMem = memento->GetChild(WorkbenchConstants::TAG_INTRO); if (introMem) { // StartupThreading.runWithoutExceptions(new StartupRunnable() { // // public void runWithException() throws Throwable { bool isStandby = false; introMem->GetBoolean(WorkbenchConstants::TAG_STANDBY, isStandby); GetWorkbench()->GetIntroManager()->ShowIntro( IWorkbenchWindow::Pointer(this), isStandby); // } // }); } // // // Only restore the trim state if we're using the default layout // if (defaultLayout != null) { // // Restore the trim state. We pass in the 'root' // // memento since we have to check for pre-3.2 // // state. // result.add(restoreTrimState(memento)); // } return result; } IAdaptable* WorkbenchWindow::GetDefaultPageInput() { return this->GetWorkbenchImpl()->GetDefaultPageInput(); } IWorkbenchPage::Pointer WorkbenchWindow::OpenPage( const std::string& perspId, IAdaptable* input) { // Run op in busy cursor. IWorkbenchPage::Pointer result; //BusyIndicator.showWhile(null, new Runnable() { // public void run() { result = this->BusyOpenPage(perspId, input); // } return result; } SmartPointer WorkbenchWindow::OpenPage(IAdaptable* input) { std::string perspId = this->GetWorkbenchImpl()->GetDefaultPerspectiveId(); return this->OpenPage(perspId, input); } IWorkbenchPage::Pointer WorkbenchWindow::BusyOpenPage( const std::string& perspID, IAdaptable* input) { IWorkbenchPage::Pointer newPage; if (pageList.IsEmpty()) { newPage = new WorkbenchPage(this, perspID, input); pageList.Add(newPage); //this->FirePageOpened(newPage); partService.PageOpened(newPage); this->SetActivePage(newPage); } else { IWorkbenchWindow::Pointer window = this->GetWorkbench()->OpenWorkbenchWindow(perspID, input); newPage = window->GetActivePage(); } return newPage; } int WorkbenchWindow::GetNumber() { return number; } void WorkbenchWindow::LargeUpdateStart() { largeUpdates++; } void WorkbenchWindow::LargeUpdateEnd() { if (--largeUpdates == 0) { //TODO WorkbenchWindow update action bars after large update //this->UpdateActionBars(); } } void WorkbenchWindow::SetActivePage(IWorkbenchPage::Pointer in) { if (this->GetActivePage() == in) { return; } // 1FVGTNR: ITPUI:WINNT - busy cursor for switching perspectives //BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { // public void run() { // Deactivate old persp. WorkbenchPage::Pointer currentPage = pageList.GetActive(); if (currentPage.IsNotNull()) { currentPage->OnDeactivate(); } // Activate new persp. if (in.IsNull() || pageList.Contains(in)) { pageList.SetActive(in); } WorkbenchPage::Pointer newPage = pageList.GetActive(); //Composite parent = getPageComposite(); //StackLayout layout = (StackLayout) parent.getLayout(); if (newPage.IsNotNull()) { //layout.topControl = newPage.getClientComposite(); //parent.layout(); this->HideEmptyWindowContents(); newPage->OnActivate(); //this->FirePageActivated(newPage); partService.PageActivated(newPage); //TODO perspective if (newPage->GetPerspective() != 0) { this->FirePerspectiveActivated(newPage, newPage->GetPerspective()); } } else { //layout.topControl = null; //parent.layout(); } //updateFastViewBar(); if (this->IsClosing()) { return; } updateDisabled = false; // Update action bars ( implicitly calls updateActionBars() ) //updateActionSets(); //submitGlobalActions(); //if (perspectiveSwitcher != null) { // perspectiveSwitcher.update(false); //} //getMenuManager().update(IAction.TEXT); // } //}); } bool WorkbenchWindow::SaveState(IMemento::Pointer memento) { // MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, // WorkbenchMessages.WorkbenchWindow_problemsSavingWindow, null); bool result = true; // Save the window's state and bounds. if (GetShell()->GetMaximized() || asMaximizedState) { memento->PutString(WorkbenchConstants::TAG_MAXIMIZED, "true"); } if (GetShell()->GetMinimized()) { memento->PutString(WorkbenchConstants::TAG_MINIMIZED, "true"); } if (normalBounds.IsEmpty()) { normalBounds = GetShell()->GetBounds(); } // IMemento fastViewBarMem = memento // .createChild(IWorkbenchConstants.TAG_FAST_VIEW_DATA); // if (fastViewBar != null) { // fastViewBar.saveState(fastViewBarMem); // } memento->PutInteger(WorkbenchConstants::TAG_X, normalBounds.x); memento->PutInteger(WorkbenchConstants::TAG_Y, normalBounds.y); memento->PutInteger(WorkbenchConstants::TAG_WIDTH, normalBounds.width); memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, normalBounds.height); IWorkbenchPage::Pointer activePage = GetActivePage(); if (activePage && activePage->FindView(IntroConstants::INTRO_VIEW_ID)) { IMemento::Pointer introMem = memento ->CreateChild(WorkbenchConstants::TAG_INTRO); bool isStandby = GetWorkbench()->GetIntroManager() ->IsIntroStandby(GetWorkbench()->GetIntroManager()->GetIntro()); introMem->PutBoolean(WorkbenchConstants::TAG_STANDBY, isStandby); } // // save the width of the perspective bar // IMemento persBarMem = memento // .createChild(IWorkbenchConstants.TAG_PERSPECTIVE_BAR); // if (perspectiveSwitcher != null) { // perspectiveSwitcher.saveState(persBarMem); // } // // / Save the order of the cool bar contribution items // ICoolBarManager2 coolBarMgr = (ICoolBarManager2) getCoolBarManager2(); // if (coolBarMgr != null) { // coolBarMgr.refresh(); // IMemento coolBarMem = memento // .createChild(IWorkbenchConstants.TAG_COOLBAR_LAYOUT); // if (coolBarMgr.getLockLayout() == true) { // coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 1); // } else { // coolBarMem.putInteger(IWorkbenchConstants.TAG_LOCKED, 0); // } // IContributionItem[] items = coolBarMgr.getItems(); // for (int i = 0; i < items.length; i++) { // IMemento coolItemMem = coolBarMem // .createChild(IWorkbenchConstants.TAG_COOLITEM); // IContributionItem item = items[i]; // // The id of the contribution item // if (item.getId() != null) { // coolItemMem.putString(IWorkbenchConstants.TAG_ID, item // .getId()); // } // // Write out type and size if applicable // if (item.isSeparator()) { // coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE, // IWorkbenchConstants.TAG_TYPE_SEPARATOR); // } else if (item.isGroupMarker() && !item.isSeparator()) { // coolItemMem.putString(IWorkbenchConstants.TAG_ITEM_TYPE, // IWorkbenchConstants.TAG_TYPE_GROUPMARKER); // } else { // if (item instanceof PlaceholderContributionItem) { // coolItemMem.putString( // IWorkbenchConstants.TAG_ITEM_TYPE, // IWorkbenchConstants.TAG_TYPE_PLACEHOLDER); // } else { // // Store the identifier. // coolItemMem // .putString( // IWorkbenchConstants.TAG_ITEM_TYPE, // IWorkbenchConstants.TAG_TYPE_TOOLBARCONTRIBUTION); // } // // /* // * Retrieve a reasonable approximation of the height and // * width, if possible. // */ // final int height; // final int width; // if (item instanceof IToolBarContributionItem) { // IToolBarContributionItem toolBarItem = (IToolBarContributionItem) item; // toolBarItem.saveWidgetState(); // height = toolBarItem.getCurrentHeight(); // width = toolBarItem.getCurrentWidth(); // } else if (item instanceof PlaceholderContributionItem) { // PlaceholderContributionItem placeholder = (PlaceholderContributionItem) item; // height = placeholder.getHeight(); // width = placeholder.getWidth(); // } else { // height = -1; // width = -1; // } // // // Store the height and width. // coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_X, // width); // coolItemMem.putInteger(IWorkbenchConstants.TAG_ITEM_Y, // height); // } // } // } // Save each page. for (PageList::iterator itr = pageList.Begin(); itr != pageList.End(); ++itr) { WorkbenchPage::Pointer page = itr->Cast(); // Save perspective. IMemento::Pointer pageMem = memento ->CreateChild(WorkbenchConstants::TAG_PAGE); pageMem->PutString(WorkbenchConstants::TAG_LABEL, page->GetLabel()); //result.add(page.saveState(pageMem)); result &= page->SaveState(pageMem); if (page == GetActivePage().Cast()) { pageMem->PutString(WorkbenchConstants::TAG_FOCUS, "true"); } // // Get the input. // IAdaptable* input = page->GetInput(); // if (input != 0) { // IPersistableElement persistable = (IPersistableElement) Util.getAdapter(input, // IPersistableElement.class); // if (persistable == null) { // WorkbenchPlugin // .log("Unable to save page input: " //$NON-NLS-1$ // + input // + ", because it does not adapt to IPersistableElement"); //$NON-NLS-1$ // } else { // // Save input. // IMemento inputMem = pageMem // .createChild(IWorkbenchConstants.TAG_INPUT); // inputMem.putString(IWorkbenchConstants.TAG_FACTORY_ID, // persistable.getFactoryId()); // persistable.saveState(inputMem); // } // } } // Save window advisor state. IMemento::Pointer windowAdvisorState = memento ->CreateChild(WorkbenchConstants::TAG_WORKBENCH_WINDOW_ADVISOR); //result.add(getWindowAdvisor().saveState(windowAdvisorState)); result &= GetWindowAdvisor()->SaveState(windowAdvisorState); // Save actionbar advisor state. IMemento::Pointer actionBarAdvisorState = memento ->CreateChild(WorkbenchConstants::TAG_ACTION_BAR_ADVISOR); //result.add(getActionBarAdvisor().saveState(actionBarAdvisorState)); result &= GetActionBarAdvisor()->SaveState(actionBarAdvisorState); // // Only save the trim state if we're using the default layout // if (defaultLayout != null) { // IMemento trimState = memento.createChild(IWorkbenchConstants.TAG_TRIM); // result.add(saveTrimState(trimState)); // } return result; } WorkbenchWindowConfigurer::Pointer WorkbenchWindow::GetWindowConfigurer() { if (windowConfigurer.IsNull()) { // lazy initialize windowConfigurer = new WorkbenchWindowConfigurer(WorkbenchWindow::Pointer(this)); } return windowConfigurer; } bool WorkbenchWindow::CanHandleShellCloseEvent() { if (!Window::CanHandleShellCloseEvent()) { return false; } // let the advisor or other interested parties // veto the user's explicit request to close the window return FireWindowShellClosing(); } void WorkbenchWindow::ConfigureShell(Shell::Pointer shell) { Window::ConfigureShell(shell); detachedWindowShells = new ShellPool(shell, Constants::TITLE | Constants::MAX | Constants::CLOSE | Constants::RESIZE | Constants::BORDER ); std::string title = this->GetWindowConfigurer()->BasicGetTitle(); if (title != "") { shell->SetText(title); } // final IWorkbench workbench = getWorkbench(); // workbench.getHelpSystem().setHelp(shell, // IWorkbenchHelpContextIds.WORKBENCH_WINDOW); // final IContextService contextService = (IContextService) getWorkbench().getService(IContextService.class); // contextService.registerShell(shell, IContextService.TYPE_WINDOW); this->TrackShellActivation(shell); this->TrackShellResize(shell); } ShellPool::Pointer WorkbenchWindow::GetDetachedWindowPool() { return detachedWindowShells; } WorkbenchAdvisor* WorkbenchWindow::GetAdvisor() { return this->GetWorkbenchImpl()->GetAdvisor(); } WorkbenchWindowAdvisor* WorkbenchWindow::GetWindowAdvisor() { if (windowAdvisor == 0) { windowAdvisor = this->GetAdvisor()->CreateWorkbenchWindowAdvisor(this->GetWindowConfigurer()); poco_check_ptr(windowAdvisor); } return windowAdvisor; } ActionBarAdvisor::Pointer WorkbenchWindow::GetActionBarAdvisor() { if (actionBarAdvisor.IsNull()) { actionBarAdvisor = this->GetWindowAdvisor()->CreateActionBarAdvisor(this->GetWindowConfigurer()->GetActionBarConfigurer()); poco_assert(actionBarAdvisor.IsNotNull()); } return actionBarAdvisor; } Workbench* WorkbenchWindow::GetWorkbenchImpl() { return dynamic_cast(this->GetWorkbench()); } void WorkbenchWindow::ShowEmptyWindowContents() { if (!emptyWindowContentsCreated) { void* parent = this->GetPageComposite(); emptyWindowContents = this->GetWindowAdvisor()->CreateEmptyWindowContents( parent); emptyWindowContentsCreated = true; // // force the empty window composite to be layed out // ((StackLayout) parent.getLayout()).topControl = emptyWindowContents; // parent.layout(); } } void WorkbenchWindow::HideEmptyWindowContents() { if (emptyWindowContentsCreated) { if (emptyWindowContents != 0) { Tweaklets::Get(GuiWidgetsTweaklet::KEY)->Dispose(emptyWindowContents); emptyWindowContents = 0; //this->GetPageComposite().layout(); } emptyWindowContentsCreated = false; } } WorkbenchWindow::ServiceLocatorOwner::ServiceLocatorOwner(WorkbenchWindow* wnd) : window(wnd) { } void WorkbenchWindow::ServiceLocatorOwner::Dispose() { Shell::Pointer shell = window->GetShell(); if (shell != 0) { window->Close(); } } bool WorkbenchWindow::PageList::Add(IWorkbenchPage::Pointer object) { pagesInCreationOrder.push_back(object); pagesInActivationOrder.push_front(object); // It will be moved to top only when activated. return true; } WorkbenchWindow::PageList::iterator WorkbenchWindow::PageList::Begin() { return pagesInCreationOrder.begin(); } WorkbenchWindow::PageList::iterator WorkbenchWindow::PageList::End() { return pagesInCreationOrder.end(); } bool WorkbenchWindow::PageList::Contains(IWorkbenchPage::Pointer object) { return std::find(pagesInCreationOrder.begin(), pagesInCreationOrder.end(), object) != pagesInCreationOrder.end(); } bool WorkbenchWindow::PageList::Remove(IWorkbenchPage::Pointer object) { if (active == object) { active = 0; } pagesInActivationOrder.remove(object); std::size_t origSize = pagesInCreationOrder.size(); pagesInCreationOrder.remove(object); return origSize != pagesInCreationOrder.size(); } void WorkbenchWindow::PageList::Clear() { pagesInCreationOrder.clear(); pagesInActivationOrder.clear(); active = 0; } bool WorkbenchWindow::PageList::IsEmpty() { return pagesInCreationOrder.empty(); } const std::list& WorkbenchWindow::PageList::GetPages() { return pagesInCreationOrder; } void WorkbenchWindow::PageList::SetActive(IWorkbenchPage::Pointer page) { if (active == page) { return; } active = page; if (page.IsNotNull()) { pagesInActivationOrder.remove(page); pagesInActivationOrder.push_back(page); } } WorkbenchPage::Pointer WorkbenchWindow::PageList::GetActive() { return active.Cast(); } WorkbenchPage::Pointer WorkbenchWindow::PageList::GetNextActive() { if (active.IsNull()) { if (pagesInActivationOrder.empty()) { return WorkbenchPage::Pointer(0); } return pagesInActivationOrder.back().Cast(); } if (pagesInActivationOrder.size() < 2) { return WorkbenchPage::Pointer(0); } std::list::reverse_iterator riter = pagesInActivationOrder.rbegin(); return (++riter)->Cast(); } WorkbenchWindow::ShellActivationListener::ShellActivationListener(WorkbenchWindow::Pointer w) : window(w) { } void WorkbenchWindow::ShellActivationListener::ShellActivated(ShellEvent::Pointer /*event*/) { WorkbenchWindow::Pointer wnd(window); wnd->shellActivated = true; wnd->serviceLocator->Activate(); wnd->GetWorkbenchImpl()->SetActivatedWindow(wnd); WorkbenchPage::Pointer currentPage = wnd->GetActivePage().Cast(); if (currentPage != 0) { IWorkbenchPart::Pointer part = currentPage->GetActivePart(); if (part != 0) { PartSite::Pointer site = part->GetSite().Cast(); site->GetPane()->ShellActivated(); } IEditorPart::Pointer editor = currentPage->GetActiveEditor(); if (editor != 0) { PartSite::Pointer site = editor->GetSite().Cast(); site->GetPane()->ShellActivated(); } wnd->GetWorkbenchImpl()->FireWindowActivated(wnd); } //liftRestrictions(); } void WorkbenchWindow::ShellActivationListener::ShellDeactivated(ShellEvent::Pointer /*event*/) { WorkbenchWindow::Pointer wnd(window); wnd->shellActivated = false; //imposeRestrictions(); wnd->serviceLocator->Deactivate(); WorkbenchPage::Pointer currentPage = wnd->GetActivePage().Cast(); if (currentPage != 0) { IWorkbenchPart::Pointer part = currentPage->GetActivePart(); if (part != 0) { PartSite::Pointer site = part->GetSite().Cast(); site->GetPane()->ShellDeactivated(); } IEditorPart::Pointer editor = currentPage->GetActiveEditor(); if (editor != 0) { PartSite::Pointer site = editor->GetSite().Cast(); site->GetPane()->ShellDeactivated(); } wnd->GetWorkbenchImpl()->FireWindowDeactivated(wnd); } } void WorkbenchWindow::TrackShellActivation(Shell::Pointer shell) { shellActivationListener = new ShellActivationListener(WorkbenchWindow::Pointer(this)); shell->AddShellListener(shellActivationListener); } WorkbenchWindow::ControlResizeListener::ControlResizeListener(WorkbenchWindow* w) : window(w) { } GuiTk::IControlListener::Events::Types WorkbenchWindow::ControlResizeListener::GetEventTypes() const { return Events::MOVED | Events::RESIZED; } void WorkbenchWindow:: ControlResizeListener::ControlMoved(GuiTk::ControlEvent::Pointer /*e*/) { this->SaveBounds(); } void WorkbenchWindow:: ControlResizeListener::ControlResized(GuiTk::ControlEvent::Pointer /*e*/) { this->SaveBounds(); } void WorkbenchWindow::ControlResizeListener::SaveBounds() { WorkbenchWindow::Pointer wnd(window); Shell::Pointer shell = wnd->GetShell(); if (shell == 0) { return; } // if (shell->IsDisposed()) // { // return; // } if (shell->GetMinimized()) { return; } if (shell->GetMaximized()) { wnd->asMaximizedState = true; return; } wnd->asMaximizedState = false; wnd->normalBounds = shell->GetBounds(); } void WorkbenchWindow::TrackShellResize(Shell::Pointer newShell) { controlResizeListener = new ControlResizeListener(this); Tweaklets::Get(GuiWidgetsTweaklet::KEY)->AddControlListener(newShell->GetControl(), controlResizeListener); } } diff --git a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h index 6a406926d8..8b09882b9c 100644 --- a/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h +++ b/BlueBerry/Bundles/org.blueberry.ui/src/internal/berryWorkbenchWindow.h @@ -1,632 +1,643 @@ /*=================================================================== BlueBerry Platform 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 BERRYWORKBENCHWINDOW_H_ #define BERRYWORKBENCHWINDOW_H_ #include "berryIWorkbenchWindow.h" #include "berryIPerspectiveListener.h" #include "guitk/berryGuiTkIControlListener.h" #include "berryWindow.h" #include "berryWorkbenchWindowConfigurer.h" #include "berryShellPool.h" #include "berryServiceLocator.h" #include "berryWWinPartService.h" #include "application/berryWorkbenchAdvisor.h" #include "application/berryWorkbenchWindowAdvisor.h" #include "application/berryActionBarAdvisor.h" #include namespace berry { struct IWorkbench; struct IWorkbenchPage; class WorkbenchPage; struct IPartService; struct ISelectionService; struct IPerspectiveDescriptor; class Workbench; /** * \ingroup org_blueberry_ui * */ class BERRY_UI WorkbenchWindow: public Window, public IWorkbenchWindow { public: berryObjectMacro(WorkbenchWindow); WorkbenchWindow(int number); ~WorkbenchWindow(); Object::Pointer GetService(const std::string& key); bool HasService(const std::string& key) const; int Open(); bool Close(); Shell::Pointer GetShell(); /** * @see org.blueberry.ui.IPageService */ void AddPerspectiveListener(IPerspectiveListener::Pointer l); /** * @see org.blueberry.ui.IPageService */ void RemovePerspectiveListener(IPerspectiveListener::Pointer l); /** * @see org.blueberry.ui.IPageService */ IPerspectiveListener::Events& GetPerspectiveEvents(); SmartPointer GetActivePage(); + SmartPointer GetPage(int i); + + void SetPerspectiveExcludeList(std::vector v); + std::vector GetPerspectiveExcludeList(); + + void SetViewExcludeList(std::vector v); + std::vector GetViewExcludeList(); + /** * Sets the active page within the window. * * @param in * identifies the new active page, or null for no * active page */ void SetActivePage(SmartPointer in); IWorkbench* GetWorkbench(); IPartService* GetPartService(); ISelectionService* GetSelectionService(); SmartPointer OpenPage(const std::string& perspectiveId, IAdaptable* input); SmartPointer OpenPage(IAdaptable* input); //TODO menu manager //virtual void* GetMenuManager() = 0; virtual bool SaveState(IMemento::Pointer memento); /** * Called when this window is about to be closed. * * Subclasses may overide to add code that returns false to * prevent closing under certain conditions. */ virtual bool OkToClose(); bool RestoreState(IMemento::Pointer memento, SmartPointer< IPerspectiveDescriptor> activeDescriptor); /** * Returns the number. This corresponds to a page number in a window or a * window number in the workbench. */ int GetNumber(); /** *

* Indicates the start of a large update within this window. This is used to * disable CPU-intensive, change-sensitive services that were temporarily * disabled in the midst of large changes. This method should always be * called in tandem with largeUpdateEnd, and the event loop * should not be allowed to spin before that method is called. *

*

* Important: always use with largeUpdateEnd! *

* * @since 3.1 */ void LargeUpdateStart(); /** *

* Indicates the end of a large update within this window. This is used to * re-enable services that were temporarily disabled in the midst of large * changes. This method should always be called in tandem with * largeUpdateStart, and the event loop should not be * allowed to spin before this method is called. *

*

* Important: always protect this call by using finally! *

* * @since 3.1 */ void LargeUpdateEnd(); protected: friend class WorkbenchConfigurer; friend class WorkbenchWindowConfigurer; friend class WorkbenchWindowConfigurer::WindowActionBarConfigurer; friend class Workbench; friend class LayoutPartSash; friend class EditorSashContainer; friend class WorkbenchPage; friend class DetachedWindow; /** * Returns the GUI dependent page composite, under which the window's * pages create their controls. */ void* GetPageComposite(); /** * Creates and remembers the client composite, under which workbench pages * create their controls. * * @since 3.0 */ virtual void* CreatePageComposite(void* parent) = 0; /** * Creates the contents of the workbench window, including trim controls and * the client composite. This MUST create the client composite via a call to * createClientComposite. * * @since 3.0 */ void* CreateContents(Shell::Pointer parent); /** * Creates the default contents and layout of the shell. * * @param shell * the shell */ virtual void CreateDefaultContents(Shell::Pointer shell); /** * Returns the unique object that applications use to configure this window. *

* IMPORTANT This method is declared package-private to prevent regular * plug-ins from downcasting IWorkbenchWindow to WorkbenchWindow and getting * hold of the workbench window configurer that would allow them to tamper * with the workbench window. The workbench window configurer is available * only to the application. *

*/ WorkbenchWindowConfigurer::Pointer GetWindowConfigurer(); bool CanHandleShellCloseEvent(); /* * @see berry::Window#configureShell(Shell::Pointer) */ void ConfigureShell(Shell::Pointer shell); ShellPool::Pointer GetDetachedWindowPool(); /** * Fills the window's real action bars. * * @param flags * indicate which bars to fill */ void FillActionBars(int flags); /** * The WorkbenchWindow implementation of this method * delegates to the window configurer. * * @since 3.0 */ Point GetInitialSize(); /** * Returns the default page input for workbench pages opened in this window. * * @return the default page input or null if none * @since 3.1 */ IAdaptable* GetDefaultPageInput(); bool IsClosing(); /** * Opens a new page. Assumes that busy cursor is active. *

* Note: Since release 2.0, a window is limited to contain at most * one page. If a page exist in the window when this method is used, then * another window is created for the new page. Callers are strongly * recommended to use the IWorkbench.openPerspective APIs to * programmatically show a perspective. *

*/ SmartPointer BusyOpenPage(const std::string& perspID, IAdaptable* input); bool ClosePage(SmartPointer in, bool save); /** * Makes the window visible and frontmost. */ void MakeVisible(); /** * The composite under which workbench pages create their controls. * * @since 3.0 */ void* pageComposite; private: /** * Constant indicating that all the actions bars should be filled. * * @since 3.0 */ static const int FILL_ALL_ACTION_BARS; ShellPool::Pointer detachedWindowShells; /** * Object for configuring this workbench window. Lazily initialized to an * instance unique to this window. * * @since 3.0 */ WorkbenchWindowConfigurer::Pointer windowConfigurer; WorkbenchWindowAdvisor* windowAdvisor; ActionBarAdvisor::Pointer actionBarAdvisor; int number; /** * The number of large updates that are currently going on. If this is * number is greater than zero, then UI updateActionBars is a no-op. */ int largeUpdates; bool closing; bool shellActivated; bool updateDisabled; /** * The map of services maintained by the workbench window. These services * are initialized during workbench window during the * {@link #configureShell(Shell)}. */ ServiceLocator::Pointer serviceLocator; bool emptyWindowContentsCreated; void* emptyWindowContents; Rectangle normalBounds; bool asMaximizedState; IPerspectiveListener::Events perspectiveEvents; WWinPartService partService; + std::vector perspectiveExcludeList; + std::vector viewExcludeList; + struct ServiceLocatorOwner: public IDisposable { ServiceLocatorOwner(WorkbenchWindow* wnd); WorkbenchWindow* window; void Dispose(); }; IDisposable::Pointer serviceLocatorOwner; class PageList { private: // List of pages in the order they were created; std::list > pagesInCreationOrder; // List of pages where the top is the last activated. std::list > pagesInActivationOrder; // The page explicitly activated SmartPointer active; public: typedef std::list >::iterator iterator; bool Add(SmartPointer object); iterator Begin(); iterator End(); void Clear(); bool Contains(SmartPointer object); bool Remove(SmartPointer object); bool IsEmpty(); const std::list >& GetPages(); void SetActive(SmartPointer page); SmartPointer GetActive(); SmartPointer GetNextActive(); }; PageList pageList; /** * Notifies interested parties (namely the advisor) that the window is about * to be opened. * * @since 3.1 */ void FireWindowOpening(); /** * Notifies interested parties (namely the advisor) that the window has been * restored from a previously saved state. * * @throws WorkbenchException * passed through from the advisor * @since 3.1 */ void FireWindowRestored(); /** * Notifies interested parties (namely the advisor) that the window has been * created. * * @since 3.1 */ void FireWindowCreated(); /** * Notifies interested parties (namely the advisor and the window listeners) * that the window has been opened. * * @since 3.1 */ void FireWindowOpened(); /** * Notifies interested parties (namely the advisor) that the window's shell * is closing. Allows the close to be vetoed. * * @return true if the close should proceed, * false if it should be canceled * @since 3.1 */ bool FireWindowShellClosing(); /** * Notifies interested parties (namely the advisor and the window listeners) * that the window has been closed. * * @since 3.1 */ void FireWindowClosed(); // /** // * Fires page activated // */ // void FirePageActivated(IWorkbenchPage::Pointer page); // // /** // * Fires page closed // */ // void FirePageClosed(IWorkbenchPage::Pointer page); // // /** // * Fires page opened // */ // void FirePageOpened(IWorkbenchPage::Pointer page); /** * Fires perspective activated */ void FirePerspectiveActivated(SmartPointer page, IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective deactivated. * * @since 3.2 */ void FirePerspectivePreDeactivate(SmartPointer page, IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective deactivated. * * @since 3.1 */ void FirePerspectiveDeactivated(SmartPointer page, IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective changed */ void FirePerspectiveChanged(SmartPointer , IPerspectiveDescriptor::Pointer perspective, const std::string& changeId); /** * Fires perspective changed for an affected part */ void FirePerspectiveChanged(SmartPointer , IPerspectiveDescriptor::Pointer perspective, IWorkbenchPartReference::Pointer partRef, const std::string& changeId); /** * Fires perspective closed */ void FirePerspectiveClosed(SmartPointer , IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective opened */ void FirePerspectiveOpened(SmartPointer , IPerspectiveDescriptor::Pointer perspective); /** * Fires perspective saved as. * * @since 3.1 */ void FirePerspectiveSavedAs(SmartPointer , IPerspectiveDescriptor::Pointer oldPerspective, IPerspectiveDescriptor::Pointer newPerspective); /** * Returns the workbench advisor. Assumes the workbench has been created * already. *

* IMPORTANT This method is declared private to prevent regular plug-ins * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of * the workbench advisor that would allow them to tamper with the workbench. * The workbench advisor is internal to the application. *

*/ /* private - DO NOT CHANGE */ WorkbenchAdvisor* GetAdvisor(); /** * Returns the window advisor, creating a new one for this window if needed. *

* IMPORTANT This method is declared private to prevent regular plug-ins * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of * the window advisor that would allow them to tamper with the window. The * window advisor is internal to the application. *

*/ /* private - DO NOT CHANGE */ WorkbenchWindowAdvisor* GetWindowAdvisor(); /** * Returns the action bar advisor, creating a new one for this window if * needed. *

* IMPORTANT This method is declared private to prevent regular plug-ins * from downcasting IWorkbenchWindow to WorkbenchWindow and getting hold of * the action bar advisor that would allow them to tamper with the window's * action bars. The action bar advisor is internal to the application. *

*/ /* private - DO NOT CHANGE */ ActionBarAdvisor::Pointer GetActionBarAdvisor(); /* * Returns the IWorkbench implementation. */ Workbench* GetWorkbenchImpl(); bool UnableToRestorePage(IMemento::Pointer pageMem); /** * Close the window. * * Assumes that busy cursor is active. */ bool BusyClose(); /** * Unconditionally close this window. Assumes the proper flags have been set * correctly (e.i. closing and updateDisabled) */ bool HardClose(); /** * Close all of the pages. */ void CloseAllPages(); /** * Save all of the pages. Returns true if the operation succeeded. */ bool SaveAllPages(bool bConfirm); void ShowEmptyWindowContents(); void HideEmptyWindowContents(); struct ShellActivationListener: public IShellListener { ShellActivationListener(WorkbenchWindow::Pointer window); void ShellActivated(ShellEvent::Pointer event); void ShellDeactivated(ShellEvent::Pointer event); private: WorkbenchWindow::WeakPtr window; }; IShellListener::Pointer shellActivationListener; /** * Hooks a listener to track the activation and deactivation of the window's * shell. Notifies the active part and editor of the change */ void TrackShellActivation(Shell::Pointer shell); struct ControlResizeListener: public GuiTk::IControlListener { ControlResizeListener(WorkbenchWindow* window); GuiTk::IControlListener::Events::Types GetEventTypes() const; void ControlMoved(GuiTk::ControlEvent::Pointer e); void ControlResized(GuiTk::ControlEvent::Pointer e); private: void SaveBounds(); WorkbenchWindow* window; }; GuiTk::IControlListener::Pointer controlResizeListener; /** * Hooks a listener to track the resize of the window's shell. Stores the * new bounds if in normal state - that is, not in minimized or maximized * state) */ void TrackShellResize(Shell::Pointer newShell); }; } #endif /*BERRYWORKBENCHWINDOW_H_*/ diff --git a/Plugins/org.mitk.gui.qt.datamanager/plugin.xml b/Plugins/org.mitk.gui.qt.datamanager/plugin.xml index d238dfdf6f..6c3dc5c4fe 100644 --- a/Plugins/org.mitk.gui.qt.datamanager/plugin.xml +++ b/Plugins/org.mitk.gui.qt.datamanager/plugin.xml @@ -1,32 +1,32 @@ + name="MITK General" + id="org.mitk.views.general"/> diff --git a/Plugins/org.mitk.gui.qt.datamanagerlight/plugin.xml b/Plugins/org.mitk.gui.qt.datamanagerlight/plugin.xml index 0e7ca74a82..083781134e 100644 --- a/Plugins/org.mitk.gui.qt.datamanagerlight/plugin.xml +++ b/Plugins/org.mitk.gui.qt.datamanagerlight/plugin.xml @@ -1,16 +1,16 @@ diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/plugin.xml b/Plugins/org.mitk.gui.qt.diffusionimaging/plugin.xml index db8942459c..b62e7906c4 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/plugin.xml +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/plugin.xml @@ -1,188 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + - + class="QmitkQBallReconstructionView"> + Q-Ball reconstruction view + + - - + icon="resources/dwiimport.png"> + Diffusion DICOM data import + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + This is a short information about this perspective + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp index 3fa659c034..9ab9b5f24a 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDiffusionImagingPublicPerspective.cpp @@ -1,78 +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. ===================================================================*/ #include "QmitkDiffusionImagingPublicPerspective.h" #include "berryIViewLayout.h" QmitkDiffusionImagingPublicPerspective::QmitkDiffusionImagingPublicPerspective() { - } QmitkDiffusionImagingPublicPerspective::QmitkDiffusionImagingPublicPerspective(const QmitkDiffusionImagingPublicPerspective& other) { Q_UNUSED(other) throw std::runtime_error("Copy constructor not implemented"); } void QmitkDiffusionImagingPublicPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .2f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mitk.leftcontrols", berry::IPageLayout::BOTTOM, 0.125f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneView("org.mitk.views.imagenavigator", false, berry::IPageLayout::BOTTOM, 0.8f, "org.mitk.leftcontrols"); layout->AddStandaloneView("org.mitk.views.perspectiveswitcher", false, berry::IPageLayout::BOTTOM, 0.99f, "org.mitk.views.imagenavigator"); // layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", // berry::IPageLayout::TOP, 0.9f, "org.mitk.views.perspectiveswitcher",false); left->AddView("org.mitk.views.diffusionpreprocessing"); left->AddView("org.mitk.views.tensorreconstruction"); left->AddView("org.mitk.views.qballreconstruction"); left->AddView("org.mitk.views.diffusionquantification"); left->AddView("org.mitk.views.diffusiondicomimport"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.diffusionpreprocessing"); lo->SetCloseable(false); lo = layout->GetViewLayout("org.mitk.views.qballreconstruction"); lo->SetCloseable(false); lo = layout->GetViewLayout("org.mitk.views.tensorreconstruction"); lo->SetCloseable(false); lo = layout->GetViewLayout("org.mitk.views.diffusionquantification"); lo->SetCloseable(false); lo = layout->GetViewLayout("org.mitk.views.diffusiondicomimport"); lo->SetCloseable(false); //berry::IFolderLayout::Pointer right2 = // layout->CreateFolder("right2", berry::IPageLayout::BOTTOM, 0.5f, "right"); - -} +} \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/files.cmake b/Plugins/org.mitk.gui.qt.diffusionimagingapp/files.cmake index 05beffb8a1..290dbb4f1f 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/files.cmake +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/files.cmake @@ -1,95 +1,103 @@ set(SRC_CPP_FILES QmitkDiffusionImagingAppApplication.cpp QmitkDiffusionImagingAppWorkbenchAdvisor.cpp ) set(INTERNAL_CPP_FILES QmitkDiffusionApplicationPlugin.cpp QmitkDiffusionImagingAppIntroPart.cpp Perspectives/QmitkDiffusionImagingAppPerspective.cpp Perspectives/QmitkWelcomePerspective.cpp Perspectives/QmitkDIAppConnectomicsPerspective.cpp Perspectives/QmitkDIAppDicomImportPerspective.cpp - Perspectives/QmitkDIAppFiberTractographyPerspective.cpp Perspectives/QmitkDIAppIVIMPerspective.cpp Perspectives/QmitkDIAppPreprocessingReconstructionPerspective.cpp Perspectives/QmitkDIAppQuantificationPerspective.cpp Perspectives/QmitkDIAppTBSSPerspective.cpp Perspectives/QmitkDIAppUtilityPerspective.cpp Perspectives/QmitkDIAppImageProcessingPerspective.cpp Perspectives/QmitkDIAppSyntheticDataGenerationPerspective.cpp Perspectives/QmitkDIAppRegistrationPerspective.cpp Perspectives/QmitkDIAppVisualizationPerspective.cpp + +# new perspectives + Perspectives/QmitkGibbsTractographyPerspective.cpp + Perspectives/QmitkStreamlineTractographyPerspective.cpp + Perspectives/QmitkProbabilisticTractographyPerspective.cpp ) set(UI_FILES src/internal/QmitkWelcomeScreenViewControls.ui ) set(MOC_H_FILES src/internal/QmitkDiffusionImagingAppIntroPart.h src/internal/QmitkDiffusionApplicationPlugin.h src/QmitkDiffusionImagingAppApplication.h src/internal/Perspectives/QmitkDiffusionImagingAppPerspective.h src/internal/Perspectives/QmitkWelcomePerspective.h src/internal/Perspectives/QmitkDIAppConnectomicsPerspective.h src/internal/Perspectives/QmitkDIAppDicomImportPerspective.h - src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h src/internal/Perspectives/QmitkDIAppIVIMPerspective.h src/internal/Perspectives/QmitkDIAppPreprocessingReconstructionPerspective.h src/internal/Perspectives/QmitkDIAppQuantificationPerspective.h src/internal/Perspectives/QmitkDIAppTBSSPerspective.h src/internal/Perspectives/QmitkDIAppUtilityPerspective.h src/internal/Perspectives/QmitkDIAppImageProcessingPerspective.h src/internal/Perspectives/QmitkDIAppSyntheticDataGenerationPerspective.h src/internal/Perspectives/QmitkDIAppRegistrationPerspective.h src/internal/Perspectives/QmitkDIAppVisualizationPerspective.h + +# new perspectives + src/internal/Perspectives/QmitkGibbsTractographyPerspective.h + src/internal/Perspectives/QmitkStreamlineTractographyPerspective.h + src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.h ) set(CACHED_RESOURCE_FILES # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench plugin.xml resources/icon_dicom.xpm resources/diffusionimaging.png resources/preprocessing.png resources/Measurement_48.png resources/volvis.png resources/perspectives/diffusionimaging.png resources/perspectives/icon_home.png resources/perspectives/connectomics.png resources/perspectives/dicomimport.png resources/perspectives/tractography.png resources/perspectives/ivim.png resources/perspectives/preprocessingreconstruction.png resources/perspectives/quantification.png resources/perspectives/tbss.png resources/perspectives/utilities.png resources/perspectives/imageProcessing.png resources/perspectives/registration.png resources/perspectives/phantomData2.png resources/perspectives/eye.png resources/perspectives/registration.xpm resources/perspectives/chart.png resources/perspectives/preprocessing.png resources/perspectives/syntheticdata.png ) set(QRC_FILES # uncomment the following line if you want to use Qt resources resources/welcome/QmitkWelcomeScreenView.qrc resources/org_mitk_gui_qt_diffusionimagingapp.qrc ) # set(CPP_FILES) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/plugin.xml b/Plugins/org.mitk.gui.qt.diffusionimagingapp/plugin.xml index 61d7c39bad..4c3a284b86 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/plugin.xml +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/plugin.xml @@ -1,93 +1,109 @@ - + icon="resources/perspectives/preprocessing.png"> + Preprocessing of raw diffusion data and diffusion propagator modeling + + - - - - + + + + + + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp index d6fb014c02..75e13e53c0 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp @@ -1,79 +1,86 @@ /*=================================================================== 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 "QmitkDiffusionImagingAppWorkbenchAdvisor.h" #include "internal/QmitkDiffusionApplicationPlugin.h" #include #include #include #include #include #include const std::string QmitkDiffusionImagingAppWorkbenchAdvisor::WELCOME_PERSPECTIVE_ID = "org.mitk.diffusionimagingapp.perspectives.welcome"; void QmitkDiffusionImagingAppWorkbenchAdvisor::Initialize(berry::IWorkbenchConfigurer::Pointer configurer) { berry::QtWorkbenchAdvisor::Initialize(configurer); configurer->SetSaveAndRestore(true); } berry::WorkbenchWindowAdvisor* QmitkDiffusionImagingAppWorkbenchAdvisor::CreateWorkbenchWindowAdvisor( berry::IWorkbenchWindowConfigurer::Pointer configurer) { std::vector perspExcludeList; perspExcludeList.push_back( std::string("org.blueberry.uitest.util.EmptyPerspective") ); perspExcludeList.push_back( std::string("org.blueberry.uitest.util.EmptyPerspective2") ); perspExcludeList.push_back( std::string("org.mitk.coreapp.defaultperspective") ); perspExcludeList.push_back( std::string("org.mitk.extapp.defaultperspective") ); perspExcludeList.push_back( std::string("org.mitk.perspectives.publicdiffusionimaging") ); perspExcludeList.push_back( std::string("org.mitk.perspectives.diffusionimaginginternal") ); // Exclude the help perspective from org.blueberry.ui.qt.help from // the normal perspective list. // The perspective gets a dedicated menu entry in the help menu perspExcludeList.push_back("org.blueberry.perspectives.help"); std::vector viewExcludeList; + viewExcludeList.push_back( std::string("org.mitk.views.controlvisualizationpropertiesview") ); + viewExcludeList.push_back( std::string("org.mitk.views.imagenavigator") ); + viewExcludeList.push_back( std::string("org.mitk.views.datamanager") ); + viewExcludeList.push_back( std::string("org.mitk.views.modules") ); + viewExcludeList.push_back( std::string("org.blueberry.ui.internal.introview") ); configurer->SetInitialSize(berry::Point(1000,770)); QmitkExtWorkbenchWindowAdvisor* advisor = new QmitkExtWorkbenchWindowAdvisor(this, configurer); - advisor->ShowViewMenuItem(false); - advisor->ShowNewWindowMenuItem(false); - advisor->ShowClosePerspectiveMenuItem(false); + advisor->ShowViewMenuItem(true); + advisor->ShowNewWindowMenuItem(true); + advisor->ShowClosePerspectiveMenuItem(true); advisor->SetPerspectiveExcludeList(perspExcludeList); advisor->SetViewExcludeList(viewExcludeList); advisor->ShowViewToolbar(false); - advisor->ShowPerspectiveToolbar(true); + advisor->ShowPerspectiveToolbar(false); advisor->ShowVersionInfo(false); + advisor->EnableCandyStore(true); advisor->ShowMitkVersionInfo(false); + advisor->ShowMemoryIndicator(false); advisor->SetProductName("MITK Diffusion"); advisor->SetWindowIcon(":/org.mitk.gui.qt.diffusionimagingapp/app-icon.png"); return advisor; } std::string QmitkDiffusionImagingAppWorkbenchAdvisor::GetInitialWindowPerspectiveId() { return WELCOME_PERSPECTIVE_ID; } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppConnectomicsPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppConnectomicsPerspective.cpp index 545efe794d..5d453d89be 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppConnectomicsPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppConnectomicsPerspective.cpp @@ -1,57 +1,57 @@ /*=================================================================== 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 "QmitkDIAppConnectomicsPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppConnectomicsPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.connectomicsstatistics"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.connectomicsstatistics"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.connectomicsnetworkoperations"); lo = layout->GetViewLayout("org.mitk.views.connectomicsnetworkoperations"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.connectomicsdata"); lo = layout->GetViewLayout("org.mitk.views.connectomicsdata"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppDicomImportPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppDicomImportPerspective.cpp index 5ddd1f377c..6e23a31e1f 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppDicomImportPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppDicomImportPerspective.cpp @@ -1,49 +1,49 @@ /*=================================================================== 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 "QmitkDIAppDicomImportPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppDicomImportPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.diffusiondicomimport"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.diffusiondicomimport"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.cpp deleted file mode 100644 index c53e45079f..0000000000 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/*=================================================================== - -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 "QmitkDIAppFiberTractographyPerspective.h" -#include "berryIViewLayout.h" - -void QmitkDIAppFiberTractographyPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) -{ - std::string editorArea = layout->GetEditorArea(); - - layout->AddStandaloneView("org.mitk.views.datamanager", - false, berry::IPageLayout::LEFT, 0.3f, editorArea); - - layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", - false, berry::IPageLayout::BOTTOM, 0.15f, "org.mitk.views.datamanager"); - - berry::IFolderLayout::Pointer left = - layout->CreateFolder("org.mitk.diffusionimaginginternal.leftcontrols2", - berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); - - berry::IFolderLayout::Pointer bottomleft = - layout->CreateFolder("org.mitk.diffusionimaginginternal.leftcontrols", - berry::IPageLayout::BOTTOM, 0.5f, "org.mitk.diffusionimaginginternal.leftcontrols2"); - - layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", - berry::IPageLayout::BOTTOM, .6f, "org.mitk.diffusionimaginginternal.leftcontrols", false); - - ///////////////////////////////////////////// - // add the views - ///////////////////////////////////////////// - - left->AddView("org.mitk.views.gibbstracking"); - berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.gibbstracking"); - lo->SetCloseable(false); - - left->AddView("org.mitk.views.stochasticfibertracking"); - lo = layout->GetViewLayout("org.mitk.views.stochasticfibertracking"); - lo->SetCloseable(false); - - left->AddView("org.mitk.views.streamlinetracking"); - lo = layout->GetViewLayout("org.mitk.views.streamlinetracking"); - lo->SetCloseable(false); - - bottomleft->AddView("org.mitk.views.fiberextraction"); - berry::IViewLayout::Pointer lo2 = layout->GetViewLayout("org.mitk.views.fiberextraction"); - lo2->SetCloseable(false); - - bottomleft->AddView("org.mitk.views.fiberprocessing"); - lo2 = layout->GetViewLayout("org.mitk.views.fiberprocessing"); - lo2->SetCloseable(false); - - bottomleft->AddView("org.mitk.views.segmentation"); - lo2 = layout->GetViewLayout("org.mitk.views.segmentation"); - lo2->SetCloseable(false); -} diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppIVIMPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppIVIMPerspective.cpp index 2873335651..dfee30f216 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppIVIMPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppIVIMPerspective.cpp @@ -1,52 +1,52 @@ /*=================================================================== 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 "QmitkDIAppIVIMPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppIVIMPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.ivim"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.ivim"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.segmentation"); lo = layout->GetViewLayout("org.mitk.views.segmentation"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppImageProcessingPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppImageProcessingPerspective.cpp index 7118b6740e..b56b29b31d 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppImageProcessingPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppImageProcessingPerspective.cpp @@ -1,56 +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 "QmitkDIAppImageProcessingPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppImageProcessingPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, 0.15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.segmentation"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.segmentation"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.segmentationutilities"); lo = layout->GetViewLayout("org.mitk.views.segmentationutilities"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.basicimageprocessing"); lo = layout->GetViewLayout("org.mitk.views.basicimageprocessing"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppPreprocessingReconstructionPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppPreprocessingReconstructionPerspective.cpp index 61d085dea3..c74d6cba29 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppPreprocessingReconstructionPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppPreprocessingReconstructionPerspective.cpp @@ -1,76 +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. ===================================================================*/ #include "QmitkDIAppPreprocessingReconstructionPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppPreprocessingReconstructionPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mitk.views.leftcontrols2", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); berry::IFolderLayout::Pointer bottomleft = layout->CreateFolder("org.mitk.views.leftcontrols", berry::IPageLayout::BOTTOM, 0.5f, "org.mitk.views.leftcontrols2"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .6f, "org.mitk.views.leftcontrols", false); ///////////////////////////////////////////// // add the views ///////////////////////////////////////////// left->AddView("org.mitk.views.diffusionpreprocessing"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.diffusionpreprocessing"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.diffusionregistrationview"); lo = layout->GetViewLayout("org.mitk.views.diffusionregistrationview"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.tensorreconstruction"); lo = layout->GetViewLayout("org.mitk.views.tensorreconstruction"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.qballreconstruction"); lo = layout->GetViewLayout("org.mitk.views.qballreconstruction"); - lo->SetCloseable(false); + bottomleft->AddView("org.mitk.views.diffusionquantification"); berry::IViewLayout::Pointer lo2 = layout->GetViewLayout("org.mitk.views.diffusionquantification"); lo2->SetCloseable(false); bottomleft->AddView("org.mitk.views.odfmaximaextraction"); lo2 = layout->GetViewLayout("org.mitk.views.odfmaximaextraction"); lo2->SetCloseable(false); bottomleft->AddView("org.mitk.views.odfdetails"); lo2 = layout->GetViewLayout("org.mitk.views.odfdetails"); lo2->SetCloseable(false); bottomleft->AddView("org.mitk.views.denoisingview"); lo2 = layout->GetViewLayout("org.mitk.views.denoisingview"); lo2->SetCloseable(false); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppQuantificationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppQuantificationPerspective.cpp index 8ff05fe48b..19c2f4d3bc 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppQuantificationPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppQuantificationPerspective.cpp @@ -1,60 +1,60 @@ /*=================================================================== 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 "QmitkDIAppQuantificationPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppQuantificationPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.partialvolumeanalysisview"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.partialvolumeanalysisview"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.tractbasedspatialstatistics"); lo = layout->GetViewLayout("org.mitk.views.tractbasedspatialstatistics"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.imagestatistics"); lo = layout->GetViewLayout("org.mitk.views.imagestatistics"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.measurement"); lo = layout->GetViewLayout("org.mitk.views.measurement"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppRegistrationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppRegistrationPerspective.cpp index e4e0cf805d..befc5502f8 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppRegistrationPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppRegistrationPerspective.cpp @@ -1,56 +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 "QmitkDIAppRegistrationPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppRegistrationPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.rigidregistration"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.rigidregistration"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.pointbasedregistration"); lo = layout->GetViewLayout("org.mitk.views.pointbasedregistration"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.diffusionregistrationview"); lo = layout->GetViewLayout("org.mitk.views.diffusionregistrationview"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppSyntheticDataGenerationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppSyntheticDataGenerationPerspective.cpp index 653aa0b8c7..d8bc4d590c 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppSyntheticDataGenerationPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppSyntheticDataGenerationPerspective.cpp @@ -1,64 +1,64 @@ /*=================================================================== 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 "QmitkDIAppSyntheticDataGenerationPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppSyntheticDataGenerationPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.fiberfoxview"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.fiberfoxview"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.fiberprocessing"); lo = layout->GetViewLayout("org.mitk.views.fiberprocessing"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.fiberextraction"); lo = layout->GetViewLayout("org.mitk.views.fiberextraction"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.fieldmapgenerator"); lo = layout->GetViewLayout("org.mitk.views.fieldmapgenerator"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.segmentation"); lo = layout->GetViewLayout("org.mitk.views.segmentation"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp index 2313d4ef0d..d6ad86179f 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp @@ -1,49 +1,49 @@ /*=================================================================== 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 "QmitkDIAppTBSSPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppTBSSPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.tractbasedspatialstatistics"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.tractbasedspatialstatistics"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTrackingEvaluationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTrackingEvaluationPerspective.cpp index d98a9994fc..184abd2bc0 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTrackingEvaluationPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTrackingEvaluationPerspective.cpp @@ -1,48 +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. ===================================================================*/ #include "QmitkDIAppTrackingEvaluationPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppTrackingEvaluationPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mitk.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.artificialqballevaluation"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.artificialqballevaluation"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppUtilityPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppUtilityPerspective.cpp index b019aee55e..c553c04c07 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppUtilityPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppUtilityPerspective.cpp @@ -1,52 +1,52 @@ /*=================================================================== 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 "QmitkDIAppUtilityPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppUtilityPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.properties"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.properties"); - lo->SetCloseable(false); + left->AddView("org.blueberry.views.logview"); lo = layout->GetViewLayout("org.blueberry.views.logview"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppVisualizationPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppVisualizationPerspective.cpp index 877800d7fb..7788a6f47f 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppVisualizationPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppVisualizationPerspective.cpp @@ -1,56 +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 "QmitkDIAppVisualizationPerspective.h" #include "berryIViewLayout.h" void QmitkDIAppVisualizationPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// left->AddView("org.mitk.views.volumevisualization"); berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.volumevisualization"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.screenshotmaker"); lo = layout->GetViewLayout("org.mitk.views.screenshotmaker"); - lo->SetCloseable(false); + left->AddView("org.mitk.views.moviemaker"); lo = layout->GetViewLayout("org.mitk.views.moviemaker"); - lo->SetCloseable(false); + } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkGibbsTractographyPerspective.cpp similarity index 82% copy from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp copy to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkGibbsTractographyPerspective.cpp index 2313d4ef0d..de5bb8dd42 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkGibbsTractographyPerspective.cpp @@ -1,49 +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. ===================================================================*/ -#include "QmitkDIAppTBSSPerspective.h" +#include "QmitkGibbsTractographyPerspective.h" #include "berryIViewLayout.h" -void QmitkDIAppTBSSPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) +void QmitkGibbsTractographyPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// - left->AddView("org.mitk.views.tractbasedspatialstatistics"); - berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.tractbasedspatialstatistics"); - lo->SetCloseable(false); - + left->AddView("org.mitk.views.tensorreconstruction"); + left->AddView("org.mitk.views.qballreconstruction"); + left->AddView("org.mitk.views.gibbstracking"); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkGibbsTractographyPerspective.h similarity index 66% copy from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h copy to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkGibbsTractographyPerspective.h index bd4611e7e6..4df9c889c0 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkGibbsTractographyPerspective.h @@ -1,36 +1,36 @@ /*=================================================================== 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 QmitkDIAppFiberTractographyPerspective_H_ -#define QmitkDIAppFiberTractographyPerspective_H_ +#ifndef QmitkGibbsTractographyPerspective_H_ +#define QmitkGibbsTractographyPerspective_H_ #include -class QmitkDIAppFiberTractographyPerspective : public QObject, public berry::IPerspectiveFactory +class QmitkGibbsTractographyPerspective : public QObject, public berry::IPerspectiveFactory { Q_OBJECT Q_INTERFACES(berry::IPerspectiveFactory) public: - QmitkDIAppFiberTractographyPerspective() {} - ~QmitkDIAppFiberTractographyPerspective() {} + QmitkGibbsTractographyPerspective() {} + ~QmitkGibbsTractographyPerspective() {} void CreateInitialLayout(berry::IPageLayout::Pointer layout); }; -#endif /* QmitkDIAppFiberTractographyPerspective_H_ */ +#endif /* QmitkGibbsTractographyPerspective_H_ */ diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.cpp similarity index 82% copy from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp copy to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.cpp index 2313d4ef0d..ff6ee899af 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.cpp @@ -1,49 +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. ===================================================================*/ -#include "QmitkDIAppTBSSPerspective.h" +#include "QmitkProbabilisticTractographyPerspective.h" #include "berryIViewLayout.h" -void QmitkDIAppTBSSPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) +void QmitkProbabilisticTractographyPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// - left->AddView("org.mitk.views.tractbasedspatialstatistics"); - berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.tractbasedspatialstatistics"); - lo->SetCloseable(false); - + left->AddView("org.mitk.views.diffusionpreprocessing"); + left->AddView("org.mitk.views.segmentation"); + left->AddView("org.mitk.views.stochasticfibertracking"); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.h similarity index 65% copy from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h copy to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.h index bd4611e7e6..010ca37c6d 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.h @@ -1,36 +1,36 @@ /*=================================================================== 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 QmitkDIAppFiberTractographyPerspective_H_ -#define QmitkDIAppFiberTractographyPerspective_H_ +#ifndef QmitkProbabilisticTractographyPerspective_H_ +#define QmitkProbabilisticTractographyPerspective_H_ #include -class QmitkDIAppFiberTractographyPerspective : public QObject, public berry::IPerspectiveFactory +class QmitkProbabilisticTractographyPerspective : public QObject, public berry::IPerspectiveFactory { Q_OBJECT Q_INTERFACES(berry::IPerspectiveFactory) public: - QmitkDIAppFiberTractographyPerspective() {} - ~QmitkDIAppFiberTractographyPerspective() {} + QmitkProbabilisticTractographyPerspective() {} + ~QmitkProbabilisticTractographyPerspective() {} void CreateInitialLayout(berry::IPageLayout::Pointer layout); }; -#endif /* QmitkDIAppFiberTractographyPerspective_H_ */ +#endif /* QmitkProbabilisticTractographyPerspective_H_ */ diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkStreamlineTractographyPerspective.cpp similarity index 82% copy from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp copy to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkStreamlineTractographyPerspective.cpp index 2313d4ef0d..1223c6f931 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppTBSSPerspective.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkStreamlineTractographyPerspective.cpp @@ -1,49 +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. ===================================================================*/ -#include "QmitkDIAppTBSSPerspective.h" +#include "QmitkStreamlineTractographyPerspective.h" #include "berryIViewLayout.h" -void QmitkDIAppTBSSPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) +void QmitkStreamlineTractographyPerspective::CreateInitialLayout(berry::IPageLayout::Pointer layout) { ///////////////////////////////////////////////////// // all di-app perspectives should have the following: ///////////////////////////////////////////////////// std::string editorArea = layout->GetEditorArea(); layout->AddStandaloneView("org.mitk.views.datamanager", false, berry::IPageLayout::LEFT, 0.3f, editorArea); layout->AddStandaloneView("org.mitk.views.controlvisualizationpropertiesview", false, berry::IPageLayout::BOTTOM, .15f, "org.mitk.views.datamanager"); berry::IFolderLayout::Pointer left = layout->CreateFolder("org.mbi.diffusionimaginginternal.leftcontrols", berry::IPageLayout::BOTTOM, 0.1f, "org.mitk.views.controlvisualizationpropertiesview"); layout->AddStandaloneViewPlaceholder("org.mitk.views.imagenavigator", berry::IPageLayout::BOTTOM, .4f, "org.mbi.diffusionimaginginternal.leftcontrols", false); ///////////////////////////////////////////// // here goes the perspective specific stuff ///////////////////////////////////////////// - left->AddView("org.mitk.views.tractbasedspatialstatistics"); - berry::IViewLayout::Pointer lo = layout->GetViewLayout("org.mitk.views.tractbasedspatialstatistics"); - lo->SetCloseable(false); - + left->AddView("org.mitk.views.tensorreconstruction"); + left->AddView("org.mitk.views.segmentation"); + left->AddView("org.mitk.views.streamlinetracking"); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkStreamlineTractographyPerspective.h similarity index 69% copy from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h copy to Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkStreamlineTractographyPerspective.h index bd4611e7e6..ba0347df7c 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkStreamlineTractographyPerspective.h @@ -1,36 +1,36 @@ /*=================================================================== 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 QmitkDIAppFiberTractographyPerspective_H_ -#define QmitkDIAppFiberTractographyPerspective_H_ +#ifndef QmitkStreamlineTractographyPerspective_H_ +#define QmitkStreamlineTractographyPerspective_H_ #include -class QmitkDIAppFiberTractographyPerspective : public QObject, public berry::IPerspectiveFactory +class QmitkStreamlineTractographyPerspective : public QObject, public berry::IPerspectiveFactory { Q_OBJECT Q_INTERFACES(berry::IPerspectiveFactory) public: - QmitkDIAppFiberTractographyPerspective() {} - ~QmitkDIAppFiberTractographyPerspective() {} + QmitkStreamlineTractographyPerspective() {} + ~QmitkStreamlineTractographyPerspective() {} void CreateInitialLayout(berry::IPageLayout::Pointer layout); }; -#endif /* QmitkDIAppFiberTractographyPerspective_H_ */ +#endif /* QmitkStreamlineTractographyPerspective_H_ */ diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionApplicationPlugin.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionApplicationPlugin.cpp index 77cb0da33d..d43779f683 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionApplicationPlugin.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionApplicationPlugin.cpp @@ -1,114 +1,121 @@ /*=================================================================== 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 "QmitkDiffusionApplicationPlugin.h" #include "src/QmitkDiffusionImagingAppApplication.h" #include "src/internal/Perspectives/QmitkWelcomePerspective.h" #include "src/internal/QmitkDiffusionImagingAppIntroPart.h" #include "src/internal/Perspectives/QmitkDiffusionImagingAppPerspective.h" #include "src/internal/Perspectives/QmitkDIAppConnectomicsPerspective.h" #include "src/internal/Perspectives/QmitkDIAppDicomImportPerspective.h" -#include "src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h" #include "src/internal/Perspectives/QmitkDIAppIVIMPerspective.h" #include "src/internal/Perspectives/QmitkDIAppImageProcessingPerspective.h" #include "src/internal/Perspectives/QmitkDIAppPreprocessingReconstructionPerspective.h" #include "src/internal/Perspectives/QmitkDIAppQuantificationPerspective.h" #include "src/internal/Perspectives/QmitkDIAppTBSSPerspective.h" #include "src/internal/Perspectives/QmitkDIAppUtilityPerspective.h" #include "src/internal/Perspectives/QmitkDIAppSyntheticDataGenerationPerspective.h" #include "src/internal/Perspectives/QmitkDIAppRegistrationPerspective.h" #include "src/internal/Perspectives/QmitkDIAppVisualizationPerspective.h" +#include "src/internal/Perspectives/QmitkGibbsTractographyPerspective.h" +#include "src/internal/Perspectives/QmitkStreamlineTractographyPerspective.h" +#include "src/internal/Perspectives/QmitkProbabilisticTractographyPerspective.h" + + #include #include #include #include #include #include #include QmitkDiffusionApplicationPlugin* QmitkDiffusionApplicationPlugin::inst = 0; QmitkDiffusionApplicationPlugin::QmitkDiffusionApplicationPlugin() { inst = this; } QmitkDiffusionApplicationPlugin::~QmitkDiffusionApplicationPlugin() { } QmitkDiffusionApplicationPlugin* QmitkDiffusionApplicationPlugin::GetDefault() { return inst; } void QmitkDiffusionApplicationPlugin::start(ctkPluginContext* context) { berry::AbstractUICTKPlugin::start(context); this->context = context; BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionImagingAppApplication, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionImagingAppIntroPart, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionImagingAppPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkWelcomePerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppConnectomicsPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppDicomImportPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppImageProcessingPerspective, context) - BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppFiberTractographyPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppIVIMPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppPreprocessingReconstructionPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppQuantificationPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppTBSSPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppUtilityPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppSyntheticDataGenerationPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppRegistrationPerspective, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkDIAppVisualizationPerspective, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkGibbsTractographyPerspective, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkStreamlineTractographyPerspective, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkProbabilisticTractographyPerspective, context) + ctkServiceReference cmRef = context->getServiceReference(); ctkConfigurationAdmin* configAdmin = 0; if (cmRef) { configAdmin = context->getService(cmRef); } // Use the CTK Configuration Admin service to configure the BlueBerry help system if (configAdmin) { ctkConfigurationPtr conf = configAdmin->getConfiguration("org.blueberry.services.help", QString()); ctkDictionary helpProps; helpProps.insert("homePage", "qthelp://org.mitk.gui.qt.diffusionimagingapp/bundle/index.html"); conf->update(helpProps); context->ungetService(cmRef); } else { MITK_WARN << "Configuration Admin service unavailable, cannot set home page url."; } } ctkPluginContext* QmitkDiffusionApplicationPlugin::GetPluginContext() const { return context; } Q_EXPORT_PLUGIN2(org_mitk_gui_qt_diffusionimagingapp, QmitkDiffusionApplicationPlugin) diff --git a/Plugins/org.mitk.gui.qt.ext/files.cmake b/Plugins/org.mitk.gui.qt.ext/files.cmake index ba1181ca41..f4191da5d4 100644 --- a/Plugins/org.mitk.gui.qt.ext/files.cmake +++ b/Plugins/org.mitk.gui.qt.ext/files.cmake @@ -1,58 +1,67 @@ set(SRC_CPP_FILES QmitkExtActionBarAdvisor.cpp QmitkExtWorkbenchWindowAdvisor.cpp QmitkExtFileSaveProjectAction.cpp QmitkOpenDicomEditorAction.cpp QmitkOpenXnatEditorAction.cpp + + QmitkCandyStoreWidget.cpp + QmitkNewPerspectiveDialog.cpp ) set(INTERNAL_CPP_FILES QmitkAppInstancesPreferencePage.cpp QmitkExternalProgramsPreferencePage.cpp QmitkCommonExtPlugin.cpp QmitkInputDevicesPrefPage.cpp QmitkModuleView.cpp ) set(UI_FILES src/internal/QmitkAppInstancesPreferencePage.ui src/internal/QmitkExternalProgramsPreferencePage.ui + src/QmitkCandyStoreWidgetControls.ui ) set(MOC_H_FILES src/QmitkExtFileSaveProjectAction.h src/QmitkExtWorkbenchWindowAdvisor.h src/internal/QmitkAppInstancesPreferencePage.h src/internal/QmitkExternalProgramsPreferencePage.h src/internal/QmitkCommonExtPlugin.h src/internal/QmitkExtWorkbenchWindowAdvisorHack.h src/internal/QmitkInputDevicesPrefPage.h src/internal/QmitkModuleView.h src/QmitkOpenDicomEditorAction.h src/QmitkOpenXnatEditorAction.h + + src/QmitkCandyStoreWidget.h + src/mitkQtPerspectiveItem.h + src/mitkQtViewItem.h + src/QmitkNewPerspectiveDialog.h ) set(CACHED_RESOURCE_FILES # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench plugin.xml resources/ModuleView.png ) set(QRC_FILES # uncomment the following line if you want to use Qt resources resources/org_mitk_gui_qt_ext.qrc ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.ext/resources/Candy_icon.png b/Plugins/org.mitk.gui.qt.ext/resources/Candy_icon.png new file mode 100644 index 0000000000..f71e77664c Binary files /dev/null and b/Plugins/org.mitk.gui.qt.ext/resources/Candy_icon.png differ diff --git a/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc b/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc index 7cadabfdac..60cefbb18c 100644 --- a/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc +++ b/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_gui_qt_ext.qrc @@ -1,13 +1,14 @@ - + Load_48.png Redo_48.png Save_48.png Undo_48.png Remove_48.png dcm-icon.png Slider.png index.html xnat-icon.png + Candy_icon.png diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.cpp new file mode 100644 index 0000000000..61c8384ddd --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.cpp @@ -0,0 +1,757 @@ +/*=================================================================== + +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 headers +#include "QmitkCandyStoreWidget.h" + +// Blueberry +#include +#include +#include +#include +#include + +#include + +// Qt +#include +#include +#include +#include + +class KeywordRegistry +{ +public: + KeywordRegistry() + { + berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); + berry::IConfigurationElement::vector keywordExts(extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.keywords")); + + std::string keywordId; + std::string keywordLabels; + berry::IConfigurationElement::vector::iterator keywordExtsIt; + for (keywordExtsIt = keywordExts.begin(); keywordExtsIt != keywordExts.end(); ++keywordExtsIt) + { + (*keywordExtsIt)->GetAttribute("id", keywordId); + (*keywordExtsIt)->GetAttribute("label", keywordLabels); + + if (m_Keywords.find(keywordId) == m_Keywords.end()) + { + m_Keywords[keywordId] = std::vector(); + } + m_Keywords[keywordId].push_back(QString::fromStdString(keywordLabels)); + } + } + + std::vector GetKeywords(const std::string& id) + { + return m_Keywords[id]; + } + + std::vector GetKeywords(const std::vector& ids) + { + std::vector result; + for (unsigned int i = 0; i < ids.size(); ++i) + { + std::vector< QString > tmpResult; + tmpResult = this->GetKeywords(ids[i]); + result.insert(result.end(), tmpResult.begin(), tmpResult.end()); + } + return result; + } + +private: + std::map > m_Keywords; +}; + + +class ClassFilterProxyModel : public QSortFilterProxyModel +{ +private : + bool hasToBeDisplayed(const QModelIndex index) const; + bool displayElement(const QModelIndex index) const; +public: + ClassFilterProxyModel(QObject *parent = NULL); + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; +}; +ClassFilterProxyModel::ClassFilterProxyModel(QObject *parent): + QSortFilterProxyModel(parent) +{ +} + +bool ClassFilterProxyModel::filterAcceptsRow(int sourceRow, + const QModelIndex &sourceParent) const +{ + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + + return hasToBeDisplayed(index); +} + +bool ClassFilterProxyModel::displayElement(const QModelIndex index) const +{ + bool result = false; + QString type = sourceModel()->data(index, Qt::DisplayRole).toString(); + QStandardItem * item = dynamic_cast(sourceModel())->itemFromIndex(index); + + if (type.contains(filterRegExp())) + { + return true; + } + { + mitk::QtViewItem* viewItem = dynamic_cast(item); + if (viewItem) + { + for (unsigned int i = 0; i < viewItem->m_Tags.size(); ++i) + { + if (viewItem->m_Tags[i].contains(filterRegExp())) + { + return true; + } + } + if (viewItem->m_Description.contains(filterRegExp())) + { + return true; + } + } + } + { + mitk::QtPerspectiveItem* viewItem = dynamic_cast(item); + if (viewItem) + { + for (unsigned int i = 0; i < viewItem->m_Tags.size(); ++i) + { + if (viewItem->m_Tags[i].contains(filterRegExp())) + { + return true; + } + } + if (viewItem->m_Description.contains(filterRegExp())) + { + return true; + } + } + } + + return result; +} + +bool ClassFilterProxyModel::hasToBeDisplayed(const QModelIndex index) const +{ + bool result = false; + if ( sourceModel()->rowCount(index) > 0 ) + { + for( int ii = 0; ii < sourceModel()->rowCount(index); ii++) + { + QModelIndex childIndex = sourceModel()->index(ii,0,index); + if ( ! childIndex.isValid() ) + break; + result = hasToBeDisplayed(childIndex); + result |= displayElement(index); + if (result) + { + break; + } + } + } + else + { + result = displayElement(index); + } + return result; +} + +class CandyStorePerspectiveListener: public berry::IPerspectiveListener +{ +public: + + CandyStorePerspectiveListener(QmitkCandyStoreWidget* p) : + parentWidget(p) + { + } + + Events::Types GetPerspectiveEventTypes() const + { + return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED + // remove the following line when command framework is finished + | Events::CLOSED | Events::OPENED | Events::PART_CHANGED; + } + + void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + parentWidget->UpdateTreeList(); + } + + void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/, + berry::IPerspectiveDescriptor::Pointer /*newPerspective*/) + { + + } + + void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + parentWidget->UpdateTreeList(); + } + + void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + parentWidget->UpdateTreeList(); + } + + void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + parentWidget->UpdateTreeList(); + } + + void PerspectiveChanged(berry::IWorkbenchPage::Pointer, + berry::IPerspectiveDescriptor::Pointer, + berry::IWorkbenchPartReference::Pointer partRef, const std::string& changeId) + { + parentWidget->UpdateTreeList(NULL, partRef.GetPointer(), changeId); + } + +private: + QmitkCandyStoreWidget* parentWidget; +}; + +struct CandyStoreWindowListener : public berry::IWindowListener +{ + CandyStoreWindowListener(QmitkCandyStoreWidget* switcher) + : switcher(switcher), + m_Done(false) + {} + + virtual void WindowOpened(berry::IWorkbenchWindow::Pointer window) + { + if (m_Done) + return; + if ( switcher->FillTreeList() ) + { + m_Done = true; + switcher->m_PerspectiveListener = CandyStorePerspectiveListener::Pointer(new CandyStorePerspectiveListener(switcher)); + window->AddPerspectiveListener(switcher->m_PerspectiveListener); + } + } + + virtual void WindowActivated(berry::IWorkbenchWindow::Pointer window) + { + if (m_Done) + return; + if ( switcher->FillTreeList() ) + { + m_Done = true; + switcher->m_PerspectiveListener = CandyStorePerspectiveListener::Pointer(new CandyStorePerspectiveListener(switcher)); + window->AddPerspectiveListener(switcher->m_PerspectiveListener); + } + } + +private: + QmitkCandyStoreWidget* switcher; + bool m_Done; +}; + +bool compareViews(berry::IViewDescriptor::Pointer a, berry::IViewDescriptor::Pointer b) +{ + if (a.IsNull() || b.IsNull()) + return false; + return a->GetLabel().compare(b->GetLabel()) < 0; +} + +bool comparePerspectives(berry::IPerspectiveDescriptor::Pointer a, berry::IPerspectiveDescriptor::Pointer b) +{ + if (a.IsNull() || b.IsNull()) + return false; + return a->GetLabel().compare(b->GetLabel()) < 0; +} + +bool compareQStandardItems(QStandardItem* a, QStandardItem* b) +{ + if (a==NULL || b==NULL) + return false; + return a->text().compare(b->text()) < 0; +} + +QmitkCandyStoreWidget::QmitkCandyStoreWidget( QWidget * parent, Qt::WindowFlags ) + : QWidget(parent) +{ + this->CreateQtPartControl(this); +} + +QmitkCandyStoreWidget::~QmitkCandyStoreWidget() +{ + +} + +void QmitkCandyStoreWidget::CreateQtPartControl( QWidget *parent ) +{ + // create GUI widgets from the Qt Designer's .ui file + m_WindowListener = CandyStoreWindowListener::Pointer(new CandyStoreWindowListener(this)); + berry::PlatformUI::GetWorkbench()->AddWindowListener(m_WindowListener); + + m_Parent = parent; + m_Controls.setupUi( parent ); + connect( m_Controls.m_PluginTreeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(CustomMenuRequested(QPoint))); + connect( m_Controls.m_PluginTreeView, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(ItemClicked(const QModelIndex&))); + connect( m_Controls.lineEdit, SIGNAL(textChanged(QString)), SLOT(FilterChanged())); + + m_ContextMenu = new QMenu(m_Controls.m_PluginTreeView); + m_Controls.m_PluginTreeView->setContextMenuPolicy(Qt::CustomContextMenu); + + // Create a new TreeModel for the data + m_TreeModel = new QStandardItemModel(); + m_FilterProxyModel = new ClassFilterProxyModel(this); + m_FilterProxyModel->setSourceModel(m_TreeModel); + //proxyModel->setFilterFixedString("Diff"); + m_Controls.m_PluginTreeView->setModel(m_FilterProxyModel); + FillTreeList(); +} + +void QmitkCandyStoreWidget::UpdateTreeList(QStandardItem* root, berry::IWorkbenchPartReference *partRef, const std::string &changeId) +{ + berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); + if (page.IsNull()) + return; + + if (root==NULL) + root = m_TreeModel->invisibleRootItem(); + for (int i=0; irowCount(); i++) + { + QStandardItem* item = root->child(i); + QFont font; + if (dynamic_cast(item)) + { + mitk::QtPerspectiveItem* pItem = dynamic_cast(item); + berry::IPerspectiveDescriptor::Pointer currentPersp = page->GetPerspective(); + + if (currentPersp.IsNotNull() && currentPersp->GetId()==pItem->m_Perspective->GetId()) + font.setBold(true); + pItem->setFont(font); + } + mitk::QtViewItem* vItem = dynamic_cast(item); + if (vItem) + { + std::vector viewParts(page->GetViews()); + for (unsigned int i=0; iGetPartName()==vItem->m_View->GetLabel()) + { + font.setBold(true); + break; + } + + if( partRef!=NULL && partRef->GetId()==vItem->m_View->GetId() && changeId=="viewHide") + font.setBold(false); + + vItem->setFont(font); + } + UpdateTreeList(item, partRef, changeId); + } +} + +bool QmitkCandyStoreWidget::FillTreeList() +{ + // active workbench window available? + if (berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow().IsNull()) + return false; + // active page available? + berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); + if (page.IsNull()) + return false; + + // everything is fine and we can remove the window listener + berry::PlatformUI::GetWorkbench()->RemoveWindowListener(m_WindowListener); + + // initialize tree model + m_TreeModel->clear(); + QStandardItem *treeRootItem = m_TreeModel->invisibleRootItem(); + + // get all available perspectives + berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); + std::vector perspectiveDescriptors(perspRegistry->GetPerspectives()); + std::sort(perspectiveDescriptors.begin(), perspectiveDescriptors.end(), comparePerspectives); + + // get all Keywords + KeywordRegistry keywordRegistry; + + berry::IPerspectiveDescriptor::Pointer currentPersp = page->GetPerspective(); + std::vector perspectiveExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetPerspectiveExcludeList(); + + std::vector< QStandardItem* > categoryItems; + QStandardItem *perspectiveRootItem = new QStandardItem("Workflows"); + perspectiveRootItem->setEditable(false); + treeRootItem->appendRow(perspectiveRootItem); + for (unsigned int i=0; iGetId()) + { + skipPerspective = true; + break; + } + if (skipPerspective) + continue; + + //QIcon* pIcon = static_cast(p->GetImageDescriptor()->CreateImage()); + mitk::QtPerspectiveItem* pItem = new mitk::QtPerspectiveItem(QString::fromStdString(p->GetLabel())); + pItem->m_Perspective = p; + pItem->m_Description = QString::fromStdString(p->GetDescription()); + std::vector keylist = p->GetKeywordReferences(); + pItem->m_Tags = keywordRegistry.GetKeywords(keylist); + pItem->setEditable(false); + + QFont font; font.setBold(true); + if (currentPersp.IsNotNull() && currentPersp->GetId()==p->GetId()) + pItem->setFont(font); + + std::vector catPath = p->GetCategoryPath(); + if (catPath.empty()) + { + perspectiveRootItem->appendRow(pItem); + } + else + { + QStandardItem* categoryItem = NULL; + + for (unsigned int c=0; ctext().toStdString() == catPath.front()) + { + categoryItem = categoryItems.at(c); + break; + } + + if (categoryItem==NULL) + { + categoryItem = new QStandardItem(QIcon(),catPath.front().c_str()); + categoryItems.push_back(categoryItem); + } + categoryItem->setEditable(false); + categoryItem->appendRow(pItem); + } + } + std::sort(categoryItems.begin(), categoryItems.end(), compareQStandardItems); + for (unsigned int i=0; iappendRow(categoryItems.at(i)); + + // get all available views + berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); + std::vector viewDescriptors(viewRegistry->GetViews()); + std::vector viewParts(page->GetViews()); + std::sort(viewDescriptors.begin(), viewDescriptors.end(), compareViews); + + std::vector viewExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetViewExcludeList(); + QStandardItem* viewRootItem = new QStandardItem(QIcon(),"Candies"); + viewRootItem->setEditable(false); + treeRootItem->appendRow(viewRootItem); + + categoryItems.clear(); + QStandardItem* noCategoryItem = new QStandardItem(QIcon(),"Miscellaneous"); + noCategoryItem->setEditable(false); + + for (unsigned int i = 0; i < viewDescriptors.size(); ++i) + { + berry::IViewDescriptor::Pointer v = viewDescriptors[i]; + bool skipView = false; + for(unsigned int e=0; eGetId()) + { + skipView = true; + break; + } + if (skipView) + continue; + + std::vector catPath = v->GetCategoryPath(); + + QIcon* icon = static_cast(v->GetImageDescriptor()->CreateImage()); + mitk::QtViewItem* vItem = new mitk::QtViewItem(*icon, QString::fromStdString(v->GetLabel())); + vItem->m_View = v; + vItem->setToolTip(v->GetDescription().c_str()); + vItem->m_Description = QString::fromStdString(v->GetDescription()); + + std::vector keylist = v->GetKeywordReferences(); + vItem->m_Tags = keywordRegistry.GetKeywords(keylist); + vItem->setEditable(false); + + for (unsigned int i=0; iGetPartName()==v->GetLabel()) + { + QFont font; font.setBold(true); + vItem->setFont(font); + break; + } + + if (catPath.empty()) + noCategoryItem->appendRow(vItem); + else + { + QStandardItem* categoryItem = NULL; + + for (unsigned int c=0; ctext().toStdString() == catPath.front()) + { + categoryItem = categoryItems.at(c); + break; + } + + if (categoryItem==NULL) + { + categoryItem = new QStandardItem(QIcon(),catPath.front().c_str()); + categoryItems.push_back(categoryItem); + } + categoryItem->setEditable(false); + categoryItem->appendRow(vItem); + } + } + std::sort(categoryItems.begin(), categoryItems.end(), compareQStandardItems); + + for (unsigned int i=0; iappendRow(categoryItems.at(i)); + if (noCategoryItem->hasChildren()) + viewRootItem->appendRow(noCategoryItem); + + m_Controls.m_PluginTreeView->expandAll(); + + return true; +} + +void QmitkCandyStoreWidget::FilterChanged() +{ + QString filterString = m_Controls.lineEdit->text(); + if (filterString.size() > 0 ) + m_Controls.m_PluginTreeView->expandAll(); + else + m_Controls.m_PluginTreeView->collapseAll(); + // QRegExp::PatternSyntax syntax = QRegExp::RegExp; + + Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive; + QString strPattern = "^*" + filterString; + QRegExp regExp(strPattern, caseSensitivity); + + m_FilterProxyModel->setFilterRegExp(regExp); +} + +void QmitkCandyStoreWidget::ItemClicked(const QModelIndex &index) +{ + QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index)); + + if ( dynamic_cast< mitk::QtPerspectiveItem* >(item) ) + { + try + { + mitk::QtPerspectiveItem* pItem = dynamic_cast< mitk::QtPerspectiveItem* >(item); + berry::PlatformUI::GetWorkbench()->ShowPerspective( pItem->m_Perspective->GetId(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() ); + } + catch (...) + { + QMessageBox::critical(0, "Opening Perspective Failed", QString("The requested perspective could not be opened.\nSee the log for details.")); + } + } + else if ( dynamic_cast< mitk::QtViewItem* >(item) ) + { + berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); + + if (page.IsNotNull()) + { + try + { + mitk::QtViewItem* vItem = dynamic_cast< mitk::QtViewItem* >(item); + page->ShowView(vItem->m_View->GetId()); + } + catch (berry::PartInitException e) + { + BERRY_ERROR << "Error: " << e.displayText() << std::endl; + } + } + } +} + +void QmitkCandyStoreWidget::AddPerspective() +{ + QmitkNewPerspectiveDialog* dialog = new QmitkNewPerspectiveDialog( m_Parent ); + + int dialogReturnValue = dialog->exec(); + if ( dialogReturnValue == QDialog::Rejected ) + return; + + berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); + try + { + berry::IPerspectiveDescriptor::Pointer perspDesc; + perspDesc = perspRegistry->CreatePerspective(dialog->GetPerspectiveName().toStdString(), perspRegistry->FindPerspectiveWithId(perspRegistry->GetDefaultPerspective())); + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->SetPerspective(perspDesc); + } + catch(...) + { + QMessageBox::warning(m_Parent, "Error", "Duplication of selected perspective failed. Please make sure the specified perspective name is not already in use!"); + } + FillTreeList(); +} + +void QmitkCandyStoreWidget::ClonePerspective() +{ + if (m_RegisteredPerspective.IsNotNull()) + { + QmitkNewPerspectiveDialog* dialog = new QmitkNewPerspectiveDialog( m_Parent ); + QString defaultName(m_RegisteredPerspective->GetLabel().c_str()); + defaultName.append(" Copy"); + dialog->SetPerspectiveName(defaultName); + + int dialogReturnValue = dialog->exec(); + if ( dialogReturnValue == QDialog::Rejected ) + return; + + berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); + try + { + berry::IPerspectiveDescriptor::Pointer perspDesc = perspRegistry->ClonePerspective(dialog->GetPerspectiveName().toStdString(), dialog->GetPerspectiveName().toStdString(), m_RegisteredPerspective); + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->SetPerspective(perspDesc); + } + catch(...) + { + QMessageBox::warning(m_Parent, "Error", "Duplication of selected perspective failed. Please make sure the specified perspective name is not already in use!"); + } + FillTreeList(); + } +} + +void QmitkCandyStoreWidget::ResetPerspective() +{ + if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to reset the curent perspective?", QMessageBox::Yes|QMessageBox::No).exec()) + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); +} + +void QmitkCandyStoreWidget::DeletePerspective() +{ + if (m_RegisteredPerspective.IsNotNull()) + { + QString question = "Do you really want to remove the perspective '"; + question.append(m_RegisteredPerspective->GetLabel().c_str()); + question.append("'?"); + if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", question, QMessageBox::Yes|QMessageBox::No).exec()) + { + berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); + perspRegistry->DeletePerspective(m_RegisteredPerspective); + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->RemovePerspective(m_RegisteredPerspective); + FillTreeList(); + if (! berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->GetPerspective()) + { + berry::IPerspectiveDescriptor::Pointer persp = perspRegistry->FindPerspectiveWithId(perspRegistry->GetDefaultPerspective()); + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->SetPerspective(persp); + } + } + } +} + +void QmitkCandyStoreWidget::ClosePerspective() +{ + if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to close the curent perspective?", QMessageBox::Yes|QMessageBox::No).exec()) + { + berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); + page->CloseCurrentPerspective(true, true); + + // if ( page->GetPerspective().IsNull() ) + // { + // berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); + // berry::PlatformUI::GetWorkbench()->ShowPerspective( perspRegistry->GetDefaultPerspective(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() ); + // } + } +} + +void QmitkCandyStoreWidget::CloseAllPerspectives() +{ + if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to close all perspectives?", QMessageBox::Yes|QMessageBox::No).exec()) + { + berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); + page->CloseAllPerspectives(true, true); + + // berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); + // berry::PlatformUI::GetWorkbench()->ShowPerspective( perspRegistry->GetDefaultPerspective(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() ); + } +} + +void QmitkCandyStoreWidget::ExpandAll() +{ + m_Controls.m_PluginTreeView->expandAll(); +} + +void QmitkCandyStoreWidget::CollapseAll() +{ + m_Controls.m_PluginTreeView->collapseAll(); +} + +void QmitkCandyStoreWidget::CustomMenuRequested(QPoint pos) +{ + QModelIndex index = m_Controls.m_PluginTreeView->indexAt(pos); + QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index)); + + if (m_ContextMenu==NULL) + return; + + m_ContextMenu->clear(); + m_RegisteredPerspective = NULL; + + QAction* expandAction = new QAction("Expand tree", this); + m_ContextMenu->addAction(expandAction); + connect(expandAction, SIGNAL(triggered()), SLOT(ExpandAll())); + + QAction* collapseAction = new QAction("Collapse tree", this); + m_ContextMenu->addAction(collapseAction); + connect(collapseAction, SIGNAL(triggered()), SLOT(CollapseAll())); + + m_ContextMenu->addSeparator(); + + if ( item!=NULL && dynamic_cast< mitk::QtPerspectiveItem* >(item) ) + { + m_RegisteredPerspective = dynamic_cast< mitk::QtPerspectiveItem* >(item)->m_Perspective; + + //m_ContextMenu->addSeparator(); + + QAction* cloneAction = new QAction("Duplicate perspective", this); + m_ContextMenu->addAction(cloneAction); + connect(cloneAction, SIGNAL(triggered()), SLOT(ClonePerspective())); + + if (!m_RegisteredPerspective->IsPredefined()) + { + QAction* deleteAction = new QAction("Remove perspective", this); + m_ContextMenu->addAction(deleteAction); + connect(deleteAction, SIGNAL(triggered()), SLOT(DeletePerspective())); + } + + m_ContextMenu->addSeparator(); + } + + QAction* resetAction = new QAction("Reset current perspective", this); + m_ContextMenu->addAction(resetAction); + connect(resetAction, SIGNAL(triggered()), SLOT(ResetPerspective())); + + QAction* closeAction = new QAction("Close current perspective", this); + m_ContextMenu->addAction(closeAction); + connect(closeAction, SIGNAL(triggered()), SLOT(ClosePerspective())); + + m_ContextMenu->addSeparator(); + + QAction* closeAllAction = new QAction("Close all perspectives", this); + m_ContextMenu->addAction(closeAllAction); + connect(closeAllAction, SIGNAL(triggered()), SLOT(CloseAllPerspectives())); + + m_ContextMenu->popup(m_Controls.m_PluginTreeView->viewport()->mapToGlobal(pos)); +} diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.h b/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.h new file mode 100644 index 0000000000..995ea9ca94 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.h @@ -0,0 +1,88 @@ +/*=================================================================== + +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 _QMITKCandyStoreWidget_H_INCLUDED +#define _QMITKCandyStoreWidget_H_INCLUDED + +//QT headers +#include +#include +#include "ui_QmitkCandyStoreWidgetControls.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class ClassFilterProxyModel; + +/** @brief + */ +class QmitkCandyStoreWidget : public QWidget +{ + //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) + Q_OBJECT + +public: + + QmitkCandyStoreWidget (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkCandyStoreWidget(); + + virtual void CreateQtPartControl(QWidget *parent); + + bool FillTreeList(); + void UpdateTreeList(QStandardItem* item = NULL, berry::IWorkbenchPartReference* partRef=NULL, const std::string& changeId=""); + + berry::IPerspectiveListener::Pointer m_PerspectiveListener; + +public slots: + + void CustomMenuRequested(QPoint pos); + void ItemClicked(const QModelIndex &index); + void AddPerspective(); + void ClonePerspective(); + void ResetPerspective(); + void DeletePerspective(); + void CloseAllPerspectives(); + void ClosePerspective(); + void ExpandAll(); + void CollapseAll(); + void FilterChanged(); + +protected: + + // member variables + Ui::QmitkCandyStoreWidgetControls m_Controls; + QWidget* m_Parent; + QStandardItemModel* m_TreeModel; + ClassFilterProxyModel* m_FilterProxyModel; + QMenu* m_ContextMenu; + berry::IPerspectiveDescriptor::Pointer m_RegisteredPerspective; + berry::IWindowListener::Pointer m_WindowListener; + + +private: + +}; + +#endif // _QMITKCandyStoreWidget_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidgetControls.ui b/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidgetControls.ui new file mode 100644 index 0000000000..2f8a961032 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidgetControls.ui @@ -0,0 +1,52 @@ + + + QmitkCandyStoreWidgetControls + + + + 0 + 0 + 752 + 974 + + + + + 0 + 0 + + + + QmitkTemplate + + + + + + Filter... + + + + + + + true + + + false + + + + + + + + + ctkSearchBox + QLineEdit +
ctkSearchBox.h
+
+
+ + +
diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp index 2bd59abf43..1945d37a05 100644 --- a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp @@ -1,1212 +1,1264 @@ /*=================================================================== 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 "QmitkExtWorkbenchWindowAdvisor.h" #include "QmitkExtActionBarAdvisor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // UGLYYY #include "internal/QmitkExtWorkbenchWindowAdvisorHack.h" #include "internal/QmitkCommonExtPlugin.h" #include "mitkUndoController.h" #include "mitkVerboseLimitedLinearUndo.h" #include #include #include #include QmitkExtWorkbenchWindowAdvisorHack * QmitkExtWorkbenchWindowAdvisorHack::undohack = -new QmitkExtWorkbenchWindowAdvisorHack(); + new QmitkExtWorkbenchWindowAdvisorHack(); QString QmitkExtWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME = "QtSettings.ini"; class PartListenerForTitle: public berry::IPartListener { public: - PartListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : - windowAdvisor(wa) - { - } + PartListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : + windowAdvisor(wa) + { + } - Events::Types GetPartEventTypes() const - { - return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED - | Events::HIDDEN | Events::VISIBLE; - } + Events::Types GetPartEventTypes() const + { + return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED + | Events::HIDDEN | Events::VISIBLE; + } - void PartActivated(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref.Cast ()) + void PartActivated(berry::IWorkbenchPartReference::Pointer ref) { - windowAdvisor->UpdateTitle(false); + if (ref.Cast ()) + { + windowAdvisor->UpdateTitle(false); + } } - } - void PartBroughtToTop(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref.Cast ()) + void PartBroughtToTop(berry::IWorkbenchPartReference::Pointer ref) { - windowAdvisor->UpdateTitle(false); + if (ref.Cast ()) + { + windowAdvisor->UpdateTitle(false); + } } - } - void PartClosed(berry::IWorkbenchPartReference::Pointer /*ref*/) - { - windowAdvisor->UpdateTitle(false); - } + void PartClosed(berry::IWorkbenchPartReference::Pointer /*ref*/) + { + windowAdvisor->UpdateTitle(false); + } - void PartHidden(berry::IWorkbenchPartReference::Pointer ref) - { - if (!windowAdvisor->lastActiveEditor.Expired() && - ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) + void PartHidden(berry::IWorkbenchPartReference::Pointer ref) { - windowAdvisor->UpdateTitle(true); + if (!windowAdvisor->lastActiveEditor.Expired() && + ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) + { + windowAdvisor->UpdateTitle(true); + } } - } - void PartVisible(berry::IWorkbenchPartReference::Pointer ref) - { - if (!windowAdvisor->lastActiveEditor.Expired() && - ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) + void PartVisible(berry::IWorkbenchPartReference::Pointer ref) { - windowAdvisor->UpdateTitle(false); + if (!windowAdvisor->lastActiveEditor.Expired() && + ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock()) + { + windowAdvisor->UpdateTitle(false); + } } - } private: - QmitkExtWorkbenchWindowAdvisor* windowAdvisor; + QmitkExtWorkbenchWindowAdvisor* windowAdvisor; }; class PartListenerForImageNavigator: public berry::IPartListener { public: - PartListenerForImageNavigator(QAction* act) : - imageNavigatorAction(act) - { - } + PartListenerForImageNavigator(QAction* act) : + imageNavigatorAction(act) + { + } - Events::Types GetPartEventTypes() const - { - return Events::OPENED | Events::CLOSED | Events::HIDDEN | - Events::VISIBLE; - } + Events::Types GetPartEventTypes() const + { + return Events::OPENED | Events::CLOSED | Events::HIDDEN | + Events::VISIBLE; + } - void PartOpened(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") + void PartOpened(berry::IWorkbenchPartReference::Pointer ref) { - imageNavigatorAction->setChecked(true); + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(true); + } } - } - void PartClosed(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") + void PartClosed(berry::IWorkbenchPartReference::Pointer ref) { - imageNavigatorAction->setChecked(false); + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(false); + } } - } - void PartVisible(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") + void PartVisible(berry::IWorkbenchPartReference::Pointer ref) { - imageNavigatorAction->setChecked(true); + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(true); + } } - } - void PartHidden(berry::IWorkbenchPartReference::Pointer ref) - { - if (ref->GetId()=="org.mitk.views.imagenavigator") + void PartHidden(berry::IWorkbenchPartReference::Pointer ref) { - imageNavigatorAction->setChecked(false); + if (ref->GetId()=="org.mitk.views.imagenavigator") + { + imageNavigatorAction->setChecked(false); + } } - } private: - QAction* imageNavigatorAction; + QAction* imageNavigatorAction; }; class PerspectiveListenerForTitle: public berry::IPerspectiveListener { public: - PerspectiveListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : - windowAdvisor(wa), perspectivesClosed(false) - { - } - - Events::Types GetPerspectiveEventTypes() const - { - return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED - // remove the following line when command framework is finished - | Events::CLOSED | Events::OPENED; - } - - void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - windowAdvisor->UpdateTitle(false); - } - - void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/, - berry::IPerspectiveDescriptor::Pointer /*newPerspective*/) - { - windowAdvisor->UpdateTitle(false); - } - - void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - windowAdvisor->UpdateTitle(false); - } - - void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - if (perspectivesClosed) - { - QListIterator i(windowAdvisor->viewActions); - while (i.hasNext()) - { - i.next()->setEnabled(true); - } - - //GetViewRegistry()->Find("org.mitk.views.imagenavigator"); - if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) - { - windowAdvisor->openDicomEditorAction->setEnabled(true); - } - if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) - { - windowAdvisor->openXnatEditorAction->setEnabled(true); - } - windowAdvisor->fileSaveProjectAction->setEnabled(true); - windowAdvisor->closeProjectAction->setEnabled(true); - windowAdvisor->undoAction->setEnabled(true); - windowAdvisor->redoAction->setEnabled(true); - windowAdvisor->imageNavigatorAction->setEnabled(true); - windowAdvisor->resetPerspAction->setEnabled(true); - if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) - { - windowAdvisor->closePerspAction->setEnabled(true); - } - } - - perspectivesClosed = false; - } - - void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer /*perspective*/) - { - berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow(); - bool allClosed = true; - if (wnd->GetActivePage()) - { - std::vector perspectives(wnd->GetActivePage()->GetOpenPerspectives()); - allClosed = perspectives.empty(); - } - - if (allClosed) - { - perspectivesClosed = true; - - QListIterator i(windowAdvisor->viewActions); - while (i.hasNext()) - { - i.next()->setEnabled(false); - } - - if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) - { - windowAdvisor->openDicomEditorAction->setEnabled(false); - } - if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) - { - windowAdvisor->openXnatEditorAction->setEnabled(false); - } - windowAdvisor->fileSaveProjectAction->setEnabled(false); - windowAdvisor->closeProjectAction->setEnabled(false); - windowAdvisor->undoAction->setEnabled(false); - windowAdvisor->redoAction->setEnabled(false); - windowAdvisor->imageNavigatorAction->setEnabled(false); - windowAdvisor->resetPerspAction->setEnabled(false); - if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) - { - windowAdvisor->closePerspAction->setEnabled(false); - } - } - } + PerspectiveListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : + windowAdvisor(wa), perspectivesClosed(false) + { + } + + Events::Types GetPerspectiveEventTypes() const + { + return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED + // remove the following line when command framework is finished + | Events::CLOSED | Events::OPENED; + } + + void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + windowAdvisor->UpdateTitle(false); + } + + void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/, + berry::IPerspectiveDescriptor::Pointer /*newPerspective*/) + { + windowAdvisor->UpdateTitle(false); + } + + void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + windowAdvisor->UpdateTitle(false); + } + + void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + if (perspectivesClosed) + { + QListIterator i(windowAdvisor->viewActions); + while (i.hasNext()) + { + i.next()->setEnabled(true); + } + + //GetViewRegistry()->Find("org.mitk.views.imagenavigator"); + if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) + { + windowAdvisor->openDicomEditorAction->setEnabled(true); + } + if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) + { + windowAdvisor->openXnatEditorAction->setEnabled(true); + } + windowAdvisor->fileSaveProjectAction->setEnabled(true); + windowAdvisor->closeProjectAction->setEnabled(true); + windowAdvisor->undoAction->setEnabled(true); + windowAdvisor->redoAction->setEnabled(true); + windowAdvisor->imageNavigatorAction->setEnabled(true); + windowAdvisor->resetPerspAction->setEnabled(true); + if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) + { + windowAdvisor->closePerspAction->setEnabled(true); + } + } + + perspectivesClosed = false; + } + + void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer /*perspective*/) + { + berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow(); + bool allClosed = true; + if (wnd->GetActivePage()) + { + std::vector perspectives(wnd->GetActivePage()->GetOpenPerspectives()); + allClosed = perspectives.empty(); + } + + if (allClosed) + { + perspectivesClosed = true; + + QListIterator i(windowAdvisor->viewActions); + while (i.hasNext()) + { + i.next()->setEnabled(false); + } + + if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) + { + windowAdvisor->openDicomEditorAction->setEnabled(false); + } + if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) + { + windowAdvisor->openXnatEditorAction->setEnabled(false); + } + windowAdvisor->fileSaveProjectAction->setEnabled(false); + windowAdvisor->closeProjectAction->setEnabled(false); + windowAdvisor->undoAction->setEnabled(false); + windowAdvisor->redoAction->setEnabled(false); + windowAdvisor->imageNavigatorAction->setEnabled(false); + windowAdvisor->resetPerspAction->setEnabled(false); + if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) + { + windowAdvisor->closePerspAction->setEnabled(false); + } + } + } private: - QmitkExtWorkbenchWindowAdvisor* windowAdvisor; - bool perspectivesClosed; + QmitkExtWorkbenchWindowAdvisor* windowAdvisor; + bool perspectivesClosed; }; class PerspectiveListenerForMenu: public berry::IPerspectiveListener { public: - PerspectiveListenerForMenu(QmitkExtWorkbenchWindowAdvisor* wa) : - windowAdvisor(wa) - { - } - - Events::Types GetPerspectiveEventTypes() const - { - return Events::ACTIVATED | Events::DEACTIVATED; - } - - void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer perspective) - { - QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; - if (action) - { - action->setChecked(true); - } - } - - void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, - berry::IPerspectiveDescriptor::Pointer perspective) - { - QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; - if (action) - { - action->setChecked(false); - } - } + PerspectiveListenerForMenu(QmitkExtWorkbenchWindowAdvisor* wa) : + windowAdvisor(wa) + { + } + + Events::Types GetPerspectiveEventTypes() const + { + return Events::ACTIVATED | Events::DEACTIVATED; + } + + void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer perspective) + { + QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; + if (action) + { + action->setChecked(true); + } + } + + void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/, + berry::IPerspectiveDescriptor::Pointer perspective) + { + QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; + if (action) + { + action->setChecked(false); + } + } private: - QmitkExtWorkbenchWindowAdvisor* windowAdvisor; + QmitkExtWorkbenchWindowAdvisor* windowAdvisor; }; QmitkExtWorkbenchWindowAdvisor::QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, - berry::IWorkbenchWindowConfigurer::Pointer configurer) : -berry::WorkbenchWindowAdvisor(configurer), -lastInput(0), -wbAdvisor(wbAdvisor), -showViewToolbar(true), -showPerspectiveToolbar(false), -showVersionInfo(true), -showMitkVersionInfo(true), -showViewMenuItem(true), -showNewWindowMenuItem(false), -showClosePerspectiveMenuItem(true), -dropTargetListener(new QmitkDefaultDropTargetListener) + berry::IWorkbenchWindowConfigurer::Pointer configurer) : + berry::WorkbenchWindowAdvisor(configurer), + lastInput(0), + wbAdvisor(wbAdvisor), + showViewToolbar(true), + showPerspectiveToolbar(false), + showVersionInfo(true), + showMitkVersionInfo(true), + showViewMenuItem(true), + showNewWindowMenuItem(false), + showClosePerspectiveMenuItem(true), + enableCandyStore(true), + showMemoryIndicator(true), + dropTargetListener(new QmitkDefaultDropTargetListener) { - productName = QCoreApplication::applicationName().toStdString(); + productName = QCoreApplication::applicationName().toStdString(); } berry::ActionBarAdvisor::Pointer QmitkExtWorkbenchWindowAdvisor::CreateActionBarAdvisor( - berry::IActionBarConfigurer::Pointer configurer) + berry::IActionBarConfigurer::Pointer configurer) { - berry::ActionBarAdvisor::Pointer actionBarAdvisor( - new QmitkExtActionBarAdvisor(configurer)); - return actionBarAdvisor; + berry::ActionBarAdvisor::Pointer actionBarAdvisor( + new QmitkExtActionBarAdvisor(configurer)); + return actionBarAdvisor; } void* QmitkExtWorkbenchWindowAdvisor::CreateEmptyWindowContents(void* parent) { - QWidget* parentWidget = static_cast(parent); - QLabel* label = new QLabel(parentWidget); - label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu."); - label->setContentsMargins(10,10,10,10); - label->setAlignment(Qt::AlignTop); - label->setEnabled(false); - parentWidget->layout()->addWidget(label); - return label; + QWidget* parentWidget = static_cast(parent); + QLabel* label = new QLabel(parentWidget); + label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu."); + label->setContentsMargins(10,10,10,10); + label->setAlignment(Qt::AlignTop); + label->setEnabled(false); + parentWidget->layout()->addWidget(label); + return label; } void QmitkExtWorkbenchWindowAdvisor::ShowClosePerspectiveMenuItem(bool show) { - showClosePerspectiveMenuItem = show; + showClosePerspectiveMenuItem = show; } bool QmitkExtWorkbenchWindowAdvisor::GetShowClosePerspectiveMenuItem() { - return showClosePerspectiveMenuItem; + return showClosePerspectiveMenuItem; +} + +void QmitkExtWorkbenchWindowAdvisor::ShowMemoryIndicator(bool show) +{ + showMemoryIndicator = show; +} + +bool QmitkExtWorkbenchWindowAdvisor::GetShowMemoryIndicator() +{ + return showMemoryIndicator; +} + +void QmitkExtWorkbenchWindowAdvisor::EnableCandyStore(bool enable) +{ + enableCandyStore = enable; +} + +bool QmitkExtWorkbenchWindowAdvisor::GetEnableCandyStore() +{ + return enableCandyStore; } void QmitkExtWorkbenchWindowAdvisor::ShowNewWindowMenuItem(bool show) { - showNewWindowMenuItem = show; + showNewWindowMenuItem = show; } void QmitkExtWorkbenchWindowAdvisor::ShowViewToolbar(bool show) { - showViewToolbar = show; + showViewToolbar = show; } void QmitkExtWorkbenchWindowAdvisor::ShowViewMenuItem(bool show) { - showViewMenuItem = show; + showViewMenuItem = show; } void QmitkExtWorkbenchWindowAdvisor::ShowPerspectiveToolbar(bool show) { - showPerspectiveToolbar = show; + showPerspectiveToolbar = show; } void QmitkExtWorkbenchWindowAdvisor::ShowVersionInfo(bool show) { - showVersionInfo = show; + showVersionInfo = show; } void QmitkExtWorkbenchWindowAdvisor::ShowMitkVersionInfo(bool show) { - showMitkVersionInfo = show; + showMitkVersionInfo = show; } void QmitkExtWorkbenchWindowAdvisor::SetProductName(const std::string& product) { - productName = product; + productName = product; } void QmitkExtWorkbenchWindowAdvisor::SetWindowIcon(const std::string& wndIcon) { - windowIcon = wndIcon; + windowIcon = wndIcon; +} + +void QmitkExtWorkbenchWindowAdvisor::onCandyStore() +{ + candyStore->setVisible(candyStoreAction->isChecked()); } void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() { - // very bad hack... - berry::IWorkbenchWindow::Pointer window = - this->GetWindowConfigurer()->GetWindow(); - QMainWindow* mainWindow = - static_cast (window->GetShell()->GetControl()); - - if (!windowIcon.empty()) - { - mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon))); - } - mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); - - /*mainWindow->setStyleSheet("color: white;" + // very bad hack... + berry::IWorkbenchWindow::Pointer window = + this->GetWindowConfigurer()->GetWindow(); + QMainWindow* mainWindow = + static_cast (window->GetShell()->GetControl()); + + window->SetPerspectiveExcludeList(perspectiveExcludeList); + window->SetViewExcludeList(viewExcludeList); + + if (!windowIcon.empty()) + { + mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon))); + } + mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); + + /*mainWindow->setStyleSheet("color: white;" "background-color: #808080;" "selection-color: #659EC7;" "selection-background-color: #808080;" " QMenuBar {" "background-color: #808080; }");*/ - // ==== Application menu ============================ - QMenuBar* menuBar = mainWindow->menuBar(); - menuBar->setContextMenuPolicy(Qt::PreventContextMenu); - - QMenu* fileMenu = menuBar->addMenu("&File"); - fileMenu->setObjectName("FileMenu"); - - QAction* fileOpenAction = new QmitkFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window); - fileMenu->addAction(fileOpenAction); - fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); - fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png")); - fileMenu->addAction(fileSaveProjectAction); - closeProjectAction = new QmitkCloseProjectAction(window); - closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png")); - fileMenu->addAction(closeProjectAction); - fileMenu->addSeparator(); - QAction* fileExitAction = new QmitkFileExitAction(window); - fileExitAction->setObjectName("QmitkFileExitAction"); - fileMenu->addAction(fileExitAction); - -if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) -{ - openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window); -} -if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) -{ - openXnatEditorAction = new QmitkOpenXnatEditorAction(QIcon(":/org.mitk.gui.qt.ext/xnat-icon.png"),window); -} + // ==== Application menu ============================ + QMenuBar* menuBar = mainWindow->menuBar(); + menuBar->setContextMenuPolicy(Qt::PreventContextMenu); + + QMenu* fileMenu = menuBar->addMenu("&File"); + fileMenu->setObjectName("FileMenu"); + + QAction* fileOpenAction = new QmitkFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window); + fileMenu->addAction(fileOpenAction); + fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); + fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png")); + fileMenu->addAction(fileSaveProjectAction); + closeProjectAction = new QmitkCloseProjectAction(window); + closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png")); + fileMenu->addAction(closeProjectAction); + fileMenu->addSeparator(); + QAction* fileExitAction = new QmitkFileExitAction(window); + fileExitAction->setObjectName("QmitkFileExitAction"); + fileMenu->addAction(fileExitAction); + + if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) + { + openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window); + } + if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) + { + openXnatEditorAction = new QmitkOpenXnatEditorAction(QIcon(":/org.mitk.gui.qt.ext/xnat-icon.png"),window); + } - berry::IViewRegistry* viewRegistry = - berry::PlatformUI::GetWorkbench()->GetViewRegistry(); - const std::vector& viewDescriptors = - viewRegistry->GetViews(); - - // another bad hack to get an edit/undo menu... - QMenu* editMenu = menuBar->addMenu("&Edit"); - undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"), - "&Undo", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), - QKeySequence("CTRL+Z")); - undoAction->setToolTip("Undo the last action (not supported by all modules)"); - redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png") - , "&Redo", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), - QKeySequence("CTRL+Y")); - redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); - - imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL); - bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); - if (imageNavigatorViewFound) - { - QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); - imageNavigatorAction->setCheckable(true); - - // add part listener for image navigator - imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction); - window->GetPartService()->AddPartListener(imageNavigatorPartListener); - berry::IViewPart::Pointer imageNavigatorView = - window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); - imageNavigatorAction->setChecked(false); - if (imageNavigatorView) - { - bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); - if (isImageNavigatorVisible) - imageNavigatorAction->setChecked(true); - } - imageNavigatorAction->setToolTip("Open image navigator for navigating through image"); - } - - // toolbar for showing file open, undo, redo and other main actions - QToolBar* mainActionsToolBar = new QToolBar; - mainActionsToolBar->setObjectName("mainActionsToolBar"); - mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); + berry::IViewRegistry* viewRegistry = + berry::PlatformUI::GetWorkbench()->GetViewRegistry(); + const std::vector& viewDescriptors = + viewRegistry->GetViews(); + + // another bad hack to get an edit/undo menu... + QMenu* editMenu = menuBar->addMenu("&Edit"); + undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"), + "&Undo", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), + QKeySequence("CTRL+Z")); + undoAction->setToolTip("Undo the last action (not supported by all modules)"); + redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png") + , "&Redo", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), + QKeySequence("CTRL+Y")); + redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); + + imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL); + bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); + if (imageNavigatorViewFound) + { + QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); + imageNavigatorAction->setCheckable(true); + + // add part listener for image navigator + imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction); + window->GetPartService()->AddPartListener(imageNavigatorPartListener); + berry::IViewPart::Pointer imageNavigatorView = + window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); + imageNavigatorAction->setChecked(false); + if (imageNavigatorView) + { + bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); + if (isImageNavigatorVisible) + imageNavigatorAction->setChecked(true); + } + imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image"); + } + + // toolbar for showing file open, undo, redo and other main actions + QToolBar* mainActionsToolBar = new QToolBar; + mainActionsToolBar->setObjectName("mainActionsToolBar"); + mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ - mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); + mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else - mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); + mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif - mainActionsToolBar->addAction(fileOpenAction); - mainActionsToolBar->addAction(fileSaveProjectAction); - mainActionsToolBar->addAction(closeProjectAction); - mainActionsToolBar->addAction(undoAction); - mainActionsToolBar->addAction(redoAction); - if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) - { - mainActionsToolBar->addAction(openDicomEditorAction); - } - if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) - { - mainActionsToolBar->addAction(openXnatEditorAction); - } - if (imageNavigatorViewFound) - { - mainActionsToolBar->addAction(imageNavigatorAction); - } - mainWindow->addToolBar(mainActionsToolBar); + mainActionsToolBar->addAction(fileOpenAction); + mainActionsToolBar->addAction(fileSaveProjectAction); + mainActionsToolBar->addAction(closeProjectAction); + mainActionsToolBar->addAction(undoAction); + mainActionsToolBar->addAction(redoAction); + if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor")) + { + mainActionsToolBar->addAction(openDicomEditorAction); + } + if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser")) + { + mainActionsToolBar->addAction(openXnatEditorAction); + } + if (imageNavigatorViewFound) + { + mainActionsToolBar->addAction(imageNavigatorAction); + } + + if (enableCandyStore) + { + candyStoreAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Candy_icon.png"), "&Candy Store", NULL); + QObject::connect(candyStoreAction, SIGNAL(triggered(bool)), SLOT(onCandyStore())); + candyStoreAction->setCheckable(true); + candyStoreAction->setChecked(false); + candyStoreAction->setToolTip("Toggle Candy Store"); + mainActionsToolBar->addAction(candyStoreAction); + } + mainWindow->addToolBar(mainActionsToolBar); #ifdef __APPLE__ - mainWindow->setUnifiedTitleAndToolBarOnMac(true); + mainWindow->setUnifiedTitleAndToolBarOnMac(true); #endif - // ==== Window Menu ========================== - QMenu* windowMenu = menuBar->addMenu("Window"); - if (showNewWindowMenuItem) - { - windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); - windowMenu->addSeparator(); - } - - QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); - - QMenu* viewMenu; - if (showViewMenuItem) - { - viewMenu = windowMenu->addMenu("Show &View"); - viewMenu->setObjectName("Show View"); - } - windowMenu->addSeparator(); - resetPerspAction = windowMenu->addAction("&Reset Perspective", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); - - if(showClosePerspectiveMenuItem) - closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); - - windowMenu->addSeparator(); - windowMenu->addAction("&Preferences...", - QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), - QKeySequence("CTRL+P")); - - // fill perspective menu - berry::IPerspectiveRegistry* perspRegistry = - window->GetWorkbench()->GetPerspectiveRegistry(); - QActionGroup* perspGroup = new QActionGroup(menuBar); - - std::vector perspectives( - perspRegistry->GetPerspectives()); + // ==== Window Menu ========================== + QMenu* windowMenu = menuBar->addMenu("Window"); + if (showNewWindowMenuItem) + { + windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); + windowMenu->addSeparator(); + } + + QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); + + QMenu* viewMenu; + if (showViewMenuItem) + { + viewMenu = windowMenu->addMenu("Show &View"); + viewMenu->setObjectName("Show View"); + } + windowMenu->addSeparator(); + resetPerspAction = windowMenu->addAction("&Reset Perspective", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); + + if(showClosePerspectiveMenuItem) + closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); + + windowMenu->addSeparator(); + windowMenu->addAction("&Preferences...", + QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), + QKeySequence("CTRL+P")); + + // fill perspective menu + berry::IPerspectiveRegistry* perspRegistry = + window->GetWorkbench()->GetPerspectiveRegistry(); + QActionGroup* perspGroup = new QActionGroup(menuBar); + + std::vector perspectives( + perspRegistry->GetPerspectives()); bool skip = false; for (std::vector::iterator perspIt = - perspectives.begin(); perspIt != perspectives.end(); ++perspIt) + perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { - // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which - // should not appear as an menu-entry in the perspective menu - if (perspectiveExcludeList.size() > 0) - { - for (unsigned int i=0; i 0) { - if (perspectiveExcludeList.at(i) == (*perspIt)->GetId()) - { - skip = true; - break; - } + for (unsigned int i=0; iGetId()) + { + skip = true; + break; + } + } + if (skip) + { + skip = false; + continue; + } } - if (skip) + + QAction* perspAction = new berry::QtOpenPerspectiveAction(window, + *perspIt, perspGroup); + mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction)); + } + perspMenu->addActions(perspGroup->actions()); + + // sort elements (converting vector to map...) + std::vector::const_iterator iter; + std::map VDMap; + + skip = false; + for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) + { + + // if viewExcludeList is set, it contains the id-strings of view, which + // should not appear as an menu-entry in the menu + if (viewExcludeList.size() > 0) + { + for (unsigned int i=0; iGetId()) + { + skip = true; + break; + } + } + if (skip) + { + skip = false; + continue; + } + } + + if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") + continue; + if ((*iter)->GetId() == "org.mitk.views.imagenavigator") + continue; + + std::pair p( + (*iter)->GetLabel(), (*iter)); + VDMap.insert(p); + } + // ================================================== + + // ==== Perspective Toolbar ================================== + QToolBar* qPerspectiveToolbar = new QToolBar; + qPerspectiveToolbar->setObjectName("perspectiveToolBar"); + + if (showPerspectiveToolbar) + { + qPerspectiveToolbar->addActions(perspGroup->actions()); + mainWindow->addToolBar(qPerspectiveToolbar); + } + else + delete qPerspectiveToolbar; + + // ==== View Toolbar ================================== + QToolBar* qToolbar = new QToolBar; + qToolbar->setObjectName("viewToolBar"); + + std::map::const_iterator + MapIter; + for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) + { + berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, + (*MapIter).second); + viewActions.push_back(viewAction); + if(showViewMenuItem) + viewMenu->addAction(viewAction); + if (showViewToolbar) { - skip = false; - continue; + qToolbar->addAction(viewAction); } - } - - QAction* perspAction = new berry::QtOpenPerspectiveAction(window, - *perspIt, perspGroup); - mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction)); - } - perspMenu->addActions(perspGroup->actions()); - - // sort elements (converting vector to map...) - std::vector::const_iterator iter; - std::map VDMap; - - skip = false; - for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) - { - - // if viewExcludeList is set, it contains the id-strings of view, which - // should not appear as an menu-entry in the menu - if (viewExcludeList.size() > 0) - { - for (unsigned int i=0; iGetId()) - { - skip = true; - break; - } - } - if (skip) - { - skip = false; - continue; - } - } - - if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") - continue; - if ((*iter)->GetId() == "org.mitk.views.imagenavigator") - continue; - - std::pair p( - (*iter)->GetLabel(), (*iter)); - VDMap.insert(p); - } - // ================================================== - - // ==== Perspective Toolbar ================================== - QToolBar* qPerspectiveToolbar = new QToolBar; - qPerspectiveToolbar->setObjectName("perspectiveToolBar"); - - if (showPerspectiveToolbar) - { - qPerspectiveToolbar->addActions(perspGroup->actions()); - mainWindow->addToolBar(qPerspectiveToolbar); - } - else - delete qPerspectiveToolbar; - - // ==== View Toolbar ================================== - QToolBar* qToolbar = new QToolBar; - qToolbar->setObjectName("viewToolBar"); - - std::map::const_iterator - MapIter; - for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) - { - berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, - (*MapIter).second); - viewActions.push_back(viewAction); - if(showViewMenuItem) - viewMenu->addAction(viewAction); - if (showViewToolbar) - { - qToolbar->addAction(viewAction); - } - } - - if (showViewToolbar) - { - mainWindow->addToolBar(qToolbar); - } - else - delete qToolbar; - - QSettings settings(GetQSettingsFile(), QSettings::IniFormat); - mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); - - - // ==================================================== - - // ===== Help menu ==================================== - QMenu* helpMenu = menuBar->addMenu("&Help"); - helpMenu->addAction("&Welcome",this, SLOT(onIntro())); - helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); - helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1")); - helpMenu->addAction("&About",this, SLOT(onAbout())); - // ===================================================== - - - QStatusBar* qStatusBar = new QStatusBar(); - - //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar - QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); - //disabling the SizeGrip in the lower right corner - statusBar->SetSizeGripEnabled(false); - - - - QmitkProgressBar *progBar = new QmitkProgressBar(); - - qStatusBar->addPermanentWidget(progBar, 0); - progBar->hide(); -// progBar->AddStepsToDo(2); -// progBar->Progress(1); - - mainWindow->setStatusBar(qStatusBar); - - QmitkMemoryUsageIndicatorView* memoryIndicator = - new QmitkMemoryUsageIndicatorView(); - qStatusBar->addPermanentWidget(memoryIndicator, 0); + } + + if (showViewToolbar) + { + mainWindow->addToolBar(qToolbar); + } + else + delete qToolbar; + + QSettings settings(GetQSettingsFile(), QSettings::IniFormat); + mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); + + + // ==================================================== + + // ===== Help menu ==================================== + QMenu* helpMenu = menuBar->addMenu("&Help"); + helpMenu->addAction("&Welcome",this, SLOT(onIntro())); + helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); + helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1")); + helpMenu->addAction("&About",this, SLOT(onAbout())); + // ===================================================== + + + QStatusBar* qStatusBar = new QStatusBar(); + + //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar + QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar); + //disabling the SizeGrip in the lower right corner + statusBar->SetSizeGripEnabled(false); + + + + QmitkProgressBar *progBar = new QmitkProgressBar(); + + qStatusBar->addPermanentWidget(progBar, 0); + progBar->hide(); + // progBar->AddStepsToDo(2); + // progBar->Progress(1); + + mainWindow->setStatusBar(qStatusBar); + +// QLabel* label = new QLabel(); +// label->setText(" Candy Store"); + candyStore = new QDockWidget("Candy Store"); + candyStore->setWidget(new QmitkCandyStoreWidget()); + candyStore->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); + candyStore->setVisible(false); + candyStore->setObjectName("Candy Store"); +// candyStore->setTitleBarWidget(label); + mainWindow->addDockWidget(Qt::LeftDockWidgetArea, candyStore); + + if (showMemoryIndicator) + { + QmitkMemoryUsageIndicatorView* memoryIndicator = new QmitkMemoryUsageIndicatorView(); + qStatusBar->addPermanentWidget(memoryIndicator, 0); + } } void QmitkExtWorkbenchWindowAdvisor::PreWindowOpen() { - berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); + berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); - // show the shortcut bar and progress indicator, which are hidden by - // default - //configurer->SetShowPerspectiveBar(true); - //configurer->SetShowFastViewBars(true); - //configurer->SetShowProgressIndicator(true); + // show the shortcut bar and progress indicator, which are hidden by + // default + //configurer->SetShowPerspectiveBar(true); + //configurer->SetShowFastViewBars(true); + //configurer->SetShowProgressIndicator(true); - // // add the drag and drop support for the editor area - // configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); - // configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); - // configurer.addEditorAreaTransfer(FileTransfer.getInstance()); - // configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); - // configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( - // configurer.getWindow())); + // // add the drag and drop support for the editor area + // configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); + // configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); + // configurer.addEditorAreaTransfer(FileTransfer.getInstance()); + // configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); + // configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( + // configurer.getWindow())); - this->HookTitleUpdateListeners(configurer); + this->HookTitleUpdateListeners(configurer); - menuPerspectiveListener = new PerspectiveListenerForMenu(this); - configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener); + menuPerspectiveListener = new PerspectiveListenerForMenu(this); + configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener); - configurer->AddEditorAreaTransfer(QStringList("text/uri-list")); - configurer->ConfigureEditorAreaDropListener(dropTargetListener); + configurer->AddEditorAreaTransfer(QStringList("text/uri-list")); + configurer->ConfigureEditorAreaDropListener(dropTargetListener); } void QmitkExtWorkbenchWindowAdvisor::PostWindowOpen() { - // Force Rendering Window Creation on startup. - berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); + // Force Rendering Window Creation on startup. + berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); - ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); - ctkServiceReference serviceRef = context->getServiceReference(); - if (serviceRef) - { - mitk::IDataStorageService *dsService = context->getService(serviceRef); - if (dsService) + ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); + ctkServiceReference serviceRef = context->getServiceReference(); + if (serviceRef) { - mitk::IDataStorageReference::Pointer dsRef = dsService->GetDataStorage(); - mitk::DataStorageEditorInput::Pointer dsInput(new mitk::DataStorageEditorInput(dsRef)); - mitk::WorkbenchUtil::OpenEditor(configurer->GetWindow()->GetActivePage(),dsInput); + mitk::IDataStorageService *dsService = context->getService(serviceRef); + if (dsService) + { + mitk::IDataStorageReference::Pointer dsRef = dsService->GetDataStorage(); + mitk::DataStorageEditorInput::Pointer dsInput(new mitk::DataStorageEditorInput(dsRef)); + mitk::WorkbenchUtil::OpenEditor(configurer->GetWindow()->GetActivePage(),dsInput); + } } - } } void QmitkExtWorkbenchWindowAdvisor::onIntro() { - QmitkExtWorkbenchWindowAdvisorHack::undohack->onIntro(); + QmitkExtWorkbenchWindowAdvisorHack::undohack->onIntro(); } void QmitkExtWorkbenchWindowAdvisor::onHelp() { - QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelp(); + QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelp(); } void QmitkExtWorkbenchWindowAdvisor::onHelpOpenHelpPerspective() { - QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelpOpenHelpPerspective(); + QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelpOpenHelpPerspective(); } void QmitkExtWorkbenchWindowAdvisor::onAbout() { - QmitkExtWorkbenchWindowAdvisorHack::undohack->onAbout(); + QmitkExtWorkbenchWindowAdvisorHack::undohack->onAbout(); } //-------------------------------------------------------------------------------- // Ugly hack from here on. Feel free to delete when command framework // and undo buttons are done. //-------------------------------------------------------------------------------- QmitkExtWorkbenchWindowAdvisorHack::QmitkExtWorkbenchWindowAdvisorHack() : QObject() { } QmitkExtWorkbenchWindowAdvisorHack::~QmitkExtWorkbenchWindowAdvisorHack() { } void QmitkExtWorkbenchWindowAdvisorHack::onUndo() { - mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); - if (model) - { - if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) - { - mitk::VerboseLimitedLinearUndo::StackDescription descriptions = - verboseundo->GetUndoDescriptions(); - if (descriptions.size() >= 1) - { - MITK_INFO << "Undo " << descriptions.front().second; - } - } - model->Undo(); - } - else - { - MITK_ERROR << "No undo model instantiated"; - } + mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); + if (model) + { + if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) + { + mitk::VerboseLimitedLinearUndo::StackDescription descriptions = + verboseundo->GetUndoDescriptions(); + if (descriptions.size() >= 1) + { + MITK_INFO << "Undo " << descriptions.front().second; + } + } + model->Undo(); + } + else + { + MITK_ERROR << "No undo model instantiated"; + } } void QmitkExtWorkbenchWindowAdvisorHack::onRedo() { - mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); - if (model) - { - if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) - { - mitk::VerboseLimitedLinearUndo::StackDescription descriptions = - verboseundo->GetRedoDescriptions(); - if (descriptions.size() >= 1) - { - MITK_INFO << "Redo " << descriptions.front().second; - } - } - model->Redo(); - } - else - { - MITK_ERROR << "No undo model instantiated"; - } + mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); + if (model) + { + if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) + { + mitk::VerboseLimitedLinearUndo::StackDescription descriptions = + verboseundo->GetRedoDescriptions(); + if (descriptions.size() >= 1) + { + MITK_INFO << "Redo " << descriptions.front().second; + } + } + model->Redo(); + } + else + { + MITK_ERROR << "No undo model instantiated"; + } } void QmitkExtWorkbenchWindowAdvisorHack::onImageNavigator() { - // get ImageNavigatorView - berry::IViewPart::Pointer imageNavigatorView = - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); - if (imageNavigatorView) - { - bool isImageNavigatorVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(imageNavigatorView); - if (isImageNavigatorVisible) - { - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->HideView(imageNavigatorView); - return; - } - } - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagenavigator"); - //berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); + // get ImageNavigatorView + berry::IViewPart::Pointer imageNavigatorView = + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); + if (imageNavigatorView) + { + bool isImageNavigatorVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(imageNavigatorView); + if (isImageNavigatorVisible) + { + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->HideView(imageNavigatorView); + return; + } + } + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagenavigator"); + //berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); } void QmitkExtWorkbenchWindowAdvisorHack::onEditPreferences() { - QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow()); - _PreferencesDialog.exec(); + QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow()); + _PreferencesDialog.exec(); } void QmitkExtWorkbenchWindowAdvisorHack::onQuit() { - berry::PlatformUI::GetWorkbench()->Close(); + berry::PlatformUI::GetWorkbench()->Close(); } void QmitkExtWorkbenchWindowAdvisorHack::onResetPerspective() { - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); } void QmitkExtWorkbenchWindowAdvisorHack::onClosePerspective() { - berry::IWorkbenchPage::Pointer - page = - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); - page->ClosePerspective(page->GetPerspective(), true, true); + berry::IWorkbenchPage::Pointer + page = + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); + page->ClosePerspective(page->GetPerspective(), true, true); } void QmitkExtWorkbenchWindowAdvisorHack::onNewWindow() { - berry::PlatformUI::GetWorkbench()->OpenWorkbenchWindow(0); + berry::PlatformUI::GetWorkbench()->OpenWorkbenchWindow(0); } void QmitkExtWorkbenchWindowAdvisorHack::onIntro() { - bool hasIntro = - berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro(); - if (!hasIntro) - { + bool hasIntro = + berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro(); + if (!hasIntro) + { - QRegExp reg("(.*)(\\n)*"); - QRegExp reg2("(\\n)*(.*)"); - QFile file(":/org.mitk.gui.qt.ext/index.html"); - file.open(QIODevice::ReadOnly | QIODevice::Text); //text file only for reading + QRegExp reg("(.*)(\\n)*"); + QRegExp reg2("(\\n)*(.*)"); + QFile file(":/org.mitk.gui.qt.ext/index.html"); + file.open(QIODevice::ReadOnly | QIODevice::Text); //text file only for reading - QString text = QString(file.readAll()); + QString text = QString(file.readAll()); - file.close(); + file.close(); - QString title = text; - title.replace(reg, ""); - title.replace(reg2, ""); + QString title = text; + title.replace(reg, ""); + title.replace(reg2, ""); - std::cout << title.toStdString() << std::endl; + std::cout << title.toStdString() << std::endl; - QMessageBox::information(NULL, title, - text, "Close"); + QMessageBox::information(NULL, title, + text, "Close"); - } - else - { - berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false); - } + } + else + { + berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false); + } } void QmitkExtWorkbenchWindowAdvisorHack::onHelp() { - ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); - if (context == 0) - { - MITK_WARN << "Plugin context not set, unable to open context help"; - return; - } - - // Check if the org.blueberry.ui.qt.help plug-in is installed and started - QList > plugins = context->getPlugins(); - foreach(QSharedPointer p, plugins) - { - if (p->getSymbolicName() == "org.blueberry.ui.qt.help") - { - if (p->getState() != ctkPlugin::ACTIVE) - { - // try to activate the plug-in explicitly - try - { - p->start(ctkPlugin::START_TRANSIENT); - } - catch (const ctkPluginException& pe) + ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); + if (context == 0) + { + MITK_WARN << "Plugin context not set, unable to open context help"; + return; + } + + // Check if the org.blueberry.ui.qt.help plug-in is installed and started + QList > plugins = context->getPlugins(); + foreach(QSharedPointer p, plugins) + { + if (p->getSymbolicName() == "org.blueberry.ui.qt.help") { - MITK_ERROR << "Activating org.blueberry.ui.qt.help failed: " << pe.what(); - return; + if (p->getState() != ctkPlugin::ACTIVE) + { + // try to activate the plug-in explicitly + try + { + p->start(ctkPlugin::START_TRANSIENT); + } + catch (const ctkPluginException& pe) + { + MITK_ERROR << "Activating org.blueberry.ui.qt.help failed: " << pe.what(); + return; + } + } } - } - } - } - - ctkServiceReference eventAdminRef = context->getServiceReference(); - ctkEventAdmin* eventAdmin = 0; - if (eventAdminRef) - { - eventAdmin = context->getService(eventAdminRef); - } - if (eventAdmin == 0) - { - MITK_WARN << "ctkEventAdmin service not found. Unable to open context help"; - } - else - { - ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); - eventAdmin->postEvent(ev); - } + } + + ctkServiceReference eventAdminRef = context->getServiceReference(); + ctkEventAdmin* eventAdmin = 0; + if (eventAdminRef) + { + eventAdmin = context->getService(eventAdminRef); + } + if (eventAdmin == 0) + { + MITK_WARN << "ctkEventAdmin service not found. Unable to open context help"; + } + else + { + ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); + eventAdmin->postEvent(ev); + } } void QmitkExtWorkbenchWindowAdvisorHack::onHelpOpenHelpPerspective() { - berry::PlatformUI::GetWorkbench()->ShowPerspective("org.blueberry.perspectives.help", - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); + berry::PlatformUI::GetWorkbench()->ShowPerspective("org.blueberry.perspectives.help", + berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); } void QmitkExtWorkbenchWindowAdvisorHack::onAbout() { - QmitkAboutDialog* aboutDialog = new QmitkAboutDialog(QApplication::activeWindow(),NULL); - aboutDialog->open(); + QmitkAboutDialog* aboutDialog = new QmitkAboutDialog(QApplication::activeWindow(),NULL); + aboutDialog->open(); } void QmitkExtWorkbenchWindowAdvisor::HookTitleUpdateListeners( - berry::IWorkbenchWindowConfigurer::Pointer configurer) + berry::IWorkbenchWindowConfigurer::Pointer configurer) { - // hook up the listeners to update the window title - titlePartListener = new PartListenerForTitle(this); - titlePerspectiveListener = new PerspectiveListenerForTitle(this); - editorPropertyListener = new berry::PropertyChangeIntAdapter< - QmitkExtWorkbenchWindowAdvisor>(this, - &QmitkExtWorkbenchWindowAdvisor::PropertyChange); - - // configurer.getWindow().addPageListener(new IPageListener() { - // public void pageActivated(IWorkbenchPage page) { - // updateTitle(false); - // } - // - // public void pageClosed(IWorkbenchPage page) { - // updateTitle(false); - // } - // - // public void pageOpened(IWorkbenchPage page) { - // // do nothing - // } - // }); - - configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener); - configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener); + // hook up the listeners to update the window title + titlePartListener = new PartListenerForTitle(this); + titlePerspectiveListener = new PerspectiveListenerForTitle(this); + editorPropertyListener = new berry::PropertyChangeIntAdapter< + QmitkExtWorkbenchWindowAdvisor>(this, + &QmitkExtWorkbenchWindowAdvisor::PropertyChange); + + // configurer.getWindow().addPageListener(new IPageListener() { + // public void pageActivated(IWorkbenchPage page) { + // updateTitle(false); + // } + // + // public void pageClosed(IWorkbenchPage page) { + // updateTitle(false); + // } + // + // public void pageOpened(IWorkbenchPage page) { + // // do nothing + // } + // }); + + configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener); + configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener); } std::string QmitkExtWorkbenchWindowAdvisor::ComputeTitle() { - berry::IWorkbenchWindowConfigurer::Pointer configurer = - GetWindowConfigurer(); - berry::IWorkbenchPage::Pointer currentPage = - configurer->GetWindow()->GetActivePage(); - berry::IEditorPart::Pointer activeEditor; - if (currentPage) - { - activeEditor = lastActiveEditor.Lock(); - } - - std::string title; - //TODO Product - // IProduct product = Platform.getProduct(); - // if (product != null) { - // title = product.getName(); - // } - // instead of the product name, we use a custom variable for now - title = productName; - - if(showMitkVersionInfo) - { - title += std::string(" ") + MITK_VERSION_STRING; - } - - if (showVersionInfo) - { - // add version informatioin - QString versions = QString(" (ITK %1.%2.%3 VTK %4.%5.%6 Qt %7 MITK %8)") - .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH) - .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION) - .arg(QT_VERSION_STR) - .arg(MITK_VERSION_STRING); - - title += versions.toStdString(); - } - - if (currentPage) - { - if (activeEditor) - { - lastEditorTitle = activeEditor->GetTitleToolTip(); - if (!lastEditorTitle.empty()) - title = lastEditorTitle + " - " + title; - } - berry::IPerspectiveDescriptor::Pointer persp = - currentPage->GetPerspective(); - std::string label = ""; - if (persp) - { - label = persp->GetLabel(); - } - berry::IAdaptable* input = currentPage->GetInput(); - if (input && input != wbAdvisor->GetDefaultPageInput()) - { - label = currentPage->GetLabel(); - } - if (!label.empty()) - { - title = label + " - " + title; - } - } - - title += " (Not for use in diagnosis or treatment of patients)"; - - return title; + berry::IWorkbenchWindowConfigurer::Pointer configurer = + GetWindowConfigurer(); + berry::IWorkbenchPage::Pointer currentPage = + configurer->GetWindow()->GetActivePage(); + berry::IEditorPart::Pointer activeEditor; + if (currentPage) + { + activeEditor = lastActiveEditor.Lock(); + } + + std::string title; + //TODO Product + // IProduct product = Platform.getProduct(); + // if (product != null) { + // title = product.getName(); + // } + // instead of the product name, we use a custom variable for now + title = productName; + + if(showMitkVersionInfo) + { + title += std::string(" ") + MITK_VERSION_STRING; + } + + if (showVersionInfo) + { + // add version informatioin + QString versions = QString(" (ITK %1.%2.%3 VTK %4.%5.%6 Qt %7 MITK %8)") + .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH) + .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION) + .arg(QT_VERSION_STR) + .arg(MITK_VERSION_STRING); + + title += versions.toStdString(); + } + + if (currentPage) + { + if (activeEditor) + { + lastEditorTitle = activeEditor->GetTitleToolTip(); + if (!lastEditorTitle.empty()) + title = lastEditorTitle + " - " + title; + } + berry::IPerspectiveDescriptor::Pointer persp = + currentPage->GetPerspective(); + std::string label = ""; + if (persp) + { + label = persp->GetLabel(); + } + berry::IAdaptable* input = currentPage->GetInput(); + if (input && input != wbAdvisor->GetDefaultPageInput()) + { + label = currentPage->GetLabel(); + } + if (!label.empty()) + { + title = label + " - " + title; + } + } + + title += " (Not for use in diagnosis or treatment of patients)"; + + return title; } void QmitkExtWorkbenchWindowAdvisor::RecomputeTitle() { - berry::IWorkbenchWindowConfigurer::Pointer configurer = - GetWindowConfigurer(); - std::string oldTitle = configurer->GetTitle(); - std::string newTitle = ComputeTitle(); - if (newTitle != oldTitle) - { - configurer->SetTitle(newTitle); - } + berry::IWorkbenchWindowConfigurer::Pointer configurer = + GetWindowConfigurer(); + std::string oldTitle = configurer->GetTitle(); + std::string newTitle = ComputeTitle(); + if (newTitle != oldTitle) + { + configurer->SetTitle(newTitle); + } } void QmitkExtWorkbenchWindowAdvisor::UpdateTitle(bool editorHidden) { - berry::IWorkbenchWindowConfigurer::Pointer configurer = - GetWindowConfigurer(); - berry::IWorkbenchWindow::Pointer window = configurer->GetWindow(); - berry::IEditorPart::Pointer activeEditor; - berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage(); - berry::IPerspectiveDescriptor::Pointer persp; - berry::IAdaptable* input = 0; - - if (currentPage) - { - activeEditor = currentPage->GetActiveEditor(); - persp = currentPage->GetPerspective(); - input = currentPage->GetInput(); - } - - if (editorHidden) - { - activeEditor = 0; - } - - // Nothing to do if the editor hasn't changed - if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock() - && persp == lastPerspective.Lock() && input == lastInput) - { - return; - } - - if (!lastActiveEditor.Expired()) - { - lastActiveEditor.Lock()->RemovePropertyListener(editorPropertyListener); - } - - lastActiveEditor = activeEditor; - lastActivePage = currentPage; - lastPerspective = persp; - lastInput = input; - - if (activeEditor) - { - activeEditor->AddPropertyListener(editorPropertyListener); - } - - RecomputeTitle(); + berry::IWorkbenchWindowConfigurer::Pointer configurer = + GetWindowConfigurer(); + berry::IWorkbenchWindow::Pointer window = configurer->GetWindow(); + berry::IEditorPart::Pointer activeEditor; + berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage(); + berry::IPerspectiveDescriptor::Pointer persp; + berry::IAdaptable* input = 0; + + if (currentPage) + { + activeEditor = currentPage->GetActiveEditor(); + persp = currentPage->GetPerspective(); + input = currentPage->GetInput(); + } + + if (editorHidden) + { + activeEditor = 0; + } + + // Nothing to do if the editor hasn't changed + if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock() + && persp == lastPerspective.Lock() && input == lastInput) + { + return; + } + + if (!lastActiveEditor.Expired()) + { + lastActiveEditor.Lock()->RemovePropertyListener(editorPropertyListener); + } + + lastActiveEditor = activeEditor; + lastActivePage = currentPage; + lastPerspective = persp; + lastInput = input; + + if (activeEditor) + { + activeEditor->AddPropertyListener(editorPropertyListener); + } + + RecomputeTitle(); } void QmitkExtWorkbenchWindowAdvisor::PropertyChange(berry::Object::Pointer /*source*/, int propId) { - if (propId == berry::IWorkbenchPartConstants::PROP_TITLE) - { - if (!lastActiveEditor.Expired()) - { - std::string newTitle = lastActiveEditor.Lock()->GetPartName(); - if (lastEditorTitle != newTitle) - { - RecomputeTitle(); - } - } - } + if (propId == berry::IWorkbenchPartConstants::PROP_TITLE) + { + if (!lastActiveEditor.Expired()) + { + std::string newTitle = lastActiveEditor.Lock()->GetPartName(); + if (lastEditorTitle != newTitle) + { + RecomputeTitle(); + } + } + } } void QmitkExtWorkbenchWindowAdvisor::SetPerspectiveExcludeList(std::vector v) { - this->perspectiveExcludeList = v; + this->perspectiveExcludeList = v; } std::vector QmitkExtWorkbenchWindowAdvisor::GetPerspectiveExcludeList() { - return this->perspectiveExcludeList; + return this->perspectiveExcludeList; } void QmitkExtWorkbenchWindowAdvisor::SetViewExcludeList(std::vector v) { - this->viewExcludeList = v; + this->viewExcludeList = v; } std::vector QmitkExtWorkbenchWindowAdvisor::GetViewExcludeList() { - return this->viewExcludeList; + return this->viewExcludeList; } void QmitkExtWorkbenchWindowAdvisor::PostWindowClose() { - berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); - QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); + berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); + QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); - QSettings settings(GetQSettingsFile(), QSettings::IniFormat); - settings.setValue("ToolbarPosition", mainWindow->saveState()); + QSettings settings(GetQSettingsFile(), QSettings::IniFormat); + settings.setValue("ToolbarPosition", mainWindow->saveState()); } QString QmitkExtWorkbenchWindowAdvisor::GetQSettingsFile() const { - QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME); - return settingsInfo.canonicalFilePath(); + QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME); + return settingsInfo.canonicalFilePath(); } diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h index 5cc0cd91f4..f79da801a3 100644 --- a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h @@ -1,169 +1,185 @@ /*=================================================================== 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 QMITKEXTWORKBENCHWINDOWADVISOR_H_ #define QMITKEXTWORKBENCHWINDOWADVISOR_H_ #include #include #include #include #include #include #include #include +#include +#include class QAction; class QMenu; class MITK_QT_COMMON_EXT_EXPORT QmitkExtWorkbenchWindowAdvisor : public QObject, public berry::WorkbenchWindowAdvisor { Q_OBJECT public: QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer); berry::ActionBarAdvisor::Pointer CreateActionBarAdvisor( berry::IActionBarConfigurer::Pointer configurer); void* CreateEmptyWindowContents(void* parent); void PostWindowCreate(); void PreWindowOpen(); void PostWindowOpen(); void PostWindowClose(); void ShowViewToolbar(bool show); void ShowPerspectiveToolbar(bool show); void ShowVersionInfo(bool show); void ShowMitkVersionInfo(bool show); void ShowViewMenuItem(bool show); void ShowNewWindowMenuItem(bool show); void ShowClosePerspectiveMenuItem(bool show); bool GetShowClosePerspectiveMenuItem(); + void EnableCandyStore(bool enable); + + bool GetEnableCandyStore(); + + void ShowMemoryIndicator(bool show); + + bool GetShowMemoryIndicator(); + //TODO should be removed when product support is here void SetProductName(const std::string& product); void SetWindowIcon(const std::string& wndIcon); void SetPerspectiveExcludeList(std::vector v); std::vector GetPerspectiveExcludeList(); void SetViewExcludeList(std::vector v); std::vector GetViewExcludeList(); protected slots: virtual void onIntro(); virtual void onHelp(); virtual void onHelpOpenHelpPerspective(); virtual void onAbout(); + void onCandyStore(); private: /** * Hooks the listeners needed on the window * * @param configurer */ void HookTitleUpdateListeners(berry::IWorkbenchWindowConfigurer::Pointer configurer); std::string ComputeTitle(); void RecomputeTitle(); QString GetQSettingsFile() const; /** * Updates the window title. Format will be: [pageInput -] * [currentPerspective -] [editorInput -] [workspaceLocation -] productName * @param editorHidden TODO */ void UpdateTitle(bool editorHidden); void PropertyChange(berry::Object::Pointer /*source*/, int propId); static QString QT_SETTINGS_FILENAME; berry::IPartListener::Pointer titlePartListener; berry::IPerspectiveListener::Pointer titlePerspectiveListener; berry::IPerspectiveListener::Pointer menuPerspectiveListener; berry::IPartListener::Pointer imageNavigatorPartListener; + berry::IPartListener::Pointer CandyStorePartListener; berry::IPropertyChangeListener::Pointer editorPropertyListener; friend struct berry::PropertyChangeIntAdapter; friend class PartListenerForTitle; friend class PerspectiveListenerForTitle; friend class PerspectiveListenerForMenu; friend class PartListenerForImageNavigator; berry::IEditorPart::WeakPtr lastActiveEditor; berry::IPerspectiveDescriptor::WeakPtr lastPerspective; berry::IWorkbenchPage::WeakPtr lastActivePage; std::string lastEditorTitle; berry::IAdaptable* lastInput; berry::WorkbenchAdvisor* wbAdvisor; bool showViewToolbar; bool showPerspectiveToolbar; bool showVersionInfo; bool showMitkVersionInfo; bool showViewMenuItem; bool showNewWindowMenuItem; bool showClosePerspectiveMenuItem; + bool enableCandyStore; + bool showMemoryIndicator; std::string productName; std::string windowIcon; // enables DnD on the editor area berry::IDropTargetListener::Pointer dropTargetListener; // stringlist for excluding perspectives from the perspective menu entry (e.g. Welcome Perspective) std::vector perspectiveExcludeList; // stringlist for excluding views from the menu entry std::vector viewExcludeList; // maps perspective ids to QAction objects std::map mapPerspIdToAction; // actions which will be enabled/disabled depending on the application state QList viewActions; QAction* fileSaveProjectAction; QAction* closeProjectAction; QAction* undoAction; QAction* redoAction; QAction* imageNavigatorAction; + QAction* candyStoreAction; QAction* resetPerspAction; QAction* closePerspAction; QAction* openDicomEditorAction; QAction* openXnatEditorAction; + QDockWidget* candyStore; }; #endif /*QMITKEXTWORKBENCHWINDOWADVISOR_H_*/ diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.cpp new file mode 100644 index 0000000000..e4c33a892c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.cpp @@ -0,0 +1,88 @@ +/*=================================================================== + +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 "QmitkNewPerspectiveDialog.h" + +#include "mitkOrganTypeProperty.h" + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +QmitkNewPerspectiveDialog::QmitkNewPerspectiveDialog(QWidget* parent) + :QDialog(parent) +{ + QGridLayout* formGridLayout = new QGridLayout( this ); + + QLabel* label = new QLabel( "Perspective name:", this ); + + m_PerspectiveNameLineEdit = new QLineEdit( "", this ); + m_PerspectiveNameLineEdit->setFocus(); + + m_AcceptNameButton = new QPushButton( tr("Ok"), this ); + m_AcceptNameButton->setDefault(true); + m_AcceptNameButton->setEnabled(false); + + QPushButton* rejectNameButton = new QPushButton( tr("Cancel"), this ); + + formGridLayout->addWidget(label, 0, 0); + formGridLayout->addWidget(m_PerspectiveNameLineEdit, 0, 1); + formGridLayout->addWidget(m_AcceptNameButton, 1, 0); + formGridLayout->addWidget(rejectNameButton, 1, 1); + setLayout(formGridLayout); + + // create connections + connect( rejectNameButton, SIGNAL(clicked()), this, SLOT(reject()) ); + connect( m_AcceptNameButton, SIGNAL(clicked()), this, SLOT(OnAcceptClicked()) ); + connect( m_PerspectiveNameLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(OnPerspectiveNameChanged(const QString&)) ); +} + +QmitkNewPerspectiveDialog::~QmitkNewPerspectiveDialog() +{ +} + +void QmitkNewPerspectiveDialog::SetPerspectiveName(QString name) +{ + m_PerspectiveNameLineEdit->setText(name); + OnPerspectiveNameChanged(name); +} + +void QmitkNewPerspectiveDialog::OnAcceptClicked() +{ + m_PerspectiveName = m_PerspectiveNameLineEdit->text(); + this->accept(); +} + +const QString QmitkNewPerspectiveDialog::GetPerspectiveName() +{ + return m_PerspectiveName; +} + +void QmitkNewPerspectiveDialog::OnPerspectiveNameChanged(const QString& newText) +{ + if (!newText.isEmpty()) + m_AcceptNameButton->setEnabled(true); + else + m_AcceptNameButton->setEnabled(false); +} diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.h b/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.h new file mode 100644 index 0000000000..b745e40282 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.h @@ -0,0 +1,72 @@ +/*=================================================================== + +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 QmitkNewPerspectiveDialog_h_Included +#define QmitkNewPerspectiveDialog_h_Included + +#include "mitkColorProperty.h" +#include + +#include + +#include + +class QLabel; +class QLineEdit; +class Q3ListBox; +class QPushButton; + +#include + +/** + \brief Dialog for QmitkInteractiveSegmentation. + + \ingroup ToolManagerEtAl + \ingroup Widgets + + This dialog is used to ask a user about the type of a newly created segmentation and a name for it. + + \warning Will not create a new organ type in the OrganTypeProperty. Client has to do that. + + Last contribution by $Author: maleike $. +*/ +class QmitkNewPerspectiveDialog : public QDialog +{ + Q_OBJECT + +public: + + QmitkNewPerspectiveDialog(QWidget* parent = 0); + virtual ~QmitkNewPerspectiveDialog(); + + const QString GetPerspectiveName(); + void SetPerspectiveName(QString name); + +signals: + +protected slots: + + void OnAcceptClicked(); + void OnPerspectiveNameChanged(const QString&); + +protected: + + QLineEdit* m_PerspectiveNameLineEdit; + QPushButton* m_AcceptNameButton; + QString m_PerspectiveName; +}; + +#endif diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h b/Plugins/org.mitk.gui.qt.ext/src/mitkQtPerspectiveItem.h similarity index 50% copy from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h copy to Plugins/org.mitk.gui.qt.ext/src/mitkQtPerspectiveItem.h index bd4611e7e6..1ede7418d3 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h +++ b/Plugins/org.mitk.gui.qt.ext/src/mitkQtPerspectiveItem.h @@ -1,36 +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 _PerspectiveItem +#define _PerspectiveItem -#ifndef QmitkDIAppFiberTractographyPerspective_H_ -#define QmitkDIAppFiberTractographyPerspective_H_ +#include +#include -#include - -class QmitkDIAppFiberTractographyPerspective : public QObject, public berry::IPerspectiveFactory +namespace mitk { - Q_OBJECT - Q_INTERFACES(berry::IPerspectiveFactory) +class QtPerspectiveItem : public QStandardItem +{ public: + QtPerspectiveItem(QString string) : + QStandardItem(string) + { + } + QtPerspectiveItem(const QIcon& icon, QString string) : + QStandardItem(icon, string) + { + } - QmitkDIAppFiberTractographyPerspective() {} - ~QmitkDIAppFiberTractographyPerspective() {} + berry::IPerspectiveDescriptor::Pointer m_Perspective; + + std::vector m_Tags; + QString m_Description; +private: - void CreateInitialLayout(berry::IPageLayout::Pointer layout); }; -#endif /* QmitkDIAppFiberTractographyPerspective_H_ */ +} + +#endif diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h b/Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h similarity index 50% rename from Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h rename to Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h index bd4611e7e6..04c2beeb80 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/internal/Perspectives/QmitkDIAppFiberTractographyPerspective.h +++ b/Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h @@ -1,36 +1,49 @@ /*=================================================================== 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 _ViewItem +#define _ViewItem -#ifndef QmitkDIAppFiberTractographyPerspective_H_ -#define QmitkDIAppFiberTractographyPerspective_H_ +#include +#include +#include -#include - -class QmitkDIAppFiberTractographyPerspective : public QObject, public berry::IPerspectiveFactory +namespace mitk { - Q_OBJECT - Q_INTERFACES(berry::IPerspectiveFactory) +class QtViewItem : public QStandardItem +{ public: + QtViewItem(QString string) : + QStandardItem(string) + { + } + QtViewItem(const QIcon& icon, QString string) : + QStandardItem(icon, string) + { + } - QmitkDIAppFiberTractographyPerspective() {} - ~QmitkDIAppFiberTractographyPerspective() {} + berry::IViewDescriptor::Pointer m_View; + std::vector m_Tags; + QString m_Description; + +private: - void CreateInitialLayout(berry::IPageLayout::Pointer layout); }; -#endif /* QmitkDIAppFiberTractographyPerspective_H_ */ +} + +#endif diff --git a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.cpp index 084c10b639..12889eb454 100644 --- a/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.cpp +++ b/Plugins/org.mitk.gui.qt.extapplication/src/internal/QmitkExtAppWorkbenchAdvisor.cpp @@ -1,60 +1,61 @@ /*=================================================================== 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 "QmitkExtAppWorkbenchAdvisor.h" #include "internal/QmitkExtApplicationPlugin.h" #include const std::string QmitkExtAppWorkbenchAdvisor::DEFAULT_PERSPECTIVE_ID = "org.mitk.extapp.defaultperspective"; void QmitkExtAppWorkbenchAdvisor::Initialize(berry::IWorkbenchConfigurer::Pointer configurer) { berry::QtWorkbenchAdvisor::Initialize(configurer); configurer->SetSaveAndRestore(true); } berry::WorkbenchWindowAdvisor* QmitkExtAppWorkbenchAdvisor::CreateWorkbenchWindowAdvisor( berry::IWorkbenchWindowConfigurer::Pointer configurer) { QmitkExtWorkbenchWindowAdvisor* advisor = new QmitkExtWorkbenchWindowAdvisor(this, configurer); // Exclude the help perspective from org.blueberry.ui.qt.help from // the normal perspective list. // The perspective gets a dedicated menu entry in the help menu std::vector excludePerspectives; excludePerspectives.push_back("org.blueberry.perspectives.help"); advisor->SetPerspectiveExcludeList(excludePerspectives); // Exclude some views from the normal view list std::vector excludeViews; excludeViews.push_back("org.mitk.views.modules"); + excludeViews.push_back( "org.blueberry.ui.internal.introview" ); advisor->SetViewExcludeList(excludeViews); advisor->SetWindowIcon(":/org.mitk.gui.qt.extapplication/icon.png"); return advisor; //return new QmitkExtWorkbenchWindowAdvisor(this, configurer); } std::string QmitkExtAppWorkbenchAdvisor::GetInitialWindowPerspectiveId() { return DEFAULT_PERSPECTIVE_ID; } diff --git a/Plugins/org.mitk.gui.qt.imagecropper/plugin.xml b/Plugins/org.mitk.gui.qt.imagecropper/plugin.xml index 38c0158df5..14f1a652bd 100644 --- a/Plugins/org.mitk.gui.qt.imagecropper/plugin.xml +++ b/Plugins/org.mitk.gui.qt.imagecropper/plugin.xml @@ -1,18 +1,18 @@ - - + - + diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/plugin.xml b/Plugins/org.mitk.gui.qt.measurementtoolbox/plugin.xml index c2b4d0ec08..a45570603b 100644 --- a/Plugins/org.mitk.gui.qt.measurementtoolbox/plugin.xml +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/plugin.xml @@ -1,24 +1,25 @@ - - + - + - + diff --git a/Plugins/org.mitk.gui.qt.moviemaker/plugin.xml b/Plugins/org.mitk.gui.qt.moviemaker/plugin.xml index 6765494265..32c792be7d 100644 --- a/Plugins/org.mitk.gui.qt.moviemaker/plugin.xml +++ b/Plugins/org.mitk.gui.qt.moviemaker/plugin.xml @@ -1,19 +1,35 @@ + icon="resources/icon.xpm" > + Take movies of your data + + + icon="resources/screenshot_maker.png" > + Take screenshots of your data + + + + + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.python/plugin.xml b/Plugins/org.mitk.gui.qt.python/plugin.xml index c69d1a6080..fccd0509cf 100644 --- a/Plugins/org.mitk.gui.qt.python/plugin.xml +++ b/Plugins/org.mitk.gui.qt.python/plugin.xml @@ -1,16 +1,16 @@ diff --git a/Plugins/org.mitk.gui.qt.registration/plugin.xml b/Plugins/org.mitk.gui.qt.registration/plugin.xml index 9f550dad2b..094f1eab40 100644 --- a/Plugins/org.mitk.gui.qt.registration/plugin.xml +++ b/Plugins/org.mitk.gui.qt.registration/plugin.xml @@ -1,25 +1,28 @@ - + - + - + diff --git a/Plugins/org.mitk.gui.qt.segmentation/plugin.xml b/Plugins/org.mitk.gui.qt.segmentation/plugin.xml index d00fd0cf2d..75c8681509 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/plugin.xml +++ b/Plugins/org.mitk.gui.qt.segmentation/plugin.xml @@ -1,40 +1,43 @@ - - + - + - + diff --git a/Plugins/org.mitk.gui.qt.volumevisualization/plugin.xml b/Plugins/org.mitk.gui.qt.volumevisualization/plugin.xml index 33ed061d6a..5ae4185899 100755 --- a/Plugins/org.mitk.gui.qt.volumevisualization/plugin.xml +++ b/Plugins/org.mitk.gui.qt.volumevisualization/plugin.xml @@ -1,15 +1,14 @@ - - + - \ No newline at end of file +