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